added exceptions to API::ReadGeology and API::InitReadBuildings

develop
mizipzor 2010-02-28 02:50:16 +01:00
parent 19cd686ac4
commit f2dcbc6372
2 changed files with 22 additions and 2 deletions

@ -71,6 +71,19 @@ namespace DFHack
return "both x and y needs to be between 0 and 48"; return "both x and y needs to be between 0 and 48";
} }
}; };
// a call to DFHack::mem_info::getAdress() failed
class MissingAddress : public exception
{
public:
MissingAddress(const char* _address) : address(_address) {}
const std::string address;
virtual const char* what() const throw()
{
return "memory address missing";
}
};
} }
} }

@ -668,8 +668,12 @@ bool API::ReadGeology (vector < vector <uint16_t> >& assign)
) )
) )
{ {
// FIXME should probably be moved into getAdress or getOffset for easy storing of
// the missing definition
throw Error::MissingAddress();
// fail if we don't have them // fail if we don't have them
return false; //return false;
} }
// read position of the region inside DF world // read position of the region inside DF world
@ -751,7 +755,9 @@ bool API::InitReadBuildings ( uint32_t& numbuildings )
{ {
d->buildingsInited = false; d->buildingsInited = false;
numbuildings = 0; numbuildings = 0;
return false;
throw Error::MissingAddress("buildings");
//return false;
} }
} }
@ -1160,6 +1166,7 @@ bool API::getItemIndexesInBox(vector<uint32_t> &indexes,
} }
} }
} }
return true;
} }
bool API::ReadCreature (const int32_t index, t_creature & furball) bool API::ReadCreature (const int32_t index, t_creature & furball)