first commit Read/Write Designations works

Signed-off-by: doomchild <doomchild@theyfear.us>
develop
unknown 2010-03-31 17:33:36 -05:00 committed by doomchild
parent c631270425
commit 93058506e0
6 changed files with 1564 additions and 0 deletions

@ -0,0 +1,909 @@
#ifndef __DFAPI__
#define __DFAPI__
#include "Python.h"
#include <string>
#include <vector>
#include "DFTypes.h"
#include "DFHackAPI.h"
#include "UnionBase.cpp"
using namespace std;
using namespace DFHack;
struct DF_API
{
PyObject_HEAD
DFHack::API* api_Ptr;
};
// API type Allocation, Deallocation, and Initialization
static PyObject* DF_API_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_API* self;
self = (DF_API*)type->tp_alloc(type, 0);
if(self != NULL)
self->api_Ptr = NULL;
return (PyObject*)self;
}
static int DF_API_init(DF_API* self, PyObject* args, PyObject* kwds)
{
const char* memFileString = NULL;
if(self->api_Ptr == NULL)
{
if(!PyArg_ParseTuple(args, "s", &memFileString))
return -1;
if(memFileString)
self->api_Ptr = new DFHack::API(std::string(memFileString));
else
return -1;
}
return 0;
}
static void DF_API_dealloc(DF_API* self)
{
if(self != NULL)
{
if(self->api_Ptr != NULL)
{
delete self->api_Ptr;
self->api_Ptr = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
}
// Accessors
static PyObject* DF_API_getIsAttached(DF_API* self, void* closure)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->isAttached())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read attached flag");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_getIsSuspended(DF_API* self, void* closure)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->isSuspended())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read suspension flag");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_getIsPaused(DF_API* self, void* closure)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->ReadPauseState())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read pause state");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_getMenuState(DF_API* self, void* closure)
{
uint32_t menuState = 0;
try
{
if(self->api_Ptr != NULL)
{
menuState = self->api_Ptr->ReadMenuState();
return PyInt_FromLong(menuState);
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read menu state");
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
static PyObject* DF_API_getViewCoords(DF_API* self, void* closure)
{
int32_t x, y, z;
bool success;
try
{
if(self->api_Ptr != NULL)
{
success = self->api_Ptr->getViewCoords(x, y, z);
if(success)
{
return Py_BuildValue("iii", x, y, z);
}
else
Py_RETURN_NONE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to get view coordinates");
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
static PyObject* DF_API_getSize(DF_API* self, void* closure)
{
uint32_t x, y, z;
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->getSize(x, y, z);
return Py_BuildValue("III", x, y, z);
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to get view coordinates");
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
static PyGetSetDef DF_API_getterSetters[] =
{
{"is_attached", (getter)DF_API_getIsAttached, NULL, "is_attached", NULL},
{"is_suspended", (getter)DF_API_getIsSuspended, NULL, "is_suspended", NULL},
{"is_paused", (getter)DF_API_getIsPaused, NULL, "is_paused", NULL},
{"menu_state", (getter)DF_API_getMenuState, NULL, "menu_state", NULL},
{"view_coords", (getter)DF_API_getViewCoords, NULL, "view_coords", NULL},
{"map_size", (getter)DF_API_getSize, NULL, "max_size", NULL},
{NULL} // Sentinel
};
// API type methods
static PyObject* DF_API_Attach(DF_API* self)
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->Attach())
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* DF_API_Detach(DF_API* self)
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->Detach())
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* DF_API_Suspend(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->Suspend())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to suspend");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_Resume(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->Resume())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to resume");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_AsyncSuspend(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->AsyncSuspend())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to asynchronously suspend");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_ForceResume(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->ForceResume())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to force resume");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitMap(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitMap())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to initialize map");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_DestroyMap(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->DestroyMap())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to destroy map");
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadConstructions(DF_API* self)
{
uint32_t numConstructions = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadConstructions(numConstructions))
return PyInt_FromLong(numConstructions);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read constructions");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadConstructions(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadConstructions();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading constructions");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadBuildings(DF_API* self)
{
uint32_t numBuildings = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadBuildings(numBuildings))
return PyInt_FromLong(numBuildings);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read buildings");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadBuildings(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadBuildings();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading buildings");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadEffects(DF_API* self)
{
uint32_t numEffects = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadEffects(numEffects))
return PyInt_FromLong(numEffects);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read effects");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadEffects(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadEffects();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading effects");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadVegetation(DF_API* self)
{
uint32_t numVegetation = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadVegetation(numVegetation))
return PyInt_FromLong(numVegetation);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read vegetation");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadVegetation(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadVegetation();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading vegetation");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadCreatures(DF_API* self)
{
uint32_t numCreatures = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadCreatures(numCreatures))
return PyInt_FromLong(numCreatures);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read creatures");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadCreatures(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadCreatures();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading creatures");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadNotes(DF_API* self)
{
uint32_t numNotes = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadNotes(numNotes))
return PyInt_FromLong(numNotes);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read notes");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadNotes(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadNotes();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading notes");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadSettlements(DF_API* self)
{
uint32_t numSettlements = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadSettlements(numSettlements))
return PyInt_FromLong(numSettlements);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read settlements");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadSettlements(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadSettlements();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading settlements");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadItems(DF_API* self)
{
uint32_t numItems = 0;
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadItems(numItems))
return PyInt_FromLong(numItems);
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read items");
}
Py_RETURN_NONE;
}
static PyObject* DF_API_FinishReadItems(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
{
self->api_Ptr->FinishReadItems();
Py_RETURN_TRUE;
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to finish reading items");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitReadHotkeys(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitReadHotkeys())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to initialize hotkey reader");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_InitViewSize(DF_API* self)
{
try
{
if(self->api_Ptr != NULL)
if(self->api_Ptr->InitViewSize())
Py_RETURN_TRUE;
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to initialize view size");
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_IsValidBlock(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
bool valid;
if(self->api_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "III", &blockx, &blocky, &blockz))
Py_RETURN_NONE;
valid = self->api_Ptr->isValidBlock(blockx, blocky, blockz);
if(valid)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_ReadDesignations(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
DFHack::designations40d designations;
PyObject* list = NULL;
if(self->api_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "III", &blockx, &blocky, &blockz))
Py_RETURN_NONE;
self->api_Ptr->ReadDesignations(blockx, blocky, blockz, &designations);
list = PyList_New(16);
for(int i = 0; i < 16; i++)
{
PyObject* innerList = PyList_New(16);
for(int j = 0; j < 16; j++)
{
PyList_SetItem(innerList, j, PyInt_FromLong(designations[i][j].whole));
}
PyList_SetItem(list, i, innerList);
}
}
return list;
}
static PyObject* DF_API_WriteDesignations(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
DFHack::designations40d designations;
PyObject* list;
if(self->api_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "IIIO", &blockx, &blocky, &blockz, &list))
Py_RETURN_NONE;
for(int i = 0; i < 16; i++)
{
PyObject* innerList = PyList_GetItem(list, i);
for(int j = 0; j < 16; j++)
{
UnionBase* obj = (UnionBase*)PyList_GetItem(innerList, j);
designations[i][j].whole = obj->whole;
}
}
self->api_Ptr->WriteDesignations(blockx, blocky, blockz, &designations);
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_ReadOccupancy(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
DFHack::occupancies40d occupancies;
PyObject* list = NULL;
if(self->api_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "III", &blockx, &blocky, &blockz))
Py_RETURN_NONE;
self->api_Ptr->ReadOccupancy(blockx, blocky, blockz, &occupancies);
list = PyList_New(16);
for(int i = 0; i < 16; i++)
{
PyObject* innerList = PyList_New(16);
for(int j = 0; j < 16; j++)
{
PyList_SetItem(innerList, j, PyInt_FromLong(occupancies[i][j].whole));
}
PyList_SetItem(list, i, innerList);
}
}
return list;
}
static PyObject* DF_API_WriteOccupancy(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
DFHack::occupancies40d occupancies;
PyObject* list;
if(self->api_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "IIIO", &blockx, &blocky, &blockz, &list))
Py_RETURN_NONE;
for(int i = 0; i < 16; i++)
{
PyObject* innerList = PyList_GetItem(list, i);
for(int j = 0; j < 16; j++)
{
UnionBase* obj = (UnionBase*)PyList_GetItem(innerList, j);
occupancies[i][j].whole = obj->whole;
}
}
self->api_Ptr->WriteOccupancy(blockx, blocky, blockz, &occupancies);
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
}
static PyObject* DF_API_ReadDirtyBit(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
bool dirty;
if(self->api_Ptr == NULL)
return NULL;
else
{
if(!PyArg_ParseTuple(args, "III", &blockx, &blocky, &blockz))
return NULL;
self->api_Ptr->ReadDirtyBit(blockx, blocky, blockz, dirty);
if(dirty)
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
}
static PyObject* DF_API_WriteDirtyBit(DF_API* self, PyObject* args)
{
uint32_t blockx, blocky, blockz;
int dirtyFlag;
if(self->api_Ptr == NULL)
return NULL;
else
{
if(!PyArg_ParseTuple(args, "IIIi", &blockx, &blocky, &blockz, &dirtyFlag))
return NULL;
self->api_Ptr->WriteDirtyBit(blockx, blocky, blockz, dirtyFlag);
Py_RETURN_TRUE;
}
}
static PyMethodDef DF_API_methods[] =
{
{"Attach", (PyCFunction)DF_API_Attach, METH_NOARGS, "Attach to the DF process"},
{"Detach", (PyCFunction)DF_API_Detach, METH_NOARGS, "Detach from the DF process"},
{"Suspend", (PyCFunction)DF_API_Suspend, METH_NOARGS, "Suspend the DF process"},
{"Resume", (PyCFunction)DF_API_Resume, METH_NOARGS, "Resume the DF process"},
{"Async_Suspend", (PyCFunction)DF_API_AsyncSuspend, METH_NOARGS, "Asynchronously suspend the DF process"},
{"Force_Resume", (PyCFunction)DF_API_ForceResume, METH_NOARGS, "Force the DF process to resume"},
{"Init_Map", (PyCFunction)DF_API_InitMap, METH_NOARGS, "Initialize the DFHack map reader"},
{"Destroy_Map", (PyCFunction)DF_API_DestroyMap, METH_NOARGS, "Shut down the DFHack map reader"},
{"Init_Read_Constructions", (PyCFunction)DF_API_InitReadConstructions, METH_NOARGS, "Initialize construction reader"},
{"Finish_Read_Constructions", (PyCFunction)DF_API_FinishReadConstructions, METH_NOARGS, "Shut down construction reader"},
{"Init_Read_Buildings", (PyCFunction)DF_API_InitReadBuildings, METH_NOARGS, "Initialize building reader"},
{"Finish_Read_Buildings", (PyCFunction)DF_API_FinishReadBuildings, METH_NOARGS, "Shut down building reader"},
{"Init_Read_Effects", (PyCFunction)DF_API_InitReadEffects, METH_NOARGS, "Initialize effect reader"},
{"Finish_Read_Effects", (PyCFunction)DF_API_FinishReadEffects, METH_NOARGS, "Shut down effect reader"},
{"Init_Read_Vegetation", (PyCFunction)DF_API_InitReadVegetation, METH_NOARGS, "Initialize vegetation reader"},
{"Finish_Read_Vegetation", (PyCFunction)DF_API_FinishReadVegetation, METH_NOARGS, "Shut down vegetation reader"},
{"Init_Read_Creatures", (PyCFunction)DF_API_InitReadCreatures, METH_NOARGS, "Initialize creature reader"},
{"Finish_Read_Creatures", (PyCFunction)DF_API_FinishReadCreatures, METH_NOARGS, "Shut down creature reader"},
{"Init_Read_Notes", (PyCFunction)DF_API_InitReadNotes, METH_NOARGS, "Initialize note reader"},
{"Finish_Read_Notes", (PyCFunction)DF_API_FinishReadNotes, METH_NOARGS, "Shut down note reader"},
{"Init_Read_Settlements", (PyCFunction)DF_API_InitReadSettlements, METH_NOARGS, "Initialize settlement reader"},
{"Finish_Read_Settlements", (PyCFunction)DF_API_FinishReadSettlements, METH_NOARGS, "Shut down settlement reader"},
{"Init_Read_Items", (PyCFunction)DF_API_InitReadItems, METH_NOARGS, "Initialize item reader"},
{"Finish_Read_Items", (PyCFunction)DF_API_FinishReadItems, METH_NOARGS, "Shut down item reader"},
{"Init_Read_Hotkeys", (PyCFunction)DF_API_InitReadHotkeys, METH_NOARGS, "Initialize hotkey reader"},
{"Init_View_Size", (PyCFunction)DF_API_InitViewSize, METH_NOARGS, "Initialize view size reader"},
{"Is_Valid_Block", (PyCFunction)DF_API_IsValidBlock, METH_VARARGS, ""},
{"Read_Designations", (PyCFunction)DF_API_ReadDesignations, METH_VARARGS, "Read a block's designations"},
{"Write_Designations", (PyCFunction)DF_API_WriteDesignations, METH_VARARGS, ""},
{"Read_Occupancy", (PyCFunction)DF_API_ReadOccupancy, METH_VARARGS, ""},
{"Write_Occupancy", (PyCFunction)DF_API_WriteOccupancy, METH_VARARGS, ""},
{"Read_Dirty_Bit", (PyCFunction)DF_API_ReadDirtyBit, METH_VARARGS, ""},
{"Write_Dirty_Bit", (PyCFunction)DF_API_WriteDirtyBit, METH_VARARGS, ""},
{NULL} // Sentinel
};
static PyTypeObject DF_API_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.API", /*tp_name*/
sizeof(DF_API), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)DF_API_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"pydfhack API objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DF_API_methods, /* tp_methods */
0, /* tp_members */
DF_API_getterSetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)DF_API_init, /* tp_init */
0, /* tp_alloc */
DF_API_new, /* tp_new */
};
#endif

@ -0,0 +1,191 @@
#ifndef __UNIONBASE__
#define __UNIONBASE__
#include <Python.h>
struct UnionBase
{
PyObject_HEAD
unsigned int whole;
};
static PyObject* UnionBase_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
UnionBase* self;
self = (UnionBase*)type->tp_alloc(type, 0);
if(self != NULL)
self->whole = 0;
else
return NULL;
return (PyObject*)self;
}
static int UnionBase_init(UnionBase* self, PyObject* args, PyObject* kwds)
{
if(!PyArg_ParseTuple(args, "|I", &self->whole))
return -1;
return 0;
}
static void UnionBase_dealloc(UnionBase* self)
{
self->ob_type->tp_free((PyObject*)self);
}
static PyObject* UnionBase_GetBitMask(UnionBase* self, PyObject* args)
{
unsigned int mask;
if(!PyArg_ParseTuple(args, "I", &mask))
Py_RETURN_NONE;
if((self->whole & mask) != 0)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* UnionBase_SetBitMask(UnionBase* self, PyObject* args)
{
unsigned int mask;
int on;
if(!PyArg_ParseTuple(args, "Ii", &mask, &on))
return NULL;
if(on)
self->whole |= mask;
else
self->whole &= ~mask;
Py_RETURN_TRUE;
}
static PyObject* UnionBase_GetSingleBit(UnionBase* self, PyObject* args)
{
unsigned int mask;
if(!PyArg_ParseTuple(args, "I", &mask))
Py_RETURN_NONE;
if((self->whole & (1 << mask)) != 0)
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
static PyObject* UnionBase_SetSingleBit(UnionBase* self, PyObject* args)
{
unsigned int mask;
int on;
if(!PyArg_ParseTuple(args, "Ii", &mask, &on))
return NULL;
if(on)
self->whole |= (1 << mask);
else
self->whole &= ~(1 << mask);
Py_RETURN_TRUE;
}
static PyObject* UnionBase_int(PyObject* self)
{
return PyInt_FromLong(((UnionBase*)self)->whole);
}
static PyObject* UnionBase_long(PyObject* self)
{
return PyInt_FromLong(((UnionBase*)self)->whole);
}
static PyObject* UnionBase_hex(PyObject* self)
{
return PyNumber_ToBase(PyInt_FromLong(((UnionBase*)self)->whole), 16);
}
static PyMethodDef UnionBase_methods[] =
{
{"_get_mask_bit", (PyCFunction)UnionBase_GetSingleBit, METH_VARARGS, "Get mask bit"},
{"_set_mask_bit", (PyCFunction)UnionBase_SetSingleBit, METH_VARARGS, "Set mask bit"},
{"_get_mask", (PyCFunction)UnionBase_GetBitMask, METH_VARARGS, ""},
{"_set_mask", (PyCFunction)UnionBase_SetBitMask, METH_VARARGS, ""},
{NULL} //Sentinel
};
static PyNumberMethods UnionBase_as_number[] =
{
0, // binaryfunc nb_add; /* __add__ */
0, // binaryfunc nb_subtract; /* __sub__ */
0, // binaryfunc nb_multiply; /* __mul__ */
0, // binaryfunc nb_divide; /* __div__ */
0, // binaryfunc nb_remainder; /* __mod__ */
0, // binaryfunc nb_divmod; /* __divmod__ */
0, // ternaryfunc nb_power; /* __pow__ */
0, // unaryfunc nb_negative; /* __neg__ */
0, // unaryfunc nb_positive; /* __pos__ */
0, // unaryfunc nb_absolute; /* __abs__ */
0, // inquiry nb_nonzero; /* __nonzero__ */
0, // unaryfunc nb_invert; /* __invert__ */
0, // binaryfunc nb_lshift; /* __lshift__ */
0, // binaryfunc nb_rshift; /* __rshift__ */
0, // binaryfunc nb_and; /* __and__ */
0, // binaryfunc nb_xor; /* __xor__ */
0, // binaryfunc nb_or; /* __or__ */
0, // coercion nb_coerce; /* __coerce__ */
UnionBase_int, // unaryfunc nb_int; /* __int__ */
UnionBase_long, // unaryfunc nb_long; /* __long__ */
0, // unaryfunc nb_float; /* __float__ */
0, // unaryfunc nb_oct; /* __oct__ */
UnionBase_hex, // unaryfunc nb_hex; /* __hex__ */
};
static PyTypeObject UnionBase_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.UnionBase", /*tp_name*/
sizeof(UnionBase), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)UnionBase_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
UnionBase_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
0, /*tp_call*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
"pydfhack UnionBase objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
UnionBase_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)UnionBase_init, /* tp_init */
0, /* tp_alloc */
UnionBase_new, /* tp_new */
};
#endif

@ -0,0 +1,31 @@
#include "Python.h"
#include "UnionBase.cpp"
#include "DF_API.cpp"
#ifndef PyMODINIT_FUNC
#define PyMODINIT_FUNC void
#endif
static PyMethodDef module_methods[] =
{
{NULL} //Sentinel
};
PyMODINIT_FUNC initpydfhack(void)
{
PyObject* module;
if(PyType_Ready(&UnionBase_type) < 0)
return;
if(PyType_Ready(&DF_API_type) < 0)
return;
module = Py_InitModule3("pydfhack", module_methods, "pydfhack extension module");
Py_INCREF(&UnionBase_type);
Py_INCREF(&DF_API_type);
PyModule_AddObject(module, "UnionBase", (PyObject*)&UnionBase_type);
PyModule_AddObject(module, "API", (PyObject*)&DF_API_type);
}

@ -0,0 +1,423 @@
from pydfhack import *
class DFAPI(API):
def Read_Designations(self, x, y, z):
d_list = [DesignationFlags(d) for d in API.Read_Designations(self, x, y, z)]
return d_list
def Read_Occupancy(self, x, y, z):
o_list = [OccupancyFlags(o) for o in API.Read_Occupancy(self, x, y, z)]
return o_list
class CreatureFlags1(_UnionBase):
move_state = property(fget = lambda self: self._get_mask_bit(0),
fset = lambda self, val: self._set_mask_bit(0, val))
dead = property(fget = lambda self: self._get_mask_bit(1),
fset = lambda self, val: self._set_mask_bit(1, val))
has_mood = property(fget = lambda self: self._get_mask_bit(2),
fset = lambda self, val: self._set_mask_bit(2, val))
had_mood = property(fget = lambda self: self._get_mask_bit(3),
fset = lambda self, val: self._set_mask_bit(3, val))
marauder = property(fget = lambda self: self._get_mask_bit(4),
fset = lambda self, val: self._set_mask_bit(4, val))
drowning = property(fget = lambda self: self._get_mask_bit(5),
fset = lambda self, val: self._set_mask_bit(5, val))
merchant = property(fget = lambda self: self._get_mask_bit(6),
fset = lambda self, val: self._set_mask_bit(6, val))
forest = property(fget = lambda self: self._get_mask_bit(7),
fset = lambda self, val: self._set_mask_bit(7, val))
left = property(fget = lambda self: self._get_mask_bit(8),
fset = lambda self, val: self._set_mask_bit(8, val))
rider = property(fget = lambda self: self._get_mask_bit(9),
fset = lambda self, val: self._set_mask_bit(9, val))
incoming = property(fget = lambda self: self._get_mask_bit(10),
fset = lambda self, val: self._set_mask_bit(10, val))
diplomat = property(fget = lambda self: self._get_mask_bit(11),
fset = lambda self, val: self._set_mask_bit(11, val))
zombie = property(fget = lambda self: self._get_mask_bit(12),
fset = lambda self: self._set_mask_bit(12, val))
skeleton = property(fget = lambda self: self._get_mask_bit(13),
fset = lambda self, val: self._set_mask_bit(13, val))
can_swap = property(fget = lambda self: self._get_mask_bit(14),
fset = lambda self, val: self._set_mask_bit(14, val))
on_ground = property(fget = lambda self: self._get_mask_bit(15),
fset = lambda self, val: self._set_mask_bit(15, val))
projectile = property(fget = lambda self: self._get_mask_bit(16),
fset = lambda self, val: self._set_mask_bit(16, val))
active_invader = property(fget = lambda self: self._get_mask_bit(17),
fset = lambda self, val: self._set_mask_bit(17, val))
hidden_in_ambush = property(fget = lambda self: self._get_mask_bit(18),
fset = lambda self, val: self._set_mask_bit(18, val))
invader_origin = property(fget = lambda self: self._get_mask_bit(19),
fset = lambda self, val: self._set_mask_bit(19, val))
coward = property(fget = lambda self: self._get_mask_bit(20),
fset = lambda self, val: self._set_mask_bit(20, val))
hidden_ambusher = property(fget = lambda self: self._get_mask_bit(21),
fset = lambda self, val: self._set_mask_bit(21, val))
invades = property(fget = lambda self: self._get_mask_bit(22),
fset = lambda self, val: self._set_mask_bit(22, val))
check_flows = property(fget = lambda self: self._get_mask_bit(23),
fset = lambda self, val: self._set_mask_bit(23, val))
ridden = property(fget = lambda self: self._get_mask_bit(24),
fset = lambda self, val: self._set_mask_bit(24, val))
caged = property(fget = lambda self: self._get_mask_bit(25),
fset = lambda self, val: self._set_mask_bit(25, val))
tame = property(fget = lambda self: self._get_mask_bit(26),
fset = lambda self, val: self._set_mask_bit(26, val))
chained = property(fget = lambda self: self._get_mask_bit(27),
fset = lambda self, val: self._set_mask_bit(27, val))
royal_guard = property(fget = lambda self: self._get_mask_bit(28),
fset = lambda self, val: self._set_mask_bit(28, val))
fortress_guard = property(fget = lambda self: self._get_mask_bit(29),
fset = lambda self, val: self._set_mask_bit(29, val))
suppress_wield = property(fget = lambda self: self._get_mask_bit(30),
fset = lambda self, val: self._set_mask_bit(30, val))
important_historial_figure = property(fget = lambda self: self._get_mask_bit(31),
fset = lambda self, val: self._set_mask_bit(31, val))
class CreatureFlags2(_UnionBase):
swimming = property(fget = lambda self: self._get_mask_bit(0),
fset = lambda self, val: self._set_mask_bit(0, val))
sparring = property(fget = lambda self: self._get_mask_bit(1),
fset = lambda self, val: self._set_mask_bit(1, val))
no_notify = property(fget = lambda self: self._get_mask_bit(2),
fset = lambda self, val: self._set_mask_bit(2, val))
unused = property(fget = lambda self: self._get_mask_bit(3),
fset = lambda self, val: self._set_mask_bit(3, val))
calculated_nerves = property(fget = lambda self: self._get_mask_bit(4),
fset = lambda self, val: self._set_mask_bit(4, val))
calculated_bodyparts = property(fget = lambda self: self._get_mask_bit(5),
fset = lambda self, val: self._set_mask_bit(5, val))
important_historical_figure = property(fget = lambda self: self._get_mask_bit(6),
fset = lambda self, val: self._set_mask_bit(6, val))
killed = property(fget = lambda self: self._get_mask_bit(7),
fset = lambda self, val: self._set_mask_bit(7, val))
cleanup_1 = property(fget = lambda self: self._get_mask_bit(8),
fset = lambda self, val: self._set_mask_bit(8, val))
cleanup_2 = property(fget = lambda self: self._get_mask_bit(9),
fset = lambda self, val: self._set_mask_bit(9, val))
cleanup_3 = property(fget = lambda self: self._get_mask_bit(10),
fset = lambda self, val: self._set_mask_bit(10, val))
for_trade = property(fget = lambda self: self._get_mask_bit(11),
fset = lambda self, val: self._set_mask_bit(11, val))
trade_resolved = property(fget = lambda self: self._get_mask_bit(12),
fset = lambda self: self._set_mask_bit(12, val))
has_breaks = property(fget = lambda self: self._get_mask_bit(13),
fset = lambda self, val: self._set_mask_bit(13, val))
gutted = property(fget = lambda self: self._get_mask_bit(14),
fset = lambda self, val: self._set_mask_bit(14, val))
circulatory_spray = property(fget = lambda self: self._get_mask_bit(15),
fset = lambda self, val: self._set_mask_bit(15, val))
locked_in_for_trading = property(fget = lambda self: self._get_mask_bit(16),
fset = lambda self, val: self._set_mask_bit(16, val))
slaughter = property(fget = lambda self: self._get_mask_bit(17),
fset = lambda self, val: self._set_mask_bit(17, val))
underworld = property(fget = lambda self: self._get_mask_bit(18),
fset = lambda self, val: self._set_mask_bit(18, val))
resident = property(fget = lambda self: self._get_mask_bit(19),
fset = lambda self, val: self._set_mask_bit(19, val))
cleanup_4 = property(fget = lambda self: self._get_mask_bit(20),
fset = lambda self, val: self._set_mask_bit(20, val))
calculated_insulation = property(fget = lambda self: self._get_mask_bit(21),
fset = lambda self, val: self._set_mask_bit(21, val))
visitor_uninvited = property(fget = lambda self: self._get_mask_bit(22),
fset = lambda self, val: self._set_mask_bit(22, val))
visitor = property(fget = lambda self: self._get_mask_bit(23),
fset = lambda self, val: self._set_mask_bit(23, val))
calculated_inventory = property(fget = lambda self: self._get_mask_bit(24),
fset = lambda self, val: self._set_mask_bit(24, val))
vision_good = property(fget = lambda self: self._get_mask_bit(25),
fset = lambda self, val: self._set_mask_bit(25, val))
vision_damaged = property(fget = lambda self: self._get_mask_bit(26),
fset = lambda self, val: self._set_mask_bit(26, val))
vision_missing = property(fget = lambda self: self._get_mask_bit(27),
fset = lambda self, val: self._set_mask_bit(27, val))
breathing_good = property(fget = lambda self: self._get_mask_bit(28),
fset = lambda self, val: self._set_mask_bit(28, val))
breathing_problem = property(fget = lambda self: self._get_mask_bit(29),
fset = lambda self, val: self._set_mask_bit(29, val))
roaming_wilderness_population_source = property(fget = lambda self: self._get_mask_bit(30),
fset = lambda self, val: self._set_mask_bit(30, val))
roaming_wilderness_population_source_not_a_map_feature = property(fget = lambda self: self._get_mask_bit(31),
fset = lambda self, val: self._set_mask_bit(31, val))
class ItemFlags(_UnionBase):
on_ground = property(fget = lambda self: self._get_mask_bit(0),
fset = lambda self, val: self._set_mask_bit(0, val))
in_job = property(fget = lambda self: self._get_mask_bit(1),
fset = lambda self, val: self._set_mask_bit(1, val))
in_inventory = property(fget = lambda self: self._get_mask_bit(2),
fset = lambda self, val: self._set_mask_bit(2, val))
u_ngrd1 = property(fget = lambda self: self._get_mask_bit(3),
fset = lambda self, val: self._set_mask_bit(3, val))
in_workshop = property(fget = lambda self: self._get_mask_bit(4),
fset = lambda self, val: self._set_mask_bit(4, val))
u_ngrd2 = property(fget = lambda self: self._get_mask_bit(5),
fset = lambda self, val: self._set_mask_bit(5, val))
u_ngrd3 = property(fget = lambda self: self._get_mask_bit(6),
fset = lambda self, val: self._set_mask_bit(6, val))
rotten = property(fget = lambda self: self._get_mask_bit(7),
fset = lambda self, val: self._set_mask_bit(7, val))
unk1 = property(fget = lambda self: self._get_mask_bit(8),
fset = lambda self, val: self._set_mask_bit(8, val))
u_ngrd4 = property(fget = lambda self: self._get_mask_bit(9),
fset = lambda self, val: self._set_mask_bit(9, val))
unk2 = property(fget = lambda self: self._get_mask_bit(10),
fset = lambda self, val: self._set_mask_bit(10, val))
u_ngrd5 = property(fget = lambda self: self._get_mask_bit(11),
fset = lambda self, val: self._set_mask_bit(11, val))
unk3 = property(fget = lambda self: self._get_mask_bit(12),
fset = lambda self: self._set_mask_bit(12, val))
u_ngrd6 = property(fget = lambda self: self._get_mask_bit(13),
fset = lambda self, val: self._set_mask_bit(13, val))
narrow = property(fget = lambda self: self._get_mask_bit(14),
fset = lambda self, val: self._set_mask_bit(14, val))
u_ngrd7 = property(fget = lambda self: self._get_mask_bit(15),
fset = lambda self, val: self._set_mask_bit(15, val))
worn = property(fget = lambda self: self._get_mask_bit(16),
fset = lambda self, val: self._set_mask_bit(16, val))
unk4 = property(fget = lambda self: self._get_mask_bit(17),
fset = lambda self, val: self._set_mask_bit(17, val))
u_ngrd8 = property(fget = lambda self: self._get_mask_bit(18),
fset = lambda self, val: self._set_mask_bit(18, val))
forbid = property(fget = lambda self: self._get_mask_bit(19),
fset = lambda self, val: self._set_mask_bit(19, val))
unk5 = property(fget = lambda self: self._get_mask_bit(20),
fset = lambda self, val: self._set_mask_bit(20, val))
dump = property(fget = lambda self: self._get_mask_bit(21),
fset = lambda self, val: self._set_mask_bit(21, val))
on_fire = property(fget = lambda self: self._get_mask_bit(22),
fset = lambda self, val: self._set_mask_bit(22, val))
melt = property(fget = lambda self: self._get_mask_bit(23),
fset = lambda self, val: self._set_mask_bit(23, val))
hidden = property(fget = lambda self: self._get_mask_bit(24),
fset = lambda self, val: self._set_mask_bit(24, val))
u_ngrd9 = property(fget = lambda self: self._get_mask_bit(25),
fset = lambda self, val: self._set_mask_bit(25, val))
unk6 = property(fget = lambda self: self._get_mask_bit(26),
fset = lambda self, val: self._set_mask_bit(26, val))
unk7 = property(fget = lambda self: self._get_mask_bit(27),
fset = lambda self, val: self._set_mask_bit(27, val))
unk8 = property(fget = lambda self: self._get_mask_bit(28),
fset = lambda self, val: self._set_mask_bit(28, val))
unk9 = property(fget = lambda self: self._get_mask_bit(29),
fset = lambda self, val: self._set_mask_bit(29, val))
unk10 = property(fget = lambda self: self._get_mask_bit(30),
fset = lambda self, val: self._set_mask_bit(30, val))
unk11 = property(fget = lambda self: self._get_mask_bit(31),
fset = lambda self, val: self._set_mask_bit(31, val))
dig_types = { "no" : 0,
"default" : 1,
"ud_stair" : 2,
"channel" : 3,
"ramp" : 4,
"d_stair" : 5,
"u_stair" : 6,
"whatever" : 7 }
traffic_types = { "normal" : 0,
"low" : 1,
"high" : 2,
"restricted" : 3 }
class DesignationFlags(_UnionBase):
def dig(self, dig_type):
if dig_type == "no":
self.dig_1 = False; self.dig_2 = False; self.dig_3 = False
elif dig_type == "default":
self.dig_1 = True; self.dig_2 = False; self.dig_3 = False
elif dig_type == "ud_stair":
self.dig_1 = False; self.dig_2 = True; self.dig_3 = False
elif dig_type == "channel":
self.dig_1 = True; self.dig_2 = True; self.dig_3 = False
elif dig_type == "ramp":
self.dig_1 = False; self.dig_2 = False; self.dig_3 = True
elif dig_type == "d_stair":
self.dig_1 = True; self.dig_2 = False; self.dig_3 = True
elif dig_type == "u_stair":
self.dig_1 = False; self.dig_2 = True; self.dig_3 = True
elif dig_type == "whatever":
self.dig_1 = True; self.dig_2 = True; self.dig_3 = True
def set_traffic(self, traffic_type):
if traffic_type == "normal":
self.traffic_1 = False; self.traffic_2 = False
elif traffic_type == "low":
self.traffic_1 = True; self.traffic_2 = False
elif traffic_type == "high":
self.traffic_1 = False; self.traffic_2 = True
elif traffic_type == "restricted":
self.traffic_1 = True; self.traffic_2 = True
flow_size_1 = property(fget = lambda self: self._get_mask_bit(0),
fset = lambda self, val: self._set_mask_bit(0, val))
flow_size_2 = property(fget = lambda self: self._get_mask_bit(1),
fset = lambda self, val: self._set_mask_bit(1, val))
flow_size_3 = property(fget = lambda self: self._get_mask_bit(2),
fset = lambda self, val: self._set_mask_bit(2, val))
pile = property(fget = lambda self: self._get_mask_bit(3),
fset = lambda self, val: self._set_mask_bit(3, val))
dig_1 = property(fget = lambda self: self._get_mask_bit(4),
fset = lambda self, val: self._set_mask_bit(4, val))
dig_2 = property(fget = lambda self: self._get_mask_bit(5),
fset = lambda self, val: self._set_mask_bit(5, val))
dig_3 = property(fget = lambda self: self._get_mask_bit(6),
fset = lambda self, val: self._set_mask_bit(6, val))
smooth_1 = property(fget = lambda self: self._get_mask_bit(7),
fset = lambda self, val: self._set_mask_bit(7, val))
smooth_2 = property(fget = lambda self: self._get_mask_bit(8),
fset = lambda self, val: self._set_mask_bit(8, val))
hidden = property(fget = lambda self: self._get_mask_bit(9),
fset = lambda self, val: self._set_mask_bit(9, val))
geolayer_index_1 = property(fget = lambda self: self._get_mask_bit(10),
fset = lambda self, val: self._set_mask_bit(10, val))
geolayer_index_2 = property(fget = lambda self: self._get_mask_bit(11),
fset = lambda self, val: self._set_mask_bit(11, val))
geolayer_index_3 = property(fget = lambda self: self._get_mask_bit(12),
fset = lambda self, val: self._set_mask_bit(12, val))
geolayer_index_4 = property(fget = lambda self: self._get_mask_bit(13),
fset = lambda self: self._set_mask_bit(13, val))
light = property(fget = lambda self: self._get_mask_bit(14),
fset = lambda self, val: self._set_mask_bit(14, val))
subterranean = property(fget = lambda self: self._get_mask_bit(15),
fset = lambda self, val: self._set_mask_bit(15, val))
skyview = property(fget = lambda self: self._get_mask_bit(16),
fset = lambda self, val: self._set_mask_bit(16, val))
biome_1 = property(fget = lambda self: self._get_mask_bit(17),
fset = lambda self, val: self._set_mask_bit(17, val))
biome_2 = property(fget = lambda self: self._get_mask_bit(18),
fset = lambda self, val: self._set_mask_bit(18, val))
biome_3 = property(fget = lambda self: self._get_mask_bit(19),
fset = lambda self, val: self._set_mask_bit(19, val))
biome_4 = property(fget = lambda self: self._get_mask_bit(20),
fset = lambda self, val: self._set_mask_bit(20, val))
liquid_type = property(fget = lambda self: self._get_mask_bit(21),
fset = lambda self, val: self._set_mask_bit(21, val))
water_table = property(fget = lambda self: self._get_mask_bit(22),
fset = lambda self, val: self._set_mask_bit(22, val))
rained = property(fget = lambda self: self._get_mask_bit(23),
fset = lambda self, val: self._set_mask_bit(23, val))
traffic_1 = property(fget = lambda self: self._get_mask_bit(24),
fset = lambda self, val: self._set_mask_bit(24, val))
traffic_2 = property(fget = lambda self: self._get_mask_bit(25),
fset = lambda self, val: self._set_mask_bit(25, val))
flow_forbid = property(fget = lambda self: self._get_mask_bit(26),
fset = lambda self, val: self._set_mask_bit(26, val))
liquid_static = property(fget = lambda self: self._get_mask_bit(27),
fset = lambda self, val: self._set_mask_bit(27, val))
moss = property(fget = lambda self: self._get_mask_bit(28),
fset = lambda self, val: self._set_mask_bit(28, val))
feature_present = property(fget = lambda self: self._get_mask_bit(29),
fset = lambda self, val: self._set_mask_bit(29, val))
liquid_character_1 = property(fget = lambda self: self._get_mask_bit(30),
fset = lambda self, val: self._set_mask_bit(30, val))
liquid_character_2 = property(fget = lambda self: self._get_mask_bit(31),
fset = lambda self, val: self._set_mask_bit(31, val))
class OccupancyFlags(_UnionBase):
def set_splatter(self, state):
if state:
self.whole &= 0xFFFFFFC0
else:
self.whole &= ~0xFFFFFFC0
building_1 = property(fget = lambda self: self._get_mask_bit(0),
fset = lambda self, val: self._set_mask_bit(0, val))
building_2 = property(fget = lambda self: self._get_mask_bit(1),
fset = lambda self, val: self._set_mask_bit(1, val))
building_3 = property(fget = lambda self: self._get_mask_bit(2),
fset = lambda self, val: self._set_mask_bit(2, val))
unit = property(fget = lambda self: self._get_mask_bit(3),
fset = lambda self, val: self._set_mask_bit(3, val))
unit_grounded = property(fget = lambda self: self._get_mask_bit(4),
fset = lambda self, val: self._set_mask_bit(4, val))
item = property(fget = lambda self: self._get_mask_bit(5),
fset = lambda self, val: self._set_mask_bit(5, val))
mud = property(fget = lambda self: self._get_mask_bit(6),
fset = lambda self, val: self._set_mask_bit(6, val))
vomit = property(fget = lambda self: self._get_mask_bit(7),
fset = lambda self, val: self._set_mask_bit(7, val))
broken_arrows_color_1 = property(fget = lambda self: self._get_mask_bit(8),
fset = lambda self, val: self._set_mask_bit(8, val))
broken_arrows_color_2 = property(fget = lambda self: self._get_mask_bit(9),
fset = lambda self, val: self._set_mask_bit(9, val))
broken_arrows_color_3 = property(fget = lambda self: self._get_mask_bit(10),
fset = lambda self, val: self._set_mask_bit(10, val))
broken_arrows_color_4 = property(fget = lambda self: self._get_mask_bit(11),
fset = lambda self, val: self._set_mask_bit(11, val))
blood_g = property(fget = lambda self: self._get_mask_bit(12),
fset = lambda self: self._set_mask_bit(12, val))
blood_g2 = property(fget = lambda self: self._get_mask_bit(13),
fset = lambda self, val: self._set_mask_bit(13, val))
blood_b = property(fget = lambda self: self._get_mask_bit(14),
fset = lambda self, val: self._set_mask_bit(14, val))
blood_b2 = property(fget = lambda self: self._get_mask_bit(15),
fset = lambda self, val: self._set_mask_bit(15, val))
blood_y = property(fget = lambda self: self._get_mask_bit(16),
fset = lambda self, val: self._set_mask_bit(16, val))
blood_y2 = property(fget = lambda self: self._get_mask_bit(17),
fset = lambda self, val: self._set_mask_bit(17, val))
blood_m = property(fget = lambda self: self._get_mask_bit(18),
fset = lambda self, val: self._set_mask_bit(18, val))
blood_m2 = property(fget = lambda self: self._get_mask_bit(19),
fset = lambda self, val: self._set_mask_bit(19, val))
blood_c = property(fget = lambda self: self._get_mask_bit(20),
fset = lambda self, val: self._set_mask_bit(20, val))
blood_c2 = property(fget = lambda self: self._get_mask_bit(21),
fset = lambda self, val: self._set_mask_bit(21, val))
blood_w = property(fget = lambda self: self._get_mask_bit(22),
fset = lambda self, val: self._set_mask_bit(22, val))
blood_w2 = property(fget = lambda self: self._get_mask_bit(23),
fset = lambda self, val: self._set_mask_bit(23, val))
blood_o = property(fget = lambda self: self._get_mask_bit(24),
fset = lambda self, val: self._set_mask_bit(24, val))
blood_o2 = property(fget = lambda self: self._get_mask_bit(25),
fset = lambda self, val: self._set_mask_bit(25, val))
slime = property(fget = lambda self: self._get_mask_bit(26),
fset = lambda self, val: self._set_mask_bit(26, val))
slime2 = property(fget = lambda self: self._get_mask_bit(27),
fset = lambda self, val: self._set_mask_bit(27, val))
blood = property(fget = lambda self: self._get_mask_bit(28),
fset = lambda self, val: self._set_mask_bit(28, val))
blood2 = property(fget = lambda self: self._get_mask_bit(29),
fset = lambda self, val: self._set_mask_bit(29, val))
broken_arrows_variant = property(fget = lambda self: self._get_mask_bit(30),
fset = lambda self, val: self._set_mask_bit(30, val))
snow = property(fget = lambda self: self._get_mask_bit(31),
fset = lambda self, val: self._set_mask_bit(31, val))

@ -0,0 +1,9 @@
from distutils.core import setup, Extension
e = Extension("pydfhack",
sources=["UnionBase.cpp", "pydfhack.cpp", "DF_API.cpp"],
include_dirs=["..\\"],
library_dirs=["..\\..\\output"],
libraries=["libdfhack"])
setup(name="PyDFHack", version="1.0", ext_modules=[e])

@ -0,0 +1 @@
import pydfhack