From a0e2abe20a1906f5449be6d931e7b53f1b4f7e21 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 4 Apr 2020 14:00:26 +0200 Subject: [PATCH] Units update need coordination with structure identity --- library/modules/Units.cpp | 32 ++++++++++++------- .../remotefortressreader.cpp | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 3ac235203..07c3a7acf 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -58,6 +58,7 @@ using namespace std; #include "df/entity_position_assignment.h" #include "df/entity_raw.h" #include "df/entity_raw_flags.h" +#include "df/identity_type.h" #include "df/game_mode.h" #include "df/histfig_entity_link_positionst.h" #include "df/historical_entity.h" @@ -200,13 +201,23 @@ void Units::setNickname(df::unit *unit, std::string nick) if (auto identity = getFigureIdentity(figure)) { - auto id_hfig = df::historical_figure::find(identity->histfig_id); + df::historical_figure *id_hfig = NULL; + + switch (identity->type) { + case df::identity_type::Hiding_Curse: + case df::identity_type::Identity: + case df::identity_type::False_Identity: + break; // We want the nickname to end up in the identity + + case df::identity_type::Unk_1: // Guess, but that's how it worked in the past + case df::identity_type::Demon_Alias: + case df::identity_type::Unk_4: // Pure guess, as this is a new case, still unseen + id_hfig = df::historical_figure::find(identity->histfig_nemesis_id); + break; + } if (id_hfig) { - // Even DF doesn't do this bit, because it's apparently - // only used for demons masquerading as gods, so you - // can't ever change their nickname in-game. Translation::setNickname(&id_hfig->name, nick); } else @@ -247,7 +258,7 @@ bool Units::isHidingCurse(df::unit *unit) if (!unit->job.hunt_target) { auto identity = Units::getIdentity(unit); - if (identity && identity->unk_4c == 0) + if (identity && identity->type == df::identity_type::Hiding_Curse) return true; } @@ -722,12 +733,11 @@ double Units::getAge(df::unit *unit, bool true_age) double birth_time = unit->birth_year + unit->birth_time/year_ticks; double cur_time = *cur_year + *cur_year_tick / year_ticks; - if (!true_age && unit->curse_year >= 0) - { - if (auto identity = getIdentity(unit)) - { - if (identity->histfig_id < 0) - birth_time = identity->birth_year + identity->birth_second/year_ticks; + if (!true_age) { + if (auto identity = getIdentity(unit)) { + if (identity->birth_year != -1) { + birth_time = identity->birth_year + identity->birth_second / year_ticks; + } } } diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index f63ae5b2c..6ab401027 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -1701,7 +1701,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques { if (auto identity = Units::getIdentity(unit)) { - if (identity->histfig_id < 0) + if (identity->histfig_nemesis_id < 0) birth_time = identity->birth_year * year_ticks + identity->birth_second; } }