Changed tabs into spaces

develop
Raoul XQ 2011-04-11 13:15:51 +02:00
parent 62a7c3037c
commit 4e6cef8b7b
1 changed files with 435 additions and 435 deletions

@ -45,41 +45,41 @@ using namespace std;
void usage(int argc, const char * argv[]) void usage(int argc, const char * argv[])
{ {
cout cout
<< "Usage:" << endl << "Usage:" << endl
<< argv[0] << " [option 1] [option 2] [...]" << endl << argv[0] << " [option 1] [option 2] [...]" << endl
<< "-q : Suppress \"Press any key to continue\" at program termination" << endl << "-q : Suppress \"Press any key to continue\" at program termination" << 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
<< "-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" << endl << "-nn : Only show/modify creatures with no custom nickname" << endl
<< "-ll : List available labors" << endl << "-ll : List available labors" << endl
<< "-al <n> : Add labor <n> to creature" << endl << "-al <n> : Add labor <n> to creature" << endl
<< "-rl <n> : Remove labor <n> from creature" << endl << "-rl <n> : Remove labor <n> from creature" << endl
<< "-ras : Remove all skills from creature" << endl << "-ras : Remove all skills from creature" << endl
<< "-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
<< "-me : Make creature an engraver" << endl << "-me : Make creature an engraver" << endl
<< "-mm : Make creature a mason" << endl << "-mm : Make creature a mason" << endl
<< "--setmood <n> : Set mood to n (-1 = no mood, max=4)" << endl << "--setmood <n> : Set mood to n (-1 = no mood, max=4)" << 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
<< endl << endl
<< "Example 1: Show all creatures" << endl << "Example 1: Show all creatures" << endl
<< argv[0] << endl << argv[0] << endl
<< endl << endl
<< "Example 2: Just show dwarfs" << endl << "Example 2: Just show dwarfs" << endl
<< argv[0] << " -c DWARF" << endl << argv[0] << " -c DWARF" << endl
<< endl << endl
<< "Example 3: Remove skill from dwarf 32" << endl << "Example 3: Remove skill from dwarf 32" << endl
<< argv[0] << " -i 32 -ras" << endl << argv[0] << " -i 32 -ras" << endl
<< endl << endl
<< "Example 4: Remove all skills and labors from dwarfs with no custom nickname" << endl << "Example 4: Remove all skills and labors from dwarfs with no custom nickname" << endl
<< argv[0] << " -c DWARF -nn -ras -ral" << endl << argv[0] << " -c DWARF -nn -ras -ral" << endl
<< endl << endl
<< "Example 5: Additionally assign the hauling labors and engraving" << endl << "Example 5: Additionally assign the hauling labors and engraving" << endl
<< argv[0] << " -c DWARF -nn -ras -ral -me -ah" << endl << argv[0] << " -c DWARF -nn -ras -ral -me -ah" << endl
; ;
} }
enum likeType enum likeType
@ -103,12 +103,12 @@ std::string toCaps(std::string s)
{ {
const int length = s.length(); const int length = s.length();
if (length == 0) { if (length == 0) {
return s; return s;
} }
s[0] = std::toupper(s[0]); s[0] = std::toupper(s[0]);
for(int i=1; i!=length ; ++i) for(int i=1; i!=length ; ++i)
{ {
s[i] = std::tolower(s[i]); s[i] = std::tolower(s[i]);
} }
return s; return s;
} }
@ -129,40 +129,40 @@ void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature, in
if(creature.name.nickname[0]) if(creature.name.nickname[0])
{ {
cout << ", " << creature.name.nickname; cout << ", " << creature.name.nickname;
} }
else else
{ {
if(creature.name.first_name[0]) if(creature.name.first_name[0])
{ {
cout << ", " << toCaps(creature.name.first_name); cout << ", " << 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())
{ {
cout << " " << toCaps(transName); cout << " " << toCaps(transName);
} }
} }
string prof_string=""; string prof_string="";
try { try {
prof_string = mem->getProfession(creature.profession); prof_string = 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) << ")"; cout << ", " << toCaps(prof_string) << "(" << int(creature.profession) << ")";
if(creature.custom_profession[0]) if(creature.custom_profession[0])
{ {
cout << "/" << creature.custom_profession; cout << "/" << creature.custom_profession;
} }
if(creature.current_job.active) if(creature.current_job.active)
{ {
cout << ", current job: " << mem->getJob(creature.current_job.jobId); cout << ", current job: " << mem->getJob(creature.current_job.jobId);
} }
cout << ", Happy = " << creature.happiness; cout << ", Happy = " << creature.happiness;
@ -170,96 +170,96 @@ void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature, in
if((creature.mood != -1) && (creature.mood<5)) if((creature.mood != -1) && (creature.mood<5))
{ {
cout << "Creature is in a strange mood (mood=" << creature.mood << "), skill: " << mem->getSkill(creature.mood_skill) << endl; cout << "Creature is in a strange mood (mood=" << creature.mood << "), skill: " << mem->getSkill(creature.mood_skill) << endl;
vector<DFHack::t_material> mymat; vector<DFHack::t_material> mymat;
if(Creatures->ReadJob(&creature, mymat)) if(Creatures->ReadJob(&creature, mymat))
{ {
for(unsigned int i = 0; i < mymat.size(); i++) for(unsigned int i = 0; i < mymat.size(); i++)
{ {
printf("\t%s(%d)\t%d %d %d - %.8x\n", Materials->getDescription(mymat[i]).c_str(), mymat[i].itemType, mymat[i].subType, mymat[i].subIndex, mymat[i].index, mymat[i].flags); printf("\t%s(%d)\t%d %d %d - %.8x\n", Materials->getDescription(mymat[i]).c_str(), mymat[i].itemType, mymat[i].subType, mymat[i].subIndex, mymat[i].index, mymat[i].flags);
} }
} }
} }
if(creature.has_default_soul) if(creature.has_default_soul)
{ {
// Print out skills // Print out skills
int skillid; int skillid;
int skillrating; int skillrating;
int skillexperience; int skillexperience;
string skillname; string skillname;
cout << setiosflags(ios::left); cout << setiosflags(ios::left);
for(unsigned int i = 0; i < creature.defaultSoul.numSkills;i++) for(unsigned int i = 0; i < creature.defaultSoul.numSkills;i++)
{ {
skillid = creature.defaultSoul.skills[i].id; skillid = creature.defaultSoul.skills[i].id;
if ( // leave out some skill that are not interesting and clutter the screen if ( // leave out some skill that are not interesting and clutter the screen
skillid != 72 skillid != 72
&& skillid != 73 && skillid != 73
&& skillid != 74 && skillid != 74
&& skillid != 79 && skillid != 79
&& skillid != 80 && skillid != 80
&& skillid != 81 && skillid != 81
&& skillid != 82 && skillid != 82
&& skillid != 83 && skillid != 83
&& skillid != 84 && skillid != 84
) )
{ {
skillrating = creature.defaultSoul.skills[i].rating; skillrating = creature.defaultSoul.skills[i].rating;
skillexperience = creature.defaultSoul.skills[i].experience; skillexperience = creature.defaultSoul.skills[i].experience;
try try
{ {
skillname = mem->getSkill(skillid); skillname = mem->getSkill(skillid);
} }
catch(DFHack::Error::AllMemdef &e) catch(DFHack::Error::AllMemdef &e)
{ {
skillname = "Unknown skill"; skillname = "Unknown skill";
cout << e.what() << endl; cout << e.what() << endl;
} }
cout << "(Skill " << int(skillid) << ") " << setw(16) << skillname << ": " cout << "(Skill " << int(skillid) << ") " << setw(16) << skillname << ": "
<< skillrating << "/" << skillexperience << endl; << skillrating << "/" << skillexperience << endl;
} }
} }
for(unsigned int i = 0; i < NUM_CREATURE_LABORS;i++) for(unsigned int i = 0; i < NUM_CREATURE_LABORS;i++)
{ {
if(!creature.labors[i]) if(!creature.labors[i])
continue; continue;
string laborname; string laborname;
try try
{ {
laborname = mem->getLabor(i); laborname = mem->getLabor(i);
} }
catch(exception &e) catch(exception &e)
{ {
//cout << "Found undefined labor (" << i << ")" << endl; //cout << "Found undefined labor (" << i << ")" << endl;
//cout << e.what() << endl; //cout << e.what() << endl;
laborname = "(Undefined)"; laborname = "(Undefined)";
//continue; //continue;
} }
cout << "(Labor " << i << ") " << setw(16) << laborname << endl; cout << "(Labor " << i << ") " << setw(16) << laborname << endl;
} }
} }
/* FLAGS 1 */ /* FLAGS 1 */
if(creature.flags1.bits.dead) { cout << "Flag: Dead" << endl; } if(creature.flags1.bits.dead) { cout << "Flag: Dead" << endl; }
if(creature.flags1.bits.on_ground) { cout << "Flag: On the ground" << endl; } if(creature.flags1.bits.on_ground) { cout << "Flag: On the ground" << endl; }
if(creature.flags1.bits.skeleton) { cout << "Flag: Skeletal" << endl; } if(creature.flags1.bits.skeleton) { cout << "Flag: Skeletal" << endl; }
if(creature.flags1.bits.zombie) { cout << "Flag: Zombie" << endl; } if(creature.flags1.bits.zombie) { cout << "Flag: Zombie" << endl; }
if(creature.flags1.bits.tame) { cout << "Flag: Tame" << endl; } if(creature.flags1.bits.tame) { cout << "Flag: Tame" << endl; }
if(creature.flags1.bits.royal_guard){ cout << "Flag: Royal_guard" << endl; } if(creature.flags1.bits.royal_guard){ cout << "Flag: Royal_guard" << endl; }
if(creature.flags1.bits.fortress_guard){cout<<"Flag: Fortress_guard" << endl; } if(creature.flags1.bits.fortress_guard){cout<<"Flag: Fortress_guard" << endl; }
/* FLAGS 2 */ /* FLAGS 2 */
if(creature.flags2.bits.killed) { cout << "Flag: Killed by kill function" << endl; } if(creature.flags2.bits.killed) { cout << "Flag: Killed by kill function" << endl; }
if(creature.flags2.bits.resident) { cout << "Flag: Resident" << endl; } if(creature.flags2.bits.resident) { cout << "Flag: Resident" << endl; }
if(creature.flags2.bits.gutted) { cout << "Flag: Gutted" << endl; } if(creature.flags2.bits.gutted) { cout << "Flag: Gutted" << endl; }
if(creature.flags2.bits.slaughter) { cout << "Flag: Marked for slaughter" << endl; } if(creature.flags2.bits.slaughter) { cout << "Flag: Marked for slaughter" << endl; }
if(creature.flags2.bits.underworld) { cout << "Flag: From the underworld" << endl; } if(creature.flags2.bits.underworld) { cout << "Flag: From the underworld" << endl; }
if(creature.flags1.bits.had_mood && (creature.mood == -1 || creature.mood == 8 ) ) if(creature.flags1.bits.had_mood && (creature.mood == -1 || creature.mood == 8 ) )
{ {
string artifact_name = Tran->TranslateName(creature.artifact_name,false); string artifact_name = Tran->TranslateName(creature.artifact_name,false);
cout << "Artifact: " << artifact_name << endl; cout << "Artifact: " << artifact_name << endl;
} }
} }
@ -267,9 +267,9 @@ int main (int argc, const char* argv[])
{ {
bool quiet = true; bool quiet = true;
// let's be more useful when double-clicked on windows // let's be more useful when double-clicked on windows
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
quiet = false; quiet = false;
#endif #endif
string creature_type = "Dwarf"; string creature_type = "Dwarf";
string creature_id = ""; string creature_id = "";
@ -294,131 +294,131 @@ int main (int argc, const char* argv[])
bool force_massdesignation = false; bool force_massdesignation = false;
if (argc == 1) { if (argc == 1) {
usage(argc, argv); usage(argc, argv);
return 1; return 1;
} }
for(int i = 1; i < argc; i++) for(int i = 1; i < argc; i++)
{ {
string arg_cur = argv[i]; string arg_cur = argv[i];
string arg_next = ""; string arg_next = "";
int arg_next_int = -99999; int arg_next_int = -99999;
/* Check if argv[i+1] is a number >= 0 */ /* Check if argv[i+1] is a number >= 0 */
if (i < argc-1) { if (i < argc-1) {
arg_next = argv[i+1]; arg_next = argv[i+1];
arg_next_int = strtoint(arg_next); arg_next_int = strtoint(arg_next);
if (arg_next != "0" && arg_next_int == 0) { if (arg_next != "0" && arg_next_int == 0) {
arg_next_int = -99999; arg_next_int = -99999;
} }
} }
if(arg_cur == "-q") if(arg_cur == "-q")
{ {
quiet = true; quiet = true;
} }
else if(arg_cur == "-ras") else if(arg_cur == "-ras")
{ {
remove_skills = true; remove_skills = true;
} }
else if(arg_cur == "-f") else if(arg_cur == "-f")
{ {
force_massdesignation = true; force_massdesignation = true;
} }
// list labors // list labors
else if(arg_cur == "-ll") else if(arg_cur == "-ll")
{ {
list_labors = true; list_labors = true;
} }
// add single labor // add single labor
else if(arg_cur == "-al" && i < argc-1) else if(arg_cur == "-al" && i < argc-1)
{ {
if (arg_next_int == -99999 || arg_next_int >= NUM_CREATURE_LABORS) { if (arg_next_int == -99999 || arg_next_int >= NUM_CREATURE_LABORS) {
usage(argc, argv); usage(argc, argv);
return 1; return 1;
} }
add_labor = true; add_labor = true;
add_labor_n = arg_next_int; add_labor_n = arg_next_int;
i++; i++;
} }
// remove single labor // remove single labor
else if(arg_cur == "-rl" && i < argc-1) else if(arg_cur == "-rl" && i < argc-1)
{ {
if (arg_next_int == -99999 || arg_next_int >= NUM_CREATURE_LABORS) { if (arg_next_int == -99999 || arg_next_int >= NUM_CREATURE_LABORS) {
usage(argc, argv); usage(argc, argv);
return 1; return 1;
} }
remove_labor = true; remove_labor = true;
remove_labor_n = arg_next_int; remove_labor_n = arg_next_int;
i++; i++;
} }
else if(arg_cur == "--setmood" && i < argc-1) else if(arg_cur == "--setmood" && i < argc-1)
{ {
if (arg_next_int < -1 || arg_next_int >= 5) { if (arg_next_int < -1 || arg_next_int >= 5) {
usage(argc, argv); usage(argc, argv);
return 1; return 1;
} }
set_mood = true; set_mood = true;
set_mood_n = arg_next_int; set_mood_n = arg_next_int;
i++; i++;
} }
else if(arg_cur == "--sethappiness" && i < argc-1) else if(arg_cur == "--sethappiness" && i < argc-1)
{ {
if (arg_next_int < 1 || arg_next_int >= 2000) { if (arg_next_int < 1 || arg_next_int >= 2000) {
usage(argc, argv); usage(argc, argv);
return 1; return 1;
} }
set_happiness = true; set_happiness = true;
set_happiness_n = arg_next_int; set_happiness_n = arg_next_int;
i++; i++;
} }
else if(arg_cur == "-ral") else if(arg_cur == "-ral")
{ {
remove_labors = true; remove_labors = true;
} }
else if(arg_cur == "-ah") else if(arg_cur == "-ah")
{ {
make_hauler = true; make_hauler = true;
} }
else if(arg_cur == "-rh") else if(arg_cur == "-rh")
{ {
remove_hauler = true; remove_hauler = true;
} }
else if(arg_cur == "-mm") else if(arg_cur == "-mm")
{ {
make_mason = true; make_mason = true;
} }
else if(arg_cur == "-me") else if(arg_cur == "-me")
{ {
make_engraver = true; make_engraver = true;
} }
else if(arg_cur == "-nn") else if(arg_cur == "-nn")
{ {
find_nonicks = true; find_nonicks = true;
} }
else if(arg_cur == "--nicks") else if(arg_cur == "--nicks")
{ {
find_nicks = true; find_nicks = true;
} }
else if(arg_cur == "-c" && i < argc-1) else if(arg_cur == "-c" && i < argc-1)
{ {
creature_type = argv[i+1]; creature_type = argv[i+1];
i++; i++;
} }
else if(arg_cur == "-i" && i < argc-1) else if(arg_cur == "-i" && i < argc-1)
{ {
creature_id = argv[i+1]; creature_id = argv[i+1];
sscanf(argv[i+1], "%d", &creature_id_int); sscanf(argv[i+1], "%d", &creature_id_int);
i++; i++;
} }
else else
{ {
if (arg_cur != "-h") { if (arg_cur != "-h") {
cout << "Unknown option '" << arg_cur << "'" << endl; cout << "Unknown option '" << arg_cur << "'" << endl;
cout << endl; cout << endl;
} }
usage(argc, argv); usage(argc, argv);
return 1; return 1;
} }
} }
DFHack::ContextManager DFMgr("Memory.xml"); DFHack::ContextManager DFMgr("Memory.xml");
@ -431,34 +431,34 @@ int main (int argc, const char* argv[])
catch (exception& e) catch (exception& e)
{ {
cerr << e.what() << endl; cerr << e.what() << endl;
if (quiet == false) if (quiet == false)
{ {
cin.ignore(); cin.ignore();
} }
return 1; return 1;
} }
Creatures = DF->getCreatures(); Creatures = DF->getCreatures();
Materials = DF->getMaterials(); Materials = DF->getMaterials();
DFHack::Translation * Tran = DF->getTranslation(); DFHack::Translation * Tran = DF->getTranslation();
uint32_t numCreatures; uint32_t numCreatures;
if(!Creatures->Start(numCreatures)) if(!Creatures->Start(numCreatures))
{ {
cerr << "Can't get creatures" << endl; cerr << "Can't get creatures" << endl;
if (quiet == false) if (quiet == false)
{ {
cin.ignore(); cin.ignore();
} }
return 1; return 1;
} }
if(!numCreatures) if(!numCreatures)
{ {
cerr << "No creatures to print" << endl; cerr << "No creatures to print" << endl;
if (quiet == false) if (quiet == false)
{ {
cin.ignore(); cin.ignore();
} }
return 1; return 1;
} }
@ -479,194 +479,194 @@ int main (int argc, const char* argv[])
// List all available labors (reproduces contents of Memory.xml) // List all available labors (reproduces contents of Memory.xml)
if (list_labors == true) { if (list_labors == true) {
string laborname; string laborname;
for (int i=0; i < NUM_CREATURE_LABORS; i++) { for (int i=0; i < NUM_CREATURE_LABORS; i++) {
try { try {
laborname = mem->getLabor(i); laborname = mem->getLabor(i);
} }
catch (exception& e) { catch (exception& e) {
laborname = "Unknown"; laborname = "Unknown";
} }
cout << "Labor " << int(i) << ": " << laborname << endl; cout << "Labor " << int(i) << ": " << laborname << endl;
} }
} }
else else
{ {
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++)
{ {
DFHack::t_creature creature; DFHack::t_creature creature;
Creatures->ReadCreature(creature_idx,creature); Creatures->ReadCreature(creature_idx,creature);
/* Check if we want to display/change this creature or skip it */ /* Check if we want to display/change this creature or skip it */
bool hasnick = (creature.name.nickname[0] != '\0'); bool hasnick = (creature.name.nickname[0] != '\0');
if ( if (
// Check for -i <num> // Check for -i <num>
(creature_id.empty() || creature_idx == creature_id_int) (creature_id.empty() || creature_idx == creature_id_int)
// Check for -c <type> // Check for -c <type>
&& (creature_type.empty() || toCaps(string(Materials->raceEx[creature.race].rawname)) == toCaps(creature_type)) && (creature_type.empty() || toCaps(string(Materials->raceEx[creature.race].rawname)) == toCaps(creature_type))
// Check for -nn // Check for -nn
&& ((find_nonicks == true && hasnick == false) && ((find_nonicks == true && hasnick == false)
|| (find_nicks == true && hasnick == true) || (find_nicks == true && hasnick == true)
|| (find_nicks == false && find_nonicks == false)) || (find_nicks == false && find_nonicks == false))
&& (find_nonicks == false || creature.name.nickname[0] == '\0') && (find_nonicks == false || creature.name.nickname[0] == '\0')
&& (!creature.flags1.bits.dead) && (!creature.flags1.bits.dead)
) )
{ {
printCreature(DF,creature,creature_idx); printCreature(DF,creature,creature_idx);
addrs.push_back(creature.origin); addrs.push_back(creature.origin);
bool dochange = ( bool dochange = (
remove_skills remove_skills
|| remove_labors || add_labor || remove_labor || remove_labors || add_labor || remove_labor
|| make_hauler || remove_hauler || make_hauler || remove_hauler
|| make_engraver || make_mason || make_engraver || make_mason
|| set_happiness || set_happiness
|| set_mood || set_mood
); );
// 96=Child, 97=Baby // 96=Child, 97=Baby
if (creature.profession == 96 || creature.profession == 97) if (creature.profession == 96 || creature.profession == 97)
{ {
dochange = false; dochange = false;
} }
bool allow_massdesignation = bool allow_massdesignation =
!creature_id.empty() || toCaps(creature_type) != "Dwarf" || find_nonicks == true || force_massdesignation; !creature_id.empty() || toCaps(creature_type) != "Dwarf" || find_nonicks == true || force_massdesignation;
if (dochange == true && allow_massdesignation == false) if (dochange == true && allow_massdesignation == false)
{ {
cout cout
<< "Not changing creature because none of -c (other than dwarf), -i or -nn was" << endl << "Not changing creature because none of -c (other than dwarf), -i or -nn was" << endl
<< "selected. Add -f to still do mass designation." << endl; << "selected. Add -f to still do mass designation." << endl;
dochange = false; dochange = false;
} }
// cout << "dochange = " << int(dochange) << endl; // cout << "dochange = " << int(dochange) << endl;
// cout << "remove_skills = " << int(remove_skills) << endl; // cout << "remove_skills = " << int(remove_skills) << endl;
// cout << "remove_labors = " << int(remove_labors) << endl; // cout << "remove_labors = " << int(remove_labors) << endl;
// cout << "add_labor = " << int(add_labor) << endl; // cout << "add_labor = " << int(add_labor) << endl;
// cout << "remove_labor = " << int(remove_labor) << endl; // cout << "remove_labor = " << int(remove_labor) << endl;
// cout << "make_hauler = " << int(make_hauler) << endl; // cout << "make_hauler = " << int(make_hauler) << endl;
// cout << "remove_hauler = " << int(remove_hauler) << endl; // cout << "remove_hauler = " << int(remove_hauler) << endl;
// cout << "make_engraver = " << int(make_engraver) << endl; // cout << "make_engraver = " << int(make_engraver) << endl;
// cout << "make_mason = " << int(make_mason) << endl; // cout << "make_mason = " << int(make_mason) << endl;
// cout << "allow_massdesignation = " << int(allow_massdesignation) << endl; // cout << "allow_massdesignation = " << int(allow_massdesignation) << endl;
// cout << "force_massdesignation = " << int(force_massdesignation) << endl; // cout << "force_massdesignation = " << int(force_massdesignation) << endl;
// cout << "creature.profession = " << int(creature.profession) << endl; // cout << "creature.profession = " << int(creature.profession) << endl;
if (dochange) if (dochange)
{ {
if(creature.has_default_soul) if(creature.has_default_soul)
{ {
if (set_mood) if (set_mood)
{ {
cout << "Setting mood to " << set_mood_n << "..." << endl; cout << "Setting mood to " << set_mood_n << "..." << endl;
Creatures->WriteMood(creature_idx, set_mood_n); Creatures->WriteMood(creature_idx, set_mood_n);
} }
if (set_happiness) if (set_happiness)
{ {
cout << "Setting happiness to " << set_happiness_n << "..." << endl; cout << "Setting happiness to " << set_happiness_n << "..." << endl;
Creatures->WriteHappiness(creature_idx, set_happiness_n); Creatures->WriteHappiness(creature_idx, set_happiness_n);
} }
if (remove_skills) if (remove_skills)
{ {
DFHack::t_soul & soul = creature.defaultSoul; DFHack::t_soul & soul = creature.defaultSoul;
cout << "Removing skills..." << endl; cout << "Removing skills..." << endl;
for(unsigned int sk = 0; sk < soul.numSkills;sk++) for(unsigned int sk = 0; sk < soul.numSkills;sk++)
{ {
soul.skills[sk].rating=0; soul.skills[sk].rating=0;
soul.skills[sk].experience=0; soul.skills[sk].experience=0;
} }
// Doesn't work anyways, so better leave it alone // Doesn't work anyways, so better leave it alone
//soul.numSkills=0; //soul.numSkills=0;
if (Creatures->WriteSkills(creature_idx, soul) == true) { if (Creatures->WriteSkills(creature_idx, soul) == true) {
cout << "Success writing skills." << endl; cout << "Success writing skills." << endl;
} else { } else {
cout << "Error writing skills." << endl; cout << "Error writing skills." << endl;
} }
} }
if (add_labor || remove_labor || remove_labors || make_hauler || remove_hauler || make_engraver || make_mason) if (add_labor || remove_labor || remove_labors || make_hauler || remove_hauler || make_engraver || make_mason)
{ {
if (add_labor) { if (add_labor) {
cout << "Adding labor " << add_labor_n << "..." << endl; cout << "Adding labor " << add_labor_n << "..." << endl;
creature.labors[add_labor_n] = 1; creature.labors[add_labor_n] = 1;
} }
if (remove_labor) { if (remove_labor) {
cout << "Removing labor " << remove_labor_n << "..." << endl; cout << "Removing labor " << remove_labor_n << "..." << endl;
creature.labors[remove_labor_n] = 0; creature.labors[remove_labor_n] = 0;
} }
if (remove_labors) { if (remove_labors) {
cout << "Removing labors..." << endl; cout << "Removing labors..." << endl;
for(unsigned int lab = 0; lab < NUM_CREATURE_LABORS; lab++) { for(unsigned int lab = 0; lab < NUM_CREATURE_LABORS; lab++) {
creature.labors[lab] = 0; creature.labors[lab] = 0;
} }
} }
if (remove_hauler) { if (remove_hauler) {
cout << "Removing hauler labors..." << endl; cout << "Removing hauler labors..." << endl;
creature.labors[1] = 0; creature.labors[1] = 0;
creature.labors[2] = 0; creature.labors[2] = 0;
creature.labors[3] = 0; creature.labors[3] = 0;
creature.labors[4] = 0; creature.labors[4] = 0;
creature.labors[5] = 0; creature.labors[5] = 0;
creature.labors[6] = 0; creature.labors[6] = 0;
creature.labors[7] = 0; creature.labors[7] = 0;
creature.labors[8] = 0; creature.labors[8] = 0;
creature.labors[9] = 0; creature.labors[9] = 0;
creature.labors[22] = 0; creature.labors[22] = 0;
creature.labors[23] = 0; creature.labors[23] = 0;
} }
if (make_hauler) { if (make_hauler) {
cout << "Setting hauler labors..." << endl; cout << "Setting hauler labors..." << endl;
creature.labors[1] = 1; creature.labors[1] = 1;
creature.labors[2] = 1; creature.labors[2] = 1;
creature.labors[3] = 1; creature.labors[3] = 1;
creature.labors[4] = 1; creature.labors[4] = 1;
creature.labors[5] = 1; creature.labors[5] = 1;
creature.labors[6] = 1; creature.labors[6] = 1;
creature.labors[7] = 1; creature.labors[7] = 1;
creature.labors[8] = 1; creature.labors[8] = 1;
creature.labors[9] = 1; creature.labors[9] = 1;
creature.labors[22] = 1; creature.labors[22] = 1;
creature.labors[23] = 1; creature.labors[23] = 1;
} }
if (make_engraver) { if (make_engraver) {
cout << "Setting 'Stone Detailing'..." << endl; cout << "Setting 'Stone Detailing'..." << endl;
creature.labors[12] = 1; creature.labors[12] = 1;
} }
if (make_mason) { if (make_mason) {
cout << "Setting 'Masonry'..." << endl; cout << "Setting 'Masonry'..." << endl;
creature.labors[13] = 1; creature.labors[13] = 1;
} }
if (Creatures->WriteLabors(creature_idx, creature.labors) == true) { if (Creatures->WriteLabors(creature_idx, creature.labors) == true) {
cout << "Success writing labors." << endl; cout << "Success writing labors." << endl;
} else { } else {
cout << "Error writing labors." << endl; cout << "Error writing labors." << endl;
} }
} }
} }
else else
{ {
cout << "Error removing skills: Creature has no default soul." << endl; cout << "Error removing skills: Creature has no default soul." << endl;
} }
printCreature(DF,creature,creature_idx); printCreature(DF,creature,creature_idx);
} /* End remove skills/labors */ } /* End remove skills/labors */
cout << endl; cout << endl;
} /* if (print creature) */ } /* if (print creature) */
} /* End for(all creatures) */ } /* End for(all creatures) */
} /* End if (we need to walk creatures) */ } /* End if (we need to walk creatures) */
Creatures->Finish(); Creatures->Finish();
DF->Detach(); DF->Detach();
if (quiet == false) if (quiet == false)
{ {
cout << "Done. Press any key to continue" << endl; cout << "Done. Press any key to continue" << endl;
cin.ignore(); cin.ignore();
} }
return 0; return 0;
} }