|
|
@ -145,17 +145,17 @@ static PyObject* DF_API_getMemoryInfo(DF_API* self, void* closure)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(self->api_Ptr != NULL)
|
|
|
|
if(self->api_Ptr != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::memory_info* mem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mem = self->api_Ptr->getMemoryInfo();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self->mem_info = _PyObject_New(&DF_MemInfo_type);
|
|
|
|
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;
|
|
|
|
return self->mem_info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_ValueError, "Error trying to read memory info");
|
|
|
|
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)
|
|
|
|
if(self->api_Ptr != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::Position* pos;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pos = self->api_Ptr->getPosition();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self->position = _PyObject_New(&DF_Position_type);
|
|
|
|
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;
|
|
|
|
return self->position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_ValueError, "Error trying to read position");
|
|
|
|
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)
|
|
|
|
if(self->api_Ptr != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DFHack::Materials* mat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mat = self->api_Ptr->getMaterials();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self->material = _PyObject_New(&DF_Material_type);
|
|
|
|
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;
|
|
|
|
return self->material;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_ValueError, "Error trying to read material");
|
|
|
|
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},
|
|
|
|
{"is_suspended", (getter)DF_API_getIsSuspended, NULL, "is_suspended", NULL},
|
|
|
|
{"memory_info", (getter)DF_API_getMemoryInfo, NULL, "memory_info", NULL},
|
|
|
|
{"memory_info", (getter)DF_API_getMemoryInfo, NULL, "memory_info", NULL},
|
|
|
|
{"position", (getter)DF_API_getPosition, NULL, "position", 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
|
|
|
|
{NULL} // Sentinel
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|