Covenant: wire CMSG_COVENANT_RENOWN_REQUEST_CATCHUP_STATE

This commit is contained in:
luis
2026-07-11 21:16:28 -03:00
parent c783f374da
commit fdf9a4e5a9
6 changed files with 42 additions and 63 deletions
-55
View File
@@ -1272,61 +1272,6 @@ void WorldSession::HandleSetCurrencyFlags(WorldPackets::Misc::SetCurrencyFlags c
_player->SetCurrencyFlagsFromClient(setCurrenctFlags.CurrencyID, setCurrenctFlags.Flags);
}
void WorldSession::HandleCovenantRenownRequestCatchupState(WorldPackets::MajorFactions::RequestCatchupState const& /*packet*/)
{
// Phase 10E: respond with the per-faction catchup state. For every Major
// Faction where this character's renown is below the account-max, emit
// a (FactionID, CatchupPercent) record. CatchupPercent is computed as a
// 0..100 ratio of how far the character has to catch up; the client uses
// this to drive the renown-catchup-bonus reputation multiplier.
//
// Wire format header byte is (payloadLen << 1) & 0xFE; max payload 127B
// = 15 records. With 20 majors today this is sufficient in practice
// because typically only a few factions need catchup at any time.
if (!_player)
return;
WorldPackets::MajorFactions::CovenantRenownSendCatchupState response;
constexpr size_t MaxEntries = 127 / 8; // 15 - matches the 127B header cap
for (uint32 factionId : sMajorFactionMgr->GetMajorFactionIDs())
{
if (response.Entries.size() >= MaxEntries)
{
TC_LOG_WARN("network", "HandleCovenantRenownRequestCatchupState: more than {} catchup-eligible majors for player {} - truncating",
MaxEntries, _player->GetName());
break;
}
FactionEntry const* faction = sFactionStore.LookupEntry(factionId);
if (!faction || !faction->CanHaveReputation())
continue;
// Read the per-character renown level via existing ReputationMgr path.
int32 charRenown = _player->GetReputationMgr().GetRenownLevel(faction);
uint32 maxRenown = sMajorFactionMgr->GetMaxRenownLevel(factionId);
if (maxRenown == 0)
continue;
// Look up the account-max renown level for this faction from the
// already-loaded ReputationMgr cache (populated by warband Phase 4
// LoadAccountWideFromDB at login). Returns -1 when the faction is
// not warband-shared or no row exists yet -> no catchup applies.
int32 accountRenown = _player->GetReputationMgr().GetAccountRenownLevel(factionId);
if (accountRenown < 0 || accountRenown <= charRenown)
continue;
int32 delta = accountRenown - charRenown;
int32 catchupPercent = std::min<int32>(100, (delta * 100) / int32(maxRenown));
response.Entries.push_back({ .FactionID = int32(factionId), .CatchupPercent = catchupPercent });
}
SendPacket(response.Write());
}
void WorldSession::HandleSelectFactionOpcode(WorldPackets::Misc::FactionSelect& selectFaction)
{
if (!_player)