getters for memory info, position, and materials should actually work now

develop
doomchild 2010-04-06 13:46:24 -05:00
parent e56e7dcbea
commit 6bec24d6c8
1 changed files with 22 additions and 22 deletions

@ -145,17 +145,17 @@ static PyObject* DF_API_getMemoryInfo(DF_API* self, void* closure)
{
if(self->api_Ptr != NULL)
{
DFHack::memory_info* mem;
mem = self->api_Ptr->getMemoryInfo();
self->mem_info = _PyObject_New(&DF_MemInfo_type);
delete ((DF_MemInfo*)(self->mem_info))->mem_Ptr;
((DF_MemInfo*)(self->mem_info))->mem_Ptr = mem;
if(self->mem_info != NULL)
{
((DF_MemInfo*)(self->mem_info))->mem_Ptr = self->api_Ptr->getMemoryInfo();
if(((DF_MemInfo*)(self->mem_info))->mem_Ptr != NULL)
return self->mem_info;
}
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read memory info");
@ -174,17 +174,17 @@ static PyObject* DF_API_getPosition(DF_API* self, void* closure)
{
if(self->api_Ptr != NULL)
{
DFHack::Position* pos;
pos = self->api_Ptr->getPosition();
self->position = _PyObject_New(&DF_Position_type);
delete ((DF_Position*)(self->position))->pos_Ptr;
((DF_Position*)(self->position))->pos_Ptr = pos;
if(self->position != NULL)
{
((DF_Position*)(self->position))->pos_Ptr = self->api_Ptr->getPosition();
if(((DF_Position*)(self->position))->pos_Ptr != NULL)
return self->position;
}
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read position");
@ -203,17 +203,17 @@ static PyObject* DF_API_getMaterial(DF_API* self, void* closure)
{
if(self->api_Ptr != NULL)
{
DFHack::Materials* mat;
mat = self->api_Ptr->getMaterials();
self->material = _PyObject_New(&DF_Material_type);
delete ((DF_Material*)(self->material))->mat_Ptr;
((DF_Material*)(self->material))->mat_Ptr = mat;
if(self->material != NULL)
{
((DF_Material*)(self->material))->mat_Ptr = self->api_Ptr->getMaterials();
if(((DF_Material*)(self->material))->mat_Ptr != NULL)
return self->material;
}
}
}
catch(...)
{
PyErr_SetString(PyExc_ValueError, "Error trying to read material");
@ -229,7 +229,7 @@ static PyGetSetDef DF_API_getterSetters[] =
{"is_suspended", (getter)DF_API_getIsSuspended, NULL, "is_suspended", NULL},
{"memory_info", (getter)DF_API_getMemoryInfo, NULL, "memory_info", NULL},
{"position", (getter)DF_API_getPosition, NULL, "position", NULL},
{"material", (getter)DF_API_getMaterial, NULL, "material", NULL},
{"materials", (getter)DF_API_getMaterial, NULL, "material", NULL},
{NULL} // Sentinel
};