aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-09-06 00:12:47 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-09-06 00:12:47 -0300
commit4c4e5381367f4739b4aeac14d1061da242a1eac2 (patch)
tree6b616f8be87b4dfa1315656857850b51319083e7
parent8d565e911691a3740c283bd33ebc11d6d0fac6b7 (diff)
downloadgame-4c4e5381367f4739b4aeac14d1061da242a1eac2.tar.gz
game-4c4e5381367f4739b4aeac14d1061da242a1eac2.zip
fix character death recording logic
-rw-r--r--src/cr.hh1
-rw-r--r--src/crmain.cc22
-rw-r--r--src/crplayer.cc14
3 files changed, 17 insertions, 20 deletions
diff --git a/src/cr.hh b/src/cr.hh
index 18cfe5e..6617c76 100644
--- a/src/cr.hh
+++ b/src/cr.hh
@@ -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;