Merge branch 'worldmap'

develop
Petr Mrázek 2011-03-24 17:43:28 +01:00
commit ecb239f64c
3 changed files with 44 additions and 13 deletions

@ -575,6 +575,8 @@ namespace DFHack
/// get size of the map in tiles
void getSize(uint32_t& x, uint32_t& y, uint32_t& z);
/// get the position of the map on world map
void getPosition(int32_t& x, int32_t& y, int32_t& z);
/**
* Return false/0 on failure, buffer allocated by client app, 256 items long

@ -62,7 +62,7 @@ struct Maps::Private
{
uint32_t * block;
uint32_t x_block_count, y_block_count, z_block_count;
uint32_t regionX, regionY, regionZ;
int32_t regionX, regionY, regionZ;
uint32_t worldSizeX, worldSizeY;
uint32_t maps_module;
@ -319,9 +319,9 @@ bool Maps::Start()
}
// read position of the region inside DF world
p->readDWord (off.region_x_offset, d->regionX);
p->readDWord (off.region_y_offset, d->regionY);
p->readDWord (off.region_z_offset, d->regionZ);
p->readDWord (off.region_x_offset, (uint32_t &) d->regionX);
p->readDWord (off.region_y_offset, (uint32_t &) d->regionY);
p->readDWord (off.region_z_offset, (uint32_t &) d->regionZ);
// alloc array for pointers to all blocks
d->block = new uint32_t[mx*my*mz];
@ -355,6 +355,15 @@ void Maps::getSize (uint32_t& x, uint32_t& y, uint32_t& z)
z = d->z_block_count;
}
// getter for map position
void Maps::getPosition (int32_t& x, int32_t& y, int32_t& z)
{
MAPS_GUARD
x = d->regionX;
y = d->regionY;
z = d->regionZ;
}
bool Maps::Finish()
{
if (d->block != NULL)

@ -17,9 +17,9 @@ std::ostream &operator<<(std::ostream &stream, DFHack::t_gamemodes funzies)
"Legends",
"Menus",
"Arena",
"Arena - Assumed",
"Kittens!",
"Worldgen"
"Arena - Assumed",
"Kittens!",
"Worldgen"
};
char * cm[]=
{
@ -48,15 +48,19 @@ int main (int argc, char** argv)
}
DFHack::Gui * Gui = 0;
DFHack::Maps * Maps = 0;
DFHack::World * World = 0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
bool have_maps = false;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
Gui = DF->getGui();
Maps = DF->getMaps();
World = DF->getWorld();
have_maps = Maps->Start();
}
catch (exception& e)
{
@ -77,13 +81,29 @@ int main (int argc, char** argv)
<< " Tick: " << World->ReadCurrentTick() << endl;
if (Gui)
{
int32_t x,y,z;
int32_t vx,vy,vz;
int32_t cx,cy,cz;
int32_t wx,wy,wz;
int32_t width,height;
if(Gui->getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
if(Gui->getCursorCoords(x,y,z))
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
if(have_maps)
{
Maps->getPosition(wx,wy,wz);
cout << "Map world offset: " << wx << "/" << wy << "/" << wz << " embark squares." << endl;
}
bool have_cursor = Gui->getCursorCoords(cx,cy,cz);
bool have_view = Gui->getViewCoords(vx,vy,vz);
if(have_view)
{
cout << "view coords: " << vx << "/" << vy << "/" << vz << endl;
if(have_maps)
cout << " world: " << vx+wx*48 << "/" << vy+wy*48 << "/" << vz+wz << endl;
}
if(have_cursor)
{
cout << "cursor coords: " << cx << "/" << cy << "/" << cz << endl;
if(have_maps)
cout << " world: " << cx+wx*48 << "/" << cy+wy*48 << "/" << cz+wz << endl;
}
if(Gui->getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
}