diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llmapresponders.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llmapresponders.cpp | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/linden/indra/newview/llmapresponders.cpp b/linden/indra/newview/llmapresponders.cpp new file mode 100644 index 0000000..0bf8754 --- /dev/null +++ b/linden/indra/newview/llmapresponders.cpp | |||
@@ -0,0 +1,199 @@ | |||
1 | /** | ||
2 | * @file llmapresponders.h | ||
3 | * @brief Processes responses received for map requests. | ||
4 | * | ||
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llmapresponders.h" | ||
31 | |||
32 | #include "llfloaterworldmap.h" | ||
33 | #include "llviewerimagelist.h" | ||
34 | #include "llworldmap.h" | ||
35 | #include "llagent.h" | ||
36 | |||
37 | //virtual | ||
38 | void LLMapLayerResponder::result(const LLSD& result) | ||
39 | { | ||
40 | llinfos << "LLMapLayerResponder::result from capabilities" << llendl; | ||
41 | |||
42 | S32 agent_flags = result["AgentData"]["Flags"]; | ||
43 | |||
44 | if (agent_flags != gWorldMap->mCurrentMap) | ||
45 | { | ||
46 | llwarns << "Invalid or out of date map image type returned!" << llendl; | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | LLUUID image_id; | ||
51 | //U32 left, right, top, bottom; | ||
52 | |||
53 | gWorldMap->mMapLayers[agent_flags].clear(); | ||
54 | |||
55 | LLSD::array_const_iterator iter; | ||
56 | BOOL adjust = FALSE; | ||
57 | for(iter = result["LayerData"].beginArray(); iter != result["LayerData"].endArray(); ++iter) | ||
58 | { | ||
59 | const LLSD& layer_data = *iter; | ||
60 | |||
61 | LLWorldMapLayer new_layer; | ||
62 | new_layer.LayerDefined = TRUE; | ||
63 | new_layer.LayerImageID = layer_data["ImageID"]; | ||
64 | new_layer.LayerImage = gImageList.getImage(new_layer.LayerImageID, MIPMAP_TRUE, FALSE); | ||
65 | new_layer.LayerImage->bindTexture(0); | ||
66 | new_layer.LayerImage->setClamp(TRUE, TRUE); | ||
67 | |||
68 | new_layer.LayerExtents.mLeft = layer_data["Left"]; | ||
69 | new_layer.LayerExtents.mRight = layer_data["Right"]; | ||
70 | new_layer.LayerExtents.mBottom = layer_data["Bottom"]; | ||
71 | new_layer.LayerExtents.mTop = layer_data["Top"]; | ||
72 | |||
73 | F32 x_meters = F32(new_layer.LayerExtents.mLeft*REGION_WIDTH_UNITS); | ||
74 | F32 y_meters = F32(new_layer.LayerExtents.mBottom*REGION_WIDTH_UNITS); | ||
75 | adjust = gWorldMap->extendAABB(U32(x_meters), U32(y_meters), | ||
76 | U32(x_meters+REGION_WIDTH_UNITS*new_layer.LayerExtents.getWidth()), | ||
77 | U32(y_meters+REGION_WIDTH_UNITS*new_layer.LayerExtents.getHeight())) || adjust; | ||
78 | |||
79 | gWorldMap->mMapLayers[agent_flags].push_back(new_layer); | ||
80 | } | ||
81 | |||
82 | gWorldMap->mMapLoaded[agent_flags] = TRUE; | ||
83 | if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); | ||
84 | |||
85 | /* | ||
86 | U32 agent_flags; | ||
87 | msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); | ||
88 | |||
89 | if (agent_flags < 0 || agent_flags >= MAP_SIM_IMAGE_TYPES) | ||
90 | { | ||
91 | llwarns << "Invalid map image type returned! " << agent_flags << llendl; | ||
92 | return; | ||
93 | } | ||
94 | */ | ||
95 | |||
96 | bool found_null_sim = false; | ||
97 | |||
98 | adjust = FALSE; | ||
99 | const LLSD& map_blocks = result["MapBlocks"]; | ||
100 | for (iter = map_blocks.beginArray(); iter != map_blocks.endArray(); ++iter) | ||
101 | { | ||
102 | const LLSD& map_block = *iter; | ||
103 | |||
104 | S32 x_regions = map_block["X"]; | ||
105 | S32 y_regions = map_block["Y"]; | ||
106 | std::string name = map_block["Name"]; | ||
107 | S32 access = map_block["Access"]; | ||
108 | S32 region_flags = map_block["RegionFlags"]; | ||
109 | S32 water_height = map_block["WaterHeight"]; | ||
110 | LLUUID image_id = map_block["MapImageID"]; | ||
111 | |||
112 | U32 x_meters = x_regions * REGION_WIDTH_UNITS; | ||
113 | U32 y_meters = y_regions * REGION_WIDTH_UNITS; | ||
114 | |||
115 | if (access == 255) | ||
116 | { | ||
117 | // This region doesn't exist | ||
118 | if (gWorldMap->mIsTrackingUnknownLocation && | ||
119 | gWorldMap->mUnknownLocation.mdV[0] >= x_meters && | ||
120 | gWorldMap->mUnknownLocation.mdV[0] < x_meters + 256 && | ||
121 | gWorldMap->mUnknownLocation.mdV[1] >= y_meters && | ||
122 | gWorldMap->mUnknownLocation.mdV[1] < y_meters + 256) | ||
123 | { | ||
124 | // We were tracking this location, but it doesn't exist | ||
125 | gWorldMap->mInvalidLocation = TRUE; | ||
126 | } | ||
127 | |||
128 | found_null_sim = true; | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | adjust = gWorldMap->extendAABB(x_meters, | ||
133 | y_meters, | ||
134 | x_meters+REGION_WIDTH_UNITS, | ||
135 | y_meters+REGION_WIDTH_UNITS) || adjust; | ||
136 | U64 handle = to_region_handle(x_meters, y_meters); | ||
137 | |||
138 | // llinfos << "Map sim " << name << " image layer " << agent_flags << " ID " << image_id.getString() << llendl; | ||
139 | |||
140 | LLSimInfo* siminfo = new LLSimInfo(); | ||
141 | LLWorldMap::sim_info_map_t::iterator iter = gWorldMap->mSimInfoMap.find(handle); | ||
142 | if (iter != gWorldMap->mSimInfoMap.end()) | ||
143 | { | ||
144 | LLSimInfo* oldinfo = iter->second; | ||
145 | for (S32 image=0; image<MAP_SIM_IMAGE_TYPES; ++image) | ||
146 | { | ||
147 | siminfo->mMapImageID[image] = oldinfo->mMapImageID[image]; | ||
148 | } | ||
149 | delete oldinfo; | ||
150 | } | ||
151 | gWorldMap->mSimInfoMap[handle] = siminfo; | ||
152 | |||
153 | siminfo->mHandle = handle; | ||
154 | siminfo->mName.assign( name ); | ||
155 | siminfo->mAccess = access; | ||
156 | siminfo->mRegionFlags = region_flags; | ||
157 | siminfo->mWaterHeight = (F32) water_height; | ||
158 | siminfo->mMapImageID[agent_flags] = image_id; | ||
159 | siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[gWorldMap->mCurrentMap], MIPMAP_TRUE, FALSE); | ||
160 | siminfo->mCurrentImage->bindTexture(0); | ||
161 | siminfo->mCurrentImage->setClamp(TRUE, TRUE); | ||
162 | |||
163 | if (siminfo->mMapImageID[2].notNull()) | ||
164 | { | ||
165 | siminfo->mOverlayImage = gImageList.getImage(siminfo->mMapImageID[2], MIPMAP_TRUE, FALSE); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | siminfo->mOverlayImage = NULL; | ||
170 | } | ||
171 | |||
172 | if (gWorldMap->mIsTrackingUnknownLocation && | ||
173 | gWorldMap->mUnknownLocation.mdV[0] >= x_meters && | ||
174 | gWorldMap->mUnknownLocation.mdV[0] < x_meters + 256 && | ||
175 | gWorldMap->mUnknownLocation.mdV[1] >= y_meters && | ||
176 | gWorldMap->mUnknownLocation.mdV[1] < y_meters + 256) | ||
177 | { | ||
178 | if (siminfo->mAccess == SIM_ACCESS_DOWN) | ||
179 | { | ||
180 | // We were tracking this location, but it doesn't exist | ||
181 | gWorldMap->mInvalidLocation = true; | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | // We were tracking this location, and it does exist | ||
186 | bool is_tracking_dbl = gWorldMap->mIsTrackingDoubleClick == TRUE; | ||
187 | gFloaterWorldMap->trackLocation(gWorldMap->mUnknownLocation); | ||
188 | if (is_tracking_dbl) | ||
189 | { | ||
190 | LLVector3d pos_global = LLTracker::getTrackedPositionGlobal(); | ||
191 | gAgent.teleportViaLocation( pos_global ); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); | ||
198 | gFloaterWorldMap->updateSims(found_null_sim); | ||
199 | } | ||