diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-04-11 19:51:06 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-04-11 19:51:06 +0200 |
commit | 353a71c6cd57c883722f8cd8d7897c15aad43fa2 (patch) | |
tree | 338dd1d755759f62ffb951e16af048c20b49b717 | |
parent | 5e47a3522a03ac193bad819e5ff04e11e6c65645 (diff) |
Core/Reputation: Fixed crash in reptutation code when PlayerStart.AllReputation is enabled in config
Closes #28915
-rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 7 | ||||
-rw-r--r-- | src/server/game/Reputation/ReputationMgr.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Server/WorldSession.h | 1 |
3 files changed, 10 insertions, 18 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 5e3d31e0a71..b2a58835e5a 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1506,13 +1506,6 @@ void WorldSession::HandleSetFactionNotAtWar(WorldPackets::Character::SetFactionN GetPlayer()->GetReputationMgr().SetAtWar(packet.FactionIndex, false); } -//I think this function is never used :/ I dunno, but i guess this opcode not exists -void WorldSession::HandleSetFactionCheat(WorldPacket& /*recvData*/) -{ - TC_LOG_ERROR("network", "WORLD SESSION: HandleSetFactionCheat, not expected call, please report."); - GetPlayer()->GetReputationMgr().SendState(nullptr); -} - void WorldSession::HandleTutorialFlag(WorldPackets::Misc::TutorialSetFlag& packet) { switch (packet.Action) diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index fb7cbedf0ce..be7ca6a728f 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -342,21 +342,21 @@ void ReputationMgr::SendState(FactionState const* faction) WorldPackets::Reputation::SetFactionStanding setFactionStanding; setFactionStanding.BonusFromAchievementSystem = 0.0f; - int32 standing = faction->VisualStandingIncrease ? faction->VisualStandingIncrease : faction->Standing; + auto getStandingForPacket = [](FactionState const* state) + { + return state->VisualStandingIncrease ? state->VisualStandingIncrease : state->Standing; + }; if (faction) - setFactionStanding.Faction.emplace_back(int32(faction->ReputationListID), standing); + setFactionStanding.Faction.emplace_back(int32(faction->ReputationListID), getStandingForPacket(faction)); - for (FactionStateList::iterator itr = _factions.begin(); itr != _factions.end(); ++itr) + for (auto& [reputationIndex, state] : _factions) { - if (itr->second.needSend) + if (state.needSend) { - itr->second.needSend = false; - if (!faction || itr->second.ReputationListID != faction->ReputationListID) - { - standing = itr->second.VisualStandingIncrease ? itr->second.VisualStandingIncrease : itr->second.Standing; - setFactionStanding.Faction.emplace_back(int32(itr->second.ReputationListID), standing); - } + state.needSend = false; + if (!faction || state.ReputationListID != faction->ReputationListID) + setFactionStanding.Faction.emplace_back(int32(state.ReputationListID), getStandingForPacket(&state)); } } diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index a8f26da3f73..146f2614d07 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -1282,7 +1282,6 @@ class TC_GAME_API WorldSession void HandleSetFactionAtWar(WorldPackets::Character::SetFactionAtWar& packet); void HandleSetFactionNotAtWar(WorldPackets::Character::SetFactionNotAtWar& packet); - void HandleSetFactionCheat(WorldPacket& recvData); void HandleSetWatchedFactionOpcode(WorldPackets::Character::SetWatchedFaction& packet); void HandleSetFactionInactiveOpcode(WorldPackets::Character::SetFactionInactive& packet); void HandleRequestForcedReactionsOpcode(WorldPackets::Reputation::RequestForcedReactions& requestForcedReactions); |