diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cr.hh | 1 | ||||
| -rw-r--r-- | src/crcombat.cc | 2 | ||||
| -rw-r--r-- | src/crplayer.cc | 25 | ||||
| -rw-r--r-- | src/operate.cc | 3 |
4 files changed, 19 insertions, 12 deletions
@@ -867,6 +867,7 @@ struct TPlayer: TCreature { void ClearPlayerkillingMarks(void); int GetPlayerkillingMark(TPlayer *Observer); uint32 GetPartyLeader(bool CheckFormer); + bool InPartyWith(TPlayer *Other, bool CheckFormer); void JoinParty(uint32 LeaderID); void LeaveParty(void); int GetPartyMark(TPlayer *Observer); diff --git a/src/crcombat.cc b/src/crcombat.cc index d6cc410..ef4b2f7 100644 --- a/src/crcombat.cc +++ b/src/crcombat.cc @@ -916,7 +916,7 @@ void TCombat::DistributeExperiencePoints(uint32 Exp){ int Amount = (int)((Exp * this->CombatList[i].Damage) / this->CombatDamage); if(Master->Type == PLAYER && Attacker->Type == PLAYER){ - if(((TPlayer*)Master)->GetPartyLeader(true) == ((TPlayer*)Attacker)->GetPartyLeader(true)){ + if(((TPlayer*)Master)->InPartyWith((TPlayer*)Attacker, true)){ continue; } 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; } diff --git a/src/operate.cc b/src/operate.cc index 92c5633..33cb6ac 100644 --- a/src/operate.cc +++ b/src/operate.cc @@ -4079,10 +4079,9 @@ void JoinParty(uint32 GuestID, uint32 HostID){ } if(Guest->GetPartyLeader(true) != 0){ - bool SameParty = Guest->GetPartyLeader(true) == Host->GetPartyLeader(true); SendMessage(Guest->Connection, TALK_INFO_MESSAGE, "You are already member of %s party.", - (SameParty ? "this" : "a")); + (Guest->InPartyWith(Host, true) ? "this" : "a")); return; } |
