Add switch -1 to skillmodify.cpp

develop
Raoul XQ 2011-04-13 01:47:15 +02:00
parent d10d8316e7
commit 19c4371581
1 changed files with 54 additions and 22 deletions

@ -20,9 +20,10 @@
* - Kill/revive creature(s) with --kill/--revive * - Kill/revive creature(s) with --kill/--revive
* - Show skills/labors only when -ss/-sl/-v is given or a skill/labor is changed * - Show skills/labors only when -ss/-sl/-v is given or a skill/labor is changed
* - Allow multiple -i switches * - Allow multiple -i switches
* - Display current job
* Done: * Done:
* - Add switch -1 to only display one line for every creature. Good for an overview.
* - Display current job (has been there all the time, but not shown in Windows due to missing memory offsets)
* - Remove magic numbers * - Remove magic numbers
* - Show social skills only when -ss is given * - Show social skills only when -ss is given
* - Hide hauler labors when +sh is given * - Hide hauler labors when +sh is given
@ -82,10 +83,12 @@ using namespace std;
#define MAX_MOOD 4 #define MAX_MOOD 4
#define NO_MOOD -1 #define NO_MOOD -1
bool quiet; bool quiet=true;
bool verbose = false; bool verbose = false;
bool showhauler = true; bool showhauler = true;
bool showsocial = false; bool showsocial = false;
bool showfirstlineonly = false;
int hauler_labors[] = { int hauler_labors[] = {
LABOR_STONE_HAULING LABOR_STONE_HAULING
,LABOR_WOOD_HAULING ,LABOR_WOOD_HAULING
@ -120,6 +123,7 @@ void usage(int argc, const char * argv[])
<< "-q : Suppress \"Press any key to continue\" at program termination" << endl << "-q : Suppress \"Press any key to continue\" at program termination" << endl
<< "-v : Increase verbosity" << endl << "-v : Increase verbosity" << endl
<< "-c creature : Only show/modify this creature type instead of dwarfes" << endl << "-c creature : Only show/modify this creature type instead of dwarfes" << endl
<< "-1 : Only display one line per creature" << endl
<< "-i id : Only show/modify creature with this id" << endl << "-i id : Only show/modify creature with this id" << endl
<< "-nn : Only show/modify creatures with no custom nickname (migrants)" << endl << "-nn : Only show/modify creatures with no custom nickname (migrants)" << endl
<< "--nicks : Only show/modify creatures with custom nickname" << endl << "--nicks : Only show/modify creatures with custom nickname" << endl
@ -130,7 +134,7 @@ void usage(int argc, const char * argv[])
<< "-ral : Remove all labors from creature" << endl << "-ral : Remove all labors from creature" << endl
<< "-ah : Add hauler labors (stone hauling, etc.) to creature" << endl << "-ah : Add hauler labors (stone hauling, etc.) to creature" << endl
<< "-rh : Remove hauler labors (stone hauling, etc.) from creature" << endl << "-rh : Remove hauler labors (stone hauling, etc.) from creature" << endl
<< "--setmood <n> : Set mood to n (-1 = no mood, max=4)" << endl << "--setmood <n> : Set mood to n (-1 = no mood, max=4, buggy!)" << endl
// Doesn't work, because hapiness is recalculated // Doesn't work, because hapiness is recalculated
//<< "--sethappiness <n> : Set happiness to n" << endl //<< "--sethappiness <n> : Set happiness to n" << endl
<< "-f : Force an action" << endl << "-f : Force an action" << endl
@ -203,51 +207,69 @@ bool is_in(int m, int set[], int set_size)
void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature, int index) void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature, int index)
{ {
cout << "Creature[" << index << "]: " << toCaps(Materials->raceEx[creature.race].rawname);
DFHack::Translation *Tran = DF->getTranslation(); DFHack::Translation *Tran = DF->getTranslation();
DFHack::VersionInfo *mem = DF->getMemoryInfo(); DFHack::VersionInfo *mem = DF->getMemoryInfo();
string name="(no name)";
if(creature.name.nickname[0]) if(creature.name.nickname[0])
{ {
cout << ", " << creature.name.nickname; name = creature.name.nickname;
} }
else else
{ {
if(creature.name.first_name[0]) if(creature.name.first_name[0])
{ {
cout << ", " << toCaps(creature.name.first_name); name = toCaps(creature.name.first_name);
}
string transName = Tran->TranslateName(creature.name,false);
string transName = Tran->TranslateName(creature.name,false); if(!transName.empty())
if(!transName.empty()) {
{ name += " " + toCaps(transName);
cout << " " << toCaps(transName); }
} }
} }
string prof_string=""; string profession="";
try { try {
prof_string = mem->getProfession(creature.profession); profession = mem->getProfession(creature.profession);
} }
catch (exception& e) catch (exception& e)
{ {
cout << "Error retrieving creature profession: " << e.what() << endl; cout << "Error retrieving creature profession: " << e.what() << endl;
} }
cout << ", " << toCaps(prof_string) << "(" << int(creature.profession) << ")";
if(creature.custom_profession[0]) if(creature.custom_profession[0])
{ {
cout << "/" << creature.custom_profession; profession = creature.custom_profession;
} }
string job="No Job";
if(creature.current_job.active) if(creature.current_job.active)
{ {
cout << ", current job: " << mem->getJob(creature.current_job.jobId); job=mem->getJob(creature.current_job.jobId);
} }
cout << ", Happy = " << creature.happiness; if (showfirstlineonly)
cout << endl; {
printf("%3d", index);
printf(" %-32s", name.c_str());
printf(" %-15s", toCaps(profession).c_str());
printf(" %-30s", job.c_str());
printf(" %d", creature.happiness);
return;
}
else
{
printf("ID: %d", index);
printf(", %s", name.c_str());
printf(", %s", toCaps(profession).c_str());
printf(", Job: %s", job.c_str());
printf(", Happiness: %d", creature.happiness);
printf("\n");
}
if((creature.mood != NO_MOOD) && (creature.mood<=MAX_MOOD)) if((creature.mood != NO_MOOD) && (creature.mood<=MAX_MOOD))
{ {
@ -392,6 +414,10 @@ int main (int argc, const char* argv[])
{ {
verbose = true; verbose = true;
} }
else if(arg_cur == "-1")
{
showfirstlineonly = true;
}
else if(arg_cur == "-ss" || arg_cur == "--showsocial") else if(arg_cur == "-ss" || arg_cur == "--showsocial")
{ {
showsocial = true; showsocial = true;
@ -572,6 +598,12 @@ int main (int argc, const char* argv[])
} }
else else
{ {
if (showfirstlineonly)
{
printf("ID Name/nickname Job title Current job Happiness\n");
printf("--- -------------------------------- --------------- ------------------------------ ---------\n");
}
vector<uint32_t> addrs; vector<uint32_t> addrs;
for(uint32_t creature_idx = 0; creature_idx < numCreatures; creature_idx++) for(uint32_t creature_idx = 0; creature_idx < numCreatures; creature_idx++)
{ {