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

develop
Petr Mrázek 2010-04-10 02:37:53 +02:00
commit b248663e33
15 changed files with 2389 additions and 1781 deletions

File diff suppressed because it is too large Load Diff

@ -0,0 +1,200 @@
/*
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 __DFCREATURES__
#define __DFCREATURES__
#include "Python.h"
#include "DFTypes.h"
#include "modules/Creatures.h"
#include "DF_CreatureType.cpp"
using namespace DFHack;
struct DF_CreatureManager
{
PyObject_HEAD
DFHack::Creatures* creature_Ptr;
};
// API type Allocation, Deallocation, and Initialization
static PyObject* DF_CreatureManager_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_CreatureManager* self;
self = (DF_CreatureManager*)type->tp_alloc(type, 0);
if(self != NULL)
self->creature_Ptr = NULL;
return (PyObject*)self;
}
static int DF_CreatureManager_init(DF_CreatureManager* self, PyObject* args, PyObject* kwds)
{
return 0;
}
static void DF_CreatureManager_dealloc(DF_CreatureManager* self)
{
if(self != NULL)
{
if(self->creature_Ptr != NULL)
{
delete self->creature_Ptr;
self->creature_Ptr = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
}
// Type methods
static PyObject* DF_CreatureManager_Start(DF_CreatureManager* self, PyObject* args)
{
uint32_t numCreatures = 0;
if(self->creature_Ptr != NULL)
{
if(self->creature_Ptr->Start(numCreatures))
return PyInt_FromLong(numCreatures);
else
return PyInt_FromLong(-1);
}
Py_RETURN_NONE;
}
static PyObject* DF_CreatureManager_Finish(DF_CreatureManager* self, PyObject* args)
{
if(self->creature_Ptr != NULL)
{
if(self->creature_Ptr->Finish())
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
Py_RETURN_NONE;
}
static PyObject* DF_CreatureManager_ReadCreature(DF_CreatureManager* self, PyObject* args)
{
uint32_t index;
DFHack::t_creature furball;
if(self->creature_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "I", &index))
return NULL;
if(self->creature_Ptr->ReadCreature(index, furball))
{
return BuildCreature(furball);
}
else
{
Py_RETURN_FALSE;
}
}
Py_RETURN_NONE;
}
static PyObject* DF_CreatureManager_ReadCreatureInBox(DF_CreatureManager* self, PyObject* args)
{
int32_t index;
uint32_t x1, y1, z1, x2, y2, z2;
DFHack::t_creature furball;
if(self->creature_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "iIIIIII", &index, &x1, &y1, &z1, &x2, &y2, &z2))
return NULL;
if(self->creature_Ptr->ReadCreatureInBox(index, furball, x1, y1, z1, x2, y2, z2) >= 0)
return BuildCreature(furball);
else
Py_RETURN_FALSE;
}
Py_RETURN_NONE;
}
static PyMethodDef DF_CreatureManager_methods[] =
{
{"Start", (PyCFunction)DF_CreatureManager_Start, METH_NOARGS, ""},
{"Finish", (PyCFunction)DF_CreatureManager_Finish, METH_NOARGS, ""},
{"Read_Creature", (PyCFunction)DF_CreatureManager_ReadCreature, METH_VARARGS, ""},
{"Read_Creature_In_Box", (PyCFunction)DF_CreatureManager_ReadCreatureInBox, METH_VARARGS, ""},
{NULL} // Sentinel
};
static PyTypeObject DF_CreatureManager_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.CreatureManager", /*tp_name*/
sizeof(DF_CreatureManager), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)DF_CreatureManager_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 CreatureManager objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DF_CreatureManager_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)DF_CreatureManager_init, /* tp_init */
0, /* tp_alloc */
DF_CreatureManager_new, /* tp_new */
};
#endif

