tweak: removed stuff, added new command 'fixmigrants' which will deal with merchants (traders) and other types of bugged migrants. having more than one command for a bug which is basically the same makes no sense.

develop
Robert Heinrich 2012-04-11 22:29:56 +02:00
parent 42e4fa79c7
commit 2caf3fb064
1 changed files with 27 additions and 40 deletions

@ -53,14 +53,12 @@ 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"
" tweak fixmigrant\n"
" Forces the selected unit to become a member or your fortress.\n"
" Intended to fix bugged migrants and merchants who stay at the map edge.\n"
" Only works for units of your own race. Can be used for stealing caravan\n"
" traders and guards, but might result into weirdness during trading.\n"
" Currently all assimilated units will drop all their clothes.\n"
));
return CR_OK;
}
@ -166,49 +164,38 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
return CR_FAILURE;
}
}
else if (cmd == "clear-resident")
else if (cmd == "fixmigrant")
{
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)
if (!unit)
{
// remove resident flag
unit->flags2.bits.resident = 0;
return fix_clothing_ownership(out, unit);
out << "No unit selected!" << endl;
return CR_FAILURE;
}
else
if(unit->race != df::global::ui->race_id)
{
out.print("That's not a resident dwarf of your civilization!\n");
out << "Selected unit does not belong to your race!" << endl;
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
if (unit->flags2.bits.resident)
unit->flags2.bits.resident = 0;
if(unit->flags1.bits.merchant)
unit->flags1.bits.merchant = 0;
return fix_clothing_ownership(out, unit);
}
else
{
out.print("That's not a dwarf merchant of your civilization!\n");
return CR_FAILURE;
}
// this one is a cheat, but bugged migrants usually have the same civ_id
// but if it happens that the player has 'foreign' units of the same race
// (dwarves not from moutainhome in vanilla df) on his map, just grab them
if(unit->civ_id != df::global::ui->civ_id)
unit->civ_id = df::global::ui->civ_id;
return fix_clothing_ownership(out, unit);
}
else return CR_WRONG_USAGE;
else
return CR_WRONG_USAGE;
return CR_OK;
}