added tweak clear-resident which fixes bugged migrants and makes them proper members of the fortress. added tweak clear-merchant which assimilates merchants who linger at the map edge into the fortress. updated readme.rst

develop
Robert Heinrich 2012-04-10 00:22:38 +02:00
parent e26fbd4e4c
commit 674337e3ae
3 changed files with 65 additions and 3 deletions

@ -615,6 +615,8 @@ Options
-------
:tweak clear-missing: Remove the missing status from the selected unit. This allows engraving slabs for ghostly, but not yet found, creatures.
:tweak clear-ghostly: Remove the ghostly status from the selected unit and mark it as dead. This allows getting rid of bugged ghosts which do not show up in the engraving slab menu at all, even after using clear-missing. It works, but is potentially very dangerous - so use with care. Probably (almost certainly) it does not have the same effects like a proper burial. You've been warned.
:tweak clear-resident: Remove the resident flag from the selected unit. Intended to fix bugged migrants who stay at the map edge and don't enter your fort. Only works for dwarves of the own civilization.
:tweak clear-merchant: Remove the merchant flag from the selected unit. Assimilates bugged merchants who don't leave the map into your fort. Only works for dwarves of the own civilization.
tubefill
========

@ -50,6 +50,14 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
" Intended to fix the case where you can't engrave memorials for ghosts.\n"
" Note that this is very dirty and possibly dangerous!\n"
" Most probably does not have the positive effect of a proper burial.\n"
" tweak clear-resident\n"
" Remove the resident flag from the selected unit.\n"
" Intended to fix bugged migrants who stay at the map edge.\n"
" Only works for dwarves of the own civilization.\n"
" tweak clear-merchant\n"
" Remove the merchant flag from the selected unit.\n"
" Assimilates bugged merchants who don't leave the map into your fort.\n"
" Only works for dwarves of the own civilization.\n"
));
return CR_OK;
}
@ -106,6 +114,46 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
return CR_FAILURE;
}
}
else if (cmd == "clear-resident")
{
df::unit *unit = getSelectedUnit(out);
if (!unit)
return CR_FAILURE;
// must be own race and civ and a merchant
if ( unit->flags2.bits.resident
&& unit->race == df::global::ui->race_id
&& unit->civ_id == df::global::ui->civ_id)
{
// remove resident flag
unit->flags2.bits.resident = 0;
}
else
{
out.print("That's not a resident dwarf of your civilization!\n");
return CR_FAILURE;
}
}
else if (cmd == "clear-merchant")
{
df::unit *unit = getSelectedUnit(out);
if (!unit)
return CR_FAILURE;
// must be own race and civ and a merchant
if ( unit->flags1.bits.merchant
&& unit->race == df::global::ui->race_id
&& unit->civ_id == df::global::ui->civ_id)
{
// remove merchant flag
unit->flags1.bits.merchant = 0;
}
else
{
out.print("That's not a dwarf merchant of your civilization!\n");
return CR_FAILURE;
}
}
else return CR_WRONG_USAGE;
return CR_OK;

@ -584,6 +584,17 @@ bool hasValidMapPos(df::unit* unit)
return false;
}
int getUnitIndexFromId(df::unit* unit_)
{
for (size_t i=0; i < world->units.all.size(); i++)
{
df::unit* unit = world->units.all[i];
if(unit->id == unit_->id)
return i;
}
return -1;
}
// dump some unit info
void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
{
@ -653,6 +664,7 @@ void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
if(verbose)
{
out << ". Pos: ("<<unit->pos.x << "/"<< unit->pos.y << "/" << unit->pos.z << ") " << endl;
out << "index in units vector: " << getUnitIndexFromId(unit) << endl;
}
out << endl;