From cc5cf995fde281224c2f03193b2cf9b065c240d1 Mon Sep 17 00:00:00 2001 From: false_genesis Date: Tue, 1 Apr 2008 01:57:31 +0000 Subject: [PATCH] * 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 --- src/Client/World/ObjMgr.cpp | 7 ++++--- src/shared/MapTile.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Client/World/ObjMgr.cpp b/src/Client/World/ObjMgr.cpp index 57a5c28..2fc4f98 100644 --- a/src/Client/World/ObjMgr.cpp +++ b/src/Client/World/ObjMgr.cpp @@ -64,14 +64,15 @@ void ObjMgr::Remove(uint64 guid, bool del) void ObjMgr::Add(Object *o) { 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... 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(gui) + if(PseuGUI *gui = _instance->GetGUI()) gui->NotifyObjectCreation(o); } diff --git a/src/shared/MapTile.cpp b/src/shared/MapTile.cpp index fcbce71..79de907 100644 --- a/src/shared/MapTile.cpp +++ b/src/shared/MapTile.cpp @@ -24,8 +24,8 @@ void MapTile::ImportFromADT(ADTFile *adt) for(uint32 ch=0; ch_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].basey = adt->_chunks[ch].hdr.ybase; // strange coords they use... :S + _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.xbase; // strange coords they use... :S uint32 fcnt=0, rcnt=0; while(true) //9*9 + 8*8 {