"import pydftypes" changed to "import dftypes"

buildings now using custom workshop callback
creatures now using material callback
fixed return value for civ and race index getters
develop
doomchild 2010-08-19 12:48:24 -05:00
parent a508542d7c
commit a08258e36b
8 changed files with 12 additions and 38 deletions

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import *
from dftypes import *
import util
libdfhack.Buildings_GetCustomWorkshopType.argtypes = [ c_void_p, POINTER(CustomWorkshop) ]
@ -28,20 +28,7 @@ class Buildings(object):
return None
def read_custom_workshop_types(self):
def read_callback(count):
allocated = util._allocate_array(CustomWorkshop, count)
workshop_types = allocated[0]
return allocated[1]
workshop_types = None
callback = _arr_create_func(read_callback)
if libdfhack.Buildings_ReadCustomWorkshopTypes(self._b_ptr, callback) > 0:
return workshop_types
else:
return None
return libdfhack.Buildings_ReadCustomWorkshopTypes(self._b_ptr)
def get_custom_workshop_type(self, custom_workshop):
return libdfhack.Buildings_GetCustomWorkshopType(self._b_ptr, byref(custom_workshop))

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import *
from dftypes import *
class Constructions(object):
def __init__(self, ptr):

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import *
from dftypes import *
libdfhack.ContextManager_Alloc.restype = c_void_p
libdfhack.ContextManager_Free.argtypes = [ c_void_p ]

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import libdfhack, Creature, Material
from dftypes import libdfhack, Creature, Material
import util
libdfhack.Creatures_WriteLabors.argtypes = [ c_void_p, c_uint, POINTER(c_ubyte) ]
@ -45,31 +45,18 @@ class Creatures(object):
return libdfhack.Creatures_WriteLabors(self._c_ptr, c_uint(index), labors) > 0
def read_job(self, creature):
def read_callback(count):
allocated = util._allocate_array(Material, count)
jobs = allocated[0]
return allocated[1]
jobs = None
callback = _arr_create_func(read_callback)
if libdfhack.Creatures_ReadJob(self._c_ptr, byref(creature), callback) > 0:
return jobs
else:
return None
return libdfhack.Creatures_ReadJob(self._c_ptr, byref(creature))
@property
def dwarf_race_index(self):
if self._d_race_index is None:
self._d_race_index = int(libdfhack.Creatures_GetDwarfRaceIndex(self._c_ptr).value)
self._d_race_index =libdfhack.Creatures_GetDwarfRaceIndex(self._c_ptr)
return self._d_race_index
@property
def dwarf_civ_id(self):
if self._d_civ_id is None:
self._d_civ_id = int(libdfhack.Creatures_GetDwarfCivId(self._c_ptr).value)
self._d_civ_id = libdfhack.Creatures_GetDwarfCivId(self._c_ptr)
return self._d_civ_id

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import *
from dftypes import *
libdfhack.Items_getItemDescription.argtypes = [ c_void_p, c_uint, c_void_ptr, _arr_create_func ]
libdfhack.Items_getItemDescription.restype = c_char_p

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import libdfhack
from dftypes import libdfhack
from util import *
_get_arg_types = [ c_void_p, _arr_create_func ]

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import libdfhack
from dftypes import libdfhack
class Position(object):
def __init__(self, ptr):

@ -1,5 +1,5 @@
from ctypes import *
from pydftypes import libdfhack, Tree
from dftypes import libdfhack, Tree
class Vegetation(object):
def __init__(self, ptr):