43 Field* fields = garrison->Fetch();
55 fields = blueprints->Fetch();
59 }
while (blueprints->NextRow());
66 fields = buildings->Fetch();
69 time_t timeBuilt = fields[2].
GetInt64();
70 bool active = fields[3].
GetBool();
85 }
while (buildings->NextRow());
94 fields = followers->Fetch();
119 }
while (followers->NextRow());
125 fields = abilities->Fetch();
136 itr->second.PacketInfo.AbilityID.push_back(ability);
137 }
while (abilities->NextRow());
162 for (
auto const& p :
_plots)
164 Plot const& plot = p.second;
179 Follower const& follower = p.second;
258 if (std::vector<GarrSiteLevelPlotInstEntry const*>
const* plots =
sGarrisonMgr.GetGarrPlotInstForSiteLevel(
_siteLevel->
ID))
260 for (std::size_t i = 0; i < plots->size(); ++i)
262 uint32 garrPlotInstanceId = plots->at(i)->GarrPlotInstanceID;
265 if (!plotInstance || !gameObject)
320 std::vector<Plot*> plots;
321 plots.reserve(
_plots.size());
323 plots.push_back(&p.second);
330 auto itr =
_plots.find(garrPlotInstanceId);
339 auto itr =
_plots.find(garrPlotInstanceId);
350 learnBlueprintResult.
BuildingID = garrBuildingId;
367 unlearnBlueprintResult.
BuildingID = garrBuildingId;
483 if (plot->BuildingInfo.CanActivate() && plot->BuildingInfo.PacketInfo && !plot->BuildingInfo.PacketInfo->Active)
485 plot->BuildingInfo.PacketInfo->Active =
true;
488 plot->DeleteGameObject(map);
507 if (
_followerIds.count(garrFollowerId) || !followerEntry)
557 Plot& plot = p.second;
564 garrison.
Followers.push_back(&p.second.PacketInfo);
576 remoteInfo.
Sites.resize(1);
580 for (
auto const& p :
_plots)
581 if (p.second.BuildingInfo.PacketInfo)
582 remoteSiteInfo.
Buildings.emplace_back(p.first, p.second.BuildingInfo.PacketInfo->GarrBuildingID);
600 for (
auto const& p :
_plots)
602 Plot const& plot = p.second;
620 if (!plotInstance || !plot)
644 for (
auto const& p :
_plots)
646 if (p.second.BuildingInfo.PacketInfo)
648 existingBuilding =
sGarrBuildingStore.AssertEntry(p.second.BuildingInfo.PacketInfo->GarrBuildingID);
684template<
class T,
void(T::*SecondaryRelocate)(
float,
float,
float,
float)>
688 if (!spawn->LoadFromDB(spawnId, map,
false,
false))
694 float x = spawn->GetPositionX();
695 float y = spawn->GetPositionY();
696 float z = spawn->GetPositionZ();
697 float o = spawn->GetOrientation();
700 spawn->Relocate(x, y, z, o);
701 (spawn->*SecondaryRelocate)(x, y, z, o);
703 if (!spawn->IsPositionValid())
731 if (!
sObjectMgr->GetGameObjectTemplate(entry))
733 TC_LOG_ERROR(
"garrison",
"Garrison attempted to spawn gameobject whose template doesn't exist ({})", entry);
745 Position const& pos2 = finalizeInfo->FactionInfo[faction].Pos;
749 finalizer->SetSpellId(finalizer->GetGOInfo()->goober.spell);
750 finalizer->SetRespawnTime(0);
752 if (
uint16 animKit = finalizeInfo->FactionInfo[faction].AnimKitId)
753 finalizer->SetAnimKitId(animKit,
false);
764 for (
auto const& [cellId, guids] : *cells)
767 if (
GameObject* spawn = BuildingSpawnHelper<GameObject, &GameObject::RelocateStationaryPosition>(building, spawnId, map))
771 if (
Creature* spawn = BuildingSpawnHelper<Creature, &Creature::SetHomePosition>(building, spawnId, map))
783 if (BuildingInfo.Guid.IsEmpty())
786 for (
ObjectGuid const& guid : BuildingInfo.Spawns)
805 BuildingInfo.Spawns.clear();
808 oldBuilding->Delete();
810 BuildingInfo.Guid.Clear();
820 BuildingInfo.PacketInfo.reset();
825 if (!BuildingInfo.PacketInfo)
832 BuildingInfo.PacketInfo = buildingInfo;
849 return (PacketInfo.ItemLevelWeapon + PacketInfo.ItemLevelArmor) / 2;
854 return std::find_if(PacketInfo.AbilityID.begin(), PacketInfo.AbilityID.end(), [garrAbilityId](
GarrAbilityEntry const* garrAbility)
856 return garrAbility->ID == garrAbilityId;
857 }) != PacketInfo.AbilityID.end();
@ 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_FACTION_INDEX_ALLIANCE
@ 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__,...)
std::unordered_map< uint32, CellObjectGuids > CellObjectGuidsMap
@ GAMEOBJECT_TYPE_GARRISON_BUILDING
Class used to access individual fields of database query result.
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
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 ObjectGuid GetGUID(Object const *o)
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
bool ModifyMoney(int64 amount, bool sendError=true)
void SendDirectMessage(WorldPacket const *data) const
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options=TELE_TO_NONE, Optional< uint32 > instanceId={})
bool HasCurrency(uint32 id, uint32 amount) const
void UpdateCriteria(CriteriaType type, uint64 miscValue1=0, uint64 miscValue2=0, uint64 miscValue3=0, WorldObject *ref=nullptr)
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 setUInt8(const uint8 index, const uint8 value)
void setInt64(const uint8 index, const int64 value)
void setBool(const uint8 index, const bool value)
void setUInt32(const uint8 index, const uint32 value)
void setUInt64(const uint8 index, const uint64 value)
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
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
WorldPacket const * Write() override
std::vector< GarrisonInfo > Garrisons
struct GameObjectTemplate::@213::@253 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
constexpr float GetPositionX() const
constexpr float GetPositionY() const
constexpr void Relocate(float x, float y)
constexpr float GetOrientation() const
constexpr float GetPositionZ() const
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
uint32 GarrPlotInstanceID
std::list< GarrAbilityEntry const * > AbilityID
std::vector< GarrisonPlotInfo * > Plots
std::vector< GarrisonFollower const * > Followers
uint32 NumFollowerActivationsRemaining
std::vector< GarrisonBuildingInfo const * > Buildings
uint32 GarrPlotInstanceID
TaggedPosition< Position::XYZO > PlotPos
std::vector< GarrisonRemoteBuildingInfo > Buildings