diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 658fc6371..a07f9d407 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -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 diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 8eb5da0e2..e0b57d73f 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -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); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 64405b43b..c06a75325 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -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; diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index f4c688c3e..cf9102efe 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -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" diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp index 9703afacf..242afeac5 100644 --- a/src/game/CombatHandler.cpp +++ b/src/game/CombatHandler.cpp @@ -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 ) { diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 0f167bfc3..b65be2ab9 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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); + + // Creature can be loaded already in map if grid has been unloaded while creature walk to another grid + if (map->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guidlow))) + return false; if (!Create(guidlow, map, data->phaseMask, data->id, TEAM_NONE, data, eventData)) return false; diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 52c6294ae..85d56050f 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -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; diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index fdeb85e21..c477303ff 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -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) diff --git a/src/game/Item.cpp b/src/game/Item.cpp index b62eda209..77faf1300 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -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; diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index e9d316b91..605b37069 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -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; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 833dce7b7..762e9ab19 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -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; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 79528f1cf..7c1582797 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -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: diff --git a/src/game/Map.h b/src/game/Map.h index 5a5eb26e1..108e1ba74 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -327,6 +327,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager uint32 i_script_id; // Map local low guid counters + ObjectGuidGenerator m_CreatureGuids; + ObjectGuidGenerator m_GameObjectGuids; ObjectGuidGenerator m_DynObjectGuids; ObjectGuidGenerator m_PetGuids; ObjectGuidGenerator m_VehicleGuids; diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index fe9cee38e..138e8e0ce 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -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); diff --git a/src/game/MapPersistentStateMgr.h b/src/game/MapPersistentStateMgr.h index b71ee1fcc..c21c6f746 100644 --- a/src/game/MapPersistentStateMgr.h +++ b/src/game/MapPersistentStateMgr.h @@ -36,6 +36,7 @@ struct MapEntry; struct MapDifficulty; class Player; class Group; +class Map; class MapPersistentStateManager; diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 30c97c4a5..d6d95718b 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -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" diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 2dfa981f2..1d151f790 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -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; diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 9081b6f59..a04d865fd 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -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 ACE_RW_Thread_Mutex HashMapHolder::i_lock; template class HashMapHolder; template class HashMapHolder; - -/// Define the static member of ObjectAccessor -std::list ObjectAccessor::i_mapList; diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index dd534fc79..3265bbd65 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -37,9 +37,7 @@ #include #include -class Creature; class Unit; -class GameObject; class WorldObject; class Map; @@ -97,13 +95,6 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton 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(guid); } - static GameObject* GetGameObjectInWorld(ObjectGuid guid) { return FindHelper(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::Remove(object); } void RemoveObject(Player *object) { HashMapHolder::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 static OBJECT* FindHelper(ObjectGuid guid) - { - for (std::list::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 i_mapList; Player2CorpsesMapType i_player2corpse; @@ -164,20 +137,6 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::SingletonGetPet(guid) : NULL; - - return GetCreatureInWorld(guid); -} - #define sObjectAccessor ObjectAccessor::Instance() #endif diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index a18d1ce79..5f2b4d01b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -141,6 +141,9 @@ template uint32 IdGenerator::Generate(); template uint64 IdGenerator::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 diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index ed55fe4bb..5db327412 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -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 m_PetNumbers; IdGenerator 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 m_CharGuids; - ObjectGuidGenerator m_CreatureGuids; ObjectGuidGenerator m_ItemGuids; - ObjectGuidGenerator m_GameobjectGuids; ObjectGuidGenerator m_CorpseGuids; ObjectGuidGenerator m_InstanceGuids; diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index f400c2bbb..c95b142d2 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -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" diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 12244414d..ba6985448 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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; diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index df9a36bf4..f530f9556 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -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) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 224cc2e7b..452111b49 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -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) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index d12a6646e..2420aa6f2 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -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; diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index cc6de7d4d..a93c83634 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -18,7 +18,6 @@ #include "TemporarySummon.h" #include "Log.h" -#include "ObjectAccessor.h" #include "CreatureAI.h" TemporarySummon::TemporarySummon( ObjectGuid summoner ) : diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 16c4f4de3..1b9a81eab 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -20,7 +20,6 @@ #include "Totem.h" #include "Creature.h" #include "DBCStores.h" -#include "ObjectAccessor.h" #include "SpellMgr.h" #include "GridNotifiers.h" diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a7b5b960e..bb39bc51e 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 "11138" + #define REVISION_NR "11139" #endif // __REVISION_NR_H__