fixed double printing of first name if creature has no nickname

develop
Robert Heinrich 2012-03-20 11:01:33 +01:00
parent 6c6438267b
commit 9853cc137b
1 changed files with 20 additions and 25 deletions

@ -1,7 +1,13 @@
// check single tile or whole map/world for vampires // vampcheck plugin
// only tested in fortress mode, maybe it should bail out if called in another mode //
// TODO: add some check for deceased vampires, currently lists everybody who has a curse active // check single tile or whole map/world for vampires by checking if a valid curse date (!=-1) is set
// curse probably persists after death to be evauluated for legends... // if a cursor is active only the selected tile will be observed
// without cursor the whole map will be checked
// by default vampires will be only counted
//
// Options:
// detail - print full name, date of birth, date of curse (vamp might use fake identity, though)
// nick - set nickname to 'CURSED' (does not always show up ingame, some vamps don't like nicknames)
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@ -13,20 +19,12 @@
#include <cstdio> #include <cstdio>
using namespace std; using namespace std;
// TODO: check if all these includes are really necessary
// (they were thrown together from the other plugins where the code was borrowed from)
#include "Core.h" #include "Core.h"
#include "Console.h" #include "Console.h"
#include "Export.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "modules/Units.h" #include "modules/Units.h"
#include <modules/Translation.h> #include <modules/Translation.h>
#include "modules/Maps.h"
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/Materials.h"
#include "modules/MapCache.h"
#include "modules/Buildings.h"
#include "MiscUtils.h" #include "MiscUtils.h"
#include "df/unit.h" #include "df/unit.h"
@ -36,10 +34,8 @@ using namespace std;
#include "df/historical_figure_info.h" #include "df/historical_figure_info.h"
#include "df/assumed_identity.h" #include "df/assumed_identity.h"
#include "df/language_name.h" #include "df/language_name.h"
#include "df/world.h" #include "df/world.h"
#include "df/world_raws.h" #include "df/world_raws.h"
#include "df/building_def.h"
using std::vector; using std::vector;
using std::string; using std::string;
@ -142,7 +138,7 @@ command_result vampcheck (color_ostream &out, vector <string> & parameters)
" will be checked. Without cursor the whole map/world will be scanned.\n" " will be checked. Without cursor the whole map/world will be scanned.\n"
" By default cursed creatures are only counted to make it more interesting.\n" " By default cursed creatures are only counted to make it more interesting.\n"
"Options:\n" "Options:\n"
" detail - show details (might give false names and ages)\n" " detail - show details (name and age shown ingame might differ)\n"
" nick - try to set nickname to CURSED (does not always work)\n" " nick - try to set nickname to CURSED (does not always work)\n"
); );
return CR_OK; return CR_OK;
@ -180,16 +176,15 @@ command_result vampcheck (color_ostream &out, vector <string> & parameters)
{ {
if(unit->name.has_name) if(unit->name.has_name)
{ {
// TODO: avoid printing the first name twice string firstname = unit->name.first_name;
// currently it behaves like this (copied from dwarfexport): string restofname = Translation::TranslateName(&unit->name, false);
// firstname nickname restofname(s) - if dwarf has nickname (fine) firstname[0] = toupper(firstname[0]);
// firstname firstname restofname(s) - if dwarf has no nickname (ugly)
// (so better use two strings and check if firstname occurs twice) // if creature has no nickname, restofname will already contain firstname
string info = unit->name.first_name; // no need for double output
info += " "; if(restofname.compare(0, firstname.length(),firstname) != 0)
info += Translation::TranslateName(&unit->name, false); out.print("%s", firstname.c_str());
info[0] = toupper(info[0]); out.print("%s", restofname.c_str());
out.print("%s ", info.c_str());
} }
else else
{ {