@ -0,0 +1,282 @@
/*
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 __DFCREATURETYPE__
#define __DFCREATURETYPE__
#include "Python.h"
#include "structmember.h"
#include "DF_Imports.cpp"
#include "DF_Helpers.cpp"
#include "modules/Creatures.h"
using namespace DFHack;
struct DF_Creature_Base
{
PyObject_HEAD
// simple type stuff
uint32_t origin;
uint32_t c_type;
uint8_t profession;
uint16_t mood;
uint32_t happiness;
uint32_t c_id;
uint32_t agility;
uint32_t strength;
uint32_t toughness;
uint32_t money;
int32_t squad_leader_id;
uint8_t sex;
uint32_t pregnancy_timer;
int32_t blood_max, blood_current;
uint32_t bleed_rate;
PyObject* custom_profession;
// composites
PyObject* position;
PyObject *name, *squad_name, *artifact_name;
PyObject* current_job;
// customs
PyObject *flags1, *flags2;
// lists
PyObject* skill_list;
PyObject* like_list;
PyObject* trait_list;
PyObject* labor_list;
};
// API type Allocation, Deallocation, and Initialization
static PyObject* DF_Creature_Base_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_Creature_Base* self;
self = (DF_Creature_Base*)type->tp_alloc(type, 0);
if(self != NULL)
{
self->origin = 0;
self->c_type = 0;
self->profession = 0;
self->mood = 0;
self->happiness = 0;
self->c_id = 0;
self->agility = 0;
self->strength = 0;
self->toughness = 0;
self->money = 0;
self->squad_leader_id = 0;
self->sex = 0;
self->pregnancy_timer = 0;
self->blood_max = 0;
self->blood_current = 0;
self->bleed_rate = 0;
self->custom_profession = PyString_FromString("");
self->name = PyString_FromString("");
self->squad_name = PyString_FromString("");
self->artifact_name = PyString_FromString("");
self->skill_list = NULL;
self->like_list = NULL;
self->trait_list = NULL;
self->labor_list = NULL;
}
return (PyObject*)self;
}
static void DF_Creature_Base_dealloc(DF_Creature_Base* self)
{
if(self != NULL)
{
Py_XDECREF(self->position);
Py_XDECREF(self->flags1);
Py_XDECREF(self->flags2);
Py_XDECREF(self->custom_profession);
Py_XDECREF(self->name);
Py_XDECREF(self->squad_name);
Py_XDECREF(self->artifact_name);
Py_XDECREF(self->current_job);
Py_XDECREF(self->flags1);
Py_XDECREF(self->flags2);
Py_XDECREF(self->labor_list);
Py_XDECREF(self->trait_list);
Py_XDECREF(self->skill_list);
Py_XDECREF(self->like_list);
// if(self->labor_list != NULL)
// PyList_Clear(self->labor_list);
// if(self->trait_list != NULL)
// PyList_Clear(self->trait_list);
// if(self->skill_list != NULL)
// PyList_Clear(self->skill_list);
// if(self->like_list != NULL)
// PyList_Clear(self->like_list);
self->ob_type->tp_free((PyObject*)self);
}
}
static PyMemberDef DF_Creature_Base_members[] =
{
{"origin", T_UINT, offsetof(DF_Creature_Base, origin), 0, ""},
{"type", T_UINT, offsetof(DF_Creature_Base, c_type), 0, ""},
{"flags1", T_OBJECT_EX, offsetof(DF_Creature_Base, flags1), 0, ""},
{"flags2", T_OBJECT_EX, offsetof(DF_Creature_Base, flags2), 0, ""},
{"name", T_OBJECT_EX, offsetof(DF_Creature_Base, name), 0, ""},
{"squad_name", T_OBJECT_EX, offsetof(DF_Creature_Base, squad_name), 0, ""},
{"artifact_name", T_OBJECT_EX, offsetof(DF_Creature_Base, artifact_name), 0, ""},
{"profession", T_INT, offsetof(DF_Creature_Base, profession), 0, ""},
{"custom_profession", T_OBJECT_EX, offsetof(DF_Creature_Base, custom_profession), 0, ""},
{"happiness", T_SHORT, offsetof(DF_Creature_Base, happiness), 0, ""},
{NULL} //Sentinel
};
static PyGetSetDef DF_Creature_Base_getterSetters[] =
{
{NULL} //Sentinel
};
static PyMethodDef DF_Creature_Base_methods[] =
{
{NULL} //Sentinel
};
static PyTypeObject DF_Creature_Base_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.Creature_Base", /*tp_name*/
sizeof(DF_Creature_Base), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)DF_Creature_Base_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 CreatureBase objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DF_Creature_Base_methods, /* tp_methods */
DF_Creature_Base_members, /* tp_members */
DF_Creature_Base_getterSetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
DF_Creature_Base_new, /* tp_new */
};
static PyObject* BuildCreature(DFHack::t_creature& creature)
{
DF_Creature_Base* obj;
obj = (DF_Creature_Base*)PyObject_Call((PyObject*)&DF_Creature_Base_type, NULL, NULL);
if(obj != NULL)
{
obj->position = Py_BuildValue("III", creature.x, creature.y, creature.z);
obj->profession = creature.profession;
obj->c_type = creature.type;
obj->mood = creature.mood;
obj->happiness = creature.happiness;
obj->c_id = creature.id;
obj->agility = creature.agility;
obj->strength = creature.strength;
obj->toughness = creature.toughness;
obj->money = creature.money;
obj->squad_leader_id = creature.squad_leader_id;
obj->sex = creature.sex;
obj->pregnancy_timer = creature.pregnancy_timer;
obj->blood_max = creature.blood_max;
obj->blood_current = creature.blood_current;
obj->bleed_rate = creature.bleed_rate;
if(creature.custom_profession[0])
obj->custom_profession = PyString_FromString(creature.custom_profession);
obj->flags1 = PyObject_Call(CreatureFlags1_type, PyInt_FromLong(creature.flags1.whole), NULL);
obj->flags2 = PyObject_Call(CreatureFlags2_type, PyInt_FromLong(creature.flags2.whole), NULL);
obj->current_job = BuildJob(creature.current_job);
obj->name = BuildName(creature.name);
obj->squad_name = BuildName(creature.squad_name);
obj->artifact_name = BuildName(creature.artifact_name);
obj->skill_list = PyList_New(creature.numSkills);
for(int i = 0; i < creature.numSkills; i++)
PyList_SetItem(obj->skill_list, i, BuildSkill(creature.skills[i]));
obj->like_list = PyList_New(creature.numLikes);
for(int i = 0; i < creature.numLikes; i++)
PyList_SetItem(obj->like_list, i, BuildLike(creature.likes[i]));
obj->labor_list = PyList_New(NUM_CREATURE_LABORS);
for(int i = 0; i < NUM_CREATURE_LABORS; i++)
PyList_SetItem(obj->labor_list, i, PyInt_FromLong(creature.labors[i]));
obj->trait_list = PyList_New(NUM_CREATURE_TRAITS);
for(int i = 0; i < NUM_CREATURE_TRAITS; i++)
PyList_SetItem(obj->trait_list, i, PyInt_FromLong(creature.traits[i]));
Py_INCREF((PyObject*)obj);
return (PyObject*)obj;
}
Py_RETURN_NONE;
}
#endif

