Merge branch 'master' of git://github.com/doomchild/dfhack
commit
39eacd2069
@ -0,0 +1,205 @@
|
||||
/*
|
||||
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 __DFBUILDINGS__
|
||||
#define __DFBUILDINGS__
|
||||
|
||||
#include "Python.h"
|
||||
#include "modules/Buildings.h"
|
||||
#include "DF_Helpers.cpp"
|
||||
|
||||
using namespace DFHack;
|
||||
|
||||
static PyObject* BuildBuilding(DFHack::t_building& building)
|
||||
{
|
||||
PyObject* t_dict;
|
||||
PyObject* temp;
|
||||
|
||||
t_dict = PyDict_New();
|
||||
|
||||
temp = PyInt_FromLong(building.origin);
|
||||
DICTADD(t_dict, "origin", temp);
|
||||
|
||||
temp = PyInt_FromLong(building.vtable);
|
||||
DICTADD(t_dict, "vtable", temp);
|
||||
|
||||
temp = PyInt_FromLong(building.type);
|
||||
DICTADD(t_dict, "type", temp);
|
||||
|
||||
temp = BuildMatglossPair(building.material);
|
||||
DICTADD(t_dict, "material", temp);
|
||||
|
||||
temp = PyTuple_Pack(2, PyTuple_Pack(2, building.x1, building.y1), PyTuple_Pack(2, building.x2, building.y2));
|
||||
DICTADD(t_dict, "bounds", temp);
|
||||
|
||||
return t_dict;
|
||||
}
|
||||
|
||||
struct DF_Building
|
||||
{
|
||||
PyObject_HEAD
|
||||
DFHack::Buildings* b_Ptr;
|
||||
};
|
||||
|
||||
static PyObject* DF_Building_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
DF_Building* self;
|
||||
|
||||
self = (DF_Building*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != NULL)
|
||||
self->b_Ptr = NULL;
|
||||
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
static int DF_Building_init(DF_Building* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DF_Building_dealloc(DF_Building* self)
|
||||
{
|
||||
PySys_WriteStdout("building dealloc\n");
|
||||
|
||||
if(self != NULL)
|
||||
{
|
||||
PySys_WriteStdout("building not NULL\n");
|
||||
|
||||
if(self->b_Ptr != NULL)
|
||||
{
|
||||
PySys_WriteStdout("b_Ptr = %i\n", (int)self->b_Ptr);
|
||||
|
||||
delete self->b_Ptr;
|
||||
|
||||
PySys_WriteStdout("b_Ptr deleted\n");
|
||||
|
||||
self->b_Ptr = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PySys_WriteStdout("building dealloc done\n");
|
||||
}
|
||||
|
||||
// Type methods
|
||||
|
||||
static PyObject* DF_Building_Start(DF_Building* self, PyObject* args)
|
||||
{
|
||||
uint32_t numBuildings = 0;
|
||||
|
||||
if(self->b_Ptr != NULL)
|
||||
{
|
||||
if(self->b_Ptr->Start(numBuildings))
|
||||
return PyInt_FromLong(numBuildings);
|
||||
else
|
||||
return PyInt_FromLong(-1);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Building_Finish(DF_Building* self, PyObject* args)
|
||||
{
|
||||
if(self->b_Ptr != NULL)
|
||||
{
|
||||
if(self->b_Ptr->Finish())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Building_Read(DF_Building* self, PyObject* args)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
t_building building;
|
||||
|
||||
if(self->b_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "I", &index))
|
||||
return NULL;
|
||||
|
||||
if(self->b_Ptr->Read(index, building))
|
||||
return BuildBuilding(building);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef DF_Building_methods[] =
|
||||
{
|
||||
{"Start", (PyCFunction)DF_Building_Start, METH_NOARGS, ""},
|
||||
{"Finish", (PyCFunction)DF_Building_Finish, METH_NOARGS, ""},
|
||||
{"Read", (PyCFunction)DF_Building_Read, METH_VARARGS, ""},
|
||||
{NULL} // Sentinel
|
||||
};
|
||||
|
||||
static PyTypeObject DF_Building_type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"pydfhack.Building", /*tp_name*/
|
||||
sizeof(DF_Building), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)DF_Building_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 Building objects", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
DF_Building_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_Building_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
DF_Building_new, /* tp_new */
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,220 @@
|
||||
/*
|
||||
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 __DFCONSTRUCTIONS__
|
||||
#define __DFCONSTRUCTIONS__
|
||||
|
||||
#include "Python.h"
|
||||
#include "modules/Constructions.h"
|
||||
#include "DF_Helpers.cpp"
|
||||
|
||||
using namespace DFHack;
|
||||
|
||||
static PyObject* BuildConstruction(DFHack::t_construction& construction)
|
||||
{
|
||||
PyObject* t_dict;
|
||||
PyObject* temp;
|
||||
|
||||
t_dict = PyDict_New();
|
||||
|
||||
temp = PyTuple_Pack(3, construction.x, construction.y, construction.z);
|
||||
DICTADD(t_dict, "position", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.form);
|
||||
DICTADD(t_dict, "form", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.unk_8);
|
||||
DICTADD(t_dict, "unk_8", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.mat_type);
|
||||
DICTADD(t_dict, "mat_type", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.mat_idx);
|
||||
DICTADD(t_dict, "mat_idx", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.unk3);
|
||||
DICTADD(t_dict, "unk3", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.unk4);
|
||||
DICTADD(t_dict, "unk4", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.unk5);
|
||||
DICTADD(t_dict, "unk5", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.unk6);
|
||||
DICTADD(t_dict, "unk6", temp);
|
||||
|
||||
temp = PyInt_FromLong(construction.origin);
|
||||
DICTADD(t_dict, "origin", temp);
|
||||
|
||||
return t_dict;
|
||||
}
|
||||
|
||||
struct DF_Construction
|
||||
{
|
||||
PyObject_HEAD
|
||||
DFHack::Constructions* c_Ptr;
|
||||
};
|
||||
|
||||
static PyObject* DF_Construction_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
DF_Construction* self;
|
||||
|
||||
self = (DF_Construction*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != NULL)
|
||||
self->c_Ptr = NULL;
|
||||
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
static int DF_Construction_init(DF_Construction* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DF_Construction_dealloc(DF_Construction* self)
|
||||
{
|
||||
PySys_WriteStdout("construction dealloc\n");
|
||||
|
||||
if(self != NULL)
|
||||
{
|
||||
PySys_WriteStdout("construction not NULL\n");
|
||||
|
||||
if(self->c_Ptr != NULL)
|
||||
{
|
||||
PySys_WriteStdout("c_Ptr = %i\n", (int)self->c_Ptr);
|
||||
|
||||
delete self->c_Ptr;
|
||||
|
||||
PySys_WriteStdout("c_Ptr deleted\n");
|
||||
|
||||
self->c_Ptr = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PySys_WriteStdout("construction dealloc done\n");
|
||||
}
|
||||
|
||||
// Type methods
|
||||
|
||||
static PyObject* DF_Construction_Start(DF_Construction* self, PyObject* args)
|
||||
{
|
||||
uint32_t numConstructions = 0;
|
||||
|
||||
if(self->c_Ptr != NULL)
|
||||
{
|
||||
if(self->c_Ptr->Start(numConstructions))
|
||||
return PyInt_FromLong(numConstructions);
|
||||
else
|
||||
return PyInt_FromLong(-1);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Construction_Finish(DF_Construction* self, PyObject* args)
|
||||
{
|
||||
if(self->c_Ptr != NULL)
|
||||
{
|
||||
if(self->c_Ptr->Finish())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Construction_Read(DF_Construction* self, PyObject* args)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
t_construction construction;
|
||||
|
||||
if(self->c_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "I", &index))
|
||||
return NULL;
|
||||
|
||||
if(self->c_Ptr->Read(index, construction))
|
||||
return BuildConstruction(construction);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef DF_Construction_methods[] =
|
||||
{
|
||||
{"Start", (PyCFunction)DF_Construction_Start, METH_NOARGS, ""},
|
||||
{"Finish", (PyCFunction)DF_Construction_Finish, METH_NOARGS, ""},
|
||||
{"Read", (PyCFunction)DF_Construction_Read, METH_VARARGS, ""},
|
||||
{NULL} // Sentinel
|
||||
};
|
||||
|
||||
static PyTypeObject DF_Construction_type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"pydfhack.Construction", /*tp_name*/
|
||||
sizeof(DF_Construction), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)DF_Construction_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 Construction objects", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
DF_Construction_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_Construction_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
DF_Construction_new, /* tp_new */
|
||||
};
|
||||
|
||||
#endif
|
@ -1,32 +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 __DFCREATURES__
|
||||
#define __DFCREATURES__
|
||||
|
||||
#include "Python.h"
|
||||
#include "DFTypes.h"
|
||||
#include "DF_CreatureType.cpp"
|
||||
|
||||
#endif
|
@ -0,0 +1,205 @@
|
||||
/*
|
||||
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 __DFGUI__
|
||||
#define __DFGUI__
|
||||
|
||||
#include "Python.h"
|
||||
#include "modules/Gui.h"
|
||||
|
||||
using namespace DFHack;
|
||||
|
||||
struct DF_GUI
|
||||
{
|
||||
PyObject_HEAD
|
||||
DFHack::Gui* g_Ptr;
|
||||
};
|
||||
|
||||
static PyObject* DF_GUI_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
DF_GUI* self;
|
||||
|
||||
self = (DF_GUI*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != NULL)
|
||||
self->g_Ptr = NULL;
|
||||
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
static int DF_GUI_init(DF_GUI* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DF_GUI_dealloc(DF_GUI* self)
|
||||
{
|
||||
PySys_WriteStdout("gui dealloc\n");
|
||||
|
||||
if(self != NULL)
|
||||
{
|
||||
PySys_WriteStdout("gui not NULL\n");
|
||||
|
||||
if(self->g_Ptr != NULL)
|
||||
{
|
||||
PySys_WriteStdout("g_Ptr = %i\n", (int)self->g_Ptr);
|
||||
|
||||
delete self->g_Ptr;
|
||||
|
||||
PySys_WriteStdout("g_Ptr deleted\n");
|
||||
|
||||
self->g_Ptr = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PySys_WriteStdout("gui dealloc done\n");
|
||||
}
|
||||
|
||||
// Type methods
|
||||
|
||||
static PyObject* DF_GUI_Start(DF_GUI* self, PyObject* args)
|
||||
{
|
||||
if(self->g_Ptr != NULL)
|
||||
{
|
||||
if(self->g_Ptr->Start())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_GUI_Finish(DF_GUI* self, PyObject* args)
|
||||
{
|
||||
if(self->g_Ptr != NULL)
|
||||
{
|
||||
if(self->g_Ptr->Finish())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_GUI_ReadViewScreen(DF_GUI* self, PyObject* args)
|
||||
{
|
||||
DFHack::t_viewscreen viewscreen;
|
||||
|
||||
if(self->g_Ptr != NULL)
|
||||
{
|
||||
if(self->g_Ptr->ReadViewScreen(viewscreen))
|
||||
return PyInt_FromLong(viewscreen.type);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef DF_GUI_methods[] =
|
||||
{
|
||||
{"Start", (PyCFunction)DF_GUI_Start, METH_NOARGS, ""},
|
||||
{"Finish", (PyCFunction)DF_GUI_Finish, METH_NOARGS, ""},
|
||||
{"Read_View_Screen", (PyCFunction)DF_GUI_ReadViewScreen, METH_NOARGS, ""},
|
||||
{NULL} //Sentinel
|
||||
};
|
||||
|
||||
// Getter/Setter
|
||||
|
||||
static PyObject* DF_GUI_getPauseState(DF_GUI* self, void* closure)
|
||||
{
|
||||
if(self->g_Ptr != NULL)
|
||||
{
|
||||
if(self->g_Ptr->ReadPauseState())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_GUI_getMenuState(DF_GUI* self, void* closure)
|
||||
{
|
||||
if(self->g_Ptr != NULL)
|
||||
{
|
||||
return PyInt_FromLong(self->g_Ptr->ReadMenuState());
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyGetSetDef DF_GUI_getterSetters[] =
|
||||
{
|
||||
{"paused", (getter)DF_GUI_getPauseState, NULL, "paused", NULL},
|
||||
{"menu_state", (getter)DF_GUI_getMenuState, NULL, "menu_state", NULL},
|
||||
{NULL} // Sentinel
|
||||
};
|
||||
|
||||
static PyTypeObject DF_GUI_type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"pydfhack.GUI", /*tp_name*/
|
||||
sizeof(DF_GUI), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)DF_GUI_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 GUI objects", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
DF_GUI_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
DF_GUI_getterSetters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
(initproc)DF_GUI_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
DF_GUI_new, /* tp_new */
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,859 @@
|
||||
/*
|
||||
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 __DFMAPS__
|
||||
#define __DFMAPS__
|
||||
|
||||
#include "Python.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "modules/Maps.h"
|
||||
#include "DF_Imports.cpp"
|
||||
#include "DF_Helpers.cpp"
|
||||
|
||||
using namespace DFHack;
|
||||
|
||||
static PyObject* BuildVein(DFHack::t_vein& v)
|
||||
{
|
||||
PyObject* vObj;
|
||||
PyObject* temp;
|
||||
|
||||
vObj = PyObject_Call(Vein_type, NULL, NULL);
|
||||
|
||||
temp = PyInt_FromLong(v.vtable);
|
||||
OBJSET(vObj, "vtable", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.type);
|
||||
OBJSET(vObj, "type", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.flags);
|
||||
OBJSET(vObj, "flags", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.address_of);
|
||||
OBJSET(vObj, "address", temp);
|
||||
|
||||
temp = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
PyList_SET_ITEM(temp, i, PyInt_FromLong(v.assignment[i]));
|
||||
|
||||
OBJSET(vObj, "assignment", temp);
|
||||
|
||||
return vObj;
|
||||
}
|
||||
|
||||
static PyObject* BuildFrozenLiquidVein(DFHack::t_frozenliquidvein& v)
|
||||
{
|
||||
PyObject* vObj;
|
||||
PyObject *temp, *list;
|
||||
|
||||
vObj = PyObject_Call(FrozenLiquidVein_type, NULL, NULL);
|
||||
|
||||
temp = PyInt_FromLong(v.vtable);
|
||||
OBJSET(vObj, "vtable", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.address_of);
|
||||
OBJSET(vObj, "address", temp);
|
||||
|
||||
list = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
temp = PyList_New(16);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
PyList_SET_ITEM(temp, j, PyInt_FromLong(v.tiles[i][j]));
|
||||
|
||||
PyList_SET_ITEM(list, i, temp);
|
||||
}
|
||||
|
||||
OBJSET(vObj, "tiles", list);
|
||||
|
||||
return vObj;
|
||||
}
|
||||
|
||||
static PyObject* BuildSpatterVein(DFHack::t_spattervein& v)
|
||||
{
|
||||
PyObject* vObj;
|
||||
PyObject *temp, *list;
|
||||
|
||||
vObj = PyObject_Call(SpatterVein_type, NULL, NULL);
|
||||
|
||||
temp = PyInt_FromLong(v.vtable);
|
||||
OBJSET(vObj, "vtable", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.address_of);
|
||||
OBJSET(vObj, "address", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.mat1);
|
||||
OBJSET(vObj, "mat1", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.unk1);
|
||||
OBJSET(vObj, "unk1", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.mat2);
|
||||
OBJSET(vObj, "mat2", temp);
|
||||
|
||||
temp = PyInt_FromLong(v.mat3);
|
||||
OBJSET(vObj, "mat3", temp);
|
||||
|
||||
list = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
temp = PyList_New(16);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
PyList_SET_ITEM(temp, j, PyInt_FromLong(v.intensity[i][j]));
|
||||
|
||||
PyList_SET_ITEM(list, i, temp);
|
||||
}
|
||||
|
||||
OBJSET(vObj, "intensity", list);
|
||||
|
||||
return vObj;
|
||||
}
|
||||
|
||||
static PyObject* BuildVeinDict(std::vector<t_vein>& veins, std::vector<t_frozenliquidvein>& ices, std::vector<t_spattervein>& splatter)
|
||||
{
|
||||
PyObject* vDict;
|
||||
PyObject* vList;
|
||||
int veinSize;
|
||||
|
||||
vDict = PyDict_New();
|
||||
|
||||
veinSize = veins.size();
|
||||
|
||||
if(veinSize <= 0)
|
||||
{
|
||||
Py_INCREF(Py_None);
|
||||
DICTADD(vDict, "veins", Py_None);
|
||||
}
|
||||
else
|
||||
{
|
||||
vList = PyList_New(veinSize);
|
||||
|
||||
for(int i = 0; i < veinSize; i++)
|
||||
PyList_SET_ITEM(vList, i, BuildVein(veins[i]));
|
||||
|
||||
DICTADD(vDict, "veins", vList);
|
||||
}
|
||||
|
||||
veinSize = ices.size();
|
||||
|
||||
if(veinSize <= 0)
|
||||
{
|
||||
Py_INCREF(Py_None);
|
||||
DICTADD(vDict, "ices", Py_None);
|
||||
}
|
||||
else
|
||||
{
|
||||
vList = PyList_New(veinSize);
|
||||
|
||||
for(int i = 0; i < veinSize; i++)
|
||||
PyList_SET_ITEM(vList, i, BuildFrozenLiquidVein(ices[i]));
|
||||
|
||||
DICTADD(vDict, "ices", vList);
|
||||
}
|
||||
|
||||
veinSize = splatter.size();
|
||||
|
||||
if(veinSize <= 0)
|
||||
{
|
||||
Py_INCREF(Py_None);
|
||||
DICTADD(vDict, "spatter", Py_None);
|
||||
}
|
||||
else
|
||||
{
|
||||
vList = PyList_New(veinSize);
|
||||
|
||||
for(int i = 0; i < veinSize; i++)
|
||||
PyList_SET_ITEM(vList, i, BuildSpatterVein(splatter[i]));
|
||||
|
||||
DICTADD(vDict, "spatter", vList);
|
||||
}
|
||||
|
||||
return vDict;
|
||||
}
|
||||
|
||||
static PyObject* BuildTileTypes40d(DFHack::tiletypes40d& types)
|
||||
{
|
||||
PyObject *list, *temp;
|
||||
|
||||
list = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
temp = PyList_New(16);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
PyList_SET_ITEM(temp, j, PyInt_FromLong(types[i][j]));
|
||||
|
||||
PyList_SET_ITEM(list, i, temp);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void ReverseBuildTileTypes40d(PyObject* list, DFHack::tiletypes40d t_types)
|
||||
{
|
||||
PyObject* innerList;
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
innerList = PyList_GetItem(list, i);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
t_types[i][j] = (uint16_t)PyInt_AsLong(PyList_GetItem(innerList, j));
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject* BuildOccupancies40d(DFHack::occupancies40d& occ)
|
||||
{
|
||||
PyObject *list, *temp, *args;
|
||||
|
||||
list = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
temp = PyList_New(16);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
args = Py_BuildValue("(I)", occ[i][j].whole);
|
||||
|
||||
PyList_SET_ITEM(temp, j, PyObject_Call(OccupancyFlags_type, args, NULL));
|
||||
|
||||
Py_DECREF(args);
|
||||
}
|
||||
|
||||
PyList_SET_ITEM(list, i, temp);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void ReverseBuildOccupancies40d(PyObject* list, DFHack::occupancies40d occ)
|
||||
{
|
||||
PyObject* innerList;
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
innerList = PyList_GetItem(list, i);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
occ[i][j].whole = (uint32_t)PyInt_AsLong(PyList_GetItem(innerList, j));
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject* BuildDesignations40d(DFHack::designations40d& des)
|
||||
{
|
||||
PyObject *list, *temp, *args;
|
||||
|
||||
list = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
temp = PyList_New(16);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
args = Py_BuildValue("(I)", des[i][j].whole);
|
||||
|
||||
PyList_SET_ITEM(temp, j, PyObject_Call(DesignationFlags_type, args, NULL));
|
||||
|
||||
Py_DECREF(args);
|
||||
}
|
||||
|
||||
PyList_SET_ITEM(list, i, temp);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void ReverseBuildDesignations40d(PyObject* list, DFHack::designations40d& des)
|
||||
{
|
||||
PyObject* innerList;
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
innerList = PyList_GetItem(list, i);
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
des[i][j].whole = (uint32_t)PyInt_AsLong(PyList_GET_ITEM(innerList, j));
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject* BuildBiomeIndices40d(DFHack::biome_indices40d& idx)
|
||||
{
|
||||
PyObject *list;
|
||||
|
||||
list = PyList_New(16);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
PyList_SET_ITEM(list, i, PyInt_FromLong(idx[i]));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void ReverseBuildBiomeIndices40d(PyObject* list, DFHack::biome_indices40d bio)
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
bio[i] = (uint8_t)PyInt_AsLong(PyList_GetItem(list, i));
|
||||
}
|
||||
|
||||
static PyObject* BuildMapBlock40d(DFHack::mapblock40d& block)
|
||||
{
|
||||
PyObject *b_Obj;
|
||||
PyObject *temp, *args;
|
||||
|
||||
b_Obj = PyObject_Call(MapBlock40d_type, NULL, NULL);
|
||||
|
||||
temp = BuildTileTypes40d(block.tiletypes);
|
||||
OBJSET(b_Obj, "tiletypes", temp);
|
||||
|
||||
temp = BuildDesignations40d(block.designation);
|
||||
OBJSET(b_Obj, "designation", temp);
|
||||
|
||||
temp = BuildOccupancies40d(block.occupancy);
|
||||
OBJSET(b_Obj, "occupancy", temp);
|
||||
|
||||
temp = BuildBiomeIndices40d(block.biome_indices);
|
||||
OBJSET(b_Obj, "biome_indices", temp);
|
||||
|
||||
temp = PyInt_FromLong(block.origin);
|
||||
OBJSET(b_Obj, "origin", temp);
|
||||
|
||||
args = Py_BuildValue("(I)", block.blockflags.whole);
|
||||
temp = PyObject_CallObject(BlockFlags_type, args);
|
||||
|
||||
temp = PyInt_FromLong(block.blockflags.whole);
|
||||
OBJSET(b_Obj, "blockflags", temp);
|
||||
|
||||
return b_Obj;
|
||||
}
|
||||
|
||||
struct DF_Map
|
||||
{
|
||||
PyObject_HEAD
|
||||
DFHack::Maps* m_Ptr;
|
||||
};
|
||||
|
||||
static PyObject* DF_Map_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
DF_Map* self;
|
||||
|
||||
self = (DF_Map*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != NULL)
|
||||
self->m_Ptr = NULL;
|
||||
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
static int DF_Map_init(DF_Map* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DF_Map_dealloc(DF_Map* self)
|
||||
{
|
||||
PySys_WriteStdout("map dealloc\n");
|
||||
|
||||
if(self != NULL)
|
||||
{
|
||||
PySys_WriteStdout("map not NULL\n");
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
PySys_WriteStdout("m_Ptr = %i\n", (int)self->m_Ptr);
|
||||
|
||||
delete self->m_Ptr;
|
||||
|
||||
PySys_WriteStdout("m_Ptr deleted\n");
|
||||
|
||||
self->m_Ptr = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PySys_WriteStdout("map dealloc done\n");
|
||||
}
|
||||
|
||||
// Type methods
|
||||
|
||||
static PyObject* DF_Map_Start(DF_Map* self, PyObject* args)
|
||||
{
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(self->m_Ptr->Start())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_Finish(DF_Map* self, PyObject* args)
|
||||
{
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(self->m_Ptr->Finish())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadGeology(DF_Map* self, PyObject* args)
|
||||
{
|
||||
PyObject *list, *temp;
|
||||
int outerSize, innerSize;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
std::vector< std::vector<uint16_t> > geoVec;
|
||||
|
||||
if(self->m_Ptr->ReadGeology(geoVec))
|
||||
{
|
||||
outerSize = geoVec.size();
|
||||
|
||||
list = PyList_New(outerSize);
|
||||
|
||||
for(int i = 0; i < outerSize; i++)
|
||||
{
|
||||
std::vector<uint16_t> innerVec = geoVec[i];
|
||||
|
||||
innerSize = innerVec.size();
|
||||
|
||||
temp = PyList_New(innerSize);
|
||||
|
||||
for(int j = 0; j < innerSize; j++)
|
||||
PyList_SET_ITEM(temp, j, PyInt_FromLong(innerVec[i]));
|
||||
|
||||
PyList_SET_ITEM(list, i, temp);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_IsValidBlock(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
if(self->m_Ptr->isValidBlock(x, y, z))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_GetBlockPtr(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
return PyInt_FromLong(self->m_Ptr->getBlockPtr(x, y, z));
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadBlock40d(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
mapblock40d mapblock;
|
||||
|
||||
if(self->m_Ptr->ReadBlock40d(x, y, z, &mapblock))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadTileTypes(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
tiletypes40d t_types;
|
||||
|
||||
if(self->m_Ptr->ReadTileTypes(x, y, z, &t_types))
|
||||
return BuildTileTypes40d(t_types);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_WriteTileTypes(DF_Map* self, PyObject* args)
|
||||
{
|
||||
PyObject* tileList;
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "IIIO", &x, &y, &z, &tileList))
|
||||
return NULL;
|
||||
|
||||
tiletypes40d t_types;
|
||||
|
||||
ReverseBuildTileTypes40d(tileList, t_types);
|
||||
|
||||
if(self->m_Ptr->WriteTileTypes(x, y, z, &t_types))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadDesignations(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
DFHack::designations40d des;
|
||||
|
||||
if(self->m_Ptr->ReadDesignations(x, y, z, &des))
|
||||
return BuildDesignations40d(des);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_WriteDesignations(DF_Map* self, PyObject* args)
|
||||
{
|
||||
PyObject* desList;
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "IIIO", &x, &y, &z, &desList))
|
||||
return NULL;
|
||||
|
||||
designations40d des;
|
||||
|
||||
ReverseBuildDesignations40d(desList, des);
|
||||
|
||||
if(self->m_Ptr->WriteDesignations(x, y, z, &des))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadOccupancy(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
occupancies40d occ;
|
||||
|
||||
if(self->m_Ptr->ReadOccupancy(x, y, z, &occ))
|
||||
return BuildOccupancies40d(occ);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_WriteOccupancy(DF_Map* self, PyObject* args)
|
||||
{
|
||||
PyObject* occList;
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "IIIO", &x, &y, &z, &occList))
|
||||
return NULL;
|
||||
|
||||
occupancies40d occ;
|
||||
|
||||
ReverseBuildOccupancies40d(occList, occ);
|
||||
|
||||
if(self->m_Ptr->WriteOccupancy(x, y, z, &occ))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadDirtyBit(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
bool bit = false;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
self->m_Ptr->ReadDirtyBit(x, y, z, bit);
|
||||
|
||||
if(bit)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_WriteDirtyBit(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z, b;
|
||||
bool bit;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "IIIi", &x, &y, &z, &b))
|
||||
return NULL;
|
||||
|
||||
if(b != 0)
|
||||
bit = true;
|
||||
else
|
||||
bit = false;
|
||||
|
||||
if(self->m_Ptr->WriteDirtyBit(x, y, z, bit))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadBlockFlags(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
t_blockflags flags;
|
||||
|
||||
if(self->m_Ptr->ReadBlockFlags(x, y, z, flags))
|
||||
return PyInt_FromLong(flags.whole);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_WriteBlockFlags(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z, whole;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "IIII", &x, &y, &z, &whole))
|
||||
return NULL;
|
||||
|
||||
t_blockflags blockFlags;
|
||||
|
||||
blockFlags.whole = whole;
|
||||
|
||||
if(self->m_Ptr->WriteBlockFlags(x, y, z, blockFlags))
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadRegionOffsets(DF_Map* self, PyObject* args)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
biome_indices40d biome;
|
||||
|
||||
if(self->m_Ptr->ReadRegionOffsets(x, y, z, &biome))
|
||||
return BuildBiomeIndices40d(biome);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Map_ReadVeins(DF_Map* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "III", &x, &y, &z))
|
||||
return NULL;
|
||||
|
||||
std::vector<t_vein> veins;
|
||||
std::vector<t_frozenliquidvein> ices;
|
||||
std::vector<t_spattervein> splatter;
|
||||
|
||||
if(self->m_Ptr->ReadVeins(x, y, z, &veins, &ices, &splatter))
|
||||
{
|
||||
return BuildVeinDict(veins, ices, splatter);
|
||||
}
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef DF_Map_methods[] =
|
||||
{
|
||||
{"Start", (PyCFunction)DF_Map_Start, METH_NOARGS, ""},
|
||||
{"Finish", (PyCFunction)DF_Map_Finish, METH_NOARGS, ""},
|
||||
{"Read_Geology", (PyCFunction)DF_Map_ReadGeology, METH_NOARGS, ""},
|
||||
{"Is_Valid_Block", (PyCFunction)DF_Map_IsValidBlock, METH_VARARGS, ""},
|
||||
{"Read_Block_40d", (PyCFunction)DF_Map_ReadBlock40d, METH_VARARGS, ""},
|
||||
{"Read_Tile_Types", (PyCFunction)DF_Map_ReadTileTypes, METH_VARARGS, ""},
|
||||
{"Write_Tile_Types", (PyCFunction)DF_Map_WriteTileTypes, METH_VARARGS, ""},
|
||||
{"Read_Designations", (PyCFunction)DF_Map_ReadDesignations, METH_VARARGS, ""},
|
||||
{"Write_Designations", (PyCFunction)DF_Map_WriteDesignations, METH_VARARGS, ""},
|
||||
{"Read_Occupancy", (PyCFunction)DF_Map_ReadOccupancy, METH_VARARGS, ""},
|
||||
{"Write_Occupancy", (PyCFunction)DF_Map_WriteOccupancy, METH_VARARGS, ""},
|
||||
{"Read_Dirty_Bit", (PyCFunction)DF_Map_ReadDirtyBit, METH_VARARGS, ""},
|
||||
{"Write_Dirty_Bit", (PyCFunction)DF_Map_WriteDirtyBit, METH_VARARGS, ""},
|
||||
{"Read_Block_Flags", (PyCFunction)DF_Map_ReadBlockFlags, METH_VARARGS, ""},
|
||||
{"Write_Block_Flags", (PyCFunction)DF_Map_WriteBlockFlags, METH_VARARGS, ""},
|
||||
{"Read_Region_Offsets", (PyCFunction)DF_Map_ReadRegionOffsets, METH_VARARGS, ""},
|
||||
{NULL} //Sentinel
|
||||
};
|
||||
|
||||
// Getter/Setter
|
||||
|
||||
static PyObject* DF_Map_getSize(DF_Map* self, void* closure)
|
||||
{
|
||||
uint32_t x, y, z;
|
||||
|
||||
if(self->m_Ptr != NULL)
|
||||
{
|
||||
self->m_Ptr->getSize(x, y, z);
|
||||
|
||||
return Py_BuildValue("III", x, y, z);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyGetSetDef DF_Map_getterSetters[] =
|
||||
{
|
||||
{"size", (getter)DF_Map_getSize, NULL, "size", NULL},
|
||||
{NULL} // Sentinel
|
||||
};
|
||||
|
||||
static PyTypeObject DF_Map_type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"pydfhack.Map", /*tp_name*/
|
||||
sizeof(DF_Map), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)DF_Map_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 Map objects", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
DF_Map_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
DF_Map_getterSetters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
(initproc)DF_Map_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
DF_Map_new, /* tp_new */
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,279 @@
|
||||
/*
|
||||
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 __DFTRANSLATE__
|
||||
#define __DFTRANSLATE__
|
||||
|
||||
#include "Python.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "modules/Translation.h"
|
||||
|
||||
using namespace DFHack;
|
||||
|
||||
struct DF_Translate
|
||||
{
|
||||
PyObject_HEAD
|
||||
PyObject* dict;
|
||||
DFHack::Translation* tran_Ptr;
|
||||
};
|
||||
|
||||
// API type Allocation, Deallocation, and Initialization
|
||||
|
||||
static PyObject* DF_Translate_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
DF_Translate* self;
|
||||
|
||||
self = (DF_Translate*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != NULL)
|
||||
self->tran_Ptr = NULL;
|
||||
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
static int DF_Translate_init(DF_Translate* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DF_Translate_dealloc(DF_Translate* self)
|
||||
{
|
||||
PySys_WriteStdout("translate dealloc\n");
|
||||
|
||||
if(self != NULL)
|
||||
{
|
||||
PySys_WriteStdout("translate not NULL\n");
|
||||
|
||||
if(self->tran_Ptr != NULL)
|
||||
{
|
||||
Py_XDECREF(self->dict);
|
||||
|
||||
PySys_WriteStdout("tran_Ptr = %i\n", (int)self->tran_Ptr);
|
||||
|
||||
delete self->tran_Ptr;
|
||||
|
||||
PySys_WriteStdout("tran_Ptr deleted\n");
|
||||
|
||||
self->tran_Ptr = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PySys_WriteStdout("translate dealloc done\n");
|
||||
}
|
||||
|
||||
// Type methods
|
||||
|
||||
static PyObject* DF_Translate_Start(DF_Translate* self, PyObject* args)
|
||||
{
|
||||
DFHack::Dicts* t_dicts;
|
||||
std::vector<std::string> wordVec;
|
||||
PyObject *list, *tempDict;
|
||||
|
||||
if(self->tran_Ptr != NULL)
|
||||
{
|
||||
if(self->tran_Ptr->Start())
|
||||
{
|
||||
Py_CLEAR(self->dict);
|
||||
|
||||
t_dicts = self->tran_Ptr->getDicts();
|
||||
|
||||
DFHack::DFDict & translations = t_dicts->translations;
|
||||
DFHack::DFDict & foreign_languages = t_dicts->foreign_languages;
|
||||
|
||||
self->dict = PyDict_New();
|
||||
tempDict = PyDict_New();
|
||||
|
||||
for(uint32_t i = 0; i < translations.size(); i++)
|
||||
{
|
||||
uint32_t size = translations[i].size();
|
||||
uint32_t j = 0;
|
||||
|
||||
list = PyList_New(size);
|
||||
|
||||
for(; j < size; j++)
|
||||
PyList_SET_ITEM(list, j, PyString_FromString(translations[i][j].c_str()));
|
||||
|
||||
PyObject* key = PyInt_FromLong(j);
|
||||
PyDict_SetItem(tempDict, key, list);
|
||||
|
||||
Py_DECREF(key);
|
||||
Py_DECREF(list);
|
||||
}
|
||||
|
||||
PyDict_SetItemString(self->dict, "translations", tempDict);
|
||||
|
||||
Py_DECREF(tempDict);
|
||||
|
||||
tempDict = PyDict_New();
|
||||
|
||||
for(uint32_t i = 0; i < foreign_languages.size(); i++)
|
||||
{
|
||||
uint32_t size = foreign_languages[i].size();
|
||||
uint32_t j = 0;
|
||||
|
||||
list = PyList_New(size);
|
||||
|
||||
for(; j < size; j++)
|
||||
PyList_SET_ITEM(list, j, PyString_FromString(foreign_languages[i][j].c_str()));
|
||||
|
||||
PyObject* key = PyInt_FromLong(j);
|
||||
PyDict_SetItem(tempDict, key, list);
|
||||
|
||||
Py_DECREF(key);
|
||||
Py_DECREF(list);
|
||||
}
|
||||
|
||||
PyDict_SetItemString(self->dict, "foreign_languages", tempDict);
|
||||
|
||||
Py_DECREF(tempDict);
|
||||
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Translate_Finish(DF_Translate* self, PyObject* args)
|
||||
{
|
||||
if(self->tran_Ptr != NULL)
|
||||
{
|
||||
if(self->tran_Ptr->Finish())
|
||||
{
|
||||
if(self->dict != NULL)
|
||||
PyDict_Clear(self->dict);
|
||||
|
||||
Py_CLEAR(self->dict);
|
||||
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Translate_TranslateName(DF_Translate* self, PyObject* args)
|
||||
{
|
||||
PyObject *nameObj, *retString;
|
||||
DFHack::t_name name;
|
||||
int inEnglish = 1;
|
||||
|
||||
if(self->tran_Ptr != NULL)
|
||||
{
|
||||
if(PyArg_ParseTuple(args, "O|i", &nameObj, &inEnglish))
|
||||
return NULL;
|
||||
|
||||
name = ReverseBuildName(nameObj);
|
||||
|
||||
std::string nameStr = self->tran_Ptr->TranslateName(name, (bool)inEnglish);
|
||||
|
||||
retString = PyString_FromString(nameStr.c_str());
|
||||
|
||||
return retString;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef DF_Translate_methods[] =
|
||||
{
|
||||
{"Start", (PyCFunction)DF_Translate_Start, METH_NOARGS, ""},
|
||||
{"Finish", (PyCFunction)DF_Translate_Finish, METH_NOARGS, ""},
|
||||
{"Translate_Name", (PyCFunction)DF_Translate_TranslateName, METH_VARARGS, ""},
|
||||
{NULL} //Sentinel
|
||||
};
|
||||
|
||||
// Getters/Setters
|
||||
|
||||
static PyObject* DF_Translate_getDicts(DF_Translate* self, PyObject* args)
|
||||
{
|
||||
if(self->tran_Ptr != NULL)
|
||||
{
|
||||
if(self->dict != NULL)
|
||||
return self->dict;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyGetSetDef DF_Translate_getterSetters[] =
|
||||
{
|
||||
{"dictionaries", (getter)DF_Translate_getDicts, NULL, "dictionaries", NULL},
|
||||
{NULL} // Sentinel
|
||||
};
|
||||
|
||||
static PyTypeObject DF_Translate_type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"pydfhack.Translate", /*tp_name*/
|
||||
sizeof(DF_Translate), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)DF_Translate_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 Translate objects", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
DF_Translate_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
DF_Translate_getterSetters, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
(initproc)DF_Translate_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
DF_Translate_new, /* tp_new */
|
||||
};
|
||||
|
||||
#endif
|
@ -1,105 +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 __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
|
@ -0,0 +1,202 @@
|
||||
/*
|
||||
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 __DFVEGETATION__
|
||||
#define __DFVEGETATION__
|
||||
|
||||
#include "Python.h"
|
||||
#include "modules/Vegetation.h"
|
||||
#include "DF_Helpers.cpp"
|
||||
|
||||
using namespace DFHack;
|
||||
|
||||
static PyObject* BuildTree(DFHack::t_tree& tree)
|
||||
{
|
||||
PyObject* t_dict;
|
||||
PyObject* temp;
|
||||
|
||||
t_dict = PyDict_New();
|
||||
|
||||
temp = PyInt_FromLong(tree.type);
|
||||
DICTADD(t_dict, "type", temp);
|
||||
|
||||
temp = PyInt_FromLong(tree.material);
|
||||
DICTADD(t_dict, "material", temp);
|
||||
|
||||
temp = PyTuple_Pack(3, tree.x, tree.y, tree.z);
|
||||
DICTADD(t_dict, "position", temp);
|
||||
|
||||
temp = PyInt_FromLong(tree.address);
|
||||
DICTADD(t_dict, "address", temp);
|
||||
|
||||
return t_dict;
|
||||
}
|
||||
|
||||
struct DF_Vegetation
|
||||
{
|
||||
PyObject_HEAD
|
||||
DFHack::Vegetation* veg_Ptr;
|
||||
};
|
||||
|
||||
static PyObject* DF_Vegetation_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
DF_Vegetation* self;
|
||||
|
||||
self = (DF_Vegetation*)type->tp_alloc(type, 0);
|
||||
|
||||
if(self != NULL)
|
||||
self->veg_Ptr = NULL;
|
||||
|
||||
return (PyObject*)self;
|
||||
}
|
||||
|
||||
static int DF_Vegetation_init(DF_Vegetation* self, PyObject* args, PyObject* kwds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void DF_Vegetation_dealloc(DF_Vegetation* self)
|
||||
{
|
||||
PySys_WriteStdout("vegetation dealloc\n");
|
||||
|
||||
if(self != NULL)
|
||||
{
|
||||
PySys_WriteStdout("vegetation not NULL\n");
|
||||
|
||||
if(self->veg_Ptr != NULL)
|
||||
{
|
||||
PySys_WriteStdout("veg_Ptr = %i\n", (int)self->veg_Ptr);
|
||||
|
||||
delete self->veg_Ptr;
|
||||
|
||||
PySys_WriteStdout("veg_Ptr deleted\n");
|
||||
|
||||
self->veg_Ptr = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
PySys_WriteStdout("vegetation dealloc done\n");
|
||||
}
|
||||
|
||||
// Type methods
|
||||
|
||||
static PyObject* DF_Vegetation_Start(DF_Vegetation* self, PyObject* args)
|
||||
{
|
||||
uint32_t numTrees = 0;
|
||||
|
||||
if(self->veg_Ptr != NULL)
|
||||
{
|
||||
if(self->veg_Ptr->Start(numTrees))
|
||||
return PyInt_FromLong(numTrees);
|
||||
else
|
||||
return PyInt_FromLong(-1);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Vegetation_Finish(DF_Vegetation* self, PyObject* args)
|
||||
{
|
||||
if(self->veg_Ptr != NULL)
|
||||
{
|
||||
if(self->veg_Ptr->Finish())
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* DF_Vegetation_Read(DF_Vegetation* self, PyObject* args)
|
||||
{
|
||||
uint32_t index = 0;
|
||||
t_tree tree;
|
||||
|
||||
if(self->veg_Ptr != NULL)
|
||||
{
|
||||
if(!PyArg_ParseTuple(args, "I", &index))
|
||||
return NULL;
|
||||
|
||||
if(self->veg_Ptr->Read(index, tree))
|
||||
return BuildTree(tree);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyMethodDef DF_Vegetation_methods[] =
|
||||
{
|
||||
{"Start", (PyCFunction)DF_Vegetation_Start, METH_NOARGS, ""},
|
||||
{"Finish", (PyCFunction)DF_Vegetation_Finish, METH_NOARGS, ""},
|
||||
{"Read", (PyCFunction)DF_Vegetation_Read, METH_VARARGS, ""},
|
||||
{NULL} // Sentinel
|
||||
};
|
||||
|
||||
static PyTypeObject DF_Vegetation_type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"pydfhack.Vegetation", /*tp_name*/
|
||||
sizeof(DF_Vegetation), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
(destructor)DF_Vegetation_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 Vegetation objects", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
DF_Vegetation_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_Vegetation_init, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
DF_Vegetation_new, /* tp_new */
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,4 @@
|
||||
python setup.py build_ext
|
||||
copy /Y .\build\lib.win32-2.6\pydfhack.pyd ..\..\output\pydfhack.pyd
|
||||
rmdir /S /Q .\build
|
||||
pause
|
@ -0,0 +1,195 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ctypes import Structure, Union, c_uint
|
||||
|
||||
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 DesignationFlags(Union):
|
||||
_fields_ = [("whole", c_uint, 32),
|
||||
("bits", DesignationStruct)]
|
||||
|
||||
def __init__(self, initial = 0):
|
||||
self.whole = initial
|
||||
|
||||
class OccupancyStruct(Structure):
|
||||
_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,
|
||||
"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 BlockFlagStruct(Structure):
|
||||
_fields_ = [("designated", c_uint, 1),
|
||||
("unk_1", c_uint, 1),
|
||||
("liquid_1", c_uint, 1),
|
||||
("liquid_2", c_uint, 1),
|
||||
("unk_2", c_uint, 28)]
|
||||
|
||||
class BlockFlags(Union):
|
||||
_fields_ = [("whole", c_uint, 32),
|
||||
("bits", BlockFlagStruct)]
|
||||
|
||||
def __init__(self, inital = 0):
|
||||
self.whole = initial
|
@ -1,224 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pydfhack import *
|
||||
from ctypes import *
|
||||
from collections import namedtuple
|
||||
|
||||
class DFAPI(API):
|
||||
def Read_Designations(self, x, y, z):
|
||||
temp = API.Read_Designations(self, x, y, z)
|
||||
Note = namedtuple("Note", "symbol, foreground, background, name, position")
|
||||
Construction = namedtuple("Construction", "position, form, unk_8, mat_type, mat_idx, unk3, unk4, unk5, unk6, origin")
|
||||
Vein = namedtuple("Vein", "vtable, type, flags, address, assignment")
|
||||
FrozenLiquidVein = namedtuple("FrozenLiquidVein", "vtable, address, tiles")
|
||||
SpatterVein = namedtuple("SpatterVein", "vtable, address, mat1, unk1, mat2, mat3, intensity")
|
||||
|
||||
d_list = []
|
||||
class Name(object):
|
||||
__slots__ = ["first_name", "nickname", "language", "has_name", "words", "parts_of_speech"]
|
||||
|
||||
for i in temp:
|
||||
d = []
|
||||
class Soul(object):
|
||||
pass
|
||||
|
||||
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):
|
||||
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 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 DesignationFlags(Union):
|
||||
_fields_ = [("whole", c_uint, 32),
|
||||
("bits", DesignationStruct)]
|
||||
|
||||
def __init__(self, initial = 0):
|
||||
self.whole = initial
|
||||
|
||||
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,
|
||||
"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 MapBlock40d(object):
|
||||
pass
|
Loading…
Reference in New Issue