* fixed crash when ObjMgr was adding an object with a guid already existing (instead of the old object the new one was deleted)

* correctly (hopefully) reversed xbase & ybase in MapChunk loading
This commit is contained in:
false_genesis 2008-04-01 01:57:31 +00:00
parent cb3081aae9
commit cc5cf995fd
2 changed files with 6 additions and 5 deletions

View File

@ -64,14 +64,15 @@ void ObjMgr::Remove(uint64 guid, bool del)
void ObjMgr::Add(Object *o) void ObjMgr::Add(Object *o)
{ {
Object *ox = GetObj(o->GetGUID(),true); // if an object already exists in the mgr, store old ptr... Object *ox = GetObj(o->GetGUID(),true); // if an object already exists in the mgr, store old ptr...
if(o == ox)
return; // if both pointers are the same, do nothing (already added and happy)
_obj[o->GetGUID()] = o; // ...assign new one... _obj[o->GetGUID()] = o; // ...assign new one...
if(ox) // and if != NULL, delete the old object (completely, from memory) if(ox) // and if != NULL, delete the old object (completely, from memory)
{ {
Remove(ox->GetGUID(),true); delete ox; // only delete pointer, everything else is already reserved for the just added new obj
} }
PseuGUI *gui = _instance->GetGUI(); if(PseuGUI *gui = _instance->GetGUI())
if(gui)
gui->NotifyObjectCreation(o); gui->NotifyObjectCreation(o);
} }

View File

@ -24,8 +24,8 @@ void MapTile::ImportFromADT(ADTFile *adt)
for(uint32 ch=0; ch<CHUNKS_PER_TILE; ch++) for(uint32 ch=0; ch<CHUNKS_PER_TILE; ch++)
{ {
_chunks[ch].baseheight = adt->_chunks[ch].hdr.zbase; // ADT files store (x/z) as ground coords and (y) as the height! _chunks[ch].baseheight = adt->_chunks[ch].hdr.zbase; // ADT files store (x/z) as ground coords and (y) as the height!
_chunks[ch].basex = adt->_chunks[ch].hdr.xbase; // here converting it to (x/y) on ground and basehight as actual height. _chunks[ch].basex = adt->_chunks[ch].hdr.ybase; // here converting it to (x/y) on ground and basehight as actual height.
_chunks[ch].basey = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S _chunks[ch].basey = adt->_chunks[ch].hdr.xbase; // strange coords they use... :S
uint32 fcnt=0, rcnt=0; uint32 fcnt=0, rcnt=0;
while(true) //9*9 + 8*8 while(true) //9*9 + 8*8
{ {