2010-05-05 15:35:42 -06:00
|
|
|
from ctypes import *
|
2010-08-19 11:47:45 -06:00
|
|
|
from flags import *
|
2010-06-17 14:29:29 -06:00
|
|
|
from enum import *
|
2011-03-09 11:29:29 -07:00
|
|
|
import util
|
2010-06-17 14:29:29 -06:00
|
|
|
from util import *
|
|
|
|
|
|
|
|
libdfhack = cdll.libdfhack
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
def _register_callback(name, func):
|
|
|
|
ptr = c_void_p.in_dll(libdfhack, name)
|
|
|
|
ptr.value = cast(func, c_void_p).value
|
2010-06-17 14:29:29 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_register_callback("alloc_byte_buffer_callback", alloc_byte_buffer)
|
|
|
|
_register_callback("alloc_ubyte_buffer_callback", alloc_ubyte_buffer)
|
|
|
|
_register_callback("alloc_short_buffer_callback", alloc_short_buffer)
|
|
|
|
_register_callback("alloc_ushort_buffer_callback", alloc_ushort_buffer)
|
|
|
|
_register_callback("alloc_int_buffer_callback", alloc_int_buffer)
|
|
|
|
_register_callback("alloc_uint_buffer_callback", alloc_uint_buffer)
|
|
|
|
_register_callback("alloc_char_buffer_callback", alloc_char_buffer)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
_arr_create_func = CFUNCTYPE(c_void_p, c_int)
|
2011-03-11 13:13:52 -07:00
|
|
|
_dfhack_string = (c_char * 128)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
TileTypes40d = ((c_int * 16) * 16)
|
|
|
|
BiomeIndices40d = c_ubyte * 16
|
|
|
|
Temperatures = ((c_ushort * 16) * 16)
|
|
|
|
Designations40d = ((DesignationFlags * 16) * 16)
|
|
|
|
Occupancies40d = ((OccupancyFlags * 16) * 16)
|
|
|
|
|
2010-08-13 11:31:31 -06:00
|
|
|
def wall_terrain_check(terrain):
|
|
|
|
return libdfhack.DFHack_isWallTerrain(terrain) > 0
|
|
|
|
|
|
|
|
def floor_terrain_check(terrain):
|
|
|
|
return libdfhack.DFHack_isFloorTerrain(terrain) > 0
|
|
|
|
|
|
|
|
def ramp_terrain_check(terrain):
|
|
|
|
return libdfhack.DFHack_isRampTerrain(terrain) > 0
|
|
|
|
|
|
|
|
def stair_terrain_check(terrain):
|
|
|
|
return libdfhack.DFHack_isStairTerrain(terrain) > 0
|
|
|
|
|
|
|
|
def open_terrain_check(terrain):
|
|
|
|
return libdfhack.DFHack_isOpenTerrain(terrain) > 0
|
|
|
|
|
|
|
|
def get_vegetation_type(terrain):
|
|
|
|
return libdfhack.DFHack_getVegetationType(terrain)
|
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class Position2D(Structure):
|
|
|
|
_fields_ = [("x", c_ushort),
|
|
|
|
("y", c_ushort)]
|
|
|
|
|
2011-03-15 14:35:50 -06:00
|
|
|
class Position3D(Structure):
|
2011-03-14 14:00:51 -06:00
|
|
|
_fields_ = [("x", c_ushort),
|
|
|
|
("y", c_ushort),
|
|
|
|
("z", c_uint)]
|
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class PlaneCoord(Union):
|
2011-03-14 14:00:51 -06:00
|
|
|
_fields_ = [("xyz", Position3D),
|
|
|
|
("dim", Position2D),
|
|
|
|
("comparate", c_ulong)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
def __cmp__(self, other):
|
|
|
|
if isinstance(other, PlaneCoord):
|
2011-03-14 14:00:51 -06:00
|
|
|
return self.comparate - other.comparate
|
2010-06-17 14:29:29 -06:00
|
|
|
else:
|
|
|
|
raise TypeError("argument must be of type %s" % type(self))
|
|
|
|
|
|
|
|
class Feature(Structure):
|
|
|
|
_fields_ = [("type", FeatureType),
|
|
|
|
("main_material", c_short),
|
|
|
|
("sub_material", c_short),
|
|
|
|
("discovered", c_byte),
|
|
|
|
("origin", c_uint)]
|
|
|
|
|
2011-03-14 14:00:51 -06:00
|
|
|
class FeatureMapNode(Structure):
|
|
|
|
_fields_ = [("coordinate", PlaneCoord),
|
|
|
|
("features", POINTER(Feature)),
|
|
|
|
("feature_length", c_uint)]
|
|
|
|
|
|
|
|
def _alloc_featuremap_buffer_callback(ptr, fmap_list, count):
|
|
|
|
arr_list = []
|
|
|
|
arr = (FeatureMapNode * count)()
|
|
|
|
|
|
|
|
for i, v in enumerate(arr):
|
|
|
|
f_count = int(fmap_list[i])
|
|
|
|
f_arr = (Feature * f_count)()
|
|
|
|
|
|
|
|
f_p = cast(f_arr, POINTER(Feature))
|
|
|
|
v.features = f_p
|
|
|
|
|
|
|
|
arr_list.extend((f_arr, f_p))
|
|
|
|
|
|
|
|
p = cast(arr, POINTER(FeatureMapNode))
|
|
|
|
ptr[0] = p
|
|
|
|
|
|
|
|
pointer_dict[addressof(arr)] = (ptr, arr, p, arr_list)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
_alloc_featuremap_buffer_functype = CFUNCTYPE(c_int, POINTER(POINTER(FeatureMapNode)), uint_ptr, c_uint)
|
|
|
|
_alloc_featuremap_buffer_func = _alloc_featuremap_buffer_functype(_alloc_featuremap_buffer_callback)
|
|
|
|
_register_callback("alloc_featuremap_buffer_callback", _alloc_featuremap_buffer_func)
|
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class Vein(Structure):
|
|
|
|
_fields_ = [("vtable", c_uint),
|
|
|
|
("type", c_int),
|
|
|
|
("assignment", c_short * 16),
|
|
|
|
("flags", c_uint),
|
|
|
|
("address_of", c_uint)]
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_vein_ptr = POINTER(Vein)
|
|
|
|
|
2010-08-13 11:31:31 -06:00
|
|
|
def _alloc_vein_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, Vein, count)
|
2010-08-13 11:31:31 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_vein_functype = CFUNCTYPE(c_int, POINTER(_vein_ptr), c_uint)
|
|
|
|
_vein_func = _vein_functype(_alloc_vein_buffer_callback)
|
|
|
|
_register_callback("alloc_vein_buffer_callback", _vein_func)
|
2010-08-13 11:31:31 -06:00
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class FrozenLiquidVein(Structure):
|
|
|
|
_fields_ = [("vtable", c_uint),
|
|
|
|
("tiles", TileTypes40d),
|
|
|
|
("address_of", c_uint)]
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_frozenvein_ptr = POINTER(FrozenLiquidVein)
|
|
|
|
|
2010-08-13 11:31:31 -06:00
|
|
|
def _alloc_frozenliquidvein_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, FrozenLiquidVein, count)
|
2010-08-13 11:31:31 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_frozenliquidvein_functype = CFUNCTYPE(c_int, POINTER(_frozenvein_ptr), c_uint)
|
|
|
|
_frozenliquidvein_func = _frozenliquidvein_functype(_alloc_frozenliquidvein_buffer_callback)
|
|
|
|
_register_callback("alloc_frozenliquidvein_buffer_callback", _frozenliquidvein_func)
|
2010-08-13 11:31:31 -06:00
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class SpatterVein(Structure):
|
|
|
|
_fields_ = [("vtable", c_uint),
|
|
|
|
("mat1", c_ushort),
|
|
|
|
("unk1", c_ushort),
|
|
|
|
("mat2", c_uint),
|
|
|
|
("mat3", c_ushort),
|
|
|
|
("intensity", ((c_ubyte * 16) * 16)),
|
|
|
|
("address_of", c_uint)]
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_spattervein_ptr = POINTER(SpatterVein)
|
|
|
|
|
2010-08-13 11:31:31 -06:00
|
|
|
def _alloc_spattervein_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, SpatterVein, count)
|
2010-08-13 11:31:31 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_spattervein_functype = CFUNCTYPE(c_int, POINTER(_spattervein_ptr), c_uint)
|
|
|
|
_spattervein_func = _spattervein_functype(_alloc_spattervein_buffer_callback)
|
|
|
|
_register_callback("alloc_spattervein_buffer_callback", _spattervein_func)
|
2010-08-13 11:31:31 -06:00
|
|
|
|
2011-03-01 13:39:33 -07:00
|
|
|
class GrassVein(Structure):
|
|
|
|
_fields_ = [("vtable", c_uint),
|
|
|
|
("material", c_uint),
|
|
|
|
("intensity", ((c_ubyte * 16) * 16)),
|
|
|
|
("address_of", c_uint)]
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_grassvein_ptr = POINTER(GrassVein)
|
|
|
|
|
2011-03-01 13:39:33 -07:00
|
|
|
def _alloc_grassvein_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, GrassVein, count)
|
2011-03-01 13:39:33 -07:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_grassvein_functype = CFUNCTYPE(c_int, POINTER(_grassvein_ptr), c_uint)
|
|
|
|
_grassvein_func = _grassvein_functype(_alloc_grassvein_buffer_callback)
|
|
|
|
_register_callback("alloc_grassvein_buffer_callback", _grassvein_func)
|
2011-03-01 13:39:33 -07:00
|
|
|
|
|
|
|
class WorldConstruction(Structure):
|
|
|
|
_fields_ = [("vtable", c_uint),
|
|
|
|
("material", c_uint),
|
|
|
|
("assignment", c_ushort * 16),
|
|
|
|
("address_of", c_uint)]
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_worldconstruction_ptr = POINTER(WorldConstruction)
|
|
|
|
|
2011-03-01 13:39:33 -07:00
|
|
|
def _alloc_worldconstruction_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, WorldConstruction, count)
|
2011-03-01 13:39:33 -07:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_worldconstruction_functype = CFUNCTYPE(c_int, POINTER(_worldconstruction_ptr), c_uint)
|
|
|
|
_worldconstruction_func = _worldconstruction_functype(_alloc_worldconstruction_buffer_callback)
|
|
|
|
_register_callback("alloc_worldconstruction_buffer_callback", _worldconstruction_func)
|
2011-03-01 13:39:33 -07:00
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class MapBlock40d(Structure):
|
|
|
|
_fields_ = [("tiletypes", TileTypes40d),
|
|
|
|
("designation", Designations40d),
|
|
|
|
("occupancy", Occupancies40d),
|
|
|
|
("biome_indices", BiomeIndices40d),
|
|
|
|
("origin", c_uint),
|
|
|
|
("blockflags", BlockFlags),
|
|
|
|
("global_feature", c_short),
|
|
|
|
("local_feature", c_short)]
|
|
|
|
|
2010-05-05 15:35:42 -06:00
|
|
|
|
|
|
|
class ViewScreen(Structure):
|
|
|
|
_fields_ = [("type", c_int)]
|
|
|
|
|
|
|
|
class Matgloss(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("id", _dfhack_string),
|
2010-05-05 15:35:42 -06:00
|
|
|
("fore", c_byte),
|
|
|
|
("back", c_byte),
|
|
|
|
("bright", c_byte),
|
2011-03-11 13:13:52 -07:00
|
|
|
("name", _dfhack_string)]
|
2010-05-05 15:35:42 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_matgloss_ptr = POINTER(Matgloss)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
def _alloc_matgloss_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, Matgloss, count)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
_matgloss_functype = CFUNCTYPE(c_int, POINTER(_matgloss_ptr), c_uint)
|
|
|
|
_matgloss_func = _matgloss_functype(_alloc_matgloss_buffer_callback)
|
|
|
|
_register_callback("alloc_matgloss_buffer_callback", _matgloss_func)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class MatglossPair(Structure):
|
|
|
|
_fields_ = [("type", c_short),
|
|
|
|
("index", c_int)]
|
|
|
|
|
|
|
|
class DescriptorColor(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("id", _dfhack_string),
|
2010-05-05 15:35:42 -06:00
|
|
|
("r", c_float),
|
|
|
|
("v", c_float),
|
|
|
|
("b", c_float),
|
2011-03-11 13:13:52 -07:00
|
|
|
("name", _dfhack_string)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
def _alloc_descriptor_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, DescriptorColor, count)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
_descriptor_functype = CFUNCTYPE(c_int, POINTER(POINTER(DescriptorColor)), c_uint)
|
2011-03-09 11:29:29 -07:00
|
|
|
_descriptor_func = _descriptor_functype(_alloc_descriptor_buffer_callback)
|
|
|
|
_register_callback("alloc_descriptor_buffer_callback", _descriptor_func)
|
2010-05-05 15:35:42 -06:00
|
|
|
|
2011-03-11 13:13:52 -07:00
|
|
|
class MatglossPlant(Structure):
|
|
|
|
_fields_ = [("id", _dfhack_string),
|
|
|
|
("fore", c_ubyte),
|
|
|
|
("back", c_ubyte),
|
|
|
|
("bright", c_ubyte),
|
|
|
|
("name", _dfhack_string),
|
|
|
|
("drink_name", _dfhack_string),
|
|
|
|
("food_name", _dfhack_string),
|
|
|
|
("extract_name", _dfhack_string)]
|
|
|
|
|
2010-05-05 15:35:42 -06:00
|
|
|
class MatglossOther(Structure):
|
2010-06-17 14:29:29 -06:00
|
|
|
_fields_ = [("rawname", c_char * 128)]
|
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
def _alloc_matgloss_other_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, MatglossOther, count)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
_matgloss_other_functype = CFUNCTYPE(c_int, POINTER(POINTER(MatglossOther)), c_uint)
|
2011-03-09 11:29:29 -07:00
|
|
|
_matgloss_other_func = _matgloss_other_functype(_alloc_matgloss_other_buffer_callback)
|
|
|
|
_register_callback("alloc_matgloss_other_buffer_callback", _matgloss_other_func)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class Building(Structure):
|
|
|
|
_fields_ = [("origin", c_uint),
|
|
|
|
("vtable", c_uint),
|
|
|
|
("x1", c_uint),
|
|
|
|
("y1", c_uint),
|
|
|
|
("x2", c_uint),
|
|
|
|
("y2", c_uint),
|
|
|
|
("z", c_uint),
|
|
|
|
("material", MatglossPair),
|
|
|
|
("type", c_uint)]
|
|
|
|
|
|
|
|
class CustomWorkshop(Structure):
|
|
|
|
_fields_ = [("index", c_uint),
|
|
|
|
("name", c_char * 256)]
|
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
def _alloc_custom_workshop_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, CustomWorkshop, count)
|
2010-08-19 11:47:45 -06:00
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
_custom_workshop_functype = CFUNCTYPE(c_int, POINTER(POINTER(CustomWorkshop)), c_uint)
|
2011-03-09 11:29:29 -07:00
|
|
|
_custom_workshop_func = _custom_workshop_functype(_alloc_custom_workshop_buffer_callback)
|
2011-03-11 15:59:25 -07:00
|
|
|
_register_callback("alloc_customWorkshop_buffer_callback", _custom_workshop_func)
|
2010-08-19 11:47:45 -06:00
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class Construction(Structure):
|
|
|
|
_fields_ = [("x", c_ushort),
|
|
|
|
("y", c_ushort),
|
|
|
|
("z", c_ushort),
|
|
|
|
("form", c_ushort),
|
|
|
|
("unk_8", c_ushort),
|
|
|
|
("mat_type", c_ushort),
|
2011-03-29 08:23:53 -06:00
|
|
|
("mat_idx", c_uint),
|
2010-06-17 14:29:29 -06:00
|
|
|
("unk3", c_ushort),
|
|
|
|
("unk4", c_ushort),
|
|
|
|
("unk5", c_ushort),
|
|
|
|
("unk6", c_uint),
|
|
|
|
("origin", c_uint)]
|
|
|
|
|
|
|
|
class Tree(Structure):
|
|
|
|
_fields_ = [("type", c_ushort),
|
|
|
|
("material", c_ushort),
|
|
|
|
("x", c_ushort),
|
|
|
|
("y", c_ushort),
|
|
|
|
("z", c_ushort),
|
|
|
|
("address", c_uint)]
|
2011-03-11 15:59:25 -07:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
water = ""
|
|
|
|
tree_type = "tree"
|
|
|
|
|
|
|
|
if self.type == 1 or self.type == 3:
|
|
|
|
water = "near-water"
|
|
|
|
if self.type == 2 or self.type == 3:
|
|
|
|
tree_type = "shrub"
|
|
|
|
|
|
|
|
s = "%d:%d = %s %s\nAddress: 0x%x\n" % (self.type, self.material, water, tree_type, self.address)
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
def _alloc_tree_buffer_callback(ptr, count):
|
|
|
|
return util._allocate_array(ptr, Tree, count)
|
|
|
|
|
|
|
|
_alloc_tree_buffer_functype = CFUNCTYPE(c_int, POINTER(POINTER(Tree)), c_uint)
|
2011-03-14 14:00:51 -06:00
|
|
|
_alloc_tree_buffer_func = _alloc_tree_buffer_functype(_alloc_tree_buffer_callback)
|
2011-03-11 15:59:25 -07:00
|
|
|
_register_callback("alloc_tree_buffer_callback", _alloc_tree_buffer_func)
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class Material(Structure):
|
|
|
|
_fields_ = [("itemType", c_short),
|
|
|
|
("subType", c_short),
|
|
|
|
("subIndex", c_short),
|
|
|
|
("index", c_int),
|
|
|
|
("flags", c_uint)]
|
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
def _alloc_material_buffer_callback(ptr, count):
|
2011-03-09 13:20:34 -07:00
|
|
|
return util._allocate_array(ptr, Material, count)
|
2010-08-19 11:47:45 -06:00
|
|
|
|
2011-03-11 15:11:34 -07:00
|
|
|
_material_functype = CFUNCTYPE(c_int, POINTER(POINTER(Material)), c_uint)
|
2011-03-09 11:29:29 -07:00
|
|
|
_material_func = _material_functype(_alloc_material_buffer_callback)
|
2011-03-11 15:59:25 -07:00
|
|
|
_register_callback("alloc_material_buffer_callback", _material_func)
|
2010-08-19 11:47:45 -06:00
|
|
|
|
2010-06-17 14:29:29 -06:00
|
|
|
class Skill(Structure):
|
2010-08-19 11:47:45 -06:00
|
|
|
_fields_ = [("id", c_uint),
|
2010-06-17 14:29:29 -06:00
|
|
|
("experience", c_uint),
|
2010-08-19 11:47:45 -06:00
|
|
|
("rating", c_uint)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class Job(Structure):
|
|
|
|
_fields_ = [("active", c_byte),
|
|
|
|
("jobId", c_uint),
|
|
|
|
("jobType", c_ubyte),
|
|
|
|
("occupationPtr", c_uint)]
|
|
|
|
|
|
|
|
class Like(Structure):
|
|
|
|
_fields_ = [("type", c_short),
|
|
|
|
("itemClass", c_short),
|
|
|
|
("itemIndex", c_short),
|
|
|
|
("material", MatglossPair),
|
|
|
|
("active", c_byte)]
|
|
|
|
|
|
|
|
class Attribute(Structure):
|
|
|
|
_fields_ = [("level", c_uint),
|
|
|
|
("field_4", c_uint),
|
|
|
|
("field_8", c_uint),
|
|
|
|
("field_C", c_uint),
|
|
|
|
("leveldiff", c_uint),
|
|
|
|
("field_14", c_uint),
|
|
|
|
("field_18", c_uint)]
|
|
|
|
|
|
|
|
class Name(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("first_name", _dfhack_string),
|
|
|
|
("nickname", _dfhack_string),
|
2010-06-17 14:29:29 -06:00
|
|
|
("words", (c_int * 7)),
|
|
|
|
("parts_of_speech", (c_ushort * 7)),
|
|
|
|
("language", c_uint),
|
|
|
|
("has_name", c_byte)]
|
|
|
|
|
|
|
|
class Note(Structure):
|
|
|
|
_fields_ = [("symbol", c_char),
|
|
|
|
("foreground", c_ushort),
|
|
|
|
("background", c_ushort),
|
2011-03-11 13:13:52 -07:00
|
|
|
("name", _dfhack_string),
|
2010-06-17 14:29:29 -06:00
|
|
|
("x", c_ushort),
|
|
|
|
("y", c_ushort),
|
|
|
|
("z", c_ushort)]
|
|
|
|
|
|
|
|
class Settlement(Structure):
|
|
|
|
_fields_ = [("origin", c_uint),
|
|
|
|
("name", Name),
|
|
|
|
("world_x", c_short),
|
|
|
|
("world_y", c_short),
|
|
|
|
("local_x1", c_short),
|
|
|
|
("local_x2", c_short),
|
|
|
|
("local_y1", c_short),
|
|
|
|
("local_y2", c_short)]
|
|
|
|
|
|
|
|
_NUM_CREATURE_TRAITS = 30
|
|
|
|
_NUM_CREATURE_LABORS = 102
|
|
|
|
|
|
|
|
class Soul(Structure):
|
|
|
|
_fields_ = [("numSkills", c_ubyte),
|
|
|
|
("skills", (Skill * 256)),
|
|
|
|
("traits", (c_ushort * _NUM_CREATURE_TRAITS)),
|
|
|
|
("analytical_ability", Attribute),
|
|
|
|
("focus", Attribute),
|
|
|
|
("willpower", Attribute),
|
|
|
|
("creativity", Attribute),
|
|
|
|
("intuition", Attribute),
|
|
|
|
("patience", Attribute),
|
|
|
|
("memory", Attribute),
|
|
|
|
("linguistic_ability", Attribute),
|
|
|
|
("spatial_sense", Attribute),
|
|
|
|
("musicality", Attribute),
|
|
|
|
("kinesthetic_sense", Attribute),
|
|
|
|
("empathy", Attribute),
|
|
|
|
("social_awareness", Attribute)]
|
|
|
|
|
|
|
|
_MAX_COLORS = 15
|
|
|
|
|
|
|
|
class Creature(Structure):
|
|
|
|
_fields_ = [("origin", c_uint),
|
|
|
|
("x", c_ushort),
|
|
|
|
("y", c_ushort),
|
|
|
|
("z", c_ushort),
|
|
|
|
("race", c_uint),
|
|
|
|
("civ", c_int),
|
|
|
|
("flags1", CreatureFlags1),
|
|
|
|
("flags2", CreatureFlags2),
|
|
|
|
("name", Name),
|
|
|
|
("mood", c_short),
|
|
|
|
("mood_skill", c_short),
|
|
|
|
("artifact_name", Name),
|
|
|
|
("profession", c_ubyte),
|
2011-03-11 13:13:52 -07:00
|
|
|
("custom_profession", _dfhack_string),
|
2010-06-17 14:29:29 -06:00
|
|
|
("labors", (c_ubyte * _NUM_CREATURE_LABORS)),
|
|
|
|
("current_job", Job),
|
|
|
|
("happiness", c_uint),
|
|
|
|
("id", c_uint),
|
|
|
|
("strength", Attribute),
|
|
|
|
("agility", Attribute),
|
|
|
|
("toughness", Attribute),
|
|
|
|
("endurance", Attribute),
|
|
|
|
("recuperation", Attribute),
|
|
|
|
("disease_resistance", Attribute),
|
|
|
|
("squad_leader_id", c_int),
|
|
|
|
("sex", c_ubyte),
|
|
|
|
("caste", c_ushort),
|
|
|
|
("pregnancy_timer", c_uint),
|
|
|
|
("has_default_soul", c_byte),
|
|
|
|
("defaultSoul", Soul),
|
|
|
|
("nbcolors", c_uint),
|
2010-08-19 11:47:45 -06:00
|
|
|
("color", (c_uint * _MAX_COLORS)),
|
2011-03-09 11:29:29 -07:00
|
|
|
("birth_year", c_int),
|
2010-08-19 11:47:45 -06:00
|
|
|
("birth_time", c_uint)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class CreatureExtract(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("rawname", _dfhack_string)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class BodyPart(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("id", _dfhack_string),
|
|
|
|
("category", _dfhack_string),
|
|
|
|
("single", _dfhack_string),
|
|
|
|
("plural", _dfhack_string)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
class ColorModifier(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("part", _dfhack_string),
|
2010-06-17 14:29:29 -06:00
|
|
|
("colorlist", POINTER(c_uint)),
|
2011-03-11 13:13:52 -07:00
|
|
|
("colorlistLength", c_uint),
|
|
|
|
("startdate", c_uint),
|
|
|
|
("enddate", c_uint)]
|
2010-06-17 14:29:29 -06:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.colorlistLength = 0
|
|
|
|
|
2011-03-11 13:13:52 -07:00
|
|
|
_colormodifier_ptr = POINTER(ColorModifier)
|
2011-03-09 11:29:29 -07:00
|
|
|
|
|
|
|
class CreatureCaste(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("rawname", _dfhack_string),
|
|
|
|
("singular", _dfhack_string),
|
|
|
|
("plural", _dfhack_string),
|
|
|
|
("adjective", _dfhack_string),
|
|
|
|
("color_modifier", _colormodifier_ptr),
|
2011-03-09 11:29:29 -07:00
|
|
|
("color_modifier_length", c_uint),
|
|
|
|
("bodypart", POINTER(BodyPart)),
|
2011-03-11 13:13:52 -07:00
|
|
|
("bodypart_length", c_uint),
|
|
|
|
("strength", Attribute),
|
|
|
|
("agility", Attribute),
|
|
|
|
("toughness", Attribute),
|
|
|
|
("endurance", Attribute),
|
|
|
|
("recuperation", Attribute),
|
|
|
|
("disease_resistance", Attribute),
|
|
|
|
("analytical_ability", Attribute),
|
|
|
|
("focus", Attribute),
|
|
|
|
("willpower", Attribute),
|
|
|
|
("creativity", Attribute),
|
|
|
|
("intuition", Attribute),
|
|
|
|
("patience", Attribute),
|
|
|
|
("memory", Attribute),
|
|
|
|
("linguistic_ability", Attribute),
|
|
|
|
("spatial_sense", Attribute),
|
|
|
|
("musicality", Attribute),
|
|
|
|
("kinesthetic_sense", Attribute)]
|
|
|
|
|
|
|
|
_creaturecaste_ptr = POINTER(CreatureCaste)
|
2011-03-09 11:29:29 -07:00
|
|
|
|
|
|
|
class TileColor(Structure):
|
|
|
|
_fields_ = [("fore", c_ushort),
|
|
|
|
("back", c_ushort),
|
|
|
|
("bright", c_ushort)]
|
|
|
|
|
2011-03-11 13:13:52 -07:00
|
|
|
class ColorDescriptor(Structure):
|
|
|
|
_fields_ = [("colorlistLength", c_uint)]
|
|
|
|
|
|
|
|
class CasteDescriptor(Structure):
|
|
|
|
_fields_ = [("color_descriptors", POINTER(ColorDescriptor)),
|
|
|
|
("colorModifierLength", c_uint),
|
|
|
|
("bodypartLength", c_uint)]
|
|
|
|
|
|
|
|
class CreatureTypeDescriptor(Structure):
|
|
|
|
_fields_ = [("caste_descriptors", POINTER(CasteDescriptor)),
|
|
|
|
("castesCount", c_uint),
|
|
|
|
("extractCount", c_uint)]
|
|
|
|
|
2011-03-09 11:29:29 -07:00
|
|
|
class CreatureType(Structure):
|
2011-03-11 13:13:52 -07:00
|
|
|
_fields_ = [("rawname", _dfhack_string),
|
|
|
|
("castes", _creaturecaste_ptr),
|
2011-03-09 11:29:29 -07:00
|
|
|
("castes_count", c_uint),
|
2011-03-11 13:13:52 -07:00
|
|
|
("extract", POINTER(CreatureExtract)),
|
|
|
|
("extract_count", c_uint),
|
2011-03-09 11:29:29 -07:00
|
|
|
("tile_character", c_ubyte),
|
|
|
|
("tilecolor", TileColor)]
|
2011-03-03 09:18:00 -07:00
|
|
|
|
2011-03-11 13:13:52 -07:00
|
|
|
_creaturetype_ptr = POINTER(CreatureType)
|
|
|
|
|
|
|
|
def _alloc_creaturetype_buffer(ptr, descriptors, count):
|
|
|
|
arr_list = []
|
|
|
|
c_arr = (CreatureType * count)()
|
|
|
|
|
|
|
|
for i, v in enumerate(c_arr):
|
|
|
|
v.castesCount = descriptors[i].castesCount
|
|
|
|
v_caste_arr = (CreatureCaste * v.castesCount)()
|
|
|
|
|
|
|
|
for j, v_c in enumerate(v_caste_arr):
|
|
|
|
caste_descriptor = descriptors[i].caste_descriptors[j]
|
|
|
|
|
|
|
|
v_c.colorModifierLength = caste_descriptor.colorModifierLength
|
|
|
|
c_color_arr = (ColorModifier * v_c.colorModifierLength)()
|
|
|
|
|
|
|
|
for k, c_c in enumerate(c_color_arr):
|
|
|
|
color_descriptor = caste_descriptor.color_descriptors[k]
|
|
|
|
|
|
|
|
c_c.colorlistLength = color_descriptor.colorlistLength
|
|
|
|
|
|
|
|
c_color_list_arr = (c_uint * c_c.colorlistLength)()
|
|
|
|
|
|
|
|
p = cast(c_color_list_arr, POINTER(c_uint))
|
|
|
|
|
|
|
|
c_c.colorlist = p
|
|
|
|
|
|
|
|
arr_list.extend((c_color_list_arr, p))
|
|
|
|
|
|
|
|
c_p = cast(c_color_arr, POINTER(ColorModifier))
|
|
|
|
v_c.colorModifier = c_p
|
|
|
|
|
|
|
|
v_c.bodypartLength = caste_descriptor.bodypartLength
|
|
|
|
c_bodypart_arr = (BodyPart * v_c.bodypartLength)()
|
|
|
|
|
|
|
|
b_p = cast(c_bodypart_arr, POINTER(BodyPart))
|
|
|
|
v_c.bodypart = b_p
|
|
|
|
|
|
|
|
arr_list.extend((c_color_arr, c_p, c_bodypart_arr, b_p))
|
|
|
|
|
|
|
|
v.extractCount = descriptors[i].extractCount
|
|
|
|
v_extract_arr = (CreatureExtract * v.extractCount)()
|
|
|
|
|
|
|
|
caste_p = cast(v_caste_arr, POINTER(CreatureCaste))
|
|
|
|
v.castes = caste_p
|
|
|
|
|
|
|
|
extract_p = cast(v_extract_arr, POINTER(CreatureExtract))
|
|
|
|
v.extract = extract_p
|
|
|
|
|
|
|
|
arr_list.extend((v_caste_arr, caste_p, v_extract_arr, extract_p))
|
|
|
|
|
|
|
|
p = cast(c_arr, _creaturetype_ptr)
|
|
|
|
ptr[0] = p
|
|
|
|
|
|
|
|
pointer_dict[addressof(c_arr)] = (ptr, c_arr, p, arr_list)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
_alloc_creaturetype_buffer_functype = CFUNCTYPE(c_int, POINTER(_creaturetype_ptr), POINTER(CreatureTypeDescriptor), c_uint)
|
|
|
|
_alloc_creaturetype_buffer_func = _alloc_creaturetype_buffer_functype(_alloc_creaturetype_buffer)
|
|
|
|
_register_callback("alloc_creaturetype_buffer_callback", _alloc_creaturetype_buffer_func)
|
|
|
|
|
2011-03-03 09:18:00 -07:00
|
|
|
class GameModes(Structure):
|
|
|
|
_fields_ = [("control_mode", c_ubyte),
|
|
|
|
("game_mode", c_ubyte)]
|
2011-03-15 14:35:50 -06:00
|
|
|
|
|
|
|
class Hotkey(Structure):
|
|
|
|
_fields_ = [("name", (c_char * 10)),
|
|
|
|
("mode", c_short),
|
|
|
|
("x", c_int),
|
|
|
|
("y", c_int),
|
|
|
|
("z", c_int)]
|
|
|
|
|
|
|
|
def _alloc_hotkey_buffer_callback(ptr, count):
|
|
|
|
print "hotkey alloc: %d" % count
|
|
|
|
return util._allocate_array(ptr, Hotkey, count)
|
|
|
|
|
|
|
|
_hotkey_functype = CFUNCTYPE(c_int, POINTER(POINTER(Hotkey)), c_uint)
|
|
|
|
_hotkey_func = _hotkey_functype(_alloc_hotkey_buffer_callback)
|
|
|
|
_register_callback("alloc_hotkey_buffer_callback", _hotkey_func)
|