diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index 90d82d086..f83f2e9b6 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -627,8 +627,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) MaNGOS::LocalizedPacketDo say_do(say_builder); MaNGOS::PlayerDistWorker > say_worker(GetPlayer(),sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do); TypeContainerVisitor >, WorldTypeMapContainer > message(say_worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY)); + cell.Visit(p, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY)); } WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8); diff --git a/src/game/Cell.h b/src/game/Cell.h index 7f5eba5e0..10ec22162 100644 --- a/src/game/Cell.h +++ b/src/game/Cell.h @@ -41,8 +41,6 @@ enum District ALL_DISTRICT = (UPPER_DISTRICT | LOWER_DISTRICT | LEFT_DISTRICT | RIGHT_DISTRICT | CENTER_DISTRICT) }; -template struct CellLock; - struct MANGOS_DLL_DECL CellArea { CellArea() : right_offset(0), left_offset(0), upper_offset(0), lower_offset(0) {} @@ -160,30 +158,13 @@ struct MANGOS_DLL_DECL Cell uint32 All; } data; - template void Visit(const CellLock &, TypeContainerVisitor &visitor, Map &) const; - template void Visit(const CellLock &, TypeContainerVisitor &visitor, Map &m, const WorldObject &obj, float radius) const; + template void Visit(const CellPair &cellPair, TypeContainerVisitor &visitor, Map &) const; + template void Visit(const CellPair &cellPair, TypeContainerVisitor &visitor, Map &m, const WorldObject &obj, float radius) const; static CellArea CalculateCellArea(const WorldObject &obj, float radius); private: - template void VisitCircle(const CellLock &, TypeContainerVisitor &, Map &, const CellPair& , const CellPair& ) const; + template void VisitCircle(const CellPair &cellPair, TypeContainerVisitor &, Map &, const CellPair& , const CellPair& ) const; }; -template -struct MANGOS_DLL_DECL CellLock -{ - const Cell& i_cell; - const CellPair &i_cellPair; - CellLock(const Cell &c, const CellPair &p) : i_cell(c), i_cellPair(p) {} - CellLock(const CellLock &cell) : i_cell(cell.i_cell), i_cellPair(cell.i_cellPair) {} - const Cell* operator->(void) const { return &i_cell; } - const Cell* operator->(void) { return &i_cell; } - operator const Cell &(void) const { return i_cell; } - CellLock& operator=(const CellLock &cell) - { - ~CellLock(); - new (this) CellLock(cell); - return *this; - } -}; #endif diff --git a/src/game/CellImpl.h b/src/game/CellImpl.h index de3061e64..a6be9f08a 100644 --- a/src/game/CellImpl.h +++ b/src/game/CellImpl.h @@ -33,18 +33,17 @@ inline Cell::Cell(CellPair const& p) data.Part.reserved = 0; } -template +template inline void -Cell::Visit(const CellLock &l, TypeContainerVisitor &visitor, Map &m) const +Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor &visitor, Map &m) const { - const CellPair &standing_cell = l.i_cellPair; if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) return; uint16 district = (District)this->data.Part.reserved; if(district == CENTER_DISTRICT) { - m.Visit(l, visitor); + m.Visit(*this, visitor); return; } @@ -121,9 +120,8 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi { CellPair cell_pair(x,y); Cell r_zone(cell_pair); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_pair); - m.Visit(lock, visitor); + r_zone.data.Part.nocreate = data.Part.nocreate; + m.Visit(r_zone, visitor); } } } @@ -165,11 +163,10 @@ inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius) return CellArea(right, left, upper, lower); } -template +template inline void -Cell::Visit(const CellLock &l, TypeContainerVisitor &visitor, Map &m, const WorldObject &obj, float radius) const +Cell::Visit(const CellPair &standing_cell, TypeContainerVisitor &visitor, Map &m, const WorldObject &obj, float radius) const { - const CellPair &standing_cell = l.i_cellPair; if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) return; @@ -178,7 +175,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi //maybe it is better to just return when radius <= 0.0f? if(radius <= 0.0f) { - m.Visit(l, visitor); + m.Visit(*this, visitor); return; } //lets limit the upper value for search radius @@ -190,7 +187,7 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi //if radius fits inside standing cell if(!area) { - m.Visit(l, visitor); + m.Visit(*this, visitor); return; } @@ -204,13 +201,13 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi //there are nothing to optimize because SIZE_OF_GRID_CELL is too big... if(((end_cell.x_coord - begin_cell.x_coord) > 4) && ((end_cell.y_coord - begin_cell.y_coord) > 4)) { - VisitCircle(l, visitor, m, begin_cell, end_cell); + VisitCircle(standing_cell, visitor, m, begin_cell, end_cell); return; } //ALWAYS visit standing cell first!!! Since we deal with small radiuses //it is very essential to call visitor for standing cell firstly... - m.Visit(l, visitor); + m.Visit(*this, visitor); // loop the cell range for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++) @@ -222,17 +219,16 @@ Cell::Visit(const CellLock &l, TypeContainerVisitor &vi if(cell_pair != standing_cell) { Cell r_zone(cell_pair); - r_zone.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock(r_zone, cell_pair); - m.Visit(lock, visitor); + r_zone.data.Part.nocreate = data.Part.nocreate; + m.Visit(r_zone, visitor); } } } } -template +template inline void -Cell::VisitCircle(const CellLock &l, TypeContainerVisitor &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const +Cell::VisitCircle(const CellPair &standing_cell, TypeContainerVisitor &visitor, Map &m, const CellPair& begin_cell, const CellPair& end_cell) const { //here is an algorithm for 'filling' circum-squared octagon uint32 x_shift = (uint32)ceilf((end_cell.x_coord - begin_cell.x_coord) * 0.3f - 0.5f); @@ -247,9 +243,8 @@ Cell::VisitCircle(const CellLock &l, TypeContainerVisitordata.Part.nocreate; - CellLock lock(r_zone, cell_pair); - m.Visit(lock, visitor); + r_zone.data.Part.nocreate = data.Part.nocreate; + m.Visit(r_zone, visitor); } } @@ -272,16 +267,14 @@ Cell::VisitCircle(const CellLock &l, TypeContainerVisitordata.Part.nocreate; - CellLock lock_left(r_zone_left, cell_pair_left); - m.Visit(lock_left, visitor); + r_zone_left.data.Part.nocreate = data.Part.nocreate; + m.Visit(r_zone_left, visitor); //right trapezoid cell visit CellPair cell_pair_right(x_end + step, y); Cell r_zone_right(cell_pair_right); - r_zone_right.data.Part.nocreate = l->data.Part.nocreate; - CellLock lock_right(r_zone_right, cell_pair_right); - m.Visit(lock_right, visitor); + r_zone_right.data.Part.nocreate = data.Part.nocreate; + m.Visit(r_zone_right, visitor); } } } diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 106f30f54..07d1cc302 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1962,8 +1962,7 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid MaNGOS::GameObjectSearcher checker(pl,obj,go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *pl->GetMap()); + cell.Visit(p, object_checker, *pl->GetMap()); } return obj; diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index d7bf68a46..94db57034 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -582,8 +582,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) MaNGOS::LocalizedPacketDo emote_do(emote_builder); MaNGOS::PlayerDistWorker > emote_worker(GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), emote_do); TypeContainerVisitor >, WorldTypeMapContainer> message(emote_worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)); + cell.Visit(p, message, *GetPlayer()->GetMap(), *GetPlayer(), sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE)); GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 27139660f..cb318b6a1 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -551,8 +551,7 @@ void Creature::DoFleeToGetAssistance() TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, radius); + cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius); SetNoSearchAssistance(true); UpdateSpeed(MOVE_RUN, false); @@ -1524,8 +1523,7 @@ void Creature::CallAssistance() TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, radius); + cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius); } if (!assistList.empty()) @@ -1558,8 +1556,7 @@ void Creature::CallForHelp(float fRadius) TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap(), *this, fRadius); + cell.Visit(p, grid_creature_searcher, *GetMap(), *this, fRadius); } bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 80e341d6c..f76eeea99 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -1234,8 +1234,7 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) */ TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_unit_searcher, *m_creature->GetMap(), *m_creature, range); + cell.Visit(p, grid_unit_searcher, *m_creature->GetMap(), *m_creature, range); return pUnit; } @@ -1251,8 +1250,7 @@ void CreatureEventAI::DoFindFriendlyCC(std::list& _list, float range) TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range); + cell.Visit(p, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range); } void CreatureEventAI::DoFindFriendlyMissingBuff(std::list& _list, float range, uint32 spellid) @@ -1267,8 +1265,7 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list& _list, flo TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range); + cell.Visit(p, grid_creature_searcher, *m_creature->GetMap(), *m_creature, range); } //********************************* diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index cfe61f308..da35b9bff 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -124,9 +124,8 @@ void DynamicObject::Update(uint32 p_time) TypeContainerVisitor world_object_notifier(notifier); TypeContainerVisitor grid_object_notifier(notifier); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *GetMap(), *this, m_radius); - cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap(), *this, m_radius); + cell.Visit(p, world_object_notifier, *GetMap(), *this, m_radius); + cell.Visit(p, grid_object_notifier, *GetMap(), *this, m_radius); } if(deleteThis) diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 9ba5cbd76..b75076ab3 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -308,16 +308,14 @@ void GameObject::Update(uint32 /*p_time*/) MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius); MaNGOS::UnitSearcher checker(this,ok, u_check); - CellLock cell_lock(cell, p); - TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); - cell_lock->Visit(cell_lock, grid_object_checker, *GetMap(), *this, radius); + cell.Visit(p, grid_object_checker, *GetMap(), *this, radius); // or unfriendly player/pet if(!ok) { TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); - cell_lock->Visit(cell_lock, world_object_checker, *GetMap(), *this, radius); + cell.Visit(p, world_object_checker, *GetMap(), *this, radius); } } else // environmental trap @@ -329,10 +327,8 @@ void GameObject::Update(uint32 /*p_time*/) MaNGOS::AnyPlayerInObjectRangeCheck p_check(this, radius); MaNGOS::PlayerSearcher checker(this,p_ok, p_check); - CellLock cell_lock(cell, p); - TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); - cell_lock->Visit(cell_lock, world_object_checker, *GetMap(), *this, radius); + cell.Visit(p, world_object_checker, *GetMap(), *this, radius); ok = p_ok; } @@ -798,8 +794,7 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target) MaNGOS::GameObjectLastSearcher checker(this, trapGO,go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *GetMap(), *target, range); + cell.Visit(p, object_checker, *GetMap(), *target, range); } // found correct GO @@ -818,10 +813,8 @@ GameObject* GameObject::LookupFishingHoleAround(float range) MaNGOS::NearestGameObjectFishingHole u_check(*this, range); MaNGOS::GameObjectSearcher checker(this, ok, u_check); - CellLock cell_lock(cell, p); - TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); - cell_lock->Visit(cell_lock, grid_object_checker, *GetMap(), *this, range); + cell.Visit(p, grid_object_checker, *GetMap(), *this, range); return ok; } diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index c6b3d082e..413d802da 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5374,8 +5374,7 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/) MaNGOS::WorldObjectWorker worker(pl,u_do); TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, obj_worker, *pl->GetMap()); + cell.Visit(p, obj_worker, *pl->GetMap()); return true; } diff --git a/src/game/Map.cpp b/src/game/Map.cpp index b8fdd2916..335e6aae9 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -508,8 +508,7 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) MaNGOS::MessageDeliverer post_man(*player, msg, to_self); TypeContainerVisitor message(post_man); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *this, *player, GetVisibilityDistance()); + cell.Visit(p, message, *this, *player, GetVisibilityDistance()); } void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) @@ -533,8 +532,7 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) //we have alot of blinking mobs because monster move packet send is broken... MaNGOS::ObjectMessageDeliverer post_man(*obj,msg); TypeContainerVisitor message(post_man); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *this, *obj, GetVisibilityDistance()); + cell.Visit(p, message, *this, *obj, GetVisibilityDistance()); } void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only) @@ -556,8 +554,7 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); TypeContainerVisitor message(post_man); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *this, *player, dist); + cell.Visit(p, message, *this, *player, dist); } void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) @@ -579,8 +576,7 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg, dist); TypeContainerVisitor message(post_man); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *this, *obj, dist); + cell.Visit(p, message, *this, *obj, dist); } bool Map::loaded(const GridPair &p) const @@ -643,9 +639,8 @@ void Map::Update(const uint32 &t_diff) 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); + cell.Visit(pair, grid_object_update, *this); + cell.Visit(pair, world_object_update, *this); } } } @@ -692,9 +687,8 @@ void Map::Update(const uint32 &t_diff) 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); + cell.Visit(pair, grid_object_update, *this); + cell.Visit(pair, world_object_update, *this); } } } @@ -2009,8 +2003,7 @@ void Map::UpdateObjectVisibility( WorldObject* obj, Cell cell, CellPair cellpair cell.SetNoCreate(); MaNGOS::VisibleChangesNotifier notifier(*obj); TypeContainerVisitor player_notifier(notifier); - CellLock cell_lock(cell, cellpair); - cell_lock->Visit(cell_lock, player_notifier, *this, *obj, GetVisibilityDistance()); + cell.Visit(cellpair, player_notifier, *this, *obj, GetVisibilityDistance()); } void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair ) @@ -2020,8 +2013,7 @@ void Map::UpdatePlayerVisibility( Player* player, Cell cell, CellPair cellpair ) MaNGOS::PlayerNotifier pl_notifier(*player); TypeContainerVisitor player_notifier(pl_notifier); - CellLock cell_lock(cell, cellpair); - cell_lock->Visit(cell_lock, player_notifier, *this, *player, GetVisibilityDistance()); + cell.Visit(cellpair, player_notifier, *this, *player, GetVisibilityDistance()); } void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair ) @@ -2032,9 +2024,8 @@ void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpa cell.SetNoCreate(); TypeContainerVisitor world_notifier(notifier); TypeContainerVisitor grid_notifier(notifier); - CellLock cell_lock(cell, cellpair); - cell_lock->Visit(cell_lock, world_notifier, *this, *player, GetVisibilityDistance()); - cell_lock->Visit(cell_lock, grid_notifier, *this, *player, GetVisibilityDistance()); + cell.Visit(cellpair, world_notifier, *this, *player, GetVisibilityDistance()); + cell.Visit(cellpair, grid_notifier, *this, *player, GetVisibilityDistance()); // send data notifier.Notify(); @@ -2042,20 +2033,18 @@ void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpa void Map::PlayerRelocationNotify( Player* player, Cell cell, CellPair cellpair ) { - CellLock cell_lock(cell, cellpair); MaNGOS::PlayerRelocationNotifier relocationNotifier(*player); cell.data.Part.reserved = ALL_DISTRICT; TypeContainerVisitor p2grid_relocation(relocationNotifier); TypeContainerVisitor p2world_relocation(relocationNotifier); - cell_lock->Visit(cell_lock, p2grid_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS); - cell_lock->Visit(cell_lock, p2world_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS); + cell.Visit(cellpair, p2grid_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS); + cell.Visit(cellpair, p2world_relocation, *this, *player, MAX_CREATURE_ATTACK_RADIUS); } void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellpair) { - CellLock cell_lock(cell, cellpair); MaNGOS::CreatureRelocationNotifier relocationNotifier(*creature); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); // not trigger load unloaded grids at notifier call @@ -2063,8 +2052,8 @@ void Map::CreatureRelocationNotify(Creature *creature, Cell cell, CellPair cellp TypeContainerVisitor c2world_relocation(relocationNotifier); TypeContainerVisitor c2grid_relocation(relocationNotifier); - cell_lock->Visit(cell_lock, c2world_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS); - cell_lock->Visit(cell_lock, c2grid_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS); + cell.Visit(cellpair, c2world_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS); + cell.Visit(cellpair, c2grid_relocation, *this, *creature, MAX_CREATURE_ATTACK_RADIUS); } void Map::SendInitSelf( Player * player ) @@ -3123,8 +3112,7 @@ void Map::ScriptsProcess() MaNGOS::GameObjectSearcher checker(summoner, go,go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *summoner->GetMap()); + cell.Visit(p, object_checker, *summoner->GetMap()); if ( !go ) { @@ -3183,8 +3171,7 @@ void Map::ScriptsProcess() MaNGOS::GameObjectSearcher checker(caster,door,go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *caster->GetMap()); + cell.Visit(p, object_checker, *caster->GetMap()); if (!door) { @@ -3239,8 +3226,7 @@ void Map::ScriptsProcess() MaNGOS::GameObjectSearcher checker(caster,door,go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *caster->GetMap()); + cell.Visit(p, object_checker, *caster->GetMap()); if ( !door ) { diff --git a/src/game/Map.h b/src/game/Map.h index 2d6b0a60a..6e6852954 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -47,27 +47,6 @@ struct ScriptInfo; struct ScriptAction; class BattleGround; - -typedef ACE_RW_Thread_Mutex GridRWLock; - -template -struct RGuard -{ - RGuard(MUTEX &l) : i_lock(l.getReadLock()) {} - MaNGOS::GeneralLock i_lock; -}; - -template -struct WGuard -{ - WGuard(MUTEX &l) : i_lock(l.getWriteLock()) {} - MaNGOS::GeneralLock i_lock; -}; - -typedef RGuard GridReadGuard; -typedef WGuard GridWriteGuard; -typedef MaNGOS::SingleThreaded::Lock NullGuard; - //****************************************** // Map file format defines //****************************************** @@ -280,7 +259,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj void PlayerRelocation(Player *, float x, float y, float z, float angl); void CreatureRelocation(Creature *creature, float x, float y, float z, float orientation); - template void Visit(const CellLock &cell, TypeContainerVisitor &visitor); + template void Visit(const Cell& cell, TypeContainerVisitor &visitor); bool IsRemovalGrid(float x, float y) const { @@ -523,9 +502,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj //InstanceMaps and BattleGroundMaps... Map* m_parentMap; - typedef GridReadGuard ReadGuard; - typedef GridWriteGuard WriteGuard; - NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; GridMap *GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; std::bitset marked_cells; @@ -638,19 +614,18 @@ Map::CalculateGridMask(const uint32 &y) const } */ -template +template inline void -Map::Visit(const CellLock &cell, TypeContainerVisitor &visitor) +Map::Visit(const Cell& cell, TypeContainerVisitor &visitor) { - const uint32 x = cell->GridX(); - const uint32 y = cell->GridY(); - const uint32 cell_x = cell->CellX(); - const uint32 cell_y = cell->CellY(); + const uint32 x = cell.GridX(); + const uint32 y = cell.GridY(); + const uint32 cell_x = cell.CellX(); + const uint32 cell_y = cell.CellY(); - if( !cell->NoCreate() || loaded(GridPair(x,y)) ) + if( !cell.NoCreate() || loaded(GridPair(x,y)) ) { EnsureGridLoaded(cell); - //LOCK_TYPE guard(i_info[x][y]->i_lock); getNGrid(x, y)->Visit(cell_x, cell_y, visitor); } } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index f5c84d20b..6d1a2b2fd 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1544,8 +1544,7 @@ void WorldObject::MonsterSay(int32 textId, uint32 language, uint64 TargetGuid) MaNGOS::LocalizedPacketDo say_do(say_build); MaNGOS::PlayerDistWorker > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do); TypeContainerVisitor >, WorldTypeMapContainer > message(say_worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY)); + cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY)); } void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid) @@ -1560,8 +1559,7 @@ void WorldObject::MonsterYell(int32 textId, uint32 language, uint64 TargetGuid) MaNGOS::LocalizedPacketDo say_do(say_build); MaNGOS::PlayerDistWorker > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),say_do); TypeContainerVisitor >, WorldTypeMapContainer > message(say_worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL)); + cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL)); } void WorldObject::MonsterYellToZone(int32 textId, uint32 language, uint64 TargetGuid) @@ -1589,8 +1587,7 @@ void WorldObject::MonsterTextEmote(int32 textId, uint64 TargetGuid, bool IsBossE MaNGOS::LocalizedPacketDo say_do(say_build); MaNGOS::PlayerDistWorker > say_worker(this,sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),say_do); TypeContainerVisitor >, WorldTypeMapContainer > message(say_worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, message, *GetMap(), *this, sWorld.getConfig(IsBossEmote ? CONFIG_LISTEN_RANGE_YELL : CONFIG_LISTEN_RANGE_TEXTEMOTE)); + cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(IsBossEmote ? CONFIG_LISTEN_RANGE_YELL : CONFIG_LISTEN_RANGE_TEXTEMOTE)); } void WorldObject::MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper) @@ -1829,9 +1826,8 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, TypeContainerVisitor, GridTypeMapContainer > grid_obj_worker(worker); TypeContainerVisitor, WorldTypeMapContainer > world_obj_worker(worker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_obj_worker, *GetMap(), *this, distance2d); - cell_lock->Visit(cell_lock, world_obj_worker, *GetMap(), *this, distance2d); + cell.Visit(p, grid_obj_worker, *GetMap(), *this, distance2d); + cell.Visit(p, world_obj_worker, *GetMap(), *this, distance2d); } // maybe can just place in primary position @@ -1989,10 +1985,9 @@ void WorldObject::BuildUpdateData( UpdateDataMapType & update_players) cell.SetNoCreate(); WorldObjectChangeAccumulator notifier(*this, update_players); TypeContainerVisitor player_notifier(notifier); - CellLock cell_lock(cell, p); Map* aMap = GetMap(); //we must build packets for all visible players - cell_lock->Visit(cell_lock, player_notifier, *aMap, *this, aMap->GetVisibilityDistance()); + cell.Visit(p, player_notifier, *aMap, *this, aMap->GetVisibilityDistance()); ClearUpdateMask(false); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7d5e6c0ed..7745379bb 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -17422,9 +17422,8 @@ void Player::HandleStealthedUnitsDetection() TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE); - cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE); + cell.Visit(p, world_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE); + cell.Visit(p, grid_unit_searcher, *GetMap(), *this, MAX_PLAYER_STEALTH_DETECT_RANGE); WorldObject const* viewPoint = GetViewPoint(); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index dbc2d4cdb..0c80e738f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -457,13 +457,12 @@ WorldObject* Spell::FindCorpseUsing() MaNGOS::WorldObjectSearcher searcher(m_caster, result, u_check); TypeContainerVisitor, GridTypeMapContainer > grid_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_searcher, *m_caster->GetMap(), *m_caster, max_range); + cell.Visit(p, grid_searcher, *m_caster->GetMap(), *m_caster, max_range); if (!result) { TypeContainerVisitor, WorldTypeMapContainer > world_searcher(searcher); - cell_lock->Visit(cell_lock, world_searcher, *m_caster->GetMap(), *m_caster, max_range); + cell.Visit(p, world_searcher, *m_caster->GetMap(), *m_caster, max_range); } return result; @@ -1453,9 +1452,8 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); - cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); + cell.Visit(p, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); + cell.Visit(p, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); } if(tempTargetUnitMap.empty()) @@ -1523,9 +1521,8 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); - cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); + cell.Visit(p, world_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); + cell.Visit(p, grid_unit_searcher, *m_caster->GetMap(), *m_caster, max_range); } if(tempTargetUnitMap.empty()) @@ -1618,10 +1615,9 @@ void Spell::SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList& targetUni MaNGOS::UnitListSearcher searcher(m_caster, tempTargetUnitMap, u_check); TypeContainerVisitor, WorldTypeMapContainer> world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer> grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); - cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); + cell.Visit(p, world_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); + cell.Visit(p, grid_unit_searcher, *m_caster->GetMap(), *pUnitTarget, max_range); } if (tempTargetUnitMap.empty()) break; @@ -4314,8 +4310,7 @@ SpellCastResult Spell::CheckCast(bool strict) MaNGOS::GameObjectLastSearcher checker(m_caster, p_GameObject, go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *m_caster->GetMap(), *m_caster, range); + cell.Visit(p, object_checker, *m_caster->GetMap(), *m_caster, range); if (p_GameObject) { @@ -4353,8 +4348,7 @@ SpellCastResult Spell::CheckCast(bool strict) TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range); + cell.Visit(p, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range); if (p_Creature) { @@ -5494,9 +5488,8 @@ SpellCastResult Spell::CheckItems() MaNGOS::GameObjectSearcher checker(m_caster, ok, go_check); TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); - CellLock cell_lock(cell, p); Map& map = *m_caster->GetMap(); - cell_lock->Visit(cell_lock, object_checker, map, *m_caster, map.GetVisibilityDistance()); + cell.Visit(p, object_checker, map, *m_caster, map.GetVisibilityDistance()); if(!ok) return SPELL_FAILED_REQUIRES_SPELL_FOCUS; @@ -6232,9 +6225,8 @@ void Spell::FillAreaTargets(UnitList &targetUnitMap, float x, float y, float rad MaNGOS::SpellNotifierCreatureAndPlayer notifier(*this, targetUnitMap, radius, pushType, spellTargets); TypeContainerVisitor world_notifier(notifier); TypeContainerVisitor grid_notifier(notifier); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_notifier, *m_caster->GetMap(), *m_caster, radius); - cell_lock->Visit(cell_lock, grid_notifier, *m_caster->GetMap(), *m_caster, radius); + cell.Visit(p, world_notifier, *m_caster->GetMap(), *m_caster, radius); + cell.Visit(p, grid_notifier, *m_caster->GetMap(), *m_caster, radius); } void Spell::FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index e150ca219..3a21ba099 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -764,9 +764,8 @@ void AreaAura::Update(uint32 diff) MaNGOS::UnitListSearcher searcher(caster,targets, u_check); TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius); - cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius); + cell.Visit(p, world_unit_searcher, *caster->GetMap(), *caster, m_radius); + cell.Visit(p, grid_unit_searcher, *caster->GetMap(), *caster, m_radius); break; } case AREA_AURA_ENEMY: @@ -780,9 +779,8 @@ void AreaAura::Update(uint32 diff) MaNGOS::UnitListSearcher searcher(caster, targets, u_check); TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius); - cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius); + cell.Visit(p, world_unit_searcher, *caster->GetMap(), *caster, m_radius); + cell.Visit(p, grid_unit_searcher, *caster->GetMap(), *caster, m_radius); break; } case AREA_AURA_OWNER: @@ -7459,10 +7457,8 @@ void Aura::PeriodicDummyTick() TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); - CellLock cell_lock(cell, p); - - cell_lock->Visit(cell_lock, grid_object_checker, *m_target->GetMap(), *m_target, radius); - cell_lock->Visit(cell_lock, world_object_checker, *m_target->GetMap(), *m_target, radius); + cell.Visit(p, grid_object_checker, *m_target->GetMap(), *m_target, radius); + cell.Visit(p, world_object_checker, *m_target->GetMap(), *m_target, radius); } if(targets.empty()) diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index f2a5934ae..115acd8c7 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -90,9 +90,8 @@ TotemAI::UpdateAI(const uint32 /*diff*/) TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_object_checker, *m_creature->GetMap(), *m_creature, max_range); - cell_lock->Visit(cell_lock, world_object_checker, *m_creature->GetMap(), *m_creature, max_range); + cell.Visit(p, grid_object_checker, *m_creature->GetMap(), *m_creature, max_range); + cell.Visit(p, world_object_checker, *m_creature->GetMap(), *m_creature, max_range); } // If have target diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 64e9564ca..41cb14929 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -12562,17 +12562,14 @@ Unit* Unit::SelectNearbyTarget(Unit* except /*= NULL*/) const std::list targets; - { - MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); - MaNGOS::UnitListSearcher searcher(this, targets, u_check); + MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE); + MaNGOS::UnitListSearcher searcher(this, targets, u_check); - TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); - TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); + TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); + TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); - CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE); - cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE); - } + cell.Visit(p, world_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE); + cell.Visit(p, grid_unit_searcher, *GetMap(), *this, ATTACK_DISTANCE); // remove current target if(except) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index aa5ffc262..25afb57b7 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 "9244" + #define REVISION_NR "9245" #endif // __REVISION_NR_H__