diff --git a/library/DFError.h b/library/DFError.h index 5a44df27c..732e44e5a 100644 --- a/library/DFError.h +++ b/library/DFError.h @@ -71,6 +71,19 @@ namespace DFHack 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"; + } + }; } } diff --git a/library/DFHackAPI.cpp b/library/DFHackAPI.cpp index cfa761378..09b3cc0d7 100644 --- a/library/DFHackAPI.cpp +++ b/library/DFHackAPI.cpp @@ -668,8 +668,12 @@ bool API::ReadGeology (vector < vector >& 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 - return false; + //return false; } // read position of the region inside DF world @@ -751,7 +755,9 @@ bool API::InitReadBuildings ( uint32_t& numbuildings ) { d->buildingsInited = false; numbuildings = 0; - return false; + + throw Error::MissingAddress("buildings"); + //return false; } } @@ -1160,6 +1166,7 @@ bool API::getItemIndexesInBox(vector &indexes, } } } + return true; } bool API::ReadCreature (const int32_t index, t_creature & furball)