mirror of
https://github.com/mangosfour/server.git
synced 2025-12-26 07:37:02 +00:00
[11139] Use for Creature/GameObject local per-map guids
* Creature/GameObject guid generators moved to Map * For avoid wrong not converted cases generic function in ObjectMgr has been replaced by specilized guid generation function like sObjectMgr.GeneratePlayerLowGuid(). This let catch all cases that need update in custom code or scripts. * Drop many ObjectAcessor.h now dead code. This is also make mangos more thread safe. * Restore one more time unix build broken in prev. commits. Note: many cases when something not wotk in instance but work in continents possible magicly start work after this commit. For example, some gm commands. From large systems that need more chnages for start work in full power in instances can be referecned pool/gamevent system. Last need just small hacks drop changes but in will addded in independent commit.
This commit is contained in:
parent
9a8a74c2ad
commit
cf685da47a
29 changed files with 69 additions and 138 deletions
|
|
@ -37,9 +37,7 @@
|
|||
#include <set>
|
||||
#include <list>
|
||||
|
||||
class Creature;
|
||||
class Unit;
|
||||
class GameObject;
|
||||
class WorldObject;
|
||||
class Map;
|
||||
|
||||
|
|
@ -97,13 +95,6 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
|||
public:
|
||||
typedef UNORDERED_MAP<ObjectGuid, Corpse*> Player2CorpsesMapType;
|
||||
|
||||
// global (obj used for map only location local guid objects (pets currently)
|
||||
static Unit* GetUnitInWorld(WorldObject const& obj, ObjectGuid guid);
|
||||
|
||||
// FIXME: map local object with global search
|
||||
static Creature* GetCreatureInWorld(ObjectGuid guid) { return FindHelper<Creature>(guid); }
|
||||
static GameObject* GetGameObjectInWorld(ObjectGuid guid) { return FindHelper<GameObject>(guid); }
|
||||
|
||||
// Search player at any map in world and other objects at same map with `obj`
|
||||
// Note: recommended use Map::GetUnit version if player also expected at same map only
|
||||
static Unit* GetUnit(WorldObject const& obj, ObjectGuid guid);
|
||||
|
|
@ -135,25 +126,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
|||
void RemoveObject(Corpse *object) { HashMapHolder<Corpse>::Remove(object); }
|
||||
void RemoveObject(Player *object) { HashMapHolder<Player>::Remove(object); }
|
||||
|
||||
// TODO: This methods will need lock in MT environment
|
||||
static void LinkMap(Map* map) { i_mapList.push_back(map); }
|
||||
static void DelinkMap(Map* map) { i_mapList.remove(map); }
|
||||
private:
|
||||
// TODO: This methods will need lock in MT environment
|
||||
// Theoreticaly multiple threads can enter and search in this method but
|
||||
// in that case linking/delinking other map should be guarded
|
||||
template <class OBJECT> static OBJECT* FindHelper(ObjectGuid guid)
|
||||
{
|
||||
for (std::list<Map*>::const_iterator i = i_mapList.begin() ; i != i_mapList.end(); ++i)
|
||||
{
|
||||
if (OBJECT* ret = (*i)->GetObjectsStore().find(guid.GetRawValue(), (OBJECT*)NULL))
|
||||
return ret;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static std::list<Map*> i_mapList;
|
||||
|
||||
Player2CorpsesMapType i_player2corpse;
|
||||
|
||||
|
|
@ -164,20 +137,6 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
|||
LockType i_corpseGuard;
|
||||
};
|
||||
|
||||
inline Unit* ObjectAccessor::GetUnitInWorld(WorldObject const& obj, ObjectGuid guid)
|
||||
{
|
||||
if(guid.IsEmpty())
|
||||
return NULL;
|
||||
|
||||
if (guid.IsPlayer())
|
||||
return FindPlayer(guid);
|
||||
|
||||
if (guid.IsPet())
|
||||
return obj.IsInWorld() ? obj.GetMap()->GetPet(guid) : NULL;
|
||||
|
||||
return GetCreatureInWorld(guid);
|
||||
}
|
||||
|
||||
#define sObjectAccessor ObjectAccessor::Instance()
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue