diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-09-04 01:40:34 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-09-04 01:40:34 -0300 |
| commit | 13819597ef078096086f03e6faf93f161949799f (patch) | |
| tree | 6c4411a3412c53c0d5baf40f687abeeddacd41cd /src/crplayer.cc | |
| parent | 81aa93cce828eee17fcbd0720f93c5fb2d08a325 (diff) | |
| download | game-13819597ef078096086f03e6faf93f161949799f.tar.gz game-13819597ef078096086f03e6faf93f161949799f.zip | |
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.
Diffstat (limited to 'src/crplayer.cc')
| -rw-r--r-- | src/crplayer.cc | 25 |
1 files changed, 16 insertions, 9 deletions
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; } |
