minor stuff, use building->is_room instead of building->isRoom() which returns unexpected values

develop
Robert Heinrich 2012-04-17 16:57:41 +02:00
parent 6d180d61c4
commit 40f36c1912
4 changed files with 18 additions and 42 deletions

@ -382,12 +382,13 @@ command_result df_bprobe (color_ostream &out, vector <string> & parameters)
out.print(", subtype %i", building.subtype); out.print(", subtype %i", building.subtype);
break; break;
} }
if(building.origin->isRoom()) if(building.origin->is_room) //isRoom())
out << ", is room"; out << ", is room";
else else
out << ", not a room"; out << ", not a room";
out.print("\n"); out.print("\n");
} }
return CR_OK; return CR_OK;
} }

@ -150,7 +150,7 @@ static command_result rename(color_ostream &out, vector <string> &parameters)
if (parameters.size() != 2) if (parameters.size() != 2)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
df::unit *unit = Gui::getSelectedUnit(out); df::unit *unit = Gui::getSelectedUnit(out, true);
if (!unit) if (!unit)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
@ -161,7 +161,7 @@ static command_result rename(color_ostream &out, vector <string> &parameters)
if (parameters.size() != 2) if (parameters.size() != 2)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
df::unit *unit = Gui::getSelectedUnit(out); df::unit *unit = Gui::getSelectedUnit(out, true);
if (!unit) if (!unit)
return CR_WRONG_USAGE; return CR_WRONG_USAGE;

@ -140,7 +140,7 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
if (cmd == "clear-missing") if (cmd == "clear-missing")
{ {
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out, true);
if (!unit) if (!unit)
return CR_FAILURE; return CR_FAILURE;
@ -157,7 +157,7 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
} }
else if (cmd == "clear-ghostly") else if (cmd == "clear-ghostly")
{ {
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out, true);
if (!unit) if (!unit)
return CR_FAILURE; return CR_FAILURE;
@ -176,13 +176,9 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
} }
else if (cmd == "fixmigrant") else if (cmd == "fixmigrant")
{ {
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out, true);
if (!unit) if (!unit)
{
out << "No unit selected!" << endl;
return CR_FAILURE; return CR_FAILURE;
}
if(unit->race != df::global::ui->race_id) if(unit->race != df::global::ui->race_id)
{ {
@ -213,12 +209,10 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
{ {
// force a unit into your fort, regardless of civ or race // force a unit into your fort, regardless of civ or race
// allows to "steal" caravan guards etc // allows to "steal" caravan guards etc
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out, true);
if (!unit) if (!unit)
{
out << "No unit selected!" << endl;
return CR_FAILURE; return CR_FAILURE;
}
if (unit->flags2.bits.resident) if (unit->flags2.bits.resident)
unit->flags2.bits.resident = 0; unit->flags2.bits.resident = 0;
if(unit->flags1.bits.merchant) if(unit->flags1.bits.merchant)

@ -1065,10 +1065,10 @@ bool isInBuiltCageRoom(df::unit* unit)
{ {
df::building* building = world->buildings.all[b]; df::building* building = world->buildings.all[b];
// !!! for whatever reason isRoom() returns true if a cage is not a room // !!! building->isRoom() returns true if the building can be made a room but currently isn't
// !!! and false if it was defined as a room/zoo ingame // !!! except for coffins/tombs which always return false
// !!! (seems not general behaviour, activity zones return false, for example) // !!! using the bool is_room however gives the correct state/value
if(building->isRoom()) if(!building->is_room)
continue; continue;
if(building->getType() == building_type::Cage) if(building->getType() == building_type::Cage)
@ -1594,11 +1594,6 @@ void zoneInfo(color_ostream & out, df::building* building, bool verbose)
else else
out << "not active"; out << "not active";
//if(building->isRoom())
// out <<", room";
//else
// out << ", not a room";
if(civ->zone_flags.bits.pen_pasture) if(civ->zone_flags.bits.pen_pasture)
out << ", pen/pasture"; out << ", pen/pasture";
else if (civ->zone_flags.bits.pit_pond) 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 << " z:" << building->z
<< endl; << endl;
//if(building->isRoom())
// out <<", bldg room";
//else
// out << ", bldg not a room";
df::building_cagest * cage = (df::building_cagest*) building; 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(); int32_t creaturecount = cage->assigned_creature.size();
out << "Creatures in this cage: " << creaturecount << endl; out << "Creatures in this cage: " << creaturecount << endl;
@ -2277,8 +2263,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
// find building under cursor // find building under cursor
if (!all && if (!all &&
!(building->x1 <= cursor->x && cursor->x <= building->x2 && !(building->x1 <= cursor->x && cursor->x <= building->x2 &&
building->y1 <= cursor->y && cursor->y <= building->y2 && building->y1 <= cursor->y && cursor->y <= building->y2 &&
building->z == cursor->z)) building->z == cursor->z))
continue; continue;
zoneInfo(out, building, verbose); zoneInfo(out, building, verbose);
@ -2465,12 +2451,9 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
else else
{ {
// must have unit selected // must have unit selected
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out, true);
if (!unit) if (!unit)
{
out << "No unit selected." << endl;
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
}
if(unit_info) if(unit_info)
{ {
@ -2503,18 +2486,16 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
if(building_unassign) if(building_unassign)
{ {
// must have unit selected // must have unit selected
df::unit *unit = getSelectedUnit(out); df::unit *unit = getSelectedUnit(out, true);
if (!unit) if (!unit)
{
out << "No unit selected." << endl;
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
}
// remove assignment reference from unit and old zone // remove assignment reference from unit and old zone
if(unassignUnitFromBuilding(unit)) if(unassignUnitFromBuilding(unit))
out << "Unit unassigned." << endl; out << "Unit unassigned." << endl;
else else
out << "Unit is not assigned to an activity zone!" << endl; out << "Unit is not assigned to an activity zone!" << endl;
return CR_OK; return CR_OK;
} }