From 9f95e67c7575cca9495062eb275ee99a590e41cb Mon Sep 17 00:00:00 2001 From: Robert Heinrich Date: Sat, 14 Apr 2012 19:06:03 +0200 Subject: [PATCH] tweak makeown: converts MERCHANT to TRADER (otherwise you can't assign jobs to kidnapped merchants. zone: fixed a bug which could lead to units being assigned to more than one cage and/or accidentally marked for slaughter --- plugins/tweak.cpp | 4 ++++ plugins/zone.cpp | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index 4c100cc48..31969bde7 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -227,6 +227,10 @@ static command_result tweak(color_ostream &out, vector ¶meters) unit->flags1.bits.forest = 0; if(unit->civ_id != df::global::ui->civ_id) unit->civ_id = df::global::ui->civ_id; + if(unit->profession == df::profession::MERCHANT) + unit->profession = df::profession::TRADER; + if(unit->profession2 == df::profession::MERCHANT) + unit->profession2 = df::profession::TRADER; return fix_clothing_ownership(out, unit); } else diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 1e90aa1cf..2f2b64588 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -905,7 +905,7 @@ bool isAssigned(df::unit* unit) if( rtype == df::general_ref_type::BUILDING_CIVZONE_ASSIGNED || rtype == df::general_ref_type::BUILDING_CAGED || rtype == df::general_ref_type::BUILDING_CHAIN - || (rtype == df::general_ref_type::CONTAINED_IN_ITEM && isBuiltCageAtPos(unit->pos)) + || (rtype == df::general_ref_type::CONTAINED_IN_ITEM && isInBuiltCage(unit)) ) { assigned = true; @@ -958,10 +958,10 @@ bool isInBuiltCage(df::unit* unit) df::building* building = world->buildings.all[b]; if( building->getType() == building_type::Cage) { - df::building_cagest* oldcage = (df::building_cagest*) building; - for(size_t oc=0; ocassigned_creature.size(); oc++) + df::building_cagest* cage = (df::building_cagest*) building; + for(size_t c=0; cassigned_creature.size(); c++) { - if(oldcage->assigned_creature[oc] == unit->id) + if(cage->assigned_creature[c] == unit->id) { caged = true; break; @@ -2769,7 +2769,9 @@ command_result autoButcher( color_ostream &out, bool verbose = false ) || !isTame(unit) || isWar(unit) // ignore war dogs etc || isHunter(unit) // ignore hunting dogs etc - || (isContainedInItem(unit) && hasValidMapPos(unit) && isBuiltCageAtPos(unit->pos)) + // ignore creatures in built cages to leave zoos alone + // (TODO: allow some kind of slaughter cages which you can place near the butcher) + || (isContainedInItem(unit) && isInBuiltCage(unit)) || unit->name.has_name ) continue;