TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Garrison::Plot Struct Reference

#include <Garrison.h>

Public Member Functions

GameObjectCreateGameObject (Map *map, GarrisonFactionIndex faction)
 
void DeleteGameObject (Map *map)
 
void ClearBuildingInfo (Player *owner)
 
void SetBuildingInfo (WorldPackets::Garrison::GarrisonBuildingInfo const &buildingInfo, Player *owner)
 

Public Attributes

WorldPackets::Garrison::GarrisonPlotInfo PacketInfo
 
uint32 EmptyGameObjectId = 0
 
uint32 GarrSiteLevelPlotInstId = 0
 
Building BuildingInfo
 

Member Function Documentation

void Garrison::Plot::ClearBuildingInfo ( Player owner)
797 {
799  plotPlaced.PlotInfo = &PacketInfo;
800  owner->SendDirectMessage(plotPlaced.Write());
801 
802  BuildingInfo.PacketInfo = boost::none;
803 }
WorldPackets::Garrison::GarrisonPlotInfo PacketInfo
Definition: Garrison.h:102
Building BuildingInfo
Definition: Garrison.h:105
GarrisonPlotInfo * PlotInfo
Definition: GarrisonPackets.h:279
Optional< WorldPackets::Garrison::GarrisonBuildingInfo > PacketInfo
Definition: Garrison.h:92
WorldPacket const * Write() override
Definition: GarrisonPackets.cpp:259
Definition: GarrisonPackets.h:272

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject * Garrison::Plot::CreateGameObject ( Map map,
GarrisonFactionIndex  faction 
)
696 {
697  uint32 entry = EmptyGameObjectId;
699  {
701  GarrPlotEntry const* plot = sGarrPlotStore.AssertEntry(plotInstance->GarrPlotID);
702  GarrBuildingEntry const* building = sGarrBuildingStore.AssertEntry(BuildingInfo.PacketInfo->GarrBuildingID);
704  if (BuildingInfo.PacketInfo->Active || !entry)
705  entry = faction == GARRISON_FACTION_INDEX_HORDE ? building->HordeGameObjectID : building->AllianceGameObjectID;
706  }
707 
708  if (!sObjectMgr->GetGameObjectTemplate(entry))
709  {
710  TC_LOG_ERROR("garrison", "Garrison attempted to spawn gameobject whose template doesn't exist (%u)", entry);
711  return nullptr;
712  }
713 
714  Position const& pos = PacketInfo.PlotPos;
715  GameObject* building = new GameObject();
716  if (!building->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, 0, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(),
717  0.0f, 0.0f, 0.0f, 0.0f, 255, GO_STATE_READY))
718  {
719  delete building;
720  return nullptr;
721  }
722 
724  {
725  if (FinalizeGarrisonPlotGOInfo const* finalizeInfo = sGarrisonMgr.GetPlotFinalizeGOInfo(PacketInfo.GarrPlotInstanceID))
726  {
727  Position const& pos2 = finalizeInfo->FactionInfo[faction].Pos;
728  GameObject* finalizer = new GameObject();
729  if (finalizer->Create(map->GenerateLowGuid<HighGuid::GameObject>(), finalizeInfo->FactionInfo[faction].GameObjectId, map, 0, pos2.GetPositionX(), pos2.GetPositionY(),
730  pos2.GetPositionZ(), pos2.GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 255, GO_STATE_READY))
731  {
732  // set some spell id to make the object delete itself after use
733  finalizer->SetSpellId(finalizer->GetGOInfo()->goober.spell);
734  finalizer->SetRespawnTime(0);
735 
736  if (uint16 animKit = finalizeInfo->FactionInfo[faction].AnimKitId)
737  finalizer->SetAnimKitId(animKit, false);
738 
739  map->AddToMap(finalizer);
740  }
741  else
742  delete finalizer;
743  }
744  }
745 
746  if (building->GetGoType() == GAMEOBJECT_TYPE_GARRISON_BUILDING && building->GetGOInfo()->garrisonBuilding.mapID)
747  {
748  for (CellObjectGuidsMap::value_type const& cellGuids : sObjectMgr->GetMapObjectGuids(building->GetGOInfo()->garrisonBuilding.mapID, map->GetSpawnMode()))
749  {
750  for (ObjectGuid::LowType spawnId : cellGuids.second.creatures)
751  if (Creature* spawn = BuildingSpawnHelper<Creature, &Creature::SetHomePosition>(building, spawnId, map))
752  BuildingInfo.Spawns.insert(spawn->GetGUID());
753 
754  for (ObjectGuid::LowType spawnId : cellGuids.second.gameobjects)
755  if (GameObject* spawn = BuildingSpawnHelper<GameObject, &GameObject::RelocateStationaryPosition>(building, spawnId, map))
756  BuildingInfo.Spawns.insert(spawn->GetGUID());
757  }
758  }
759 
760  BuildingInfo.Guid = building->GetGUID();
761  return building;
762 }
uint8 GetSpawnMode() const
Definition: Map.h:369
struct GameObjectTemplate::@221::@261 garrisonBuilding
DB2Storage< GarrBuildingEntry > sGarrBuildingStore("GarrBuilding.db2", GarrBuildingFormat, HOTFIX_SEL_GARR_BUILDING)
Definition: DB2Structure.h:439
DB2Storage< GarrPlotInstanceEntry > sGarrPlotInstanceStore("GarrPlotInstance.db2", GarrPlotInstanceFormat, HOTFIX_SEL_GARR_PLOT_INSTANCE)
void SetAnimKitId(uint16 animKitId, bool oneshot)
Definition: GameObject.cpp:2438
Definition: SharedDefines.h:2103
Definition: Creature.h:467
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
WorldPackets::Garrison::GarrisonPlotInfo PacketInfo
Definition: Garrison.h:102
uint64 LowType
Definition: ObjectGuid.h:199
uint32 GarrPlotID
Definition: DB2Structure.h:545
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 HordeConstructionGameObjectID
Definition: DB2Structure.h:532
Building BuildingInfo
Definition: Garrison.h:105
Definition: DB2Structure.h:522
uint32 HordeGameObjectID
Definition: DB2Structure.h:442
uint32 GarrPlotInstanceID
Definition: GarrisonPackets.h:63
float GetOrientation() const
Definition: Position.h:107
Position PlotPos
Definition: GarrisonPackets.h:64
uint32 EmptyGameObjectId
Definition: Garrison.h:103
uint32 AllianceGameObjectID
Definition: DB2Structure.h:443
float GetPositionY() const
Definition: Position.h:105
bool AddToMap(T *)
Definition: Map.cpp:566
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
#define sGarrisonMgr
Definition: GarrisonMgr.h:77
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint16_t uint16
Definition: Define.h:151
ObjectGuid Guid
Definition: Garrison.h:90
Definition: GameObject.h:880
DB2Storage< GarrPlotEntry > sGarrPlotStore("GarrPlot.db2", GarrPlotFormat, HOTFIX_SEL_GARR_PLOT)
struct GameObjectTemplate::@221::@233 goober
Definition: GameObject.h:823
bool CanActivate() const
Definition: Garrison.cpp:817
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: DB2Structure.h:542
std::unordered_set< ObjectGuid > Spawns
Definition: Garrison.h:91
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Optional< WorldPackets::Garrison::GarrisonBuildingInfo > PacketInfo
Definition: Garrison.h:92
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
void SetSpellId(uint32 id)
Definition: GameObject.h:928
Definition: Position.h:27
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Garrison.h:26
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
float GetPositionX() const
Definition: Position.h:104
uint32 AllianceConstructionGameObjectID
Definition: DB2Structure.h:531
Definition: GarrisonMgr.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Garrison::Plot::DeleteGameObject ( Map map)
765 {
766  if (BuildingInfo.Guid.IsEmpty())
767  return;
768 
769  for (ObjectGuid const& guid : BuildingInfo.Spawns)
770  {
771  WorldObject* object = nullptr;
772  switch (guid.GetHigh())
773  {
774  case HighGuid::Creature:
775  object = map->GetCreature(guid);
776  break;
778  object = map->GetGameObject(guid);
779  break;
780  default:
781  continue;
782  }
783 
784  if (object)
785  object->AddObjectToRemoveList();
786  }
787 
788  BuildingInfo.Spawns.clear();
789 
790  if (GameObject* oldBuilding = map->GetGameObject(BuildingInfo.Guid))
791  oldBuilding->Delete();
792 
794 }
Definition: Object.h:423
Building BuildingInfo
Definition: Garrison.h:105
void AddObjectToRemoveList()
Definition: Object.cpp:2205
ObjectGuid Guid
Definition: Garrison.h:90
Definition: GameObject.h:880
void Clear()
Definition: ObjectGuid.h:215
std::unordered_set< ObjectGuid > Spawns
Definition: Garrison.h:91
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
Definition: ObjectGuid.h:189
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Garrison::Plot::SetBuildingInfo ( WorldPackets::Garrison::GarrisonBuildingInfo const buildingInfo,
Player owner 
)
806 {
808  {
811  owner->SendDirectMessage(plotRemoved.Write());
812  }
813 
814  BuildingInfo.PacketInfo = buildingInfo;
815 }
WorldPackets::Garrison::GarrisonPlotInfo PacketInfo
Definition: Garrison.h:102
Building BuildingInfo
Definition: Garrison.h:105
uint32 GarrPlotInstanceID
Definition: GarrisonPackets.h:63
Definition: GarrisonPackets.h:282
Optional< WorldPackets::Garrison::GarrisonBuildingInfo > PacketInfo
Definition: Garrison.h:92
WorldPacket const * Write() override
Definition: GarrisonPackets.cpp:266
uint32 GarrPlotInstanceID
Definition: GarrisonPackets.h:289

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Building Garrison::Plot::BuildingInfo
uint32 Garrison::Plot::EmptyGameObjectId = 0
uint32 Garrison::Plot::GarrSiteLevelPlotInstId = 0
WorldPackets::Garrison::GarrisonPlotInfo Garrison::Plot::PacketInfo

The documentation for this struct was generated from the following files: