From fd872922a53744994235ce8a33ddd86499a7542f Mon Sep 17 00:00:00 2001 From: doomchild Date: Wed, 18 Aug 2010 16:00:49 -0500 Subject: [PATCH] updated to match C++ additions --- library/include/dfhack-c/modules/Items_C.h | 3 +++ .../include/dfhack-c/modules/Materials_C.h | 2 +- library/modules/Items_C.cpp | 20 ++++++++++++++++ library/modules/Materials_C.cpp | 24 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/library/include/dfhack-c/modules/Items_C.h b/library/include/dfhack-c/modules/Items_C.h index 5c1e08e48..5c61513f7 100644 --- a/library/include/dfhack-c/modules/Items_C.h +++ b/library/include/dfhack-c/modules/Items_C.h @@ -34,6 +34,9 @@ distribution. extern "C" { #endif +DFHACK_EXPORT int Items_Start(DFHackObject* items); +DFHACK_EXPORT int Items_Finish(DFHackObject* items); + DFHACK_EXPORT char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats); DFHACK_EXPORT char* Items_getItemClass(DFHackObject* items, int32_t index); DFHACK_EXPORT int Items_getItemData(DFHackObject* items, uint32_t itemptr, t_item* item); diff --git a/library/include/dfhack-c/modules/Materials_C.h b/library/include/dfhack-c/modules/Materials_C.h index 25a9a7df3..888978a50 100644 --- a/library/include/dfhack-c/modules/Materials_C.h +++ b/library/include/dfhack-c/modules/Materials_C.h @@ -62,9 +62,9 @@ DFHACK_EXPORT t_matgloss* Materials_getPlant(DFHackObject* mat); DFHACK_EXPORT t_matgloss* Materials_getRace(DFHackObject* mat); DFHACK_EXPORT c_creaturetype* Materials_getRaceEx(DFHackObject* mat); - DFHACK_EXPORT t_descriptor_color* Materials_getColor(DFHackObject* mat); DFHACK_EXPORT t_matglossOther* Materials_getOther(DFHackObject* mat); +DFHACK_EXPORT t_matgloss* Materials_getAllDesc(DFHackObject* mat); #ifdef __cplusplus } diff --git a/library/modules/Items_C.cpp b/library/modules/Items_C.cpp index b9978f962..f0231617f 100644 --- a/library/modules/Items_C.cpp +++ b/library/modules/Items_C.cpp @@ -28,6 +28,26 @@ distribution. extern "C" { #endif +int Items_Start(DFHackObject* items) +{ + if(items != NULL) + { + return ((DFHack::Items*)items)->Start(); + } + + return -1; +} + +int Items_Finish(DFHackObject* items) +{ + if(items != NULL) + { + return ((DFHack::Items*)items)->Finish(); + } + + return -1; +} + //FIXME: beware of bad null-termination! I haven't tested anything here, but it seems that it could be corrupting or truncating strings. char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats) diff --git a/library/modules/Materials_C.cpp b/library/modules/Materials_C.cpp index 1d70f8716..f95c4e76c 100644 --- a/library/modules/Materials_C.cpp +++ b/library/modules/Materials_C.cpp @@ -407,6 +407,30 @@ t_matglossOther* Materials_getOther(DFHackObject* mat) return NULL; } +t_matgloss* Materials_getAllDesc(DFHackObject* mat) +{ + if(mat != NULL) + { + DFHack::Materials* materials = (DFHack::Materials*)mat; + + if(materials->alldesc.size() > 0) + { + t_matgloss* buf; + + ((*alloc_matgloss_buffer_callback)(buf, materials->alldesc.size())); + + if(buf != NULL) + { + copy(materials->race.begin(), materials->alldesc.end(), buf); + + return buf; + } + } + } + + return NULL; +} + #ifdef __cplusplus } #endif