@ -0,0 +1,32 @@
/*
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 __DFCREATURES__
#define __DFCREATURES__
#include "Python.h"
#include "DFTypes.h"
#include "DF_CreatureType.cpp"
#endif

@ -0,0 +1,213 @@
/*
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 __DFHELPERS__
#define __DFHELPERS__
#include "Python.h"
#include "DF_Imports.cpp"
#include "DFTypes.h"
using namespace DFHack;
#include "modules/Creatures.h"
static PyObject* BuildMatglossPair(DFHack::t_matglossPair& matgloss)
{
return Py_BuildValue("ii", matgloss.type, matgloss.index);
}
// static PyObject* BuildTreeDesc(DFHack::t_tree_desc& tree)
// {
// return Py_BuildValue("OO", BuildMatglossPair(tree.material), Py_BuildValue("III", tree.x, tree.y, tree.z));
// }
static PyObject* BuildSkill(DFHack::t_skill& skill)
{
return Py_BuildValue("III", skill.id, skill.experience, skill.rating);
}
static PyObject* BuildJob(DFHack::t_job& job)
{
return Py_BuildValue("Oi", PyBool_FromLong((int)job.active), job.jobId);
}
static PyObject* BuildItemType(DFHack::t_itemType& item)
{
PyObject *id, *name;
if(item.id[0])
id = PyString_FromString(item.id);
else
id = PyString_FromString("");
if(item.name[0])
name = PyString_FromString(item.name);
else
name = PyString_FromString("");
return Py_BuildValue("OO", id, name);
}
static PyObject* BuildLike(DFHack::t_like& like)
{
PyObject* item;
item = Py_BuildValue("iii", like.type, like.itemClass, like.itemIndex);
return Py_BuildValue("OOO", item, BuildMatglossPair(like.material), PyBool_FromLong((int)like.active));
}
//PyDict_SetItem and PyDict_SetItemString don't steal references, so this had to get a bit more complicated...
static PyObject* BuildNote(DFHack::t_note& note)
{
PyObject* noteDict = PyDict_New();
PyObject* temp;
temp = PyString_FromFormat("%c", note.symbol);
PyDict_SetItemString(noteDict, "symbol", temp);
Py_DECREF(temp);
temp = Py_BuildValue("II", note.foreground, note.background);
PyDict_SetItemString(noteDict, "fore_back", temp);
Py_DECREF(temp);
if(note.name[0])
temp = PyString_FromString(note.name);
else
PyString_FromString("");
PyDict_SetItemString(noteDict, "name", temp);
Py_DECREF(temp);
temp = Py_BuildValue("III", note.x, note.y, note.z);
PyDict_SetItemString(noteDict, "position", temp);
Py_DECREF(temp);
return noteDict;
}
//same here...reference counting is kind of a pain, assuming I'm even doing it right...
static PyObject* BuildName(DFHack::t_name& name)
{
PyObject* nameDict;
PyObject *wordList, *speechList;
PyObject* temp;
int wordCount = 7;
nameDict = PyDict_New();
if(name.first_name[0])
temp = PyString_FromString(name.first_name);
else
temp = PyString_FromString("");
PyDict_SetItemString(nameDict, "first_name", temp);
Py_DECREF(temp);
if(name.nickname[0])
temp = PyString_FromString(name.nickname);
else
temp = PyString_FromString("");
PyDict_SetItemString(nameDict, "nickname", temp);
Py_DECREF(temp);
temp = PyInt_FromLong(name.language);
PyDict_SetItemString(nameDict, "language", temp);
Py_DECREF(temp);
temp = PyBool_FromLong((int)name.has_name);
PyDict_SetItemString(nameDict, "has_name", temp);
Py_DECREF(temp);
wordList = PyList_New(wordCount);
speechList = PyList_New(wordCount);
for(int i = 0; i < wordCount; i++)
{
PyList_SetItem(wordList, i, PyInt_FromLong(name.words[i]));
PyList_SetItem(wordList, i, PyInt_FromLong(name.parts_of_speech[i]));
}
PyDict_SetItemString(nameDict, "words", wordList);
PyDict_SetItemString(nameDict, "parts_of_speech", speechList);
Py_DECREF(wordList);
Py_DECREF(speechList);
return nameDict;
}
static PyObject* BuildSettlement(DFHack::t_settlement& settlement)
{
PyObject* setDict;
PyObject *local_pos1, *local_pos2;
PyObject* temp;
setDict = PyDict_New();
temp = PyInt_FromLong(settlement.origin);
PyDict_SetItemString(setDict, "origin", temp);
Py_DECREF(temp);
temp = BuildName(settlement.name);
PyDict_SetItemString(setDict, "name", temp);
Py_DECREF(temp);
temp = Py_BuildValue("ii", settlement.world_x, settlement.world_y);
PyDict_SetItemString(setDict, "world_pos", temp);
Py_DECREF(temp);
local_pos1 = Py_BuildValue("ii", settlement.local_x1, settlement.local_y1);
local_pos2 = Py_BuildValue("ii", settlement.local_x2, settlement.local_y2);
PyDict_SetItemString(setDict, "local_pos", Py_BuildValue("OO", local_pos1, local_pos2));
Py_DECREF(local_pos1);
Py_DECREF(local_pos2);
return setDict;
}
#endif

@ -0,0 +1,51 @@
/*
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 __DFIMPORTS__
#define __DFIMPORTS__
#include "Python.h"
static PyObject* TypesModule = NULL;
static PyObject* CreatureFlags1_type = NULL;
static PyObject* CreatureFlags2_type = NULL;
static PyObject* DesignationFlags_type = NULL;
static PyObject* OccupancyFlags_type = NULL;
static PyObject* ItemFlags_type = NULL;
static void DoImports()
{
if(TypesModule == NULL)
{
TypesModule = PyImport_ImportModule("pydftypes");
CreatureFlags1_type = PyObject_GetAttrString(TypesModule, "CreatureFlags1");
CreatureFlags2_type = PyObject_GetAttrString(TypesModule, "CreatureFlags2");
DesignationFlags_type = PyObject_GetAttrString(TypesModule, "DesignationFlags");
OccupancyFlags_type = PyObject_GetAttrString(TypesModule, "OccupancyFlags");
ItemFlags_type = PyObject_GetAttrString(TypesModule, "ItemFlags");
}
}
#endif

@ -0,0 +1,312 @@
/*
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 __DFMATERIAL__
#define __DFMATERIAL__
#include "Python.h"
#include <vector>
using namespace std;
#include "modules/Materials.h"
using namespace DFHack;
struct DF_Material
{
PyObject_HEAD
DFHack::Materials* mat_Ptr;
};
// Helpers
static PyObject* BuildMatgloss(t_matgloss& matgloss)
{
PyObject* matDict;
PyObject* temp;
matDict = PyDict_New();
if(matgloss.id[0])
temp = PyString_FromString(matgloss.id);
else
temp = PyString_FromString("");
PyDict_SetItemString(matDict, "id", temp);
Py_DECREF(temp);
temp = PyInt_FromLong(matgloss.fore);
PyDict_SetItemString(matDict, "fore", temp);
Py_DECREF(temp);
temp = PyInt_FromLong(matgloss.back);
PyDict_SetItemString(matDict, "back", temp);
Py_DECREF(temp);
temp = PyInt_FromLong(matgloss.bright);
PyDict_SetItemString(matDict, "bright", temp);
Py_DECREF(temp);
if(matgloss.name[0])
temp = PyString_FromString(matgloss.name);
else
temp = PyString_FromString("");
PyDict_SetItemString(matDict, "name", temp);
Py_DECREF(temp);
return matDict;
}
static PyObject* BuildMatglossPlant(t_matglossPlant& matgloss)
{
PyObject* matDict;
matDict = PyDict_New();
if(matgloss.id[0])
PyDict_SetItemString(matDict, "id", PyString_FromString(matgloss.id));
else
PyDict_SetItemString(matDict, "id", PyString_FromString(""));
PyDict_SetItemString(matDict, "fore", PyInt_FromLong(matgloss.fore));
PyDict_SetItemString(matDict, "back", PyInt_FromLong(matgloss.back));
PyDict_SetItemString(matDict, "bright", PyInt_FromLong(matgloss.bright));
if(matgloss.name[0])
PyDict_SetItemString(matDict, "name", PyString_FromString(matgloss.name));
else
PyDict_SetItemString(matDict, "name", PyString_FromString(""));
if(matgloss.drink_name[0])
PyDict_SetItemString(matDict, "drink_name", PyString_FromString(matgloss.drink_name));
else
PyDict_SetItemString(matDict, "drink_name", PyString_FromString(""));
if(matgloss.food_name[0])
PyDict_SetItemString(matDict, "food_name", PyString_FromString(matgloss.food_name));
else
PyDict_SetItemString(matDict, "food_name", PyString_FromString(""));
if(matgloss.extract_name[0])
PyDict_SetItemString(matDict, "extract_name", PyString_FromString(matgloss.extract_name));
else
PyDict_SetItemString(matDict, "extract_name", PyString_FromString(""));
return matDict;
}
static PyObject* BuildMatglossList(std::vector<t_matgloss> & matVec)
{
PyObject* matList;
std::vector<t_matgloss>::iterator matIter;
matList = PyList_New(0);
for(matIter = matVec.begin(); matIter != matVec.end(); matIter++)
{
PyObject* matgloss = BuildMatgloss(*matIter);
PyList_Append(matList, matgloss);
Py_DECREF(matgloss);
}
return matList;
}
// API type Allocation, Deallocation, and Initialization
static PyObject* DF_Material_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_Material* self;
self = (DF_Material*)type->tp_alloc(type, 0);
if(self != NULL)
self->mat_Ptr = NULL;
return (PyObject*)self;
}
static int DF_Material_init(DF_Material* self, PyObject* args, PyObject* kwds)
{
return 0;
}
static void DF_Material_dealloc(DF_Material* self)
{
if(self != NULL)
{
if(self->mat_Ptr != NULL)
{
delete self->mat_Ptr;
self->mat_Ptr = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
}
// Type methods
static PyObject* DF_Material_ReadInorganicMaterials(DF_Material* self, PyObject* args)
{
if(self->mat_Ptr != NULL)
{
std::vector<DFHack::t_matgloss> matVec;
if(self->mat_Ptr->ReadInorganicMaterials(matVec))
{
return BuildMatglossList(matVec);
}
}
Py_RETURN_NONE;
}
static PyObject* DF_Material_ReadOrganicMaterials(DF_Material* self, PyObject* args)
{
if(self->mat_Ptr != NULL)
{
std::vector<DFHack::t_matgloss> matVec;
if(self->mat_Ptr->ReadOrganicMaterials(matVec))
{
return BuildMatglossList(matVec);
}
}
Py_RETURN_NONE;
}
static PyObject* DF_Material_ReadWoodMaterials(DF_Material* self, PyObject* args)
{
if(self->mat_Ptr != NULL)
{
std::vector<DFHack::t_matgloss> matVec;
if(self->mat_Ptr->ReadWoodMaterials(matVec))
{
return BuildMatglossList(matVec);
}
}
Py_RETURN_NONE;
}
static PyObject* DF_Material_ReadPlantMaterials(DF_Material* self, PyObject* args)
{
if(self->mat_Ptr != NULL)
{
std::vector<DFHack::t_matgloss> matVec;
if(self->mat_Ptr->ReadPlantMaterials(matVec))
{
return BuildMatglossList(matVec);
}
}
Py_RETURN_NONE;
}
static PyObject* DF_Material_ReadCreatureTypes(DF_Material* self, PyObject* args)
{
if(self->mat_Ptr != NULL)
{
std::vector<DFHack::t_matgloss> matVec;
if(self->mat_Ptr->ReadCreatureTypes(matVec))
{
return BuildMatglossList(matVec);
}
}
Py_RETURN_NONE;
}
static PyMethodDef DF_Material_methods[] =
{
{"Read_Inorganic_Materials", (PyCFunction)DF_Material_ReadInorganicMaterials, METH_NOARGS, ""},
{"Read_Organic_Materials", (PyCFunction)DF_Material_ReadOrganicMaterials, METH_NOARGS, ""},
{"Read_Wood_Materials", (PyCFunction)DF_Material_ReadWoodMaterials, METH_NOARGS, ""},
{"Read_Plant_Materials", (PyCFunction)DF_Material_ReadPlantMaterials, METH_NOARGS, ""},
{"Read_Creature_Types", (PyCFunction)DF_Material_ReadCreatureTypes, METH_NOARGS, ""},
{NULL} //Sentinel
};
static PyTypeObject DF_Material_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.Material", /*tp_name*/
sizeof(DF_Material), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)DF_Material_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 Material objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DF_Material_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)DF_Material_init, /* tp_init */
0, /* tp_alloc */
DF_Material_new, /* tp_new */
};
#endif

@ -0,0 +1,674 @@
/*
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 __DF_MEMINFO__
#define __DF_MEMINFO__
#include "Python.h"
#include <string>
using namespace std;
#include "Export.h"
#include "DFCommonInternal.h"
#include "DFMemInfo.h"
using namespace DFHack;
struct DF_MemInfo
{
PyObject_HEAD
DFHack::memory_info* mem_Ptr;
};
// MemInfo type Allocation, Deallocation, and Initialization
static PyObject* DF_MemInfo_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_MemInfo* self;
self = (DF_MemInfo*)type->tp_alloc(type, 0);
if(self != NULL)
self->mem_Ptr = NULL;
return (PyObject*)self;
}
static int DF_MemInfo_init(DF_MemInfo* self, PyObject* args, PyObject* kwds)
{
return 0;
}
static void DF_MemInfo_dealloc(DF_MemInfo* self)
{
if(self != NULL)
{
if(self->mem_Ptr != NULL)
{
delete self->mem_Ptr;
self->mem_Ptr = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
}
// Setters/Getters
static PyObject* DF_MemInfo_getBase(DF_MemInfo* self)
{
if(self->mem_Ptr != NULL)
{
return PyInt_FromLong(self->mem_Ptr->getBase());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_setBase(DF_MemInfo* self, PyObject* args)
{
PyObject* arg = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "O", arg))
{
PyErr_SetString(PyExc_ValueError, "Bad argument list");
return NULL;
}
if(PyString_Check(arg))
self->mem_Ptr->setBase(std::string(PyString_AsString(arg)));
else if(PyInt_Check(arg))
self->mem_Ptr->setBase((uint32_t)PyInt_AsUnsignedLongMask(arg));
else
{
PyErr_SetString(PyExc_ValueError, "Argument must be string or integer");
return NULL;
}
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_getVersion(DF_MemInfo* self)
{
if(self->mem_Ptr != NULL)
{
return PyString_FromString(self->mem_Ptr->getVersion().c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_setVersion(DF_MemInfo* self, PyObject* args)
{
const char* v = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "s", &v))
return NULL;
self->mem_Ptr->setVersion(v);
}
Py_RETURN_NONE;
}
static PyGetSetDef DF_MemInfo_getterSetters[] =
{
{"base", (getter)DF_MemInfo_getBase, (setter)DF_MemInfo_setBase, "base", NULL},
{"version", (getter)DF_MemInfo_getVersion, (setter)DF_MemInfo_setVersion, "version", NULL},
{NULL} // Sentinel
};
// Member methods
static PyObject* DF_MemInfo_GetOffset(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "s", &s))
return NULL;
return PyInt_FromLong(self->mem_Ptr->getOffset(s));
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetOffset(DF_MemInfo* self, PyObject* args)
{
// const char* s = NULL;
// const char* n = NULL;
// int32_t i;
// PyObject* obj;
// if(self->mem_Ptr != NULL)
// {
// if(!PyArg_ParseTuple(args, "sO", &s, &obj))
// return NULL;
// if(PyString_Check(obj))
// {
// n = PyString_AsString(obj);
// self->mem_Ptr->setOffset(s, n);
// }
// else if(PyInt_Check(obj))
// {
// i = (int32_t)PyInt_AsLong(obj);
// self->mem_Ptr->setOffset(s, i);
// }
// }
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetAddress(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "s", &s))
return NULL;
return PyInt_FromLong(self->mem_Ptr->getAddress(s));
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetAddress(DF_MemInfo* self, PyObject* args)
{
// const char* s = NULL;
// const char* n = NULL;
// int32_t i;
// PyObject* obj;
// if(self->mem_Ptr != NULL)
// {
// if(!PyArg_ParseTuple(args, "sO", &s, &obj))
// return NULL;
// if(PyString_Check(obj))
// {
// n = PyString_AsString(obj);
// self->mem_Ptr->setAddress(s, n);
// }
// else if(PyInt_Check(obj))
// {
// i = (int32_t)PyInt_AsLong(obj);
// self->mem_Ptr->setAddress(s, i);
// }
// }
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetHexValue(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "s", &s))
return NULL;
return PyInt_FromLong(self->mem_Ptr->getHexValue(s));
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetHexValue(DF_MemInfo* self, PyObject* args)
{
// const char* s = NULL;
// const char* n = NULL;
// int32_t i;
// PyObject* obj;
// if(self->mem_Ptr != NULL)
// {
// if(!PyArg_ParseTuple(args, "sO", &s, &obj))
// return NULL;
// if(PyString_Check(obj))
// {
// n = PyString_AsString(obj);
// self->mem_Ptr->setHexValue(s, n);
// }
// else if(PyInt_Check(obj))
// {
// i = (int32_t)PyInt_AsLong(obj);
// self->mem_Ptr->setHexValue(s, i);
// }
// }
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetString(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "s", &s))
return NULL;
return PyString_FromString(self->mem_Ptr->getString(s).c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetString(DF_MemInfo* self, PyObject* args)
{
// const char* s = NULL;
// const char* n = NULL;
// if(self->mem_Ptr != NULL)
// {
// if(!PyArg_ParseTuple(args, "ss", &s, &n))
// return NULL;
// self->mem_Ptr->setString(s, n);
// }
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetProfession(DF_MemInfo* self, PyObject* args)
{
uint32_t s;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "I", &s))
return NULL;
return PyString_FromString(self->mem_Ptr->getProfession(s).c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetProfession(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
const char* n = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "ss", &s, &n))
return NULL;
self->mem_Ptr->setProfession(s, n);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetJob(DF_MemInfo* self, PyObject* args)
{
uint32_t s;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "I", &s))
return NULL;
return PyString_FromString(self->mem_Ptr->getJob(s).c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetJob(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
const char* n = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "ss", &s, &n))
return NULL;
self->mem_Ptr->setJob(s, n);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetSkill(DF_MemInfo* self, PyObject* args)
{
uint32_t s;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "I", &s))
return NULL;
return PyString_FromString(self->mem_Ptr->getSkill(s).c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetSkill(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
const char* n = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "ss", &s, &n))
return NULL;
self->mem_Ptr->setSkill(s, n);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetTrait(DF_MemInfo* self, PyObject* args)
{
uint32_t s, n;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "II", &s, &n))
return NULL;
return PyString_FromString(self->mem_Ptr->getTrait(s, n).c_str());
}
Py_RETURN_NONE;
}
// I have no idea what any of the strings are, so I can't really put meaningful names - doomchild
static PyObject* DF_MemInfo_SetTrait(DF_MemInfo* self, PyObject* args)
{
const char* a = NULL;
const char* b = NULL;
const char* c = NULL;
const char* d = NULL;
const char* e = NULL;
const char* f = NULL;
const char* g = NULL;
const char* h = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "ssssssss", &a, &b, &c, &d, &e, &f, &g, &h))
return NULL;
self->mem_Ptr->setTrait(a, b, c, d, e, f, g, h);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetTraitName(DF_MemInfo* self, PyObject* args)
{
uint32_t s;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "I", &s))
return NULL;
return PyString_FromString(self->mem_Ptr->getTraitName(s).c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_GetLabor(DF_MemInfo* self, PyObject* args)
{
uint32_t s;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "i", &s))
return NULL;
return PyString_FromString(self->mem_Ptr->getLabor(s).c_str());
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_SetLabor(DF_MemInfo* self, PyObject* args)
{
const char* s = NULL;
const char* n = NULL;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "ss", &s, &n))
return NULL;
self->mem_Ptr->setLabor(s, n);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_RebaseAddresses(DF_MemInfo* self, PyObject* args)
{
int32_t base;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "i", &base))
return NULL;
self->mem_Ptr->RebaseAddresses(base);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_RebaseAll(DF_MemInfo* self, PyObject* args)
{
int32_t base;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "i", &base))
return NULL;
self->mem_Ptr->RebaseAll(base);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_RebaseVTable(DF_MemInfo* self, PyObject* args)
{
int32_t offset;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "i", &offset))
return NULL;
self->mem_Ptr->RebaseVTable(offset);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_ResolveObjectToClassID(DF_MemInfo* self, PyObject* args)
{
uint32_t address;
int32_t classID;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "I", &address))
return NULL;
if(self->mem_Ptr->resolveObjectToClassID(address, classID))
return PyInt_FromLong(classID);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_ResolveClassNameToClassID(DF_MemInfo* self, PyObject* args)
{
// const char* name;
// int32_t classID;
// if(self->mem_Ptr != NULL)
// {
// if(!PyArg_ParseTuple(args, "s", &name))
// return NULL;
// if(self->mem_Ptr->resolveClassnameToClassID(name, classID))
// return PyInt_FromLong(classID);
// }
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_ResolveClassNameToVPtr(DF_MemInfo* self, PyObject* args)
{
const char* n;
uint32_t vPtr;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "s", &n))
return NULL;
std::string name(n);
if(self->mem_Ptr->resolveClassnameToVPtr(name, vPtr))
return PyInt_FromLong(vPtr);
}
Py_RETURN_NONE;
}
static PyObject* DF_MemInfo_ResolveClassIDToClassName(DF_MemInfo* self, PyObject* args)
{
int32_t id;
string name;
if(self->mem_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "i", &id))
return NULL;
if(self->mem_Ptr->resolveClassIDToClassname(id, name))
return PyString_FromString(name.c_str());
}
Py_RETURN_NONE;
}
static PyMethodDef DF_MemInfo_methods[] =
{
{"Rebase_Addresses", (PyCFunction)DF_MemInfo_RebaseAddresses, METH_VARARGS, ""},
{"Rebase_All", (PyCFunction)DF_MemInfo_RebaseAll, METH_VARARGS, ""},
{"Rebase_VTable", (PyCFunction)DF_MemInfo_RebaseVTable, METH_VARARGS, ""},
{"Get_Offset", (PyCFunction)DF_MemInfo_GetOffset, METH_VARARGS, ""},
{"Set_Offset", (PyCFunction)DF_MemInfo_SetOffset, METH_VARARGS, ""},
{"Get_Address", (PyCFunction)DF_MemInfo_GetAddress, METH_VARARGS, ""},
{"Set_Address", (PyCFunction)DF_MemInfo_SetAddress, METH_VARARGS, ""},
{"Get_HexValue", (PyCFunction)DF_MemInfo_GetHexValue, METH_VARARGS, ""},
{"Set_HexValue", (PyCFunction)DF_MemInfo_SetHexValue, METH_VARARGS, ""},
{"Get_String", (PyCFunction)DF_MemInfo_GetString, METH_VARARGS, ""},
{"Set_String", (PyCFunction)DF_MemInfo_SetString, METH_VARARGS, ""},
{"Get_Profession", (PyCFunction)DF_MemInfo_GetProfession, METH_VARARGS, ""},
{"Set_Profession", (PyCFunction)DF_MemInfo_SetProfession, METH_VARARGS, ""},
{"Get_Job", (PyCFunction)DF_MemInfo_GetJob, METH_VARARGS, ""},
{"Set_Job", (PyCFunction)DF_MemInfo_SetJob, METH_VARARGS, ""},
{"Get_Skill", (PyCFunction)DF_MemInfo_GetSkill, METH_VARARGS, ""},
{"Set_Skill", (PyCFunction)DF_MemInfo_SetSkill, METH_VARARGS, ""},
{"Get_Trait", (PyCFunction)DF_MemInfo_GetTrait, METH_VARARGS, ""},
{"Set_Trait", (PyCFunction)DF_MemInfo_SetTrait, METH_VARARGS, ""},
{"Get_Trait_Name", (PyCFunction)DF_MemInfo_GetTraitName, METH_VARARGS, ""},
{"Get_Labor", (PyCFunction)DF_MemInfo_GetLabor, METH_VARARGS, ""},
{"Set_Labor", (PyCFunction)DF_MemInfo_SetLabor, METH_VARARGS, ""},
{"Resolve_Object_To_Class_ID", (PyCFunction)DF_MemInfo_ResolveObjectToClassID, METH_VARARGS, ""},
{"Resolve_Classname_To_Class_ID", (PyCFunction)DF_MemInfo_ResolveClassNameToClassID, METH_VARARGS, ""},
{"Resolve_Classname_To_VPtr", (PyCFunction)DF_MemInfo_ResolveClassNameToVPtr, METH_VARARGS, ""},
{"Resolve_Class_ID_To_Classname", (PyCFunction)DF_MemInfo_ResolveClassIDToClassName, METH_VARARGS, ""},
{NULL} //Sentinel
};
static PyTypeObject DF_MemInfo_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.DF_MemInfo", /*tp_name*/
sizeof(DF_MemInfo), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)DF_MemInfo_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 DF_MemInfo objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
DF_MemInfo_methods, /* tp_methods */
0, /* tp_members */
DF_MemInfo_getterSetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)DF_MemInfo_init, /* tp_init */
0, /* tp_alloc */
DF_MemInfo_new, /* tp_new */
};
#endif

@ -0,0 +1,201 @@
/*
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 __DFPOSITION__
#define __DFPOSITION__
#include "Python.h"
#include "modules/Position.h"
using namespace DFHack;
struct DF_Position
{
PyObject_HEAD
DFHack::Position* pos_Ptr;
};
// API type Allocation, Deallocation, and Initialization
static PyObject* DF_Position_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_Position* self;
self = (DF_Position*)type->tp_alloc(type, 0);
if(self != NULL)
self->pos_Ptr = NULL;
return (PyObject*)self;
}
static int DF_Position_init(DF_Position* self, PyObject* args, PyObject* kwds)
{
return 0;
}
static void DF_Position_dealloc(DF_Position* self)
{
if(self != NULL)
{
if(self->pos_Ptr != NULL)
{
delete self->pos_Ptr;
self->pos_Ptr = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
}
// Getters/Setters
static PyObject* DF_Position_getViewCoords(DF_Position* self, void* closure)
{
int32_t x, y, z;
if(self->pos_Ptr != NULL)
{
if(self->pos_Ptr->getViewCoords(x, y, z))
return Py_BuildValue("iii", x, y, z);
}
Py_RETURN_NONE;
}
static PyObject* DF_Position_setViewCoords(DF_Position* self, PyObject* args)
{
int32_t x, y, z;
if(self->pos_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "iii", &x, &y, &z))
return NULL;
if(self->pos_Ptr->setViewCoords(x, y, z))
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
Py_RETURN_NONE;
}
static PyObject* DF_Position_getCursorCoords(DF_Position* self, void* closure)
{
int32_t x, y, z;
if(self->pos_Ptr != NULL)
{
if(self->pos_Ptr->getCursorCoords(x, y, z))
return Py_BuildValue("iii", x, y, z);
}
Py_RETURN_NONE;
}
static PyObject* DF_Position_setCursorCoords(DF_Position* self, PyObject* args)
{
int32_t x, y, z;
if(self->pos_Ptr != NULL)
{
if(!PyArg_ParseTuple(args, "iii", &x, &y, &z))
return NULL;
if(self->pos_Ptr->setCursorCoords(x, y, z))
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
Py_RETURN_NONE;
}
static PyObject* DF_Position_getWindowSize(DF_Position* self, void* closure)
{
int32_t x, y;
if(self->pos_Ptr != NULL)
{
if(self->pos_Ptr->getWindowSize(x, y))
return Py_BuildValue("ii", x, y);
}
Py_RETURN_NONE;
}
static PyGetSetDef DF_Position_getterSetters[] =
{
{"view_coords", (getter)DF_Position_getViewCoords, (setter)DF_Position_setViewCoords, "view_coords", NULL},
{"cursor_coords", (getter)DF_Position_getCursorCoords, (setter)DF_Position_setCursorCoords, "cursor_coords", NULL},
{"window_size", (getter)DF_Position_getWindowSize, NULL, "window_size", NULL},
{NULL} // Sentinel
};
static PyTypeObject DF_Position_type =
{
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"pydfhack.Position", /*tp_name*/
sizeof(DF_Position), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)DF_Position_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 Position objects", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
DF_Position_getterSetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)DF_Position_init, /* tp_init */
0, /* tp_alloc */
DF_Position_new, /* tp_new */
};
#endif

@ -0,0 +1,105 @@
/*
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 __DFTRANSLATION__
#define __DFTRANSLATION__
#include "Python.h"
#include "modules/Translation.h"
using namespace
struct DF_Translation
{
PyObject_HEAD
DFHack::Translation* trans_Ptr;
};
// API type Allocation, Deallocation, and Initialization
static PyObject* DF_Translation_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
{
DF_Translation* self;
self = (DF_Translation*)type->tp_alloc(type, 0);
if(self != NULL)
self->trans_Ptr = NULL;
return (PyObject*)self;
}
static int DF_Translation_init(DF_Translation* self, PyObject* args, PyObject* kwds)
{
return 0;
}
static void DF_Translation_dealloc(DF_Translation* self)
{
if(self != NULL)
{
if(self->trans_Ptr != NULL)
{
delete self->trans_Ptr;
self->trans_Ptr = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
}
// Type methods
static PyObject* DF_Translation_Start(DF_Translation* self, PyObject* args)
{
if(self->trans_Ptr != NULL)
{
if(self->trans_Ptr->Start())
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
Py_RETURN_NONE;
}
static PyObject* DF_Translation_Finish(DF_Translation* self, PyObject* args)
{
if(self->trans_Ptr != NULL)
{
if(self->trans_Ptr->Finish())
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
Py_RETURN_NONE;
}
static PyObject* DF_Translation_TranslateName(DF_Translation* self, PyObject* args)
{
}
#endif

@ -1,215 +0,0 @@
/*
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

@ -1,231 +0,0 @@
/*
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

@ -23,13 +23,36 @@ distribution.
*/
#include "Python.h"
#include "UnionBase.cpp"
#include "DF_Imports.cpp"
#include "DF_MemInfo.cpp"
#include "DF_Material.cpp"
#include "DF_CreatureType.cpp"
#include "DF_CreatureManager.cpp"
#include "DF_API.cpp"
#ifndef PyMODINIT_FUNC
#define PyMODINIT_FUNC void
#endif
extern "C"
{
void ReadRaw(DF_API* self, const uint32_t offset, const uint32_t size, uint8_t* target)
{
if(self != NULL && self->api_Ptr != NULL)
{
self->api_Ptr->ReadRaw(offset, size, target);
}
}
void WriteRaw(DF_API* self, const uint32_t offset, const uint32_t size, uint8_t* source)
{
if(self != NULL && self->api_Ptr != NULL)
{
self->api_Ptr->WriteRaw(offset, size, source);
}
}
};
static PyMethodDef module_methods[] =
{
{NULL} //Sentinel
@ -39,17 +62,39 @@ PyMODINIT_FUNC initpydfhack(void)
{
PyObject* module;
if(PyType_Ready(&UnionBase_type) < 0)
if(PyType_Ready(&DF_API_type) < 0)
return;
if(PyType_Ready(&DF_API_type) < 0)
if(PyType_Ready(&DF_MemInfo_type) < 0)
return;
if(PyType_Ready(&DF_Position_type) < 0)
return;
if(PyType_Ready(&DF_Material_type) < 0)
return;
if(PyType_Ready(&DF_Creature_Base_type) < 0)
return;
if(PyType_Ready(&DF_CreatureManager_type) < 0)
return;
module = Py_InitModule3("pydfhack", module_methods, "pydfhack extension module");
Py_INCREF(&UnionBase_type);
Py_INCREF(&DF_API_type);
Py_INCREF(&DF_MemInfo_type);
Py_INCREF(&DF_Position_type);
Py_INCREF(&DF_Material_type);
Py_INCREF(&DF_Creature_Base_type);
Py_INCREF(&DF_CreatureManager_type);
PyModule_AddObject(module, "UnionBase", (PyObject*)&UnionBase_type);
PyModule_AddObject(module, "API", (PyObject*)&DF_API_type);
PyModule_AddObject(module, "MemInfo", (PyObject*)&DF_MemInfo_type);
PyModule_AddObject(module, "Position", (PyObject*)&DF_Position_type);
PyModule_AddObject(module, "Materials", (PyObject*)&DF_Material_type);
PyModule_AddObject(module, "Creature_Base", (PyObject*)&DF_Position_type);
PyModule_AddObject(module, "CreatureManager", (PyObject*)&DF_Material_type);
DoImports();
}

@ -1,234 +1,213 @@
# -*- coding: utf-8 -*-
from pydfhack import *
from ctypes 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)]
temp = API.Read_Designations(self, x, y, z)
d_list = []
for i in temp:
d = []
for j in i:
d.append(DesignationFlags(j))
d_list.append(d)
return d_list
def Write_Designations(self, x, y, z, d_list):
temp = []
for i in d_list:
t = []
for j in i:
t.append(j.whole)
temp.append(t)
API.Write_Designations(self, x, y, z, temp)
def Read_Occupancy(self, x, y, z):
o_list = [OccupancyFlags(o) for o in API.Read_Occupancy(self, x, y, z)]
temp = API.Read_Occupancy(self, x, y, z)
o_list = []
for i in temp:
o = []
for j in i:
o.append(OccupancyFlags(j))
o_list.append(o)
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 DesignationStruct(Structure):
_fields_ = [("flow_size", c_uint, 3),
("pile", c_uint, 1),
("dig", c_uint, 3),
("smooth", c_uint, 2),
("hidden", c_uint, 1),
("geolayer_index", c_uint, 4),
("light", c_uint, 1),
("subterranean", c_uint, 1),
("skyview", c_uint, 1),
("biome", c_uint, 4),
("liquid_type", c_uint, 1),
("water_table", c_uint, 1),
("rained", c_uint, 1),
("traffic", c_uint, 2),
("flow_forbid", c_uint, 1),
("liquid_static", c_uint, 1),
("moss", c_uint, 1),
("feature_present", c_uint, 1),
("liquid_character", c_uint, 2)]
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))
class DesignationFlags(Union):
_fields_ = [("whole", c_uint, 32),
("bits", DesignationStruct)]
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))
def __init__(self, initial = 0):
self.whole = initial
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))
class OccupancyStruct(Strucure):
_fields_ = [("building", c_uint, 3),
("unit", c_uint, 1),
("unit_grounded", c_uint, 1),
("item", c_uint, 1),
("splatter", c_uint, 26)]
class OccupancyFlags(Union):
_fields_ = [("whole", c_uint, 32),
("bits", OccupancyStruct)]
def __init__(self, initial = 0):
self.whole = initial
class CreatureStruct1(Structure):
_fields_ = [("move_state", c_uint, 1),
("dead", c_uint, 1),
("has_mood", c_uint, 1),
("had_mood", c_uint, 1),
("marauder", c_uint, 1),
("drowning", c_uint, 1),
("merchant", c_uint, 1),
("forest", c_uint, 1),
("left", c_uint, 1),
("rider", c_uint, 1),
("incoming", c_uint, 1),
("diplomat", c_uint, 1),
("zombie", c_uint, 1),
("skeleton", c_uint, 1),
("can_swap", c_uint, 1),
("on_ground", c_uint, 1),
("projectile", c_uint, 1),
("active_invader", c_uint, 1),
("hidden_in_ambush", c_uint, 1),
("invader_origin", c_uint, 1),
("coward", c_uint, 1),
("hidden_ambusher", c_uint, 1),
("invades", c_uint, 1),
("check_flows", c_uint, 1),
("ridden", c_uint, 1),
("caged", c_uint, 1),
("tame", c_uint, 1),
("chained", c_uint, 1),
("royal_guard", c_uint, 1),
("fortress_guard", c_uint, 1),
("suppress_wield", c_uint, 1),
("important_historical_figure", c_uint, 1)]
class CreatureFlags1(Union):
_fields_ = [("whole", c_uint, 32),
("bits", CreatureStruct1)]
def __init__(self, initial = 0):
self.whole = initial
class CreatureStruct2(Structure):
_fields_ = [("swimming", c_uint, 1),
("sparring", c_uint, 1),
("no_notify", c_uint, 1),
("unused", c_uint, 1),
("calculated_nerves", c_uint, 1),
("calculated_bodyparts", c_uint, 1),
("important_historical_figure", c_uint, 1),
("killed", c_uint, 1),
("cleanup_1", c_uint, 1),
("cleanup_2", c_uint, 1),
("cleanup_3", c_uint, 1),
("for_trade", c_uint, 1),
("trade_resolved", c_uint, 1),
("has_breaks", c_uint, 1),
("gutted", c_uint, 1),
("circulatory_spray", c_uint, 1),
("locked_in_for_trading", c_uint, 1),
("slaughter", c_uint, 1),
("underworld", c_uint, 1),
("resident", c_uint, 1),
("cleanup_4", c_uint, 1),
("calculated_insulation", c_uint, 1),
("visitor_uninvited", c_uint, 1),
("visitor", c_uint, 1),
("calculated_inventory", c_uint, 1),
("vision_good", c_uint, 1),
("vision_damaged", c_uint, 1),
("vision_missing", c_uint, 1),
("breathing_good", c_uint, 1),
("breathing_problem", c_uint, 1),
("roaming_wilderness_population_source", c_uint, 1),
("roaming_wilderness_population_source_not_a_map_feature", c_uint, 1)]
class CreatureFlags2(Union):
_fields_ = [("whole", c_uint, 32),
("bits", CreatureStruct2)]
def __init__(self, initial = 0):
self.whole = initial
class ItemStruct(Structure):
_fields_ = [("on_ground", c_uint, 1),
("in_job", c_uint, 1),
("in_inventory", c_uint, 1),
("u_ngrd1", c_uint, 1),
("in_workshop", c_uint, 1),
("u_ngrd2", c_uint, 1),
("u_ngrd3", c_uint, 1),
("rotten", c_uint, 1),
("unk1", c_uint, 1),
("u_ngrd4", c_uint, 1),
("unk2", c_uint, 1),
("u_ngrd5", c_uint, 1),
("unk3", c_uint, 1),
("u_ngrd6", c_uint, 1),
("narrow", c_uint, 1),
("u_ngrd7", c_uint, 1),
("worn", c_uint, 1),
("unk4", c_uint, 1),
("u_ngrd8", c_uint, 1),
("forbid", c_uint, 1),
("unk5", c_uint, 1),
("dump", c_uint, 1),
("on_fire", c_uint, 1),
("melt", c_uint, 1),
("hidden", c_uint, 1),
("u_ngrd9", c_uint, 1),
("unk6", c_uint, 1),
("unk7", c_uint, 1),
("unk8", c_uint, 1),
("unk9", c_uint, 1),
("unk10", c_uint, 1),
("unk11", c_uint, 1)]
class ItemFlags(Union):
_fields_ = [("whole", c_uint, 32),
("bits", ItemStruct)]
def __init__(self, initial = 0):
self.whole = initial
dig_types = { "no" : 0,
"default" : 1,
@ -243,182 +222,3 @@ 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))

@ -2,9 +2,10 @@
from distutils.core import setup, Extension
e = Extension("pydfhack",
sources=["UnionBase.cpp", "pydfhack.cpp", "DF_API.cpp"],
include_dirs=["..\\include"],
sources=["DF_MemInfo.cpp", "DF_API.cpp", "pydfhack.cpp"],
include_dirs=["..\\", "..\\include", "..\\depends\\md5", "..\\depends\\tinyxml"],
library_dirs=["..\\..\\output"],
libraries=["libdfhack"])
libraries=["libdfhack"],
export_symbols=["initpydfhack", "ReadRaw", "WriteRaw"])
setup(name="PyDFHack", version="1.0", ext_modules=[e])