aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerregion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewerregion.cpp')
-rw-r--r--linden/indra/newview/llviewerregion.cpp148
1 files changed, 49 insertions, 99 deletions
diff --git a/linden/indra/newview/llviewerregion.cpp b/linden/indra/newview/llviewerregion.cpp
index 0f20fd8..0a21e45 100644
--- a/linden/indra/newview/llviewerregion.cpp
+++ b/linden/indra/newview/llviewerregion.cpp
@@ -202,8 +202,9 @@ void LLViewerRegion::loadCache()
202 } 202 }
203 203
204 U32 zero; 204 U32 zero;
205 fread(&zero, 1, sizeof(U32), fp); 205 size_t nread;
206 if (zero) 206 nread = fread(&zero, sizeof(U32), 1, fp);
207 if (nread != 1 || zero)
207 { 208 {
208 // a non-zero value here means bad things! 209 // a non-zero value here means bad things!
209 // skip reading the cached values 210 // skip reading the cached values
@@ -213,8 +214,8 @@ void LLViewerRegion::loadCache()
213 } 214 }
214 215
215 U32 version; 216 U32 version;
216 fread(&version, 1, sizeof(U32), fp); 217 nread = fread(&version, sizeof(U32), 1, fp);
217 if (version != INDRA_OBJECT_CACHE_VERSION) 218 if (nread != 1 || version != INDRA_OBJECT_CACHE_VERSION)
218 { 219 {
219 // a version mismatch here means we've changed the binary format! 220 // a version mismatch here means we've changed the binary format!
220 // skip reading the cached values 221 // skip reading the cached values
@@ -224,8 +225,8 @@ void LLViewerRegion::loadCache()
224 } 225 }
225 226
226 LLUUID cache_id; 227 LLUUID cache_id;
227 fread(&cache_id.mData, UUID_BYTES, sizeof(U8), fp); 228 nread = fread(&cache_id.mData, 1, UUID_BYTES, fp);
228 if (mCacheID != cache_id) 229 if (nread != UUID_BYTES || mCacheID != cache_id)
229 { 230 {
230 llinfos << "Cache ID doesn't match for this region, discarding" 231 llinfos << "Cache ID doesn't match for this region, discarding"
231 << llendl; 232 << llendl;
@@ -234,7 +235,14 @@ void LLViewerRegion::loadCache()
234 } 235 }
235 236
236 S32 num_entries; 237 S32 num_entries;
237 fread(&num_entries, 1, sizeof(S32), fp); 238 nread = fread(&num_entries, sizeof(S32), 1, fp);
239 if (nread != 1)
240 {
241 llinfos << "Short read, discarding" << llendl;
242 fclose(fp);
243 return;
244 }
245
238 S32 i; 246 S32 i;
239 for (i = 0; i < num_entries; i++) 247 for (i = 0; i < num_entries; i++)
240 { 248 {
@@ -284,16 +292,28 @@ void LLViewerRegion::saveCache()
284 292
285 // write out zero to indicate a version cache file 293 // write out zero to indicate a version cache file
286 U32 zero = 0; 294 U32 zero = 0;
287 fwrite(&zero, 1, sizeof(U32), fp); 295 if (fwrite(&zero, sizeof(U32), 1, fp) != 1)
296 {
297 llwarns << "Short write" << llendl;
298 }
288 299
289 // write out version number 300 // write out version number
290 U32 version = INDRA_OBJECT_CACHE_VERSION; 301 U32 version = INDRA_OBJECT_CACHE_VERSION;
291 fwrite(&version, 1, sizeof(U32), fp); 302 if (fwrite(&version, sizeof(U32), 1, fp) != 1)
303 {
304 llwarns << "Short write" << llendl;
305 }
292 306
293 // write the cache id for this sim 307 // write the cache id for this sim
294 fwrite(&mCacheID.mData, UUID_BYTES, sizeof(U8), fp); 308 if (fwrite(&mCacheID.mData, 1, UUID_BYTES, fp) != UUID_BYTES)
309 {
310 llwarns << "Short write" << llendl;
311 }
295 312
296 fwrite(&num_entries, 1, sizeof(S32), fp); 313 if (fwrite(&num_entries, sizeof(S32), 1, fp) != 1)
314 {
315 llwarns << "Short write" << llendl;
316 }
297 317
298 LLVOCacheEntry *entry; 318 LLVOCacheEntry *entry;
299 319
@@ -321,89 +341,15 @@ void LLViewerRegion::sendReliableMessage()
321 gMessageSystem->sendReliable(mHost); 341 gMessageSystem->sendReliable(mHost);
322} 342}
323 343
324 344void LLViewerRegion::setFlags(BOOL b, U32 flags)
325void LLViewerRegion::setAllowDamage(BOOL b)
326{
327 if (b)
328 {
329 mRegionFlags |= REGION_FLAGS_ALLOW_DAMAGE;
330 }
331 else
332 {
333 mRegionFlags &= ~REGION_FLAGS_ALLOW_DAMAGE;
334 }
335}
336
337
338void LLViewerRegion::setAllowLandmark(BOOL b)
339{
340 if (b)
341 {
342 mRegionFlags |= REGION_FLAGS_ALLOW_LANDMARK;
343 }
344 else
345 {
346 mRegionFlags &= ~REGION_FLAGS_ALLOW_LANDMARK;
347 }
348}
349
350void LLViewerRegion::setAllowSetHome(BOOL b)
351{
352 if (b)
353 {
354 mRegionFlags |= REGION_FLAGS_ALLOW_SET_HOME;
355 }
356 else
357 {
358 mRegionFlags &= ~REGION_FLAGS_ALLOW_SET_HOME;
359 }
360}
361
362void LLViewerRegion::setResetHomeOnTeleport(BOOL b)
363{ 345{
364 if (b) 346 if (b)
365 { 347 {
366 mRegionFlags |= REGION_FLAGS_RESET_HOME_ON_TELEPORT; 348 mRegionFlags |= flags;
367 } 349 }
368 else 350 else
369 { 351 {
370 mRegionFlags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT; 352 mRegionFlags &= ~flags;
371 }
372}
373
374void LLViewerRegion::setSunFixed(BOOL b)
375{
376 if (b)
377 {
378 mRegionFlags |= REGION_FLAGS_SUN_FIXED;
379 }
380 else
381 {
382 mRegionFlags &= ~REGION_FLAGS_SUN_FIXED;
383 }
384}
385
386void LLViewerRegion::setBlockFly(BOOL b)
387{
388 if (b)
389 {
390 mRegionFlags |= REGION_FLAGS_BLOCK_FLY;
391 }
392 else
393 {
394 mRegionFlags &= ~REGION_FLAGS_BLOCK_FLY;
395 }
396}
397
398void LLViewerRegion::setAllowDirectTeleport(BOOL b)
399{
400 if (b)
401 {
402 mRegionFlags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
403 }
404 else
405 {
406 mRegionFlags &= ~REGION_FLAGS_ALLOW_DIRECT_TELEPORT;
407 } 353 }
408} 354}
409 355
@@ -737,14 +683,7 @@ void LLViewerRegion::calculateCenterGlobal()
737 mCenterGlobal = mOriginGlobal; 683 mCenterGlobal = mOriginGlobal;
738 mCenterGlobal.mdV[VX] += 0.5 * mWidth; 684 mCenterGlobal.mdV[VX] += 0.5 * mWidth;
739 mCenterGlobal.mdV[VY] += 0.5 * mWidth; 685 mCenterGlobal.mdV[VY] += 0.5 * mWidth;
740 if (mLandp) 686 mCenterGlobal.mdV[VZ] = 0.5*mLandp->getMinZ() + mLandp->getMaxZ();
741 {
742 mCenterGlobal.mdV[VZ] = 0.5*mLandp->getMinZ() + mLandp->getMaxZ();
743 }
744 else
745 {
746 mCenterGlobal.mdV[VZ] = F64( getWaterHeight() );
747 }
748} 687}
749 688
750void LLViewerRegion::calculateCameraDistance() 689void LLViewerRegion::calculateCameraDistance()
@@ -867,13 +806,23 @@ F32 LLViewerRegion::getLandHeightRegion(const LLVector3& region_pos)
867 806
868BOOL LLViewerRegion::isOwnedSelf(const LLVector3& pos) 807BOOL LLViewerRegion::isOwnedSelf(const LLVector3& pos)
869{ 808{
870 return mParcelOverlay->isOwnedSelf(pos); 809 if (mParcelOverlay)
810 {
811 return mParcelOverlay->isOwnedSelf(pos);
812 } else {
813 return FALSE;
814 }
871} 815}
872 816
873// Owned by a group you belong to? (officer or member) 817// Owned by a group you belong to? (officer or member)
874BOOL LLViewerRegion::isOwnedGroup(const LLVector3& pos) 818BOOL LLViewerRegion::isOwnedGroup(const LLVector3& pos)
875{ 819{
876 return mParcelOverlay->isOwnedGroup(pos); 820 if (mParcelOverlay)
821 {
822 return mParcelOverlay->isOwnedGroup(pos);
823 } else {
824 return FALSE;
825 }
877} 826}
878 827
879void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg) 828void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
@@ -1325,9 +1274,10 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
1325 capabilityNames.append("UntrustedSimulatorMessage"); 1274 capabilityNames.append("UntrustedSimulatorMessage");
1326 capabilityNames.append("ParcelVoiceInfoRequest"); 1275 capabilityNames.append("ParcelVoiceInfoRequest");
1327 capabilityNames.append("ChatSessionRequest"); 1276 capabilityNames.append("ChatSessionRequest");
1277 capabilityNames.append("ProvisionVoiceAccountRequest");
1328 1278
1329 llinfos << "posting to seed " << url << llendl; 1279 llinfos << "posting to seed " << url << llendl;
1330 1280
1331 LLHTTPClient::post(url, capabilityNames, BaseCapabilitiesComplete::build(this)); 1281 LLHTTPClient::post(url, capabilityNames, BaseCapabilitiesComplete::build(this));
1332} 1282}
1333 1283