diff options
author | megamage <none@none> | 2009-05-31 14:26:57 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-05-31 14:26:57 -0500 |
commit | da871e2fc07ef529beea3d3e8a52518bde842775 (patch) | |
tree | 7314d7c7b03304d75d606874693cf565e95daa28 | |
parent | 8d1f4f9ea0beb503e2a3014abb95263e501ef1c5 (diff) |
*Move addcre/go functions from opvp to objmgr.
*Do not save respawn time for internally added cre/go.
--HG--
branch : trunk
-rw-r--r-- | src/game/Creature.cpp | 5 | ||||
-rw-r--r-- | src/game/Creature.h | 2 | ||||
-rw-r--r-- | src/game/GameObject.cpp | 5 | ||||
-rw-r--r-- | src/game/GameObject.h | 4 | ||||
-rw-r--r-- | src/game/Object.cpp | 1 | ||||
-rw-r--r-- | src/game/Object.h | 2 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 96 | ||||
-rw-r--r-- | src/game/ObjectMgr.h | 4 | ||||
-rw-r--r-- | src/game/OutdoorPvP.cpp | 125 | ||||
-rw-r--r-- | src/game/Wintergrasp.cpp | 6 |
10 files changed, 130 insertions, 120 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 01a3b057ce9..0627f6419fb 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1532,6 +1532,9 @@ bool Creature::LoadFromDB(uint32 guid, Map *map) // checked at creature_template loading m_defaultMovementType = MovementGeneratorType(data->movementType); + if(!data->dbData) + SetInternallyAdded(); + return true; } @@ -2079,7 +2082,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction / void Creature::SaveRespawnTime() { - if(isPet() || !m_DBTableGuid) + if(isSummon() || !m_DBTableGuid || m_isInternallyAdded) return; if(m_respawnTime > time(NULL)) // dead (no corpse) diff --git a/src/game/Creature.h b/src/game/Creature.h index 31c127f983f..be62ad66493 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -289,6 +289,7 @@ struct EquipmentInfo // from `creature` table struct CreatureData { + explicit CreatureData() : dbData(true) {} uint32 id; // entry in creature_template uint16 mapid; uint16 phaseMask; @@ -306,6 +307,7 @@ struct CreatureData bool is_dead; uint8 movementType; uint8 spawnMask; + bool dbData; }; struct CreatureDataAddonAura diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 0cc32ce4f2d..ea848e95a52 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -628,6 +628,9 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map) } } + if(!data->dbData) + SetInternallyAdded(); + return true; } @@ -707,7 +710,7 @@ Unit* GameObject::GetOwner() const void GameObject::SaveRespawnTime() { - if(m_respawnTime > time(NULL) && m_spawnedByDefault) + if(!m_isInternallyAdded && m_respawnTime > time(NULL) && m_spawnedByDefault) objmgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime); } diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 0b0245cecd7..3493bec6bb0 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -417,6 +417,7 @@ enum GOState // from `gameobject` struct GameObjectData { + explicit GameObjectData() : dbData(true) {} uint32 id; // entry in gamobject_template uint16 mapid; uint16 phaseMask; @@ -432,7 +433,8 @@ struct GameObjectData uint32 animprogress; GOState go_state; uint8 spawnMask; - uint32 ArtKit; + uint8 ArtKit; + bool dbData; }; // For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ... diff --git a/src/game/Object.cpp b/src/game/Object.cpp index a4850615d07..a1f54398331 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1077,6 +1077,7 @@ WorldObject::WorldObject() m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f) , m_map(NULL), m_zoneScript(NULL) , m_isActive(false), IsTempWorldObject(false) + , m_isInternallyAdded(false) , m_name("") { } diff --git a/src/game/Object.h b/src/game/Object.h index 1667d266016..fa2a3a7eeb3 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -550,6 +550,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object bool isActiveObject() const { return m_isActive; } void setActive(bool isActiveObject); + void SetInternallyAdded() { m_isInternallyAdded = true; } void SetWorldObject(bool apply); template<class NOTIFIER> void VisitNearbyObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); } template<class NOTIFIER> void VisitNearbyGridObject(const float &radius, NOTIFIER ¬ifier) const { GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); } @@ -568,6 +569,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object explicit WorldObject(); std::string m_name; bool m_isActive; + bool m_isInternallyAdded; ZoneScript *m_zoneScript; private: diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index e23d114f0f2..1b661bc41ba 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1229,6 +1229,102 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) } } +uint32 ObjectMgr::AddGameObject(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3) +{ + GameObjectInfo const* goinfo = GetGameObjectInfo(entry); + if (!goinfo) + return 0; + + uint32 guid = GenerateLowGuid(HIGHGUID_GAMEOBJECT); + GameObjectData& data = NewGOData(guid); + data.id = entry; + data.mapid = mapId; + data.posX = x; + data.posY = y; + data.posZ = z; + data.orientation = o; + data.rotation0 = rotation0; + data.rotation1 = rotation1; + data.rotation2 = rotation2; + data.rotation3 = rotation3; + data.spawntimesecs = spawntimedelay; + data.animprogress = 100; + data.spawnMask = 1; + data.go_state = GO_STATE_READY; + data.phaseMask = PHASEMASK_NORMAL; + data.dbData = false; + + AddGameobjectToGrid(guid, &data); + + // Spawn if necessary (loaded grids only) + if(Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(mapId))) + { + // We use spawn coords to spawn + if(!map->Instanceable() && !map->IsRemovalGrid(x, y)) + { + GameObject *go = new GameObject; + if(!go->LoadFromDB(guid, map)) + { + sLog.outError("AddGameObject: cannot add gameobject entry %u to map", entry); + delete go; + return 0; + } + map->Add(go); + } + } + + return guid; +} + +uint32 ObjectMgr::AddCreature(uint32 entry, uint32 team, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay) +{ + CreatureInfo const *cInfo = GetCreatureTemplate(entry); + if(!cInfo) + return 0; + + uint32 guid = GenerateLowGuid(HIGHGUID_UNIT); + CreatureData& data = NewOrExistCreatureData(guid); + data.id = entry; + data.mapid = mapId; + data.displayid = 0; + data.equipmentId = cInfo->equipmentId; + data.posX = x; + data.posY = y; + data.posZ = z; + data.orientation = o; + data.spawntimesecs = spawntimedelay; + data.spawndist = 0; + data.currentwaypoint = 0; + data.curhealth = cInfo->maxhealth; + data.curmana = cInfo->maxmana; + data.is_dead = false; + data.movementType = cInfo->MovementType; + data.spawnMask = 1; + data.phaseMask = PHASEMASK_NORMAL; + data.dbData = false; + + AddCreatureToGrid(guid, &data); + + // Spawn if necessary (loaded grids only) + if(Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(mapId))) + { + // We use spawn coords to spawn + if(!map->Instanceable() && !map->IsRemovalGrid(x, y)) + { + Creature* creature = new Creature; + if(!creature->LoadFromDB(guid, map)) + { + sLog.outError("AddCreature: cannot add creature entry %u to map", entry); + delete creature; + return 0; + } + map->Add(creature); + } + } + + return guid; +} + void ObjectMgr::LoadGameobjects() { uint32 count = 0; diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index ca4093f875a..ae1222cccfb 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -708,7 +708,7 @@ class ObjectMgr } const char *GetTrinityString(int32 entry, int locale_idx) const; const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); } - int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } + int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance); @@ -725,6 +725,8 @@ class ObjectMgr void RemoveCreatureFromGrid(uint32 guid, CreatureData const* data); void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); + uint32 AddGameObject(uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0); + uint32 AddCreature(uint32 entry, uint32 team, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0); // reserved names void LoadReservedPlayersNames(); diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp index 483574c45f7..a08cbe949ad 100644 --- a/src/game/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP.cpp @@ -50,114 +50,25 @@ void OPvPCapturePoint::HandlePlayerLeave(Player * plr) bool OPvPCapturePoint::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3) { - GameObjectInfo const* goinfo = objmgr.GetGameObjectInfo(entry); - if (!goinfo) + uint32 guid = objmgr.AddGameObject(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3); + if(!guid) return false; - uint32 guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); - - GameObjectData& data = objmgr.NewGOData(guid); - - data.id = entry; - data.mapid = map; - data.posX = x; - data.posY = y; - data.posZ = z; - data.orientation = o; - data.rotation0 = rotation0; - data.rotation1 = rotation1; - data.rotation2 = rotation2; - data.rotation3 = rotation3; - data.spawntimesecs = 0; - data.animprogress = 100; - data.spawnMask = 1; - data.go_state = GO_STATE_READY; - data.phaseMask = PHASEMASK_NORMAL; - - objmgr.AddGameobjectToGrid(guid, &data); - // 2 way registering m_Objects[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_GAMEOBJECT); m_ObjectTypes[m_Objects[type]]=type; - Map * pMap = MapManager::Instance().FindMap(map); - if(!pMap) - return true; - GameObject * go = new GameObject; - if(!go->Create(guid,entry, pMap,PHASEMASK_NORMAL,x,y,z,o,rotation0,rotation1,rotation2,rotation3,100,GO_STATE_READY)) - { - sLog.outError("Gameobject template %u not found in database.", entry); - delete go; - return true; - } - - go->SetRespawnTime(0); - objmgr.SaveGORespawnTime(go->GetDBTableGUIDLow(),0,0); - pMap->Add(go); - return true; } -bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay) +bool OPvPCapturePoint::AddCreature(uint32 type, uint32 entry, uint32 team, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay) { - CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(entry); - if(!cinfo) - { + uint32 guid = objmgr.AddCreature(entry, team, map, x, y, z, o, spawntimedelay); + if(!guid) return false; - } - - uint32 displayId = objmgr.ChooseDisplayId(teamval, cinfo, NULL); - CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(displayId); - if (!minfo) - { - return false; - } - else - displayId = minfo->modelid; // it can be different (for another gender) - - uint32 guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT); - - CreatureData& data = objmgr.NewOrExistCreatureData(guid); - - data.id = entry; - data.mapid = map; - data.displayid = displayId; - data.equipmentId = cinfo->equipmentId; - data.posX = x; - data.posY = y; - data.posZ = z; - data.orientation = o; - data.spawntimesecs = spawntimedelay; - data.spawndist = 0; - data.currentwaypoint = 0; - data.curhealth = cinfo->maxhealth; - data.curmana = cinfo->maxmana; - data.is_dead = false; - data.movementType = cinfo->MovementType; - data.spawnMask = 1; - data.phaseMask = PHASEMASK_NORMAL; - - objmgr.AddCreatureToGrid(guid, &data); m_Creatures[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_UNIT); m_CreatureTypes[m_Creatures[type]] = type; - - Map * pMap = MapManager::Instance().FindMap(map); - if(!pMap) - return true; - Creature* pCreature = new Creature; - if (!pCreature->Create(guid, pMap, PHASEMASK_NORMAL, entry, teamval, x, y, z, o)) - { - sLog.outError("Can't create creature entry: %u",entry); - delete pCreature; - return false; - } - - if(spawntimedelay) - pCreature->SetRespawnDelay(spawntimedelay); - - pMap->Add(pCreature); - return true; } @@ -173,33 +84,15 @@ bool OPvPCapturePoint::AddCapturePoint(uint32 entry, uint32 map, float x, float return false; } - // create capture point go - m_CapturePointGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); + m_CapturePointGUID = objmgr.AddGameObject(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3); + if(!m_CapturePointGUID) + return false; + // get the needed values from goinfo m_ShiftMaxPhase = goinfo->capturePoint.maxTime; m_ShiftMaxCaptureSpeed = m_ShiftMaxPhase / float(goinfo->capturePoint.minTime); m_NeutralValue = goinfo->capturePoint.neutralPercent; - GameObjectData& data = objmgr.NewGOData(m_CapturePointGUID); - - data.id = entry; - data.mapid = map; - data.posX = x; - data.posY = y; - data.posZ = z; - data.orientation = o; - data.rotation0 = rotation0; - data.rotation1 = rotation1; - data.rotation2 = rotation2; - data.rotation3 = rotation3; - data.spawntimesecs = 1; - data.animprogress = 100; - data.spawnMask = 1; - data.go_state = GO_STATE_READY; - data.phaseMask = PHASEMASK_NORMAL; - - objmgr.AddGameobjectToGrid(m_CapturePointGUID, &data); - return true; } diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp index 06ef39bd599..02cc9d00a03 100644 --- a/src/game/Wintergrasp.cpp +++ b/src/game/Wintergrasp.cpp @@ -37,6 +37,10 @@ bool OPvPWintergrasp::SetupOutdoorPvP() //m_defender = TEAM_ALLIANCE; //gameeventmgr.StartInternalEvent(GameEventWintergraspDefender[m_defender]); + //Titan Relic eventid = 19982 + objmgr.AddGameObject(192829, 571, 5444.6, 2840.8, 420.43, 0); + + return true; } @@ -48,6 +52,8 @@ uint32 OPvPWintergrasp::GetCreatureEntry(uint32 guidlow, uint32 entry) { case 30739: return 30740; case 30740: return 30739; + case 30400: return 30499; + case 30499: return 30400; } } return entry; |