added ReadGeology

develop
doomchild 2010-09-20 12:39:50 -05:00
parent 9844a8f8b3
commit 1a5bce53a7
2 changed files with 44 additions and 0 deletions

@ -36,6 +36,8 @@ extern "C" {
DFHACK_EXPORT int Maps_Start(DFHackObject* maps);
DFHACK_EXPORT int Maps_Finish(DFHackObject* maps);
DFHACK_EXPORT uint16_t* Maps_ReadGeology(DFHackObject* maps);
DFHACK_EXPORT t_feature* Maps_ReadGlobalFeatures(DFHackObject* maps);
DFHACK_EXPORT void Maps_getSize(DFHackObject* maps, uint32_t* x, uint32_t* y, uint32_t* z);

@ -54,6 +54,48 @@ int Maps_Finish(DFHackObject* maps)
return -1;
}
uint16_t* Maps_ReadGeology(DFHackObject* maps)
{
if(maps != NULL)
{
std::vector < std::vector <uint16_t> > geology;
if(((DFHack::Maps*)maps)->ReadGeology(geology))
{
uint16_t* buf;
uint32_t geoLength = 0;
for(int i = 0; i < geology.size(); i++)
{
for(int j = 0; j < geology[i].size(); j++)
{
geoLength += geology[i].size();
}
}
(*alloc_ushort_buffer_callback)(buf, geoLength);
if(buf != NULL)
{
uint16_t* bufCopyPtr = buf;
for(int i = 0; i < geology.size(); i++)
{
copy(geology[i].begin(), geology[i].end(), bufCopyPtr);
bufCopyPtr += geology[i].size();
}
return buf;
}
else
return NULL;
}
}
return NULL;
}
t_feature* Maps_ReadGlobalFeatures(DFHackObject* maps)
{
if(maps != NULL)