Massive tool and wrapper fixage.

develop
Petr Mrázek 2011-03-18 11:38:37 +01:00
parent a6c724bfb5
commit e1b80e6f33
31 changed files with 249 additions and 280 deletions

@ -10,5 +10,4 @@ __all__ = [ "buildings",
"items",
"maps",
"materials",
"position"
"vegetation" ]

@ -12,7 +12,6 @@ libdfhack.API_getWindow.restype = c_void_p
libdfhack.API_getCreatures.restype = c_void_p
libdfhack.API_getMaps.restype = c_void_p
libdfhack.API_getGui.restype = c_void_p
libdfhack.API_getPosition.restype = c_void_p
libdfhack.API_getMaterials.restype = c_void_p
libdfhack.API_getTranslation.restype = c_void_p
libdfhack.API_getVegetation.restype = c_void_p
@ -24,7 +23,6 @@ class API(object):
def __init__(self, memory_path):
self._api_ptr = libdfhack.API_Alloc(create_string_buffer(memory_path))
self._pos_obj = None
self._mat_obj = None
self._map_obj = None
self._veg_obj = None
@ -64,14 +62,6 @@ class API(object):
def is_suspended(self):
return libdfhack.API_isSuspended(self._api_ptr) > 0
@property
def position(self):
import position
if self._pos_obj is None:
self._pos_obj = position.Position(libdfhack.API_getPosition(self._api_ptr))
return self._pos_obj
@property
def materials(self):
import materials

@ -1,21 +1,23 @@
from ctypes import *
from pydfhack import libdfhack, ViewScreen
libdfhack.Gui_ReadHotkeys.restype = c_void_p
libdfhack.Gui_ReadViewScreen.argtypes = [ c_void_p, c_void_p ]
class Gui(object):
def __init__(self, ptr):
self._gui_ptr = ptr
self._vx, self._vy, self._vz = c_int(), c_int(), c_int()
self._cx, self._cy, self._cz = c_int(), c_int(), c_int()
self._ww, self._wh = c_int(), c_int()
def start(self):
return libdfhack.Gui_Start(self._gui_ptr)
def finish(self):
return libdfhack.Gui_Finish(self._gui_ptr)
def read_pause_state(self):
return libdfhack.Gui_ReadPauseState(self._pos_ptr) > 0
def read_view_screen(self):
s = ViewScreen()
@ -23,3 +25,39 @@ class Gui(object):
return s
else:
return None
def get_view_coords(self):
if libdfhack.Gui_getViewCoords(self._gui_ptr, byref(self._vx), byref(self._vy), byref(self._vz)) > 0:
return (self._vx.value, self._vy.value, self._vz.value)
else:
return (-1, -1, -1)
def set_view_coords(self, v_coords):
self._vx.value, self._vy.value, self._vz.value = v_coords
libdfhack.Gui_setViewCoords(self._gui_ptr, self._vx, self._vy, self._vz)
view_coords = property(get_view_coords, set_view_coords)
def get_cursor_coords(self):
if libdfhack.Gui_getCursorCoords(self._gui_ptr, byref(self._cx), byref(self._cy), byref(self._cz)) > 0:
return (self._cx.value, self._cy.value, self._cz.value)
else:
return (-1, -1, -1)
def set_cursor_coords(self, c_coords):
self._cx.value, self._cy.value, self_cz.value = c_coords
libdfhack.Gui_setCursorCoords(self._gui_ptr, self._cx, self._cy, self._cz)
cursor_coords = property(get_cursor_coords, set_cursor_coords)
def read_hotkeys(self):
return check_pointer_cache(libdfhack.Gui_ReadHotkeys(self._gui_ptr))
@property
def window_size(self):
if libdfhack.Gui_getWindowSize(self._gui_ptr, byref(self._ww), byref(self._wh)) > 0:
return (self._ww.value, self._wh.value)
else:
return (-1, -1)

@ -1,49 +0,0 @@
from ctypes import *
from dftypes import libdfhack
from util import check_pointer_cache
libdfhack.Position_ReadHotkeys.restype = c_void_p
class Position(object):
def __init__(self, ptr):
self._pos_ptr = ptr
self._vx, self._vy, self._vz = c_int(), c_int(), c_int()
self._cx, self._cy, self._cz = c_int(), c_int(), c_int()
self._ww, self._wh = c_int(), c_int()
def get_view_coords(self):
if libdfhack.Position_getViewCoords(self._pos_ptr, byref(self._vx), byref(self._vy), byref(self._vz)) > 0:
return (self._vx.value, self._vy.value, self._vz.value)
else:
return (-1, -1, -1)
def set_view_coords(self, v_coords):
self._vx.value, self._vy.value, self._vz.value = v_coords
libdfhack.Position_setViewCoords(self._pos_ptr, self._vx, self._vy, self._vz)
view_coords = property(get_view_coords, set_view_coords)
def get_cursor_coords(self):
if libdfhack.Position_getCursorCoords(self._pos_ptr, byref(self._cx), byref(self._cy), byref(self._cz)) > 0:
return (self._cx.value, self._cy.value, self._cz.value)
else:
return (-1, -1, -1)
def set_cursor_coords(self, c_coords):
self._cx.value, self._cy.value, self_cz.value = c_coords
libdfhack.Position_setCursorCoords(self._pos_ptr, self._cx, self._cy, self._cz)
cursor_coords = property(get_cursor_coords, set_cursor_coords)
def read_hotkeys(self):
return check_pointer_cache(libdfhack.Position_ReadHotkeys(self._pos_ptr))
@property
def window_size(self):
if libdfhack.Position_getWindowSize(self._pos_ptr, byref(self._ww), byref(self._wh)) > 0:
return (self._ww.value, self._wh.value)
else:
return (-1, -1)

@ -14,6 +14,9 @@ class World(object):
def finish(self):
return libdfhack.World_Finish(self._world_ptr) > 0
def read_pause_state(self):
return libdfhack.World_ReadPauseState(self._world_ptr) > 0
def read_current_tick(self):
tick = c_uint(0)

@ -266,16 +266,6 @@ DFHackObject* Context_getGui(DFHackObject* context)
return NULL;
}
DFHackObject* Context_getPosition(DFHackObject* context)
{
if(context != NULL)
{
return (DFHackObject*)((DFHack::Context*)context)->getPosition();
}
return NULL;
}
DFHackObject* Context_getMaterials(DFHackObject* context)
{
if(context != NULL)

@ -29,7 +29,7 @@ distribution.
#include "dfhack/DFTypes.h"
#include "dfhack/modules/Maps.h"
#include "dfhack/modules/Materials.h"
#include "dfhack/modules/Position.h"
#include "dfhack/modules/Gui.h"
#include "dfhack/DFTileTypes.h"
#define HBUILD(a) a ## BufferCallback

@ -36,8 +36,6 @@ extern "C" {
DFHACK_EXPORT int Gui_Start(DFHackObject* gui);
DFHACK_EXPORT int Gui_Finish(DFHackObject* gui);
DFHACK_EXPORT int Gui_ReadPauseState(DFHackObject* gui);
DFHACK_EXPORT int Gui_SetPauseState(DFHackObject* gui, int8_t paused);
DFHACK_EXPORT int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen);
DFHACK_EXPORT int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState);

@ -46,6 +46,8 @@ DFHACK_EXPORT int World_WriteCurrentWeather(DFHackObject* world, uint8_t weather
DFHACK_EXPORT int World_ReadGameMode(DFHackObject* world, t_gamemodes*);
DFHACK_EXPORT int World_WriteGameMode(DFHackObject* world, t_gamemodes);
DFHACK_EXPORT int World_ReadPauseState(DFHackObject* gui);
DFHACK_EXPORT int World_SetPauseState(DFHackObject* gui, int8_t paused);
#ifdef __cplusplus
}
#endif

@ -32,7 +32,6 @@ namespace DFHack
class Maps;
class Gui;
class World;
class Position;
class Materials;
class Items;
class Translation;
@ -94,9 +93,6 @@ namespace DFHack
/// get the world module
World * getWorld();
/// get the position module
Position * getPosition();
/// get the materials module
Materials * getMaterials();

@ -89,7 +89,6 @@ namespace DFHack
struct Private;
Private *d;
};
typedef class Gui Position;
}
#endif

@ -23,7 +23,7 @@ distribution.
*/
#include "dfhack-c/modules/Gui_C.h"
#include "dfhack-c/DFTypes_C.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -48,26 +48,21 @@ int Gui_Finish(DFHackObject* gui)
return -1;
}
int Gui_ReadPauseState(DFHackObject* gui)
int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen)
{
if(gui != NULL)
{
return ((DFHack::Gui*)gui)->ReadPauseState();
return ((DFHack::Gui*)gui)->ReadViewScreen(*viewscreen);
}
return -1;
}
int Gui_SetPauseState(DFHackObject* gui, int8_t paused)
int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState)
{
if(gui != NULL)
{
bool pauseState = false;
if(paused > 0)
pauseState = true;
((DFHack::Gui*)gui)->SetPauseState(pauseState);
*menuState = ((DFHack::Gui*)gui)->ReadMenuState();
return 1;
}
@ -75,28 +70,138 @@ int Gui_SetPauseState(DFHackObject* gui, int8_t paused)
return -1;
}
int Gui_ReadViewScreen(DFHackObject* gui, t_viewscreen* viewscreen)
int Gui_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
{
if(gui != NULL)
{
return ((DFHack::Gui*)gui)->ReadViewScreen(*viewscreen);
}
return -1;
if(pos != NULL)
{
int32_t tx, ty, tz;
if(((DFHack::Gui*)pos)->getViewCoords(tx, ty, tz))
{
*x = tx;
*y = ty;
*z = tz;
return 1;
}
else
return 0;
}
return -1;
}
int Gui_ReadMenuState(DFHackObject* gui, uint32_t* menuState)
int Gui_setViewCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
{
if(gui != NULL)
{
*menuState = ((DFHack::Gui*)gui)->ReadMenuState();
return 1;
}
return -1;
if(pos != NULL)
{
if(((DFHack::Gui*)pos)->setViewCoords(x, y, z))
return 1;
else
return 0;
}
return -1;
}
int Gui_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
{
if(pos != NULL)
{
int32_t tx, ty, tz;
if(((DFHack::Gui*)pos)->getCursorCoords(tx, ty, tz))
{
*x = tx;
*y = ty;
*z = tz;
return 1;
}
else
return 0;
}
return -1;
}
int Gui_setCursorCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
{
if(pos != NULL)
{
if(((DFHack::Gui*)pos)->setCursorCoords(x, y, z))
return 1;
else
return 0;
}
return -1;
}
t_hotkey* Gui_ReadHotkeys(DFHackObject* pos)
{
if(pos != NULL)
{
t_hotkey* buf = NULL;
(*alloc_hotkey_buffer_callback)(&buf, NUM_HOTKEYS);
if(buf != NULL)
{
if(((DFHack::Gui*)pos)->ReadHotkeys(buf))
return buf;
else
return NULL;
}
else
return NULL;
}
return NULL;
}
int Gui_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height)
{
if(pos != NULL)
{
int32_t tw, th;
if(((DFHack::Gui*)pos)->getWindowSize(tw, th))
{
*width = tw;
*height = th;
return 1;
}
else
return 0;
}
return -1;
}
t_screen* Gui_getScreenTiles(DFHackObject* pos, int32_t width, int32_t height)
{
if(pos != NULL)
{
t_screen* buf = NULL;
(*alloc_screen_buffer_callback)(&buf, width * height);
if(buf == NULL)
return NULL;
if(((DFHack::Gui*)pos)->getScreenTiles(width, height, buf))
return buf;
else
return NULL;
}
return NULL;
}
#ifdef __cplusplus
}
#endif

@ -29,136 +29,6 @@ distribution.
extern "C" {
#endif
int Position_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
{
if(pos != NULL)
{
int32_t tx, ty, tz;
if(((DFHack::Position*)pos)->getViewCoords(tx, ty, tz))
{
*x = tx;
*y = ty;
*z = tz;
return 1;
}
else
return 0;
}
return -1;
}
int Position_setViewCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
{
if(pos != NULL)
{
if(((DFHack::Position*)pos)->setViewCoords(x, y, z))
return 1;
else
return 0;
}
return -1;
}
int Position_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z)
{
if(pos != NULL)
{
int32_t tx, ty, tz;
if(((DFHack::Position*)pos)->getCursorCoords(tx, ty, tz))
{
*x = tx;
*y = ty;
*z = tz;
return 1;
}
else
return 0;
}
return -1;
}
int Position_setCursorCoords(DFHackObject* pos, int32_t x, int32_t y, int32_t z)
{
if(pos != NULL)
{
if(((DFHack::Position*)pos)->setCursorCoords(x, y, z))
return 1;
else
return 0;
}
return -1;
}
t_hotkey* Position_ReadHotkeys(DFHackObject* pos)
{
if(pos != NULL)
{
t_hotkey* buf = NULL;
(*alloc_hotkey_buffer_callback)(&buf, NUM_HOTKEYS);
if(buf != NULL)
{
if(((DFHack::Position*)pos)->ReadHotkeys(buf))
return buf;
else
return NULL;
}
else
return NULL;
}
return NULL;
}
int Position_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height)
{
if(pos != NULL)
{
int32_t tw, th;
if(((DFHack::Position*)pos)->getWindowSize(tw, th))
{
*width = tw;
*height = th;
return 1;
}
else
return 0;
}
return -1;
}
t_screen* Position_getScreenTiles(DFHackObject* pos, int32_t width, int32_t height)
{
if(pos != NULL)
{
t_screen* buf = NULL;
(*alloc_screen_buffer_callback)(&buf, width * height);
if(buf == NULL)
return NULL;
if(((DFHack::Position*)pos)->getScreenTiles(width, height, buf))
return buf;
else
return NULL;
}
return NULL;
}
#ifdef __cplusplus
}

@ -25,6 +25,7 @@ distribution.
#include "DFHack_C.h"
#include "dfhack/modules/World.h"
#include "dfhack-c/modules/World_C.h"
#include "dfhack-c/DFTypes_C.h"
#ifdef __cplusplus
extern "C" {
@ -148,6 +149,33 @@ int World_WriteGameMode(DFHackObject* world, t_gamemodes modes)
return -1;
}
int World_ReadPauseState(DFHackObject* gui)
{
if(gui != NULL)
{
return ((DFHack::World*)gui)->ReadPauseState();
}
return -1;
}
int World_SetPauseState(DFHackObject* gui, int8_t paused)
{
if(gui != NULL)
{
bool pauseState = false;
if(paused > 0)
pauseState = true;
((DFHack::World*)gui)->SetPauseState(pauseState);
return 1;
}
return -1;
}
#ifdef __cplusplus
}
#endif

@ -56,7 +56,7 @@ int main (int argc,const char* argv[])
DFHack::VersionInfo * mem = DF->getMemoryInfo();
DFHack::Buildings * Bld = DF->getBuildings();
DFHack::Position * Pos = DF->getPosition();
DFHack::Gui * Gui = DF->getGui();
uint32_t numBuildings;
if(Bld->Start(numBuildings))
@ -93,7 +93,7 @@ int main (int argc,const char* argv[])
else // mode
{
int32_t x,y,z;
Pos->getCursorCoords(x,y,z);
Gui->getCursorCoords(x,y,z);
if(x != -30000)
{
for(uint32_t i = 0; i < numBuildings; i++)

@ -31,7 +31,7 @@ int main (int numargs, const char ** args)
return 1;
}
DFHack::Position *Pos = DF->getPosition();
DFHack::Gui *Gui = DF->getGui();
DFHack::Constructions *Cons = DF->getConstructions();
DFHack::Materials *Mats = DF->getMaterials();
@ -41,7 +41,7 @@ int main (int numargs, const char ** args)
Cons->Start(numConstr);
int32_t cx, cy, cz;
Pos->getCursorCoords(cx,cy,cz);
Gui->getCursorCoords(cx,cy,cz);
if(cx != -30000)
{
t_construction con;

@ -26,7 +26,7 @@ int main (void)
}
DFHack::VersionInfo * mem = DF->getMemoryInfo();
DFHack::Position * Pos = DF->getPosition();
DFHack::Gui * Gui = DF->getGui();
// get stone matgloss mapping
/*
uint32_t numNotes;
@ -49,7 +49,7 @@ int main (void)
*/
cout << "Hotkeys" << endl;
DFHack::t_hotkey hotkeys[NUM_HOTKEYS];
Pos->ReadHotkeys(hotkeys);
Gui->ReadHotkeys(hotkeys);
for(uint32_t i =0;i< NUM_HOTKEYS;i++)
{
cout << "x: " << hotkeys[i].x << "\ty: " << hotkeys[i].y << "\tz: " << hotkeys[i].z <<

@ -88,7 +88,7 @@ int main (int numargs, const char ** args)
}
DFHack::Maps *Maps =DF->getMaps();
DFHack::Position *Pos =DF->getPosition();
DFHack::Gui *Gui =DF->getGui();
DFHack::Materials *Mats =DF->getMaterials();
Mats->ReadCreatureTypes();
@ -105,7 +105,7 @@ int main (int numargs, const char ** args)
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Pos->getCursorCoords(cx,cy,cz);
Gui->getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
// walk the map

@ -61,14 +61,14 @@ int main (int numargs, const char ** args)
DFHack::Process* p = DF->getProcess();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Position * pos = DF->getPosition();
DFHack::Gui * Gui = DF->getGui();
DFHack::Vegetation * v = DF->getVegetation();
DFHack::Maps * mps = DF->getMaps();
DFHack::Materials * mat = DF->getMaterials();
mat->ReadOrganicMaterials();
int32_t x,y,z;
pos->getCursorCoords(x,y,z);
Gui->getCursorCoords(x,y,z);
uint32_t numVegs = 0;
v->Start(numVegs);

@ -158,7 +158,7 @@ int main (int numargs, const char ** args)
return 1;
}
DFHack::Position *Pos = DF->getPosition();
DFHack::Gui *Gui = DF->getGui();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Process * p = DF->getProcess();
OffsetGroup * OG_Maps = mem->getGroup("Maps");
@ -185,7 +185,7 @@ int main (int numargs, const char ** args)
cout << "Set cursor at first position, then press any key";
cin.ignore();
DF->Suspend();
Pos->getCursorCoords(cx1,cy1,cz1);
Gui->getCursorCoords(cx1,cy1,cz1);
}
uint32_t tx1,ty1,tz1;
@ -200,7 +200,7 @@ int main (int numargs, const char ** args)
cout << "Set cursor at second position, then press any key";
cin.ignore();
DF->Suspend();
Pos->getCursorCoords(cx2,cy2,cz2);
Gui->getCursorCoords(cx2,cy2,cz2);
}
uint32_t tx2,ty2,tz2;
tx2 = cx2/16;
@ -315,7 +315,7 @@ int main (int numargs, const char ** args)
cout << "Set cursor at new position, then press any key:";
result = cin.get();
DF->Suspend();
Pos->getCursorCoords(cx3,cy3,cz3);
Gui->getCursorCoords(cx3,cy3,cz3);
}
if(result == 'q'){
break;

@ -26,11 +26,11 @@ using namespace std;
#define BLOCK_SIZE 16
void dig(DFHack::Maps* layers, DFHack::Position* position, ::std::vector< ::std::string >& dig_map, bool verbose = false) {
void dig(DFHack::Maps* layers, DFHack::Gui* Gui, ::std::vector< ::std::string >& dig_map, bool verbose = false) {
int32_t x_cent;
int32_t y_cent;
int32_t z_cent;
position->getCursorCoords(x_cent, y_cent, z_cent);
Gui->getCursorCoords(x_cent, y_cent, z_cent);
// ::std::cout << "x_cent: " << x_cent << " y_cent: " << y_cent << " z_cent: " << z_cent << ::std::endl;
@ -154,7 +154,7 @@ int main(int argc, char** argv) {
DFHack::Maps *layers = DF->getMaps();
if (layers && layers->Start()) {
dig(layers, DF->getPosition(), dig_map, true);
dig(layers, DF->getGui(), dig_map, true);
::std::cout << "Finished digging" << ::std::endl;
layers->Finish();

@ -630,8 +630,8 @@ int main (void)
//Get cursor
int32_t cursorX, cursorY, cursorZ;
DFHack::Position *Pos = DF->getPosition();
Pos->getCursorCoords(cursorX,cursorY,cursorZ);
DFHack::Gui *Gui = DF->getGui();
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if (-30000==cursorX)
{
cout << "No cursor position found. Exiting." << endl;

@ -11,11 +11,11 @@ if not df.attach():
raw_input()
sys.exit(1)
pos = df.position
gui = df.gui
print "view coords: %s" % (pos.view_coords,)
print "cursor coords: %s" % (pos.cursor_coords,)
print "window size: %s" % (pos.window_size,)
print "view coords: %s" % (gui.view_coords,)
print "cursor coords: %s" % (gui.cursor_coords,)
print "window size: %s" % (gui.window_size,)
if not df.detach():
print "Unable to detach!"

@ -5,12 +5,12 @@ df = cm.get_single_context()
df.attach()
pos = df.position
gui = df.gui
veg = df.vegetation
mps = df.maps
mat = df.materials
x, y, z = pos.get_cursor_coords()
x, y, z = gui.get_cursor_coords()
num_veg = veg.start()

@ -36,10 +36,10 @@ int main (int argc, char** argv)
return 1;
}
DFHack::Gui *Gui =DF->getGui();
DFHack::World *World =DF->getWorld();
cout << "Pausing..." << endl;
Gui->SetPauseState(true);
World->SetPauseState(true);
DF->Resume();
#ifndef LINUX_BUILD
cout << "Done. The current game frame will have to finish first. This can take some time on bugged maps." << endl;

@ -463,7 +463,7 @@ void FindCoords(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ran
DFMgr.Refresh();
DFHack::Context * DF = DFMgr.getSingleContext();
DF->Attach();
DFHack::Position * pos = DF->getPosition();
DFHack::Gui * pos = DF->getGui();
pos->Start();
int32_t x, y, z;
pos->getCursorCoords(x,y,z);

@ -150,7 +150,7 @@ int main (int argc, char** argv)
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
DFHack::Maps * Maps;
DFHack::Position * Position;
DFHack::Gui * Position;
Brush * brush = new RectangleBrush(1,1);
try
{
@ -159,7 +159,7 @@ int main (int argc, char** argv)
Maps = DF->getMaps();
Maps->Start();
Maps->getSize(x_max,y_max,z_max);
Position = DF->getPosition();
Position = DF->getGui();
}
catch (exception& e)
{

@ -47,7 +47,7 @@ int main (int argc, char** argv)
}
}
DFHack::Position * Position = 0;
DFHack::Gui * Gui = 0;
DFHack::World * World = 0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
@ -55,7 +55,7 @@ int main (int argc, char** argv)
{
DF = DFMgr.getSingleContext();
DF->Attach();
Position = DF->getPosition();
Gui = DF->getGui();
World = DF->getWorld();
}
catch (exception& e)
@ -75,16 +75,16 @@ int main (int argc, char** argv)
<< " Month: " << World->ReadCurrentMonth()
<< " Day: " << World->ReadCurrentDay()
<< " Tick: " << World->ReadCurrentTick() << endl;
if (Position)
if (Gui)
{
int32_t x,y,z;
int32_t width,height;
if(Position->getViewCoords(x,y,z))
if(Gui->getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
if(Position->getCursorCoords(x,y,z))
if(Gui->getCursorCoords(x,y,z))
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
if(Position->getWindowSize(width,height))
if(Gui->getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
}
else

@ -35,7 +35,7 @@ int main (int numargs, const char ** args)
}
DFHack::Position *Pos = DF->getPosition();
DFHack::Gui *Gui = DF->getGui();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Maps *Maps = DF->getMaps();
DFHack::Process * p = DF->getProcess();
@ -65,7 +65,7 @@ int main (int numargs, const char ** args)
bool have_global = Maps->ReadGlobalFeatures(global_features);
int32_t cursorX, cursorY, cursorZ;
Pos->getCursorCoords(cursorX,cursorY,cursorZ);
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX != -30000)
{
uint32_t blockX = cursorX / 16;

@ -52,7 +52,7 @@ int main (void)
}
DFHack::Maps *Maps =DF->getMaps();
DFHack::Gui *Gui =DF->getGui();
DFHack::World *World =DF->getWorld();
// walk the map, save the hide bits, reveal.
cout << "Pausing..." << endl;
@ -60,7 +60,7 @@ int main (void)
// preblem here is that we could be 'arriving' at the wrong time and DF could be in the middle of a frame.
// that could mean that revealing, even with suspending DF's thread, would mean unleashing hell *in the same frame*
// this here hack sets the pause state, resumes DF, waits a second for it to enter the pause (I know, BS value.) and suspends.
Gui->SetPauseState(true);
World->SetPauseState(true);
DF->Resume();
waitmsec(1000);
DF->Suspend();

@ -52,7 +52,7 @@ int main (int argc, char* argv[])
uint32_t x_max,y_max,z_max;
DFHack::Maps * Maps = DF->getMaps();
DFHack::Position * Pos = DF->getPosition();
DFHack::Gui * Gui = DF->getGui();
// init the map
if(!Maps->Start())
@ -70,14 +70,14 @@ int main (int argc, char* argv[])
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Pos->getCursorCoords(cx,cy,cz);
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
cerr << "Cursor is not active. Point the cursor at a vein." << endl;
DF->Resume();
cin.ignore();
DF->Suspend();
Pos->getCursorCoords(cx,cy,cz);
Gui->getCursorCoords(cx,cy,cz);
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)