diff options
| -rw-r--r-- | src/cr.hh | 1 | ||||
| -rw-r--r-- | src/crmain.cc | 22 | ||||
| -rw-r--r-- | src/crplayer.cc | 14 |
3 files changed, 17 insertions, 20 deletions
@@ -862,6 +862,7 @@ struct TPlayer: TCreature { bool IsAttackJustified(uint32 VictimID); void RecordAttack(uint32 VictimID); void RecordMurder(uint32 VictimID); + void RecordDeath(uint32 AttackerID, int OldLevel, const char *Remark); int CheckPlayerkilling(int Now); void ClearAttacker(uint32 VictimID); void ClearPlayerkillingMarks(void); diff --git a/src/crmain.cc b/src/crmain.cc index 586f78e..f2f13ac 100644 --- a/src/crmain.cc +++ b/src/crmain.cc @@ -817,34 +817,16 @@ int TCreature::Damage(TCreature *Attacker, int Damage, int DamageType){ } if(this->Type == PLAYER){ - if(MurdererID != 0 && MurdererID != this->ID){ - bool Justified = true; - if(IsCreaturePlayer(MurdererID)){ - TPlayer *Murderer = GetPlayer(MurdererID); - if(Murderer != NULL){ - Justified = Murderer->IsAttackJustified(this->ID); - Murderer->RecordMurder(this->ID); - } - } - CharacterDeathOrder(this, OldLevel, MurdererID, Remark, !Justified); - } + ((TPlayer*)this)->RecordDeath(MurdererID, OldLevel, Remark); uint32 MostDangerousID = this->Combat.GetMostDangerousAttacker(); if(MostDangerousID != 0 && MostDangerousID != MurdererID - && MostDangerousID != this->ID && IsCreaturePlayer(MostDangerousID)){ - bool Justified = true; - TPlayer *MostDangerous = GetPlayer(MostDangerousID); - if(MostDangerous != NULL){ - Justified = MostDangerous->IsAttackJustified(this->ID); - MostDangerous->RecordMurder(this->ID); - } - // TODO(fusion): The original function is confusing at this point // but it seems correct that the remark is included only with the // murderer. - CharacterDeathOrder(this, OldLevel, MostDangerousID, "", !Justified); + ((TPlayer*)this)->RecordDeath(MostDangerousID, OldLevel, ""); } } } diff --git a/src/crplayer.cc b/src/crplayer.cc index c4dbd80..86c2aba 100644 --- a/src/crplayer.cc +++ b/src/crplayer.cc @@ -1534,6 +1534,20 @@ void TPlayer::RecordMurder(uint32 VictimID){ } } +void TPlayer::RecordDeath(uint32 AttackerID, int OldLevel, const char *Remark){ + bool Justified = true; + if(AttackerID != 0 && AttackerID != this->ID && IsCreaturePlayer(AttackerID)){ + TPlayer *Attacker = GetPlayer(AttackerID); + if(Attacker == NULL){ + return; + } + + Justified = Attacker->IsAttackJustified(this->ID); + Attacker->RecordMurder(this->ID); + } + CharacterDeathOrder(this, OldLevel, AttackerID, Remark, !Justified); +} + int TPlayer::CheckPlayerkilling(int Now){ int LastDay = 0; int LastWeek = 0; |
