summaryrefslogtreecommitdiff
path: root/indra/newview/llnavmeshstation.cpp
diff options
context:
space:
mode:
authorprep <prep@lindenlab.com>2011-11-10 15:11:51 -0500
committerprep <prep@lindenlab.com>2011-11-10 15:11:51 -0500
commit9f996fdc5684a3e55c9f86508979ad943e2eaded (patch)
tree4505e4c6ce1e4b2c4d841555400da666616170eb /indra/newview/llnavmeshstation.cpp
parent1194063e316461e5b4bf93c1c9ab8e99fefb435b (diff)
Initial commit for retrieving navmesh support
Diffstat (limited to 'indra/newview/llnavmeshstation.cpp')
-rw-r--r--indra/newview/llnavmeshstation.cpp203
1 files changed, 138 insertions, 65 deletions
diff --git a/indra/newview/llnavmeshstation.cpp b/indra/newview/llnavmeshstation.cpp
index 565cc4eb2d..3a29730328 100644
--- a/indra/newview/llnavmeshstation.cpp
+++ b/indra/newview/llnavmeshstation.cpp
@@ -27,82 +27,155 @@
#include "llviewerprecompiledheaders.h"
#include "llnavmeshstation.h"
#include "llcurl.h"
+#include "LLPathingLib.h"//prep# fixme
+#include "llagent.h"
+#include "llviewerregion.h"
//===============================================================================
LLNavMeshStation::LLNavMeshStation()
{
}
-//===============================================================================
-class LLNavMeshUploadResponder : public LLCurl::Responder
-{
-public:
- LLNavMeshUploadResponder( const LLHandle<LLNavMeshObserver>& observer_handle )
- : mObserverHandle( observer_handle )
- {
- LLNavMeshObserver* pObserver = mObserverHandle.get();
- }
-
- void clearPendingRequests ( void )
- {
- }
-
- void error( U32 statusNum, const std::string& reason )
- {
- statusNum;
- llwarns << "Transport error "<<reason<<llendl;
- }
-
- void result( const LLSD& content )
- {
- llinfos<<"Content received"<<llendl;
- //TODO# some sanity checking
- if ( content.has("error") )
- {
- llwarns << "Error on fetched data"<< llendl;
- }
- else
- {
- LLNavMeshObserver* pObserver = mObserverHandle.get();
- if ( pObserver )
- {
- llinfos<<"Do something immensely important w/content"<<llendl;
- //pObserver->execute();
- }
- }
- }
-
-private:
- //Observer handle
- LLHandle<LLNavMeshObserver> mObserverHandle;
-};
+//===============================================================================
+class LLNavMeshUploadResponder : public LLCurl::Responder
+{
+public:
+ LLNavMeshUploadResponder( const LLHandle<LLNavMeshObserver>& observer_handle )
+ : mObserverHandle( observer_handle )
+ {
+ LLNavMeshObserver* pObserver = mObserverHandle.get();
+ }
+
+ void clearPendingRequests ( void )
+ {
+ }
+
+ void error( U32 statusNum, const std::string& reason )
+ {
+ statusNum;
+ llwarns << "Transport error "<<reason<<llendl;
+ }
+
+ void result( const LLSD& content )
+ {
+ llinfos<<"Content received"<<llendl;
+ //TODO# some sanity checking
+ if ( content.has("error") )
+ {
+ llwarns << "Error on fetched data"<< llendl;
+ }
+ else
+ {
+ LLNavMeshObserver* pObserver = mObserverHandle.get();
+ if ( pObserver )
+ {
+ llinfos<<"Do something immensely important w/content"<<llendl;
+ //pObserver->execute();
+ }
+ }
+ }
+
+private:
+ //Observer handle
+ LLHandle<LLNavMeshObserver> mObserverHandle;
+};
+//===============================================================================
+class LLNavMeshDownloadResponder : public LLCurl::Responder
+{
+public:
+ LLNavMeshDownloadResponder( const LLHandle<LLNavMeshDownloadObserver>& observer_handle )
+ : mObserverHandle( observer_handle )
+ {
+ LLNavMeshDownloadObserver* pObserver = mObserverHandle.get();
+ }
+
+ void clearPendingRequests ( void )
+ {
+ }
+
+ void error( U32 statusNum, const std::string& reason )
+ {
+ statusNum;
+ llwarns << "Transport error "<<reason<<llendl;
+ }
+
+ void result( const LLSD& content )
+ {
+ llinfos<<"Content received"<<llendl;
+ //TODO# some sanity checking
+ if ( content.has("error") )
+ {
+ llwarns << "Error on fetched data"<< llendl;
+ }
+ else
+ {
+ LLNavMeshDownloadObserver* pObserver = mObserverHandle.get();
+ if ( pObserver )
+ {
+ llinfos<<"Do something immensely important w/content"<<llendl;
+ LLPathingLib::getInstance()->extractNavMeshSrcFromLLSD( content );
+ }
+ }
+ }
+
+private:
+ //Observer handle
+ LLHandle<LLNavMeshDownloadObserver> mObserverHandle;
+};
//===============================================================================
bool LLNavMeshStation::postNavMeshToServer( LLSD& data, const LLHandle<LLNavMeshObserver>& observerHandle )
{
- mCurlRequest = new LLCurlRequest();
-
- if ( mNavMeshUploadURL.empty() )
- {
- llinfos << "Unable to upload navmesh because of missing URL" << llendl;
- }
- else
- {
- LLCurlRequest::headers_t headers;
- mCurlRequest->post( mNavMeshUploadURL, headers, data,
- new LLNavMeshUploadResponder(/*this, data,*/ observerHandle ) );
- do
- {
- mCurlRequest->process();
- //sleep for 10ms to prevent eating a whole core
- apr_sleep(10000);
- } while ( mCurlRequest->getQueued() > 0 );
- }
-
- delete mCurlRequest;
-
- mCurlRequest = NULL;
+ mCurlRequest = new LLCurlRequest();
+
+ if ( mNavMeshUploadURL.empty() )
+ {
+ llinfos << "Unable to upload navmesh because of missing URL" << llendl;
+ }
+ else
+ {
+ LLCurlRequest::headers_t headers;
+ mCurlRequest->post( mNavMeshUploadURL, headers, data,
+ new LLNavMeshUploadResponder(/*this, data,*/ observerHandle ) );
+ do
+ {
+ mCurlRequest->process();
+ //sleep for 10ms to prevent eating a whole core
+ apr_sleep(10000);
+ } while ( mCurlRequest->getQueued() > 0 );
+ }
+
+ delete mCurlRequest;
+
+ mCurlRequest = NULL;
return true;
}
//===============================================================================
+void LLNavMeshStation::downloadNavMeshSrc( const LLHandle<LLNavMeshDownloadObserver>& observerHandle )
+{
+ mCurlRequest = new LLCurlRequest();
+
+ if ( mNavMeshDownloadURL.empty() )
+ {
+ llinfos << "Unable to upload navmesh because of missing URL" << llendl;
+ }
+ else
+ {
+ LLCurlRequest::headers_t headers;
+ LLSD data;
+ data["agent_id"] = gAgent.getID();
+ data["region_id"] = gAgent.getRegion()->getRegionID();
+ mCurlRequest->post( mNavMeshDownloadURL, headers, data,
+ new LLNavMeshDownloadResponder( observerHandle ) );
+ do
+ {
+ mCurlRequest->process();
+ //sleep for 10ms to prevent eating a whole core
+ apr_sleep(10000);
+ } while ( mCurlRequest->getQueued() > 0 );
+ }
+ delete mCurlRequest;
+ mCurlRequest = NULL;
+}
+//=============================================================================== \ No newline at end of file