Fix a few zone plugin crashes

* Avoid checking building types of null pointers
* Detect selected cages properly

Fixes #646
develop
lethosor 2015-06-23 21:21:21 -04:00
parent 01c4d4540b
commit 38d377f4c4
1 changed files with 3 additions and 3 deletions

@ -601,12 +601,12 @@ void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
bool isCage(df::building * building) bool isCage(df::building * building)
{ {
return building->getType() == building_type::Cage; return building && (building->getType() == building_type::Cage);
} }
bool isChain(df::building * building) bool isChain(df::building * building)
{ {
return building->getType() == building_type::Chain; return building && (building->getType() == building_type::Chain);
} }
// returns building of cage at cursor position (NULL if nothing found) // returns building of cage at cursor position (NULL if nothing found)
@ -2004,7 +2004,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
// cagezone wants a pen/pit as starting point // cagezone wants a pen/pit as starting point
if(!cagezone_assign) if(!cagezone_assign)
target_building = findCageAtCursor(); target_building = findCageAtCursor();
if(!target_building) if(target_building)
{ {
out << "Target building type: cage." << endl; out << "Target building type: cage." << endl;
} }