diff --git a/README.rst b/README.rst index 332919152..be601180b 100644 --- a/README.rst +++ b/README.rst @@ -613,8 +613,10 @@ Contains various tweaks for minor bugs (currently just one). 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-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 ======== diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index d2fef313b..edfa7081a 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -50,6 +50,14 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector ¶meters) 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; diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 0038a707b..8affd2a6d 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -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) { @@ -652,7 +663,8 @@ void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false) if(verbose) { - out << ". Pos: ("<pos.x << "/"<< unit->pos.y << "/" << unit->pos.z << ")" << endl; + out << ". Pos: ("<pos.x << "/"<< unit->pos.y << "/" << unit->pos.z << ") " << endl; + out << "index in units vector: " << getUnitIndexFromId(unit) << endl; } out << endl;