Merge branch 'catsplosion' into develop

develop
lethosor 2015-02-17 14:35:46 -05:00
commit 962df78ff0
2 changed files with 36 additions and 11 deletions

@ -23,6 +23,7 @@ DFHack Future
tradereq-pet-gender: Displays pet genders on the trade request screen
Removed
Misc Improvements
catsplosion: Can now trigger pregnancies in (most) other creatures
exportlegends: 'info' and 'all' exports legends_plus xml with more data for legends utilities
remotefortressreader: Exposes more information

@ -50,9 +50,31 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
command_result catsplosion (color_ostream &out, std::vector <std::string> & parameters)
{
if (!Core::getInstance().isWorldLoaded())
{
out.printerr("World not loaded.\n");
return CR_FAILURE;
}
bool list_only = false;
list<string> s_creatures;
// only cats for now.
s_creatures.push_back("CAT");
if (parameters.size())
{
for (size_t i = 0; i < parameters.size(); i++)
{
if (parameters[i] == "list")
{
list_only = true;
}
else
{
s_creatures.push_back(parameters[i]);
}
}
}
else
{
s_creatures.push_back("CAT");
}
// make the creature list unique ... with cats. they are always unique
s_creatures.unique();
// SUSPEND THE CORE! ::Evil laugh::
@ -61,7 +83,7 @@ command_result catsplosion (color_ostream &out, std::vector <std::string> & para
uint32_t numCreatures;
if(!(numCreatures = Units::getNumCreatures()))
{
cerr << "Can't get any creatures." << endl;
out.printerr("Can't get any creatures.\n");
return CR_FAILURE;
}
@ -70,8 +92,6 @@ command_result catsplosion (color_ostream &out, std::vector <std::string> & para
int totalcreated=0;
string sextype;
// shows all the creatures and returns.
int maxlength = 0;
map<string, vector <df::unit *> > male_counts;
map<string, vector <df::unit *> > female_counts;
@ -93,17 +113,16 @@ command_result catsplosion (color_ostream &out, std::vector <std::string> & para
}
}
// print (optional)
//if (showcreatures == 1)
if (list_only)
{
out.print("Type Male # Female #\n");
for(auto it1 = male_counts.begin();it1!=male_counts.end();it1++)
out.print("Type Male # Female #\n");
for (auto it1 = male_counts.begin(); it1!=male_counts.end(); it1++)
{
out.print("%20s %6d %8d\n", it1->first.c_str(), it1->second.size(), female_counts[it1->first].size());
out.print("%22s %6d %8d\n", it1->first.c_str(), it1->second.size(), female_counts[it1->first].size());
}
return CR_OK;
}
// process
for (list<string>::iterator it = s_creatures.begin(); it != s_creatures.end(); ++it)
{
@ -137,6 +156,11 @@ command_result catsplosion (color_ostream &out, std::vector <std::string> & para
out.print("%d pregnancies accelerated.\n", totalchanged);
if(totalcreated)
out.print("%d pregnancies created.\n", totalcreated);
if (!totalcount)
{
out.printerr("No creatures matched.\n");
return CR_FAILURE;
}
out.print("Total creatures checked: %d\n", totalcount);
return CR_OK;
}