mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +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
|
|
@ -20,9 +20,10 @@
|
|||
#include "Errors.h"
|
||||
#include "Creature.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "World.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Map.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
|
|
|
|||
|
|
@ -1386,7 +1386,7 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
|
|||
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
|
||||
// so we must create it specific for this instance
|
||||
GameObject * go = new GameObject;
|
||||
if(!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT),entry, GetBgMap(),
|
||||
if(!go->Create(GetBgMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT),entry, GetBgMap(),
|
||||
PHASEMASK_NORMAL, x,y,z,o,rotation0,rotation1,rotation2,rotation3,GO_ANIMPROGRESS_DEFAULT,GO_STATE_READY))
|
||||
{
|
||||
sLog.outErrorDb("Gameobject template %u not found in database! BattleGround not created!", entry);
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ void WorldSession::HandleCharCreateOpcode( WorldPacket & recv_data )
|
|||
recv_data >> hairStyle >> hairColor >> facialHair >> outfitId;
|
||||
|
||||
Player *pNewChar = new Player(this);
|
||||
if(!pNewChar->Create( sObjectMgr.GenerateLowGuid(HIGHGUID_PLAYER), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId ))
|
||||
if (!pNewChar->Create(sObjectMgr.GeneratePlayerLowGuid(), name, race_, class_, gender, skin, face, hairStyle, hairColor, facialHair, outfitId))
|
||||
{
|
||||
// Player not create (race/class problem?)
|
||||
delete pNewChar;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "ChannelMgr.h"
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "Language.h"
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
#include "Log.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Player.h"
|
||||
|
||||
void WorldSession::HandleAttackSwingOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1241,17 +1241,10 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
|
|||
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(guidlow);
|
||||
|
||||
m_DBTableGuid = guidlow;
|
||||
if (map->GetInstanceId() == 0)
|
||||
{
|
||||
|
||||
// Creature can be loaded already in map if grid has been unloaded while creature walk to another grid
|
||||
// FIXME: until creature guids is global and for instances used dynamic generated guids
|
||||
// in instance possible load creature duplicates with same DB guid but different in game guids
|
||||
// This will be until implementing per-map creature guids
|
||||
if (map->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guidlow)))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
guidlow = sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT);
|
||||
|
||||
if (!Create(guidlow, map, data->phaseMask, data->id, TEAM_NONE, data, eventData))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "GridNotifiersImpl.h"
|
||||
#include "CellImpl.h"
|
||||
#include "InstanceData.h"
|
||||
#include "MapManager.h"
|
||||
#include "MapPersistentStateMgr.h"
|
||||
#include "BattleGround.h"
|
||||
#include "BattleGroundAV.h"
|
||||
|
|
@ -579,7 +580,6 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
|
|||
GOState go_state = data->go_state;
|
||||
|
||||
m_DBTableGuid = guid;
|
||||
if (map->GetInstanceId() != 0) guid = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
|
||||
if (!Create(guid,entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state) )
|
||||
return false;
|
||||
|
|
@ -829,7 +829,7 @@ void GameObject::SummonLinkedTrapIfAny()
|
|||
return;
|
||||
|
||||
GameObject* linkedGO = new GameObject;
|
||||
if (!linkedGO->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, GetMap(),
|
||||
if (!linkedGO->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, GetMap(),
|
||||
GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
delete linkedGO;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include "Errors.h"
|
||||
#include "Creature.h"
|
||||
#include "Player.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "World.h"
|
||||
|
||||
int GuardAI::Permissible(const Creature *creature)
|
||||
|
|
|
|||
|
|
@ -1019,19 +1019,18 @@ void Item::SendTimeUpdate(Player* owner)
|
|||
|
||||
Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
|
||||
{
|
||||
if ( count < 1 )
|
||||
if (count < 1)
|
||||
return NULL; //don't create item at zero count
|
||||
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype( item );
|
||||
if( pProto )
|
||||
if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item))
|
||||
{
|
||||
if ( count > pProto->GetMaxStackSize())
|
||||
if (count > pProto->GetMaxStackSize())
|
||||
count = pProto->GetMaxStackSize();
|
||||
|
||||
MANGOS_ASSERT(count !=0 && "pProto->Stackable==0 but checked at loading already");
|
||||
|
||||
Item *pItem = NewItemOrBag( pProto );
|
||||
if( pItem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_ITEM), item, player) )
|
||||
if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player) )
|
||||
{
|
||||
pItem->SetCount( count );
|
||||
return pItem;
|
||||
|
|
|
|||
|
|
@ -1086,7 +1086,7 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
|
|||
Map *map = chr->GetMap();
|
||||
|
||||
GameObject* pGameObj = new GameObject;
|
||||
uint32 db_lowGUID = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
uint32 db_lowGUID = map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
|
||||
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
|
|
@ -1559,7 +1559,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
|
|||
Map *map = chr->GetMap();
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
delete pCreature;
|
||||
return false;
|
||||
|
|
@ -3183,7 +3183,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
|
|||
// create the waypoint creature
|
||||
wpGuid = 0;
|
||||
Creature* wpCreature = new Creature;
|
||||
if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
|
||||
if (!wpCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature;
|
||||
|
|
@ -3303,7 +3303,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
|
|||
wpCreature->AddObjectToRemoveList();
|
||||
// re-create
|
||||
Creature* wpCreature2 = new Creature;
|
||||
if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
|
||||
if (!wpCreature2->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature2;
|
||||
|
|
@ -3607,7 +3607,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
|
|||
float o = chr->GetOrientation();
|
||||
|
||||
Creature* wpCreature = new Creature;
|
||||
if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
if (!wpCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete wpCreature;
|
||||
|
|
@ -3665,7 +3665,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
|
|||
Map *map = chr->GetMap();
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id))
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete pCreature;
|
||||
|
|
@ -3725,7 +3725,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
|
|||
Map *map = chr->GetMap();
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id))
|
||||
{
|
||||
PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
delete pCreature;
|
||||
|
|
|
|||
|
|
@ -696,17 +696,17 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data )
|
|||
}
|
||||
|
||||
Item *bodyItem = new Item; // This is not bag and then can be used new Item.
|
||||
if(!bodyItem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_ITEM), MAIL_BODY_ITEM_TEMPLATE, pl))
|
||||
if (!bodyItem->Create(sObjectMgr.GenerateItemLowGuid(), MAIL_BODY_ITEM_TEMPLATE, pl))
|
||||
{
|
||||
delete bodyItem;
|
||||
return;
|
||||
}
|
||||
|
||||
// in mail template case we need create new item text
|
||||
if(m->mailTemplateId)
|
||||
if (m->mailTemplateId)
|
||||
{
|
||||
MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId);
|
||||
if(!mailTemplateEntry)
|
||||
if (!mailTemplateEntry)
|
||||
{
|
||||
pl->SendMailResult(mailId, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
Map::~Map()
|
||||
{
|
||||
ObjectAccessor::DelinkMap(this);
|
||||
UnloadAll(true);
|
||||
|
||||
if(!m_scriptSchedule.empty())
|
||||
|
|
@ -78,6 +77,9 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode)
|
|||
i_gridExpiry(expiry), m_TerrainData(sTerrainMgr.LoadTerrain(id)),
|
||||
i_data(NULL), i_script_id(0)
|
||||
{
|
||||
m_CreatureGuids.Set(sObjectMgr.GetFirstCreatureLowGuid());
|
||||
m_GameObjectGuids.Set(sObjectMgr.GetFirstGameObjectLowGuid());
|
||||
|
||||
for(unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j)
|
||||
{
|
||||
for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
|
||||
|
|
@ -87,7 +89,6 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode)
|
|||
setNGrid(NULL, idx, j);
|
||||
}
|
||||
}
|
||||
ObjectAccessor::LinkMap(this);
|
||||
|
||||
//lets initialize visibility distance for map
|
||||
Map::InitVisibilityDistance();
|
||||
|
|
@ -3027,6 +3028,10 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh)
|
|||
// TODO: for map local guid counters possible force reload map instead shutdown server at guid counter overflow
|
||||
switch(guidhigh)
|
||||
{
|
||||
case HIGHGUID_UNIT:
|
||||
return m_CreatureGuids.Generate();
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
return m_GameObjectGuids.Generate();
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return m_DynObjectGuids.Generate();
|
||||
case HIGHGUID_PET:
|
||||
|
|
|
|||
|
|
@ -327,6 +327,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
|
|||
uint32 i_script_id;
|
||||
|
||||
// Map local low guid counters
|
||||
ObjectGuidGenerator<HIGHGUID_UNIT> m_CreatureGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_GameObjectGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_DYNAMICOBJECT> m_DynObjectGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_PET> m_PetGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_VEHICLE> m_VehicleGuids;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ Map* MapManager::CreateBgMap(uint32 mapid, BattleGround* bg)
|
|||
TerrainInfo * pData = sTerrainMgr.LoadTerrain(mapid);
|
||||
|
||||
Guard _guard(*this);
|
||||
return CreateBattleGroundMap(mapid, sObjectMgr.GenerateLowGuid(HIGHGUID_INSTANCE), bg);
|
||||
return CreateBattleGroundMap(mapid, sObjectMgr.GenerateInstanceLowGuid(), bg);
|
||||
}
|
||||
|
||||
Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
|
||||
|
|
@ -383,7 +383,7 @@ Map* MapManager::CreateInstance(uint32 id, Player * player)
|
|||
{
|
||||
// if no instanceId via group members or instance saves is found
|
||||
// the instance will be created for the first time
|
||||
NewInstanceId = sObjectMgr.GenerateLowGuid(HIGHGUID_INSTANCE);
|
||||
NewInstanceId = sObjectMgr.GenerateInstanceLowGuid();
|
||||
|
||||
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(entry->IsRaid()) : player->GetDifficulty(entry->IsRaid());
|
||||
pNewMap = CreateDungeonMap(id, NewInstanceId, diff);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ struct MapEntry;
|
|||
struct MapDifficulty;
|
||||
class Player;
|
||||
class Group;
|
||||
class Map;
|
||||
|
||||
class MapPersistentStateManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include "GossipDef.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Creature.h"
|
||||
#include "Pet.h"
|
||||
#include "Guild.h"
|
||||
|
|
|
|||
|
|
@ -1653,7 +1653,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
|
|||
if (GetTypeId()==TYPEID_PLAYER)
|
||||
team = ((Player*)this)->GetTeam();
|
||||
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), GetPhaseMask(), id, team))
|
||||
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), GetMap(), GetPhaseMask(), id, team))
|
||||
{
|
||||
delete pCreature;
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -20,10 +20,6 @@
|
|||
#include "ObjectMgr.h"
|
||||
#include "Policies/SingletonImp.h"
|
||||
#include "Player.h"
|
||||
#include "Creature.h"
|
||||
#include "GameObject.h"
|
||||
#include "DynamicObject.h"
|
||||
#include "Vehicle.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Item.h"
|
||||
#include "Corpse.h"
|
||||
|
|
@ -32,7 +28,6 @@
|
|||
#include "Map.h"
|
||||
#include "CellImpl.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Opcodes.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "World.h"
|
||||
|
||||
|
|
@ -282,6 +277,3 @@ template <class T> ACE_RW_Thread_Mutex HashMapHolder<T>::i_lock;
|
|||
|
||||
template class HashMapHolder<Player>;
|
||||
template class HashMapHolder<Corpse>;
|
||||
|
||||
/// Define the static member of ObjectAccessor
|
||||
std::list<Map*> ObjectAccessor::i_mapList;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -141,6 +141,9 @@ template uint32 IdGenerator<uint32>::Generate();
|
|||
template uint64 IdGenerator<uint64>::Generate();
|
||||
|
||||
ObjectMgr::ObjectMgr() :
|
||||
m_CreatureFirstGuid(1),
|
||||
m_GameObjectFirstGuid(1),
|
||||
|
||||
m_ArenaTeamIds("Arena team ids"),
|
||||
m_AuctionIds("Auction ids"),
|
||||
m_EquipmentSetIds("Equipment set ids"),
|
||||
|
|
@ -5602,7 +5605,7 @@ void ObjectMgr::SetHighestGuids()
|
|||
result = WorldDatabase.Query( "SELECT MAX(guid) FROM creature" );
|
||||
if( result )
|
||||
{
|
||||
m_CreatureGuids.Set((*result)[0].GetUInt32()+1);
|
||||
m_CreatureFirstGuid = (*result)[0].GetUInt32()+1;
|
||||
delete result;
|
||||
}
|
||||
|
||||
|
|
@ -5631,7 +5634,7 @@ void ObjectMgr::SetHighestGuids()
|
|||
result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject" );
|
||||
if( result )
|
||||
{
|
||||
m_GameobjectGuids.Set((*result)[0].GetUInt32()+1);
|
||||
m_CreatureFirstGuid = (*result)[0].GetUInt32()+1;
|
||||
delete result;
|
||||
}
|
||||
|
||||
|
|
@ -5685,30 +5688,6 @@ void ObjectMgr::SetHighestGuids()
|
|||
}
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
||||
{
|
||||
switch(guidhigh)
|
||||
{
|
||||
case HIGHGUID_ITEM:
|
||||
return m_ItemGuids.Generate();
|
||||
case HIGHGUID_UNIT:
|
||||
return m_CreatureGuids.Generate();
|
||||
case HIGHGUID_PLAYER:
|
||||
return m_CharGuids.Generate();
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
return m_GameobjectGuids.Generate();
|
||||
case HIGHGUID_CORPSE:
|
||||
return m_CorpseGuids.Generate();
|
||||
case HIGHGUID_INSTANCE:
|
||||
return m_InstanceGuids.Generate();
|
||||
default:
|
||||
MANGOS_ASSERT(0);
|
||||
}
|
||||
|
||||
MANGOS_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGameObjectLocales()
|
||||
{
|
||||
mGameObjectLocaleMap.clear(); // need for reload case
|
||||
|
|
|
|||
|
|
@ -717,7 +717,16 @@ class ObjectMgr
|
|||
void ReturnOrDeleteOldMails(bool serverUp);
|
||||
|
||||
void SetHighestGuids();
|
||||
uint32 GenerateLowGuid(HighGuid guidhigh);
|
||||
|
||||
// used for set initial guid counter for map local guids
|
||||
uint32 GetFirstCreatureLowGuid() const { return m_CreatureFirstGuid; }
|
||||
uint32 GetFirstGameObjectLowGuid() const { return m_GameObjectFirstGuid; }
|
||||
|
||||
uint32 GeneratePlayerLowGuid() { return m_CharGuids.Generate(); }
|
||||
uint32 GenerateItemLowGuid() { return m_ItemGuids.Generate(); }
|
||||
uint32 GenerateCorpseLowGuid() { return m_CorpseGuids.Generate(); }
|
||||
uint32 GenerateInstanceLowGuid() { return m_InstanceGuids.Generate(); }
|
||||
|
||||
uint32 GenerateArenaTeamId() { return m_ArenaTeamIds.Generate(); }
|
||||
uint32 GenerateAuctionID() { return m_AuctionIds.Generate(); }
|
||||
uint64 GenerateEquipmentSetGuid() { return m_EquipmentSetIds.Generate(); }
|
||||
|
|
@ -1034,11 +1043,13 @@ class ObjectMgr
|
|||
IdGenerator<uint32> m_PetNumbers;
|
||||
IdGenerator<uint32> m_GroupIds;
|
||||
|
||||
// initial free low guid for selected guid type for map local guids
|
||||
uint32 m_CreatureFirstGuid;
|
||||
uint32 m_GameObjectFirstGuid;
|
||||
|
||||
// first free low guid for selected guid type
|
||||
ObjectGuidGenerator<HIGHGUID_PLAYER> m_CharGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_UNIT> m_CreatureGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_ITEM> m_ItemGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_GameobjectGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_CORPSE> m_CorpseGuids;
|
||||
ObjectGuidGenerator<HIGHGUID_INSTANCE> m_InstanceGuids;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Spell.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Util.h"
|
||||
#include "Pet.h"
|
||||
|
|
|
|||
|
|
@ -4597,7 +4597,7 @@ Corpse* Player::CreateCorpse()
|
|||
Corpse *corpse = new Corpse( (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) ? CORPSE_RESURRECTABLE_PVP : CORPSE_RESURRECTABLE_PVE );
|
||||
SetPvPDeath(false);
|
||||
|
||||
if (!corpse->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_CORPSE), this))
|
||||
if (!corpse->Create(sObjectMgr.GenerateCorpseLowGuid(), this))
|
||||
{
|
||||
delete corpse;
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
#include "ReactorAI.h"
|
||||
#include "Errors.h"
|
||||
#include "Creature.h"
|
||||
#include "Map.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
|
||||
#define REACTOR_VISIBLE_RANGE (26.46f)
|
||||
|
||||
|
|
|
|||
|
|
@ -4186,7 +4186,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
|
|||
if(GetId() == 39837)
|
||||
{
|
||||
GameObject* pObj = new GameObject;
|
||||
if(pObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, target->GetMap(), target->GetPhaseMask(),
|
||||
if(pObj->Create(target->GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), 185584, target->GetMap(), target->GetPhaseMask(),
|
||||
target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
pObj->SetRespawnTime(GetAuraDuration()/IN_MILLISECONDS);
|
||||
|
|
@ -8607,12 +8607,7 @@ Unit* SpellAuraHolder::GetCaster() const
|
|||
if(GetCasterGuid() == m_target->GetObjectGuid())
|
||||
return m_target;
|
||||
|
||||
//must return caster even if it's in another grid/map
|
||||
if (m_casterGuid.IsPlayer())
|
||||
if (Player* caster = sObjectMgr.GetPlayer(m_casterGuid))
|
||||
return caster->IsInWorld() ? caster : NULL;
|
||||
|
||||
return m_target->IsInWorld() ? m_target->GetMap()->GetCreature(m_casterGuid) : NULL;
|
||||
return ObjectAccessor::GetUnit(*m_target, m_casterGuid);// player will search at any maps
|
||||
}
|
||||
|
||||
bool SpellAuraHolder::IsWeaponBuffCoexistableWith(SpellAuraHolder* ref)
|
||||
|
|
|
|||
|
|
@ -952,7 +952,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
|
|||
|
||||
Map *map = unitTarget->GetMap();
|
||||
|
||||
if (!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 177704,
|
||||
if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), 177704,
|
||||
map, m_caster->GetPhaseMask(),
|
||||
unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(),
|
||||
unitTarget->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
|
|
@ -993,7 +993,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
|
|||
Map *map = creatureTarget->GetMap();
|
||||
|
||||
// create before death for get proper coordinates
|
||||
if (!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(),
|
||||
if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(),
|
||||
creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(),
|
||||
creatureTarget->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY) )
|
||||
{
|
||||
|
|
@ -5798,7 +5798,7 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx)
|
|||
|
||||
Map *map = target->GetMap();
|
||||
|
||||
if(!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map,
|
||||
if(!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map,
|
||||
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
delete pGameObj;
|
||||
|
|
@ -7233,7 +7233,7 @@ void Spell::EffectDuel(SpellEffectIndex eff_idx)
|
|||
uint32 gameobject_id = m_spellInfo->EffectMiscValue[eff_idx];
|
||||
|
||||
Map *map = m_caster->GetMap();
|
||||
if(!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id,
|
||||
if(!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id,
|
||||
map, m_caster->GetPhaseMask(),
|
||||
m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 ,
|
||||
m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 ,
|
||||
|
|
@ -7393,7 +7393,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
|
|||
|
||||
Totem* pTotem = new Totem;
|
||||
|
||||
if (!pTotem->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_caster->GetPhaseMask(),
|
||||
if (!pTotem->Create(m_caster->GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), m_caster->GetMap(), m_caster->GetPhaseMask(),
|
||||
m_spellInfo->EffectMiscValue[eff_idx], team))
|
||||
{
|
||||
delete pTotem;
|
||||
|
|
@ -7614,7 +7614,7 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx)
|
|||
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
|
||||
Map *map = m_caster->GetMap();
|
||||
if(!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map,
|
||||
if(!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), go_id, map,
|
||||
m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
delete pGameObj;
|
||||
|
|
@ -8193,7 +8193,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx)
|
|||
|
||||
GameObject* pGameObj = new GameObject;
|
||||
|
||||
if(!pGameObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap,
|
||||
if(!pGameObj->Create(cMap->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap,
|
||||
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
|
||||
{
|
||||
delete pGameObj;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "TemporarySummon.h"
|
||||
#include "Log.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CreatureAI.h"
|
||||
|
||||
TemporarySummon::TemporarySummon( ObjectGuid summoner ) :
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include "Totem.h"
|
||||
#include "Creature.h"
|
||||
#include "DBCStores.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
#include "GridNotifiers.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11138"
|
||||
#define REVISION_NR "11139"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue