diff options
author | Shauren <shauren.trinity@gmail.com> | 2016-04-25 22:03:34 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2016-05-20 23:49:53 +0200 |
commit | 70102f32fe38ae7d49acbd5ddee0239602d3cb94 (patch) | |
tree | 22dcecc33942c7f60e2edb5402f6f7feaf559ece /src/server/game/Garrison/Garrison.cpp | |
parent | 885d9b53c38662e00e3b4977b82e9cf36d197f94 (diff) |
Core/DataStores: Updated opcodes and db2 to 7.0.3.21414
Diffstat (limited to 'src/server/game/Garrison/Garrison.cpp')
-rw-r--r-- | src/server/game/Garrison/Garrison.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/server/game/Garrison/Garrison.cpp b/src/server/game/Garrison/Garrison.cpp index 7ba412f5a69..2789978a7fe 100644 --- a/src/server/game/Garrison/Garrison.cpp +++ b/src/server/game/Garrison/Garrison.cpp @@ -23,7 +23,7 @@ #include "ObjectMgr.h" #include "VehicleDefines.h" -Garrison::Garrison(Player* owner) : _owner(owner), _siteLevelId(0), _siteLevel(nullptr), _followerActivationsRemainingToday(1) +Garrison::Garrison(Player* owner) : _owner(owner), _siteLevel(nullptr), _followerActivationsRemainingToday(1) { } @@ -34,8 +34,7 @@ bool Garrison::LoadFromDB(PreparedQueryResult garrison, PreparedQueryResult blue return false; Field* fields = garrison->Fetch(); - _siteLevelId = fields[0].GetUInt32(); - _siteLevel = sGarrSiteLevelStore.LookupEntry(_siteLevelId); + _siteLevel = sGarrSiteLevelStore.LookupEntry(_siteLevel->ID); _followerActivationsRemainingToday = fields[1].GetUInt32(); if (!_siteLevel) return false; @@ -142,7 +141,7 @@ void Garrison::SaveToDB(SQLTransaction trans) PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_GARRISON); stmt->setUInt64(0, _owner->GetGUID().GetCounter()); - stmt->setUInt32(1, _siteLevelId); + stmt->setUInt32(1, _siteLevel->ID); stmt->setUInt32(2, _followerActivationsRemainingToday); trans->Append(stmt); @@ -220,17 +219,16 @@ void Garrison::DeleteFromDB(ObjectGuid::LowType ownerGuid, SQLTransaction trans) bool Garrison::Create(uint32 garrSiteId) { - DBStorageIterator<GarrSiteLevelEntry> siteLevelItr = sGarrisonMgr.GetGarrSiteLevelEntry(garrSiteId, 1); - if (siteLevelItr == sGarrSiteLevelStore.end()) + GarrSiteLevelEntry const* siteLevel = sGarrisonMgr.GetGarrSiteLevelEntry(garrSiteId, 1); + if (!siteLevel) return false; - _siteLevelId = siteLevelItr.ID(); - _siteLevel = siteLevelItr.Data(); + _siteLevel = siteLevel; InitializePlots(); WorldPackets::Garrison::GarrisonCreateResult garrisonCreateResult; - garrisonCreateResult.GarrSiteLevelID = _siteLevelId; + garrisonCreateResult.GarrSiteLevelID = _siteLevel->ID; _owner->SendDirectMessage(garrisonCreateResult.Write()); _owner->SendUpdatePhasing(); SendRemoteInfo(); @@ -251,11 +249,11 @@ void Garrison::Delete() void Garrison::InitializePlots() { - if (std::vector<std::pair<uint32, GarrSiteLevelPlotInstEntry const*>> const* plots = sGarrisonMgr.GetGarrPlotInstForSiteLevel(_siteLevelId)) + if (std::vector<GarrSiteLevelPlotInstEntry const*> const* plots = sGarrisonMgr.GetGarrPlotInstForSiteLevel(_siteLevel->ID)) { for (std::size_t i = 0; i < plots->size(); ++i) { - uint32 garrPlotInstanceId = plots->at(i).second->GarrPlotInstanceID; + uint32 garrPlotInstanceId = plots->at(i)->GarrPlotInstanceID; GarrPlotInstanceEntry const* plotInstance = sGarrPlotInstanceStore.LookupEntry(garrPlotInstanceId); GameObjectsEntry const* gameObject = sGarrisonMgr.GetPlotGameObject(_siteLevel->MapID, garrPlotInstanceId); if (!plotInstance || !gameObject) @@ -270,7 +268,7 @@ void Garrison::InitializePlots() plotInfo.PacketInfo.PlotPos.Relocate(gameObject->Position.X, gameObject->Position.Y, gameObject->Position.Z, 2 * std::acos(gameObject->RotationW)); plotInfo.PacketInfo.PlotType = plot->PlotType; plotInfo.EmptyGameObjectId = gameObject->ID; - plotInfo.GarrSiteLevelPlotInstId = plots->at(i).first; + plotInfo.GarrSiteLevelPlotInstId = plots->at(i)->ID; } } } @@ -531,7 +529,7 @@ void Garrison::SendInfo() { WorldPackets::Garrison::GetGarrisonInfoResult garrisonInfo; garrisonInfo.GarrSiteID = _siteLevel->SiteID; - garrisonInfo.GarrSiteLevelID = _siteLevelId; + garrisonInfo.GarrSiteLevelID = _siteLevel->ID; garrisonInfo.FactionIndex = GetFaction(); garrisonInfo.NumFollowerActivationsRemaining = _followerActivationsRemainingToday; for (auto& p : _plots) @@ -558,7 +556,7 @@ void Garrison::SendRemoteInfo() const remoteInfo.Sites.resize(1); WorldPackets::Garrison::GarrisonRemoteSiteInfo& remoteSiteInfo = remoteInfo.Sites[0]; - remoteSiteInfo.GarrSiteLevelID = _siteLevelId; + remoteSiteInfo.GarrSiteLevelID = _siteLevel->ID; for (auto const& p : _plots) if (p.second.BuildingInfo.PacketInfo) remoteSiteInfo.Buildings.emplace_back(p.first, p.second.BuildingInfo.PacketInfo->GarrBuildingID); |