44 Field* fields = garrison->Fetch();
56 fields = blueprints->Fetch();
60 }
while (blueprints->NextRow());
67 fields = buildings->Fetch();
70 time_t timeBuilt = fields[2].
GetInt64();
71 bool active = fields[3].
GetBool();
86 }
while (buildings->NextRow());
95 fields = followers->Fetch();
120 }
while (followers->NextRow());
126 fields = abilities->Fetch();
137 itr->second.PacketInfo.AbilityID.push_back(ability);
138 }
while (abilities->NextRow());
163 for (
auto const& p :
_plots)
165 Plot const& plot = p.second;
180 Follower const& follower = p.second;
259 if (std::vector<GarrSiteLevelPlotInstEntry const*>
const* plots =
sGarrisonMgr.GetGarrPlotInstForSiteLevel(
_siteLevel->
ID))
261 for (std::size_t i = 0; i < plots->size(); ++i)
263 uint32 garrPlotInstanceId = plots->at(i)->GarrPlotInstanceID;
266 if (!plotInstance || !gameObject)
309 std::vector<Plot*> plots;
310 plots.reserve(
_plots.size());
312 plots.push_back(&p.second);
319 auto itr =
_plots.find(garrPlotInstanceId);
328 auto itr =
_plots.find(garrPlotInstanceId);
339 learnBlueprintResult.
BuildingID = garrBuildingId;
356 unlearnBlueprintResult.
BuildingID = garrBuildingId;
472 if (plot->BuildingInfo.CanActivate() && plot->BuildingInfo.PacketInfo && !plot->BuildingInfo.PacketInfo->Active)
474 plot->BuildingInfo.PacketInfo->Active =
true;
477 plot->DeleteGameObject(map);
496 if (
_followerIds.count(garrFollowerId) || !followerEntry)
541 Plot const& plot = p.second;
548 garrison.
Followers.push_back(&p.second.PacketInfo);
558 remoteInfo.
Sites.resize(1);
562 for (
auto const& p :
_plots)
563 if (p.second.BuildingInfo.PacketInfo)
564 remoteSiteInfo.
Buildings.emplace_back(p.first, p.second.BuildingInfo.PacketInfo->GarrBuildingID);
582 for (
auto const& p :
_plots)
584 Plot const& plot = p.second;
602 if (!plotInstance || !plot)
626 for (
auto const& p :
_plots)
628 if (p.second.BuildingInfo.PacketInfo)
630 existingBuilding =
sGarrBuildingStore.AssertEntry(p.second.BuildingInfo.PacketInfo->GarrBuildingID);
666template<
class T,
void(T::*SecondaryRelocate)(Position const&)>
670 if (!spawn->LoadFromDB(spawnId, map,
false,
false))
679 (spawn->*SecondaryRelocate)(globalPosition);
681 if (!spawn->IsPositionValid())
709 if (!
sObjectMgr->GetGameObjectTemplate(entry))
711 TC_LOG_ERROR(
"garrison",
"Garrison attempted to spawn gameobject whose template doesn't exist ({})", entry);
723 Position const& pos2 = finalizeInfo->FactionInfo[faction].Pos;
727 finalizer->SetSpellId(finalizer->GetGOInfo()->goober.spell);
728 finalizer->SetRespawnTime(0);
730 if (
uint16 animKit = finalizeInfo->FactionInfo[faction].AnimKitId)
731 finalizer->SetAnimKitId(animKit,
false);
742 for (
auto const& [cellId, guids] : *cells)
745 if (
GameObject* spawn = BuildingSpawnHelper<GameObject, &GameObject::RelocateStationaryPosition>(building, spawnId, map))
749 if (
Creature* spawn = BuildingSpawnHelper<Creature, &Creature::SetHomePosition>(building, spawnId, map))
761 if (BuildingInfo.Guid.IsEmpty())
764 for (
ObjectGuid const& guid : BuildingInfo.Spawns)
767 switch (guid.GetHigh())
783 BuildingInfo.Spawns.clear();
786 oldBuilding->Delete();
788 BuildingInfo.Guid.Clear();
798 BuildingInfo.PacketInfo.reset();
803 if (!BuildingInfo.PacketInfo)
810 BuildingInfo.PacketInfo = buildingInfo;
827 return (PacketInfo.ItemLevelWeapon + PacketInfo.ItemLevelArmor) / 2;
@ CHAR_DEL_CHARACTER_GARRISON
@ CHAR_INS_CHARACTER_GARRISON_BUILDINGS
@ CHAR_DEL_CHARACTER_GARRISON_FOLLOWERS
@ CHAR_INS_CHARACTER_GARRISON_BLUEPRINTS
@ CHAR_DEL_CHARACTER_GARRISON_BLUEPRINTS
@ CHAR_INS_CHARACTER_GARRISON_FOLLOWER_ABILITIES
@ CHAR_INS_CHARACTER_GARRISON
@ CHAR_DEL_CHARACTER_GARRISON_BUILDINGS
@ CHAR_INS_CHARACTER_GARRISON_FOLLOWERS
DB2Storage< MapEntry > sMapStore("Map.db2", &MapLoadInfo::Instance)
DB2Storage< GarrBuildingEntry > sGarrBuildingStore("GarrBuilding.db2", &GarrBuildingLoadInfo::Instance)
DB2Storage< GarrPlotInstanceEntry > sGarrPlotInstanceStore("GarrPlotInstance.db2", &GarrPlotInstanceLoadInfo::Instance)
DB2Storage< GarrSiteLevelEntry > sGarrSiteLevelStore("GarrSiteLevel.db2", &GarrSiteLevelLoadInfo::Instance)
DB2Storage< GarrFollowerEntry > sGarrFollowerStore("GarrFollower.db2", &GarrFollowerLoadInfo::Instance)
DB2Storage< GarrAbilityEntry > sGarrAbilityStore("GarrAbility.db2", &GarrAbilityLoadInfo::Instance)
DB2Storage< GarrPlotEntry > sGarrPlotStore("GarrPlot.db2", &GarrPlotLoadInfo::Instance)
@ ActivateAnyGarrisonBuilding
@ RecruitGarrisonFollower
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
T * BuildingSpawnHelper(GameObject *building, ObjectGuid::LowType spawnId, Map *map)
@ GARRISON_FACTION_INDEX_HORDE
@ GARRISON_BUILDING_FLAG_NEEDS_PLAN
@ GARRISON_ERROR_REQUIRES_BLUEPRINT
@ GARRISON_ERROR_INVALID_BUILDINGID
@ GARRISON_ERROR_INVALID_PLOT_BUILDING
@ GARRISON_ERROR_INVALID_PLOT_INSTANCEID
@ GARRISON_ERROR_NOT_ENOUGH_CURRENCY
@ GARRISON_ERROR_BUILDING_EXISTS
@ GARRISON_ERROR_NO_BUILDING
@ GARRISON_ERROR_NOT_ENOUGH_GOLD
@ GARRISON_ERROR_FOLLOWER_EXISTS
@ GARRISON_ERROR_BLUEPRINT_EXISTS
#define TC_LOG_ERROR(filterType__, message__,...)
std::unordered_map< uint32, CellObjectGuids > CellObjectGuidsMap
@ GAMEOBJECT_TYPE_GARRISON_BUILDING
ObjectGuid const & GetGUID() const
Class used to access individual fields of database query result.
uint64 GetUInt64() const noexcept
bool GetBool() const noexcept
uint32 GetUInt32() const noexcept
int64 GetInt64() const noexcept
GameObjectTemplate const * GetGOInfo() const
static GameObject * CreateGameObject(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit=0)
GameobjectTypes GetGoType() const
void SendRemoteInfo() const
GarrisonError CheckBuildingRemoval(uint32 garrPlotInstanceId) const
void SendBlueprintAndSpecializationData()
GarrSiteLevelEntry const * _siteLevel
std::unordered_map< uint64, Follower > _followers
void SaveToDB(CharacterDatabaseTransaction trans)
std::unordered_set< uint32 > _followerIds
bool Create(uint32 garrSiteId)
Follower const * GetFollower(uint64 dbId) const
GarrisonType GetType() const
void UnlearnBlueprint(uint32 garrBuildingId)
void CancelBuildingConstruction(uint32 garrPlotInstanceId)
bool LoadFromDB(PreparedQueryResult garrison, PreparedQueryResult blueprints, PreparedQueryResult buildings, PreparedQueryResult followers, PreparedQueryResult abilities)
void AddFollower(uint32 garrFollowerId)
void PlaceBuilding(uint32 garrPlotInstanceId, uint32 garrBuildingId)
GarrisonFactionIndex GetFaction() const
Plot * GetPlot(uint32 garrPlotInstanceId)
GarrisonError CheckBuildingPlacement(uint32 garrPlotInstanceId, uint32 garrBuildingId) const
void LearnBlueprint(uint32 garrBuildingId)
bool HasBlueprint(uint32 garrBuildingId) const
std::unordered_map< uint32, Plot > _plots
std::unordered_set< uint32 > _knownBuildings
void SendMapData(Player *receiver) const
void BuildInfoPacket(WorldPackets::Garrison::GarrisonInfo &garrison) const
static void DeleteFromDB(ObjectGuid::LowType ownerGuid, CharacterDatabaseTransaction trans)
void ActivateBuilding(uint32 garrPlotInstanceId)
uint32 _followerActivationsRemainingToday
std::vector< Plot * > GetPlots()
GameObject * GetGameObject(ObjectGuid const &guid)
Difficulty GetDifficultyID() const
Creature * GetCreature(ObjectGuid const &guid)
LowType GetCounter() const
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
bool ModifyMoney(int64 amount, bool sendError=true)
void SendDirectMessage(WorldPacket const *data) const
bool HasCurrency(uint32 id, uint32 amount) const
void UpdateCriteria(CriteriaType type, uint64 miscValue1=0, uint64 miscValue2=0, uint64 miscValue3=0, WorldObject *ref=nullptr)
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options=TELE_TO_NONE, Optional< uint32 > instanceId={}, uint32 teleportSpellId=0)
void RemoveCurrency(uint32 id, int32 amount, CurrencyDestroyReason destroyReason=CurrencyDestroyReason::Cheat)
void AddCurrency(uint32 id, uint32 amount, CurrencyGainSource gainSource=CurrencyGainSource::Cheat)
bool HasEnoughMoney(uint64 amount) const
void setUInt32(uint8 index, uint32 value)
void setInt64(uint8 index, int64 value)
void setBool(uint8 index, bool value)
void setUInt64(uint8 index, uint64 value)
void setUInt8(uint8 index, uint8 value)
constexpr uint32 GetMapId() const
void AddObjectToRemoveList()
WorldPacket const * Write() override
GarrisonFollower Follower
uint32 GarrPlotInstanceID
WorldPacket const * Write() override
WorldPacket const * Write() override
uint32 GarrPlotInstanceID
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< GarrisonBuildingMapData > Buildings
WorldPacket const * Write() override
GarrisonBuildingInfo BuildingInfo
WorldPacket const * Write() override
GarrisonPlotInfo * PlotInfo
uint32 GarrPlotInstanceID
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< GarrisonRemoteSiteInfo > Sites
std::unordered_set< uint32 > const * BlueprintsKnown
WorldPacket const * Write() override
WorldPacket const * Write() override
struct advstd::ranges::Contains contains
struct GameObjectTemplate::@197::@237 garrisonBuilding
std::array< float, 4 > Rot
int32 AllianceGameObjectID
int32 HordeConstructObjID
int32 AllianceConstructObjID
Optional< WorldPackets::Garrison::GarrisonBuildingInfo > PacketInfo
std::unordered_set< ObjectGuid > Spawns
WorldPackets::Garrison::GarrisonFollower PacketInfo
bool HasAbility(uint32 garrAbilityId) const
uint32 GetItemLevel() const
WorldPackets::Garrison::GarrisonPlotInfo PacketInfo
GameObject * CreateGameObject(Map *map, GarrisonFactionIndex faction)
void SetBuildingInfo(WorldPackets::Garrison::GarrisonBuildingInfo const &buildingInfo, Player *owner)
void DeleteGameObject(Map *map)
void ClearBuildingInfo(GarrisonType garrisonType, Player *owner)
uint32 GarrSiteLevelPlotInstId
Position GetPositionWithOffset(Position const &offset) const
constexpr void Relocate(float x, float y)
constexpr float GetOrientation() const
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
uint32 GarrPlotInstanceID
std::list< GarrAbilityEntry const * > AbilityID
std::vector< GarrisonFollower const * > Followers
uint32 NumFollowerActivationsRemaining
std::vector< GarrisonBuildingInfo const * > Buildings
std::vector< GarrisonPlotInfo const * > Plots
uint32 GarrPlotInstanceID
TaggedPosition< Position::XYZO > PlotPos
std::vector< GarrisonRemoteBuildingInfo > Buildings