From 40f36c19128f2daa7e40c5a1d882ffd1f5b5f47f Mon Sep 17 00:00:00 2001 From: Robert Heinrich Date: Tue, 17 Apr 2012 16:57:41 +0200 Subject: [PATCH 1/2] minor stuff, use building->is_room instead of building->isRoom() which returns unexpected values --- plugins/probe.cpp | 3 ++- plugins/rename.cpp | 4 ++-- plugins/tweak.cpp | 16 +++++----------- plugins/zone.cpp | 37 +++++++++---------------------------- 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 3f4a3b6fe..4eff1d49d 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -382,12 +382,13 @@ command_result df_bprobe (color_ostream &out, vector & parameters) out.print(", subtype %i", building.subtype); break; } - if(building.origin->isRoom()) + if(building.origin->is_room) //isRoom()) out << ", is room"; else out << ", not a room"; out.print("\n"); + } return CR_OK; } diff --git a/plugins/rename.cpp b/plugins/rename.cpp index 7302aea60..1871d0f73 100644 --- a/plugins/rename.cpp +++ b/plugins/rename.cpp @@ -150,7 +150,7 @@ static command_result rename(color_ostream &out, vector ¶meters) if (parameters.size() != 2) return CR_WRONG_USAGE; - df::unit *unit = Gui::getSelectedUnit(out); + df::unit *unit = Gui::getSelectedUnit(out, true); if (!unit) return CR_WRONG_USAGE; @@ -161,7 +161,7 @@ static command_result rename(color_ostream &out, vector ¶meters) if (parameters.size() != 2) return CR_WRONG_USAGE; - df::unit *unit = Gui::getSelectedUnit(out); + df::unit *unit = Gui::getSelectedUnit(out, true); if (!unit) return CR_WRONG_USAGE; diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index 31969bde7..43b557fef 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -140,7 +140,7 @@ static command_result tweak(color_ostream &out, vector ¶meters) if (cmd == "clear-missing") { - df::unit *unit = getSelectedUnit(out); + df::unit *unit = getSelectedUnit(out, true); if (!unit) return CR_FAILURE; @@ -157,7 +157,7 @@ static command_result tweak(color_ostream &out, vector ¶meters) } else if (cmd == "clear-ghostly") { - df::unit *unit = getSelectedUnit(out); + df::unit *unit = getSelectedUnit(out, true); if (!unit) return CR_FAILURE; @@ -176,13 +176,9 @@ static command_result tweak(color_ostream &out, vector ¶meters) } else if (cmd == "fixmigrant") { - df::unit *unit = getSelectedUnit(out); - + df::unit *unit = getSelectedUnit(out, true); if (!unit) - { - out << "No unit selected!" << endl; return CR_FAILURE; - } if(unit->race != df::global::ui->race_id) { @@ -213,12 +209,10 @@ static command_result tweak(color_ostream &out, vector ¶meters) { // force a unit into your fort, regardless of civ or race // allows to "steal" caravan guards etc - df::unit *unit = getSelectedUnit(out); + df::unit *unit = getSelectedUnit(out, true); if (!unit) - { - out << "No unit selected!" << endl; return CR_FAILURE; - } + if (unit->flags2.bits.resident) unit->flags2.bits.resident = 0; if(unit->flags1.bits.merchant) diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 968fda72f..3c0f645fb 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -1065,10 +1065,10 @@ bool isInBuiltCageRoom(df::unit* unit) { df::building* building = world->buildings.all[b]; - // !!! for whatever reason isRoom() returns true if a cage is not a room - // !!! and false if it was defined as a room/zoo ingame - // !!! (seems not general behaviour, activity zones return false, for example) - if(building->isRoom()) + // !!! building->isRoom() returns true if the building can be made a room but currently isn't + // !!! except for coffins/tombs which always return false + // !!! using the bool is_room however gives the correct state/value + if(!building->is_room) continue; if(building->getType() == building_type::Cage) @@ -1594,11 +1594,6 @@ void zoneInfo(color_ostream & out, df::building* building, bool verbose) else out << "not active"; - //if(building->isRoom()) - // out <<", room"; - //else - // out << ", not a room"; - if(civ->zone_flags.bits.pen_pasture) out << ", pen/pasture"; else if (civ->zone_flags.bits.pit_pond) @@ -1655,16 +1650,7 @@ void cageInfo(color_ostream & out, df::building* building, bool verbose) << " z:" << building->z << endl; - //if(building->isRoom()) - // out <<", bldg room"; - //else - // out << ", bldg not a room"; - df::building_cagest * cage = (df::building_cagest*) building; - //if(cage->isRoom()) - // out <<", cage is room"; - //else - // out << ", cage is not a room"; int32_t creaturecount = cage->assigned_creature.size(); out << "Creatures in this cage: " << creaturecount << endl; @@ -2277,8 +2263,8 @@ command_result df_zone (color_ostream &out, vector & parameters) // find building under cursor if (!all && !(building->x1 <= cursor->x && cursor->x <= building->x2 && - building->y1 <= cursor->y && cursor->y <= building->y2 && - building->z == cursor->z)) + building->y1 <= cursor->y && cursor->y <= building->y2 && + building->z == cursor->z)) continue; zoneInfo(out, building, verbose); @@ -2465,12 +2451,9 @@ command_result df_zone (color_ostream &out, vector & parameters) else { // must have unit selected - df::unit *unit = getSelectedUnit(out); + df::unit *unit = getSelectedUnit(out, true); if (!unit) - { - out << "No unit selected." << endl; return CR_WRONG_USAGE; - } if(unit_info) { @@ -2503,18 +2486,16 @@ command_result df_zone (color_ostream &out, vector & parameters) if(building_unassign) { // must have unit selected - df::unit *unit = getSelectedUnit(out); + df::unit *unit = getSelectedUnit(out, true); if (!unit) - { - out << "No unit selected." << endl; return CR_WRONG_USAGE; - } // remove assignment reference from unit and old zone if(unassignUnitFromBuilding(unit)) out << "Unit unassigned." << endl; else out << "Unit is not assigned to an activity zone!" << endl; + return CR_OK; } From 299510f0d9f87c09a505a31aea4b94d11237597d Mon Sep 17 00:00:00 2001 From: Robert Heinrich Date: Tue, 17 Apr 2012 18:11:14 +0200 Subject: [PATCH 2/2] zone: don't assign to cages which are designated but not yet placed (minor fix, it's not like bad things happen without it) --- plugins/probe.cpp | 2 ++ plugins/zone.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 4eff1d49d..4e041f180 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -386,6 +386,8 @@ command_result df_bprobe (color_ostream &out, vector & parameters) out << ", is room"; else out << ", not a room"; + if(building.origin->getBuildStage()!=building.origin->getMaxBuildStage()) + out << ", in construction"; out.print("\n"); diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 3c0f645fb..ee6abf327 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -897,6 +897,10 @@ int32_t findCageAtCursor() building->z == cursor->z)) continue; + // don't set id if cage is not constructed yet + if(building->getBuildStage()!=building->getMaxBuildStage()) + break; + if(isCage(building)) { foundID = building->id; @@ -1122,6 +1126,10 @@ df::building * getBuiltCageAtPos(df::coord pos) && building->y1 == pos.y && building->z == pos.z ) { + // don't set pointer if not constructed yet + if(building->getBuildStage()!=building->getMaxBuildStage()) + break; + cage = building; break; }