* disabled thread locking in DrawObjMgr (Object pointer corruption problem solved in [263])
* fixed setting MapMgr to loading state to fix problems with GUI thread trying to access not yet loaded maps
This commit is contained in:
parent
6d5b8de2d5
commit
57fed6d6cc
@ -50,12 +50,12 @@ void DrawObjMgr::UnlinkAll(void)
|
||||
|
||||
void DrawObjMgr::Update(void)
|
||||
{
|
||||
ZThread::FastMutex mut;
|
||||
//ZThread::FastMutex mut;
|
||||
|
||||
// now for the threadsafe part: lock every thread except this one
|
||||
// to prevent obj ptr corruption caused by other running threads
|
||||
// TODO: lock only main thread (that should be the only one to delete objects anyway!)
|
||||
mut.acquire();
|
||||
//mut.acquire();
|
||||
|
||||
// add objects waiting on the add queue to the real storage
|
||||
while(_add.size())
|
||||
@ -89,6 +89,6 @@ void DrawObjMgr::Update(void)
|
||||
i->second->Draw();
|
||||
}
|
||||
|
||||
mut.release();
|
||||
//mut.release();
|
||||
|
||||
}
|
||||
|
||||
@ -234,6 +234,7 @@ void SceneWorld::UpdateTerrain(void)
|
||||
logdebug("SceneWorld: Waiting until maps are loaded...");
|
||||
while(!mapmgr->Loaded())
|
||||
device->sleep(1);
|
||||
logdebug("SceneWorld: ... maps done loading");
|
||||
}
|
||||
|
||||
// TODO: as soon as WMO-only worlds are implemented, remove this!!
|
||||
@ -251,6 +252,7 @@ void SceneWorld::UpdateTerrain(void)
|
||||
// EDIT: it seems to display fine now, but i am still not sure if the way it is done is correct...
|
||||
mutex.acquire(); // prevent other threads from deleting the maptile
|
||||
logdebug("SceneWorld: Displaying MapTiles near grids x:%u y:%u",mapmgr->GetGridX(),mapmgr->GetGridY());
|
||||
logdebug("Loaded maps: %u: %s",mapmgr->GetLoadedMapsCount(), mapmgr->GetLoadedTilesString().c_str());
|
||||
for(s32 tiley = 0; tiley < 3; tiley++)
|
||||
{
|
||||
for(s32 tilex = 0; tilex < 3; tilex++)
|
||||
@ -277,7 +279,7 @@ void SceneWorld::UpdateTerrain(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("SceneWorld: MapTile not loaded, can't apply heightmap!");
|
||||
logerror("SceneWorld: MapTile (%u, %u) not loaded, can't apply heightmap!", mapmgr->GetGridX()+tilex, mapmgr->GetGridY()+tiley);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,15 +312,20 @@ void SceneWorld::UpdateTerrain(void)
|
||||
|
||||
// to set the correct position of the terrain, we have to use the top-left tile's coords as terrain base pos
|
||||
MapTile *maptile = mapmgr->GetNearTile(-1, -1);
|
||||
vector3df tpos(0,0,0); // height already managed when building up terrain (-> Y = always 0)
|
||||
if(maptile)
|
||||
{
|
||||
vector3df tpos;
|
||||
tpos.X = -maptile->GetBaseX();
|
||||
tpos.Y = 0; // height already managed when building up terrain
|
||||
tpos.Z = -maptile->GetBaseY();
|
||||
logdebug("SceneWorld: Setting position of terrain (x:%.2f y:%.2f z:%.2f)", tpos.X, tpos.Y, tpos.Z);
|
||||
terrain->setPosition(tpos);
|
||||
}
|
||||
else if(maptile = mapmgr->GetCurrentTile()) // this is tile (0, 0) in relative coords
|
||||
{
|
||||
logdebug("SceneWorld: Using alternative coords due to missing MapTile");
|
||||
tpos.X = -(maptile->GetBaseX() + TILESIZE);
|
||||
tpos.Y = -(maptile->GetBaseY() + TILESIZE);
|
||||
}
|
||||
logdebug("SceneWorld: Setting position of terrain (x:%.2f y:%.2f z:%.2f)", tpos.X, tpos.Y, tpos.Z);
|
||||
terrain->setPosition(tpos);
|
||||
|
||||
logdebug("SceneWorld: Smoothing terrain normals...");
|
||||
terrain->smoothNormals();
|
||||
|
||||
@ -55,6 +55,7 @@ void MapMgr::Update(float x, float y, uint32 m)
|
||||
_LoadNearTiles(_gridx,_gridy,m);
|
||||
_UnloadOldTiles();
|
||||
}
|
||||
_mapsLoaded = true; // at this point, everything should be loaded (if maps existing)
|
||||
}
|
||||
|
||||
void MapMgr::Flush(void)
|
||||
@ -67,6 +68,7 @@ void MapMgr::Flush(void)
|
||||
|
||||
void MapMgr::_LoadNearTiles(uint32 gx, uint32 gy, uint32 m)
|
||||
{
|
||||
_mapsLoaded = false;
|
||||
logdebug("MAPMGR: Loading near tiles for (%u, %u) map %u",gx,gy,m);
|
||||
for(uint32 v = gy-1; v <= gy+1; v++)
|
||||
{
|
||||
@ -75,11 +77,11 @@ void MapMgr::_LoadNearTiles(uint32 gx, uint32 gy, uint32 m)
|
||||
_LoadTile(h,v,m);
|
||||
}
|
||||
}
|
||||
_mapsLoaded = true;
|
||||
}
|
||||
|
||||
void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m)
|
||||
{
|
||||
_mapsLoaded = false;
|
||||
if(!_tiles->TileExists(gx,gy))
|
||||
{
|
||||
if(TileExistsInFile(m,gx,gy))
|
||||
@ -121,11 +123,11 @@ void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m)
|
||||
|
||||
void MapMgr::_UnloadOldTiles(void)
|
||||
{
|
||||
for(uint32 gy=0; gy<64; gy++)
|
||||
for(int32 gy=0; gy<64; gy++)
|
||||
{
|
||||
for(uint32 gx=0; gx<64; gx++)
|
||||
for(int32 gx=0; gx<64; gx++)
|
||||
{
|
||||
if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) )
|
||||
if( (int32(_gridx) < gx-1 || int32(_gridx) > gx+1) && (int32(_gridy) < gy-1 || int32(_gridy) > gy+1) )
|
||||
{
|
||||
if(_tiles->GetTile(gx,gy))
|
||||
{
|
||||
@ -199,4 +201,16 @@ float MapMgr::GetZ(float x, float y)
|
||||
logerror("MapMgr::GetZ() called for not loaded MapTile (%u, %u) for (%f, %f)",gcoords.x,gcoords.y,x,y);
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
|
||||
std::string MapMgr::GetLoadedTilesString(void)
|
||||
{
|
||||
std::stringstream s;
|
||||
for(uint32 x = 0; x < 64; x++)
|
||||
{
|
||||
for(uint32 y = 0; y < 64; y++)
|
||||
if(_tiles->GetTile(x,y))
|
||||
s << "(" << x << "|" << y << ") ";
|
||||
}
|
||||
return s.str();
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ public:
|
||||
MapTile *GetNearTile(int32, int32);
|
||||
inline bool Loaded(void) { return _mapsLoaded; }
|
||||
uint32 GetLoadedMapsCount(void);
|
||||
std::string GetLoadedTilesString(void);
|
||||
inline uint32 GetGridX(void) { return _gridx; }
|
||||
inline uint32 GetGridY(void) { return _gridy; }
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user