From ad518faeecca67ec7195bd9287c70b4618d96038 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 12 May 2018 14:59:04 -0400 Subject: [PATCH] cursecheck: Replace setUnitNickname (older) with Units::setNickname --- plugins/cursecheck.cpp | 58 +----------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/plugins/cursecheck.cpp b/plugins/cursecheck.cpp index 263f91490..e006bd17c 100644 --- a/plugins/cursecheck.cpp +++ b/plugins/cursecheck.cpp @@ -68,62 +68,6 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) return CR_OK; } - -// code for setting nicknames is copypasta from rename.cpp -// will not work in all cases, some vampires don't like to get nicks - -static void set_nickname(df::language_name *name, std::string nick) -{ - if (!name->has_name) - { - *name = df::language_name(); - - name->language = 0; - name->has_name = true; - } - - name->nickname = nick; -} - -void setUnitNickname(df::unit *unit, const std::string &nick) -{ - // There are >=3 copies of the name, and the one - // in the unit is not the authoritative one. - // This is the reason why military units often - // lose nicknames set from Dwarf Therapist. - set_nickname(&unit->name, nick); - - if (unit->status.current_soul) - set_nickname(&unit->status.current_soul->name, nick); - - df::historical_figure *figure = df::historical_figure::find(unit->hist_figure_id); - if (figure) - { - set_nickname(&figure->name, nick); - - // v0.34.01: added the vampire's assumed identity - if (figure->info && figure->info->reputation) - { - auto identity = df::identity::find(figure->info->reputation->cur_identity); - - if (identity) - { - auto id_hfig = df::historical_figure::find(identity->histfig_id); - - 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. - set_nickname(&id_hfig->name, nick); - } - else - set_nickname(&identity->name, nick); - } - } - } -} - std::string determineCurse(df::unit * unit) { string cursetype = "unknown"; @@ -237,7 +181,7 @@ command_result cursecheck (color_ostream &out, vector & parameters) if(giveNick) { - setUnitNickname(unit, cursetype); //"CURSED"); + Units::setNickname(unit, cursetype); //"CURSED"); } if(giveDetails)