Merge remote-tracking branch 'rh73/master'

develop
Kelly Martin 2012-04-11 21:49:03 -05:00
commit cdf4298f5a
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;
}