00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "lllandmarklist.h"
00035
00036 #include "message.h"
00037 #include "llassetstorage.h"
00038
00039 #include "llagent.h"
00040 #include "llnotify.h"
00041 #include "llvfile.h"
00042 #include "llviewerstats.h"
00043
00044
00045 LLLandmarkList gLandmarkList;
00046
00047
00049
00050
00051 LLLandmarkList::~LLLandmarkList()
00052 {
00053 std::for_each(mList.begin(), mList.end(), DeletePairedPointer());
00054 }
00055
00056 LLLandmark* LLLandmarkList::getAsset( const LLUUID& asset_uuid )
00057 {
00058 LLLandmark* landmark = get_ptr_in_map(mList, asset_uuid);
00059 if(landmark)
00060 {
00061 return landmark;
00062 }
00063 else
00064 {
00065 if ( gLandmarkList.mBadList.find(asset_uuid) == gLandmarkList.mBadList.end() )
00066 {
00067 gAssetStorage->getAssetData(
00068 asset_uuid,
00069 LLAssetType::AT_LANDMARK,
00070 LLLandmarkList::processGetAssetReply,
00071 NULL);
00072 }
00073 }
00074 return NULL;
00075 }
00076
00077
00078 void LLLandmarkList::processGetAssetReply(
00079 LLVFS *vfs,
00080 const LLUUID& uuid,
00081 LLAssetType::EType type,
00082 void* user_data,
00083 S32 status,
00084 LLExtStat ext_status )
00085 {
00086 if( status == 0 )
00087 {
00088 LLVFile file(vfs, uuid, type);
00089 S32 file_length = file.getSize();
00090
00091 char* buffer = new char[ file_length + 1 ];
00092 file.read( (U8*)buffer, file_length);
00093 buffer[ file_length ] = 0;
00094
00095 LLLandmark* landmark = LLLandmark::constructFromString(buffer);
00096 if (landmark)
00097 {
00098 LLVector3d pos;
00099 if(!landmark->getGlobalPos(pos))
00100 {
00101 LLUUID region_id;
00102 if(landmark->getRegionID(region_id))
00103 {
00104 LLLandmark::requestRegionHandle(
00105 gMessageSystem,
00106 gAgent.getRegionHost(),
00107 region_id,
00108 NULL);
00109 }
00110 }
00111 gLandmarkList.mList[ uuid ] = landmark;
00112 }
00113
00114 delete[] buffer;
00115 }
00116 else
00117 {
00118 if( gViewerStats )
00119 {
00120 gViewerStats->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
00121 }
00122
00123 if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
00124 {
00125 LLNotifyBox::showXml("LandmarkMissing");
00126 }
00127 else
00128 {
00129 LLNotifyBox::showXml("UnableToLoadLandmark");
00130 }
00131
00132 gLandmarkList.mBadList.insert(uuid);
00133 }
00134
00135 }
00136
00137 BOOL LLLandmarkList::assetExists(const LLUUID& asset_uuid)
00138 {
00139 return mList.count(asset_uuid) != 0 || mBadList.count(asset_uuid) != 0;
00140 }