From ca83e14f8b141fab0a13e08f48fca6c1ace0c4c7 Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 25 Feb 2015 00:13:14 +0100 Subject: Core/Entities: Reworked guid scopes * Added ObjectGuid traits to easily access whether guid type can be generated globally (ObjectMgr) or not * This adds separate (per map) guid sequences depending on object type * Ported map object container from cmangos/mangos-wotlk@a2d396eb0bb195efc460944dd4e0fab2a858b300 * Added type container visitor for TypeUnorderedMapContainer * Implemented helper function to erase unique pairs from multimap containers * Moved object storage of all objects except players and transports to map level * Added containers linking database spawn id with creature/gameobject in world * Renamed DBTableGuid to spawnId * Added a separate spawn id sequence generator for creatures and gameobjects - this will be used in db tables * Moved building SMSG_UPDATE_OBJECT - updatefields changes broadcast to map update --- src/server/game/Scripting/MapScripts.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/server/game/Scripting/MapScripts.cpp') diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 8797caf2cf7..1db3dbb9f93 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -321,26 +321,23 @@ void Map::ScriptsProcess() break; case HighGuid::Creature: case HighGuid::Vehicle: - source = HashMapHolder::Find(step.sourceGUID); + source = GetCreature(step.sourceGUID); break; case HighGuid::Pet: - source = HashMapHolder::Find(step.sourceGUID); + source = GetPet(step.sourceGUID); break; case HighGuid::Player: source = HashMapHolder::Find(step.sourceGUID); break; case HighGuid::GameObject: - source = HashMapHolder::Find(step.sourceGUID); + source = GetGameObject(step.sourceGUID); break; case HighGuid::Corpse: - source = HashMapHolder::Find(step.sourceGUID); + source = GetCorpse(step.sourceGUID); break; case HighGuid::Transport: - { - GameObject* go = HashMapHolder::Find(step.sourceGUID); - source = go ? go->ToTransport() : NULL; + source = GetTransport(step.sourceGUID); break; - } default: TC_LOG_ERROR("scripts", "%s source with unsupported high guid %s.", step.script->GetDebugInfo().c_str(), step.sourceGUID.ToString().c_str()); @@ -355,26 +352,23 @@ void Map::ScriptsProcess() { case HighGuid::Creature: case HighGuid::Vehicle: - target = HashMapHolder::Find(step.targetGUID); + target = GetCreature(step.targetGUID); break; case HighGuid::Pet: - target = HashMapHolder::Find(step.targetGUID); + target = GetPet(step.targetGUID); break; case HighGuid::Player: target = HashMapHolder::Find(step.targetGUID); break; case HighGuid::GameObject: - target = HashMapHolder::Find(step.targetGUID); + target = GetGameObject(step.targetGUID); break; case HighGuid::Corpse: - target = HashMapHolder::Find(step.targetGUID); + target = GetCorpse(step.targetGUID); break; case HighGuid::Transport: - { - GameObject* go = HashMapHolder::Find(step.targetGUID); - target = go ? go->ToTransport() : NULL; + target = GetTransport(step.targetGUID); break; - } default: TC_LOG_ERROR("scripts", "%s target with unsupported high guid %s.", step.script->GetDebugInfo().c_str(), step.targetGUID.ToString().c_str()); @@ -827,7 +821,11 @@ void Map::ScriptsProcess() else //check hashmap holders { if (CreatureData const* data = sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry)) - cTarget = ObjectAccessor::GetObjectInWorld(data->mapid, data->posX, data->posY, ObjectGuid::Create(data->mapid, data->id, uint64(step.script->CallScript.CreatureEntry)), cTarget); + { + auto creatureBounds = _creatureBySpawnIdStore.equal_range(step.script->CallScript.CreatureEntry); + if (creatureBounds.first != creatureBounds.second) + cTarget = creatureBounds.first->second; + } } if (!cTarget) -- cgit v1.2.3