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" " Intended to fix the case where you can't engrave memorials for ghosts.\n"
" Note that this is very dirty and possibly dangerous!\n" " Note that this is very dirty and possibly dangerous!\n"
" Most probably does not have the positive effect of a proper burial.\n" " Most probably does not have the positive effect of a proper burial.\n"
" tweak clear-resident\n" " tweak fixmigrant\n"
" Remove the resident flag from the selected unit.\n" " Forces the selected unit to become a member or your fortress.\n"
" Intended to fix bugged migrants who stay at the map edge.\n" " Intended to fix bugged migrants and merchants who stay at the map edge.\n"
" Only works for dwarves of the own civilization.\n" " Only works for units of your own race. Can be used for stealing caravan\n"
" tweak clear-merchant\n" " traders and guards, but might result into weirdness during trading.\n"
" Remove the merchant flag from the selected unit.\n" " Currently all assimilated units will drop all their clothes.\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; return CR_OK;
} }
@ -166,49 +164,38 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
return CR_FAILURE; return CR_FAILURE;
} }
} }
else if (cmd == "clear-resident") else if (cmd == "fixmigrant")
{ {
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out);
if (!unit)
return CR_FAILURE;
// must be own race and civ and a merchant if (!unit)
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;
return fix_clothing_ownership(out, unit);
}
else
{ {
out.print("That's not a resident dwarf of your civilization!\n"); out << "No unit selected!" << endl;
return CR_FAILURE; return CR_FAILURE;
} }
}
else if (cmd == "clear-merchant") if(unit->race != df::global::ui->race_id)
{ {
df::unit *unit = getSelectedUnit(out); out << "Selected unit does not belong to your race!" << endl;
if (!unit)
return CR_FAILURE; return CR_FAILURE;
}
// must be own race and civ and a merchant if (unit->flags2.bits.resident)
if ( unit->flags1.bits.merchant unit->flags2.bits.resident = 0;
&& unit->race == df::global::ui->race_id
&& unit->civ_id == df::global::ui->civ_id) if(unit->flags1.bits.merchant)
{
// remove merchant flag
unit->flags1.bits.merchant = 0; unit->flags1.bits.merchant = 0;
// 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); return fix_clothing_ownership(out, unit);
} }
else else
{ return CR_WRONG_USAGE;
out.print("That's not a dwarf merchant of your civilization!\n");
return CR_FAILURE;
}
}
else return CR_WRONG_USAGE;
return CR_OK; return CR_OK;
} }