From 13819597ef078096086f03e6faf93f161949799f Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 4 Sep 2025 01:40:34 -0300 Subject: fix small bug with experience distribution Before checking if players are in the same party, we need to check if they're in any party at all. I made a small wrapper `TPlayer::InPartyWith` to help prevent this mistake again. --- src/crplayer.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/crplayer.cc') diff --git a/src/crplayer.cc b/src/crplayer.cc index 16ae6bb..1339ada 100644 --- a/src/crplayer.cc +++ b/src/crplayer.cc @@ -1449,8 +1449,7 @@ bool TPlayer::IsAttackJustified(uint32 VictimID){ return true; } - if(Victim->GetPartyLeader(true) != 0 - && Victim->GetPartyLeader(true) == this->GetPartyLeader(true)){ + if(Victim->InPartyWith(this, true)){ return true; } @@ -1471,9 +1470,9 @@ void TPlayer::RecordAttack(uint32 VictimID){ return; } - if(!Victim->IsAttacker(this->ID, true) && !this->IsAttacker(VictimID, false) - && (Victim->GetPartyLeader(true) == 0 - || Victim->GetPartyLeader(true) != this->GetPartyLeader(true))){ + if(!Victim->InPartyWith(this, true) + && !Victim->IsAttacker(this->ID, true) + && !this->IsAttacker(VictimID, false)){ *this->AttackedPlayers.at(this->NumberOfAttackedPlayers) = VictimID; this->NumberOfAttackedPlayers += 1; print(3, "Spieler %s ist Angreifer für Spieler %s.\n", this->Name, Victim->Name); @@ -1650,8 +1649,7 @@ int TPlayer::GetPlayerkillingMark(TPlayer *Observer){ return SKULL_WHITE; } - if(this->GetPartyLeader(false) != 0 - && this->GetPartyLeader(false) == Observer->GetPartyLeader(false)){ + if(this->InPartyWith(Observer, false)){ return SKULL_GREEN; } @@ -1671,6 +1669,16 @@ uint32 TPlayer::GetPartyLeader(bool CheckFormer){ } } +bool TPlayer::InPartyWith(TPlayer *Other, bool CheckFormer){ + if(Other == NULL){ + error("TPlayer::InPartyWith: Other player is NULL.\n"); + return false; + } + + return this->GetPartyLeader(CheckFormer) != 0 + && this->GetPartyLeader(CheckFormer) == Other->GetPartyLeader(CheckFormer); +} + void TPlayer::JoinParty(uint32 LeaderID){ this->PartyLeavingRound = 0; this->PartyLeader = LeaderID; @@ -1690,8 +1698,7 @@ int TPlayer::GetPartyMark(TPlayer *Observer){ return PARTY_SHIELD_LEADER; } - if(this->GetPartyLeader(false) != 0 - && this->GetPartyLeader(false) == Observer->GetPartyLeader(false)){ + if(this->InPartyWith(Observer, false)){ return PARTY_SHIELD_MEMBER; } -- cgit v1.2.3