added exceptions to API::InitMap

develop
mizipzor 2010-02-28 02:37:05 +01:00
parent decb20ef67
commit 19cd686ac4
2 changed files with 27 additions and 3 deletions

@ -49,6 +49,28 @@ namespace DFHack
return "couldn't attach to process";
}
};
class NoMapLoaded : public exception
{
public:
virtual const char* what() const throw()
{
return "no map has been loaded in the dwarf fortress process";
}
};
class BadMapDimensions : public exception
{
public:
BadMapDimensions(uint32_t& _x, uint32_t& _y) : x(_x), y(_y) {}
const uint32_t x;
const uint32_t y;
virtual const char* what() const throw()
{
return "both x and y needs to be between 0 and 48";
}
};
}
}

@ -188,8 +188,9 @@ bool API::InitMap()
//FIXME: very inadequate
if (!x_array_loc)
{
throw Error::NoMapLoaded();
// bad stuffz happend
return false;
//return false;
}
uint32_t mx, my, mz;
@ -201,7 +202,8 @@ bool API::InitMap()
// test for wrong map dimensions
if (mx == 0 || mx > 48 || my == 0 || my > 48 || mz == 0)
{
return false;
throw Error::BadMapDimensions(mx, my);
//return false;
}
// alloc array for pointers to all blocks