Core/Reputation: Fixed crash in reptutation code when PlayerStart.AllReputation is enabled in config

Closes #28915
This commit is contained in:
Shauren
2023-04-11 19:51:06 +02:00
parent 5e47a3522a
commit 353a71c6cd
3 changed files with 10 additions and 18 deletions

View File

@@ -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)

View File

@@ -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));
}
}

View File

@@ -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);