Merge branch 'pydfhack' of git://github.com/doomchild/dfhack into DF2010

develop
Petr Mrázek 2010-04-02 16:47:46 +02:00
commit d3f1f63d92
8 changed files with 2220 additions and 12 deletions

@ -109,16 +109,16 @@ ENDIF(UNIX)
# SWIG stuff
FIND_PACKAGE(SWIG)
IF(SWIG_FOUND)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs)
IF(PYTHONLIBS_FOUND)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
SET(CMAKE_SWIG_FLAGS "-c++")
SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES CPLUSPLUS ON)
#IF(SWIG_FOUND)
# INCLUDE(${SWIG_USE_FILE})
# FIND_PACKAGE(PythonLibs)
# IF(PYTHONLIBS_FOUND)
# INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
# SET(CMAKE_SWIG_FLAGS "-c++")
# SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES CPLUSPLUS ON)
# SET(CMAKE_DFHACK_SWIG_OUTDIR ${dfhack_SOURCE_DIR}/output CACHE PATH "Directory where Java wrapped libraries will be saved.")
# SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(pydfhack python pydfhack.i)
SWIG_LINK_LIBRARIES(pydfhack ${PYTHON_LIBRARIES} dfhack)
ENDIF(PYTHONLIBS_FOUND)
ENDIF(SWIG_FOUND)
# # SET_SOURCE_FILES_PROPERTIES(pydfhack.i PROPERTIES SWIG_FLAGS "-includeall")
# SWIG_ADD_MODULE(pydfhack python pydfhack.i)
# SWIG_LINK_LIBRARIES(pydfhack ${PYTHON_LIBRARIES} dfhack)
# ENDIF(PYTHONLIBS_FOUND)
#ENDIF(SWIG_FOUND)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,215 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#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,231 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef __MATGLOSS__
#define __MATGLOSS__
#include <Python.h>
#include <stdio.h>
#include <string.h>
#include "DFTypes.h"
using namespace DFHack;
// MatGloss
struct MatGloss
{
PyObject_HEAD
DFHack::t_matgloss native;
};
static PyObject* MatGloss_new(PyTypeObject* type, PyObject* arg, PyObject* kwds)
{
MatGloss* self;
self = (MatGloss*)type->tp_alloc(type, 0);
self->native->id[0] = '\0';
self->native->name[0] = '\0';
return (PyObject*)self;
}
static void MatGloss_dealloc(MatGloss* self)
{
self->ob_type->tp_free((PyObject*)self);
}
static PyObject* MatGloss_GetID(MatGloss* self, void* closure)
{
return PyString_FromString(self->native->id);
}
static int MatGloss_SetID(MatGloss* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->id, temp, 127);
self->native->id[127] = '\0';
return 0;
}
static PyObject* MatGloss_GetName(MatGloss* self, PyObject* args, void* closure)
{
return PyString_FromString(self->native->name);
}
static PyObject* MatGloss_SetName(MatGloss* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->native->name, temp, 127);
self->native->name[127] = '\0';
return 0;
}
static PyGetSetDef MatGloss_getSetters[] =
{
{"id", (getter)MatGloss_GetID, (setter)MatGloss_SetID, "id", NULL},
{"name", (getter)MatGloss_GetName, (setter)MatGloss_SetName, "name", NULL},
{NULL}
};
// MatGlossPlant
struct MatGlossPlant
{
PyObject_HEAD
DFHack::t_matglossPlant native;
};
static PyObject* MatGlossPlant_new(PyTypeObject* type, PyObject* arg, PyObject* kwds)
{
MatGlossPlant* self;
self = (MatGlossPlant*)type->tp_alloc(type, 0);
self->native->id[0] = '\0';
self->native->name[0] = '\0';
self->native->drink_name[127] = '\0';
self->native->food_name[127] = '\0';
self->native->extract_name[127] = '\0';
return (PyObject*)self;
}
static void MatGlossPlant_dealloc(MatGlossPlant* self)
{
self->ob_type->tp_free((PyObject*)self);
}
static PyObject* MatGlossPlant_GetID(MatGlossPlant* self, void* closure)
{
return PyString_FromString(self->native->id);
}
static int MatGlossPlant_SetID(MatGlossPlant* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->native->id, temp, 127);
self->native->id[127] = '\0';
return 0;
}
static PyObject* MatGlossPlant_GetName(MatGlossPlant* self, PyObject* args, void* closure)
{
return PyString_FromString(self->native->name);
}
static PyObject* MatGlossPlant_SetName(MatGlossPlant* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->native->name, temp, 127);
self->native->name[127] = '\0';
return 0;
}
static PyObject* MatGlossPlant_GetDrinkName(MatGlossPlant* self, PyObject* args, void* closure)
{
return PyString_FromString(self->native->drink_name);
}
static PyObject* MatGlossPlant_SetDrinkName(MatGlossPlant* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->native->drink_name, temp, 127);
self->native->drink_name[127] = '\0';
return 0;
}
static PyObject* MatGlossPlant_GetFoodName(MatGlossPlant* self, PyObject* args, void* closure)
{
return PyString_FromString(self->native->food_name);
}
static PyObject* MatGlossPlant_SetFoodName(MatGlossPlant* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->native->food_name, temp, 127);
self->native->food_name[127] = '\0';
return 0;
}
static PyObject* MatGlossPlant_GetExtractName(MatGlossPlant* self, PyObject* args, void* closure)
{
return PyString_FromString(self->native->extract_name);
}
static PyObject* MatGlossPlant_SetExtractName(MatGlossPlant* self, PyObject* args, void* closure)
{
char* temp;
if(!PyArg_ParseTuple(args, "s", &temp))
return -1;
strncpy(self->native->extract_name, temp, 127);
self->native->extract_name[127] = '\0';
return 0;
}
static PyGetSetDef MatGlossPlant_getSetters[] =
{
{"id", (getter)MatGlossPlant_GetID, (setter)MatGlossPlant_SetID, "id", NULL},
{"name", (getter)MatGlossPlant_GetName, (setter)MatGlossPlant_SetName, "name", NULL},
{"drink_name", (getter)MatGlossPlant_GetDrinkName, (setter)MatGlossPlant_SetDrinkName, "drink_name", NULL},
{"food_name", (getter)MatGlossPlant_GetFoodName, (setter)MatGlossPlant_SetFoodName, "food_name", NULL},
{"extract_name", (getter)MatGlossPlant_GetExtractName, (setter)MatGlossPlant_SetExtractName, "extract_name", NULL},
{NULL}
};
#endif

@ -0,0 +1,55 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#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