From d238457803553ba9d83be68993758102c962c4f5 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 4 Dec 2017 15:05:16 +0100 Subject: [PATCH] log death just once --- src/creature/creature.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/creature/creature.cpp b/src/creature/creature.cpp index 39b96b2..8c7d235 100644 --- a/src/creature/creature.cpp +++ b/src/creature/creature.cpp @@ -209,22 +209,6 @@ void Creature::DoWork(double amount) noexcept { void Creature::Hurt(double amount) noexcept { stats.Damage().Add(amount); if (stats.Damage().Full()) { - std::ostream &log = sim.Log() << name << " "; - if (stats.Exhaustion().Full()) { - log << "died of exhaustion"; - } else if (stats.Breath().Full()) { - log << "suffocated"; - } else if (stats.Thirst().Full()) { - log << "died of thirst"; - } else if (stats.Hunger().Full()) { - log << "starved to death"; - } else { - log << "succumed to wounds"; - } - log << " at an age of " << ui::TimeString(Age()) - << " (" << ui::PercentageString(Age() / properties.Lifetime()) - << " of life expectancy of " << ui::TimeString(properties.Lifetime()) - << ")" << std::endl; Die(); } } @@ -232,6 +216,23 @@ void Creature::Hurt(double amount) noexcept { void Creature::Die() noexcept { if (Dead()) return; + std::ostream &log = sim.Log() << name << " "; + if (stats.Exhaustion().Full()) { + log << "died of exhaustion"; + } else if (stats.Breath().Full()) { + log << "suffocated"; + } else if (stats.Thirst().Full()) { + log << "died of thirst"; + } else if (stats.Hunger().Full()) { + log << "starved to death"; + } else { + log << "succumed to wounds"; + } + log << " at an age of " << ui::TimeString(Age()) + << " (" << ui::PercentageString(Age() / properties.Lifetime()) + << " of life expectancy of " << ui::TimeString(properties.Lifetime()) + << ")" << std::endl; + sim.SetDead(this); death = sim.Time(); steering.Off(); -- 2.39.2