summaryrefslogtreecommitdiff
path: root/indra/newview/llworld.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llworld.cpp')
-rw-r--r--indra/newview/llworld.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index aa32ef04b2..871583e071 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -93,7 +93,7 @@ LLWorld::LLWorld() :
mLastPacketsLost(0),
mSpaceTimeUSec(0)
{
- for (S32 i = 0; i < 8; i++)
+ for (S32 i = 0; i < EDGE_WATER_OBJECTS_COUNT; i++)
{
mEdgeWaterObjects[i] = NULL;
}
@@ -126,7 +126,7 @@ void LLWorld::resetClass()
LLViewerPartSim::getInstance()->destroyClass();
mDefaultWaterTexturep = NULL ;
- for (S32 i = 0; i < 8; i++)
+ for (S32 i = 0; i < EDGE_WATER_OBJECTS_COUNT; i++)
{
mEdgeWaterObjects[i] = NULL;
}
@@ -293,13 +293,13 @@ void LLWorld::removeRegion(const LLHost &host)
mRegionRemovedSignal(regionp);
- delete regionp;
-
updateWaterObjects();
//double check all objects of this region are removed.
gObjectList.clearAllMapObjectsInRegion(regionp) ;
//llassert_always(!gObjectList.hasMapObjectInRegion(regionp)) ;
+
+ delete regionp; // Delete last to prevent use after free
}
@@ -753,6 +753,8 @@ void LLWorld::clearAllVisibleObjects()
//clear all cached visible objects.
(*iter)->clearCachedVisibleObjects();
}
+ clearHoleWaterObjects();
+ clearEdgeWaterObjects();
}
void LLWorld::updateParticles()
@@ -920,7 +922,7 @@ void LLWorld::precullWaterObjects(LLCamera& camera, LLCullResult* cull, bool inc
}
S32 dir;
- for (dir = 0; dir < 8; dir++)
+ for (dir = 0; dir < EDGE_WATER_OBJECTS_COUNT; dir++)
{
LLVOWater* waterp = mEdgeWaterObjects[dir];
if (waterp && waterp->mDrawable)
@@ -931,6 +933,26 @@ void LLWorld::precullWaterObjects(LLCamera& camera, LLCullResult* cull, bool inc
}
}
+void LLWorld::clearHoleWaterObjects()
+{
+ for (std::list<LLPointer<LLVOWater> >::iterator iter = mHoleWaterObjects.begin();
+ iter != mHoleWaterObjects.end(); ++iter)
+ {
+ LLVOWater* waterp = (*iter).get();
+ gObjectList.killObject(waterp);
+ }
+ mHoleWaterObjects.clear();
+}
+
+void LLWorld::clearEdgeWaterObjects()
+{
+ for (S32 i = 0; i < EDGE_WATER_OBJECTS_COUNT; i++)
+ {
+ gObjectList.killObject(mEdgeWaterObjects[i]);
+ mEdgeWaterObjects[i] = NULL;
+ }
+}
+
void LLWorld::updateWaterObjects()
{
if (!gAgent.getRegion())
@@ -974,13 +996,7 @@ void LLWorld::updateWaterObjects()
}
}
- for (std::list<LLPointer<LLVOWater> >::iterator iter = mHoleWaterObjects.begin();
- iter != mHoleWaterObjects.end(); ++ iter)
- {
- LLVOWater* waterp = (*iter).get();
- gObjectList.killObject(waterp);
- }
- mHoleWaterObjects.clear();
+ clearHoleWaterObjects();
// Use the water height of the region we're on for areas where there is no region
F32 water_height = gAgent.getRegion()->getWaterHeight();
@@ -1021,7 +1037,7 @@ void LLWorld::updateWaterObjects()
(S32)(512 - (region_y - min_y)) };
S32 dir;
- for (dir = 0; dir < 8; dir++)
+ for (dir = 0; dir < EDGE_WATER_OBJECTS_COUNT; dir++)
{
S32 dim[2] = { 0 };
switch (gDirAxes[dir][0])