From 2bc0bc0f9a5487a9e239dae0f930408ecdbbc593 Mon Sep 17 00:00:00 2001 From: Wyk3d Date: Sat, 15 Nov 2008 15:29:21 +0200 Subject: [PATCH 1/3] [6825] Update only the cells around players and do not update the same cell twice --- src/game/Map.cpp | 43 ++++++++++++++++++++-------------------- src/game/Map.h | 5 +++-- src/shared/revision_nr.h | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 601a69e86..68a4ddf74 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -564,6 +564,12 @@ void Map::Update(const uint32 &t_diff) { resetMarkedCells(); + MaNGOS::ObjectUpdater updater(t_diff); + // for creature + TypeContainerVisitor grid_object_update(updater); + // for pets + TypeContainerVisitor world_object_update(updater); + //TODO: Player guard HashMapHolder::MapType& playerMap = HashMapHolder::GetContainer(); for(HashMapHolder::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) @@ -592,33 +598,28 @@ void Map::Update(const uint32 &t_diff) end_cell >> 1; end_cell += 1; // lower right for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) - for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) - markCell(x,y); - } - - MaNGOS::ObjectUpdater updater(t_diff); - // for creature - TypeContainerVisitor grid_object_update(updater); - // for pets - TypeContainerVisitor world_object_update(updater); - - for(int x = 0; x < TOTAL_NUMBER_OF_CELLS_PER_MAP; ++x) - { - for(int y = 0; y < TOTAL_NUMBER_OF_CELLS_PER_MAP; ++y) { - if(isCellMarked(x,y)) + for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) { - CellPair pair(x,y); - Cell cell(pair); - cell.data.Part.reserved = CENTER_DISTRICT; - cell.SetNoCreate(); - CellLock cell_lock(cell, pair); - cell_lock->Visit(cell_lock, grid_object_update, *this); - cell_lock->Visit(cell_lock, world_object_update, *this); + // marked cells are those that have been visited + // don't visit the same cell twice + uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; + if(!isCellMarked(cell_id)) + { + markCell(cell_id); + CellPair pair(x,y); + Cell cell(pair); + cell.data.Part.reserved = CENTER_DISTRICT; + cell.SetNoCreate(); + CellLock cell_lock(cell, pair); + cell_lock->Visit(cell_lock, grid_object_update, *this); + cell_lock->Visit(cell_lock, world_object_update, *this); + } } } } + // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended if (IsBattleGroundOrArena()) diff --git a/src/game/Map.h b/src/game/Map.h index 454bc0e17..df4b8d004 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -230,8 +230,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair); void resetMarkedCells() { marked_cells.reset(); } - bool isCellMarked(uint32 x, uint32 y) { return marked_cells.test(y * TOTAL_NUMBER_OF_CELLS_PER_MAP + x); } - void markCell(uint32 x, uint32 y) { marked_cells.set(y * TOTAL_NUMBER_OF_CELLS_PER_MAP + x); } + bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); } + void markCell(uint32 pCellId) { marked_cells.set(pCellId); } + private: void LoadVMap(int pX, int pY); void LoadMap(uint32 mapid, uint32 instanceid, int x,int y); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 264605f9f..5848e9f14 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6824" + #define REVISION_NR "6825" #endif // __REVISION_NR_H__ From 5944377d94e2b0431e7227a0e2da2a62f1c78c8d Mon Sep 17 00:00:00 2001 From: hunuza Date: Sat, 15 Nov 2008 17:53:41 +0100 Subject: [PATCH 2/3] [6826] Fixed typo in debug output. --- src/game/Unit.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index dc9d83774..30d4f9e17 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10103,7 +10103,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag } case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: { - sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s class script aura of spell %u)", + sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)", (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown); break; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5848e9f14..6c2212faa 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6825" + #define REVISION_NR "6826" #endif // __REVISION_NR_H__ From b195eb87a950d7710733f6d811b20dee751129df Mon Sep 17 00:00:00 2001 From: derex Date: Sat, 15 Nov 2008 20:46:02 +0200 Subject: [PATCH 3/3] Add missing call to World::RemoveQueuedPlayer, now auth queue should work! --- src/game/World.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/game/World.cpp b/src/game/World.cpp index db9bee3c1..182a2a6df 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -2436,6 +2436,7 @@ void World::UpdateSessions( time_t diff ) ///- and remove not active sessions from the list if(!itr->second->Update(diff)) // As interval = 0 { + RemoveQueuedPlayer (itr->second); delete itr->second; m_sessions.erase(itr); }