A whole bunch of fixes for crash bugs.

develop
Petr Mrázek 2011-08-05 05:02:36 +02:00
parent be358ec1de
commit 4d6ad9e073
4 changed files with 28 additions and 14 deletions

@ -106,7 +106,7 @@ bool Translation::Start()
for (uint32_t i = 0;i < genericVec.size();i++)
{
uint32_t genericNamePtr = genericVec.at(i);
for(int j=0; j<10;i++)
for(int j=0; j<10;j++)
{
string word = p->readSTLString (genericNamePtr + j * d->sizeof_string);
translations[j].push_back (word);

@ -31,7 +31,7 @@ DFhackCExport const char * plugin_name ( void )
DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand> &commands)
{
commands.clear();
commands.push_back(PluginCommand("cleanowned",
commands.push_back(PluginCommand("vlub",
"Confiscates and dumps garbage owned by dwarfs.",
df_cleanowned));
return CR_OK;
@ -42,8 +42,6 @@ DFhackCExport command_result plugin_shutdown ( Core * c )
return CR_OK;
}
typedef std::map <DFCoord, uint32_t> coordmap;
DFhackCExport command_result df_cleanowned (Core * c, vector <string> & parameters)
{
bool dump_scattered = false;
@ -51,7 +49,7 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
bool dry_run = false;
int wear_dump_level = 65536;
for(int i = 0; i < parameters.size(); i++)
for(std::size_t i = 0; i < parameters.size(); i++)
{
string & param = parameters[i];
if(param == "dryrun")
@ -63,10 +61,24 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
else if(param == "x")
wear_dump_level = 1;
else if(param == "X")
wear_dump_level = 1;
wear_dump_level = 2;
else if(param == "?" || param == "help")
{
c->con.print("Oh no! Someone has to write the help text!\n");
c->con.print("This tool lets you confiscate and dump all the garbage\n"
"dwarves ultimately accumulate.\n"
"By default, only rotten and dropped food is confiscated.\n"
"Options:\n"
" dryrun - don't actually do anything, just print what would be done.\n"
" scattered - confiscate owned items on the ground\n"
" all - confiscate everything\n"
" x - confiscate & dump 'x' and worse damaged items\n"
" X - confiscate & dump 'X' and worse damaged items\n"
" ? - this help\n"
"Example:\n"
" confiscate scattered X\n"
" This will confiscate rotten and dropped food, garbage on the floors\n"
" and any worn items wit 'X' damage and above.\n"
);
return CR_OK;
}
else
@ -75,6 +87,7 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
return CR_FAILURE;
}
}
c->Suspend();
DFHack::Materials *Materials = c->getMaterials();
DFHack::Items *Items = c->getItems();
DFHack::Creatures *Creatures = c->getCreatures();
@ -152,13 +165,15 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
if (confiscate)
{
if (!dry_run) {
if (!dry_run)
{
if (!Items->removeItemOwner(itm, Creatures))
c->con.print("(unsuccessfully) ");
if (dump)
itm.base->flags.dump = 1;
Items->writeItem(itm);
// NO-OP really
//Items->writeItem(itm);
}
c->con.print(
@ -199,5 +214,6 @@ DFhackCExport command_result df_cleanowned (Core * c, vector <string> & paramete
*/
}
}
c->Resume();
return CR_OK;
}

@ -54,9 +54,7 @@ DFhackCExport command_result df_cleartask (Core * c, vector <string> & parameter
int numtasked = 0;
for (std::size_t i = 0; i < p_items.size(); i++)
{
t_item * ptr;
DFHack::dfh_item temp;
Items->readItem(p_items[i],temp);
t_item * ptr = p_items[i];
if (ptr->flags.in_job)
{
ptr->flags.in_job = 0;

@ -141,8 +141,8 @@ DFhackCExport command_result df_deramp (Core * c, vector <string> & parameters)
}
c->Resume();
if(count)
c->con.print("Found and changed %d tiles.",count);
c->con.print("Found and changed %d tiles.\n",count);
if(countbad)
c->con.print("Fixed %d bad down ramps.",countbad);
c->con.print("Fixed %d bad down ramps.\n",countbad);
return CR_OK;
}