using preregistered callbacks

develop
doomchild 2010-05-25 08:30:40 -05:00
parent 5e65f5568b
commit 119d344af9
2 changed files with 25 additions and 21 deletions

@ -42,6 +42,10 @@ typedef t_matgloss* (*MatglossBufferFunc)(int);
typedef t_descriptor_color* (*DescriptorColorBufferFunc)(int);
typedef t_matglossOther* (*MatglossOtherBufferFunc)(int);
MatglossBufferFunc alloc_matgloss_buffer_callback;
DescriptorColorBufferFunc alloc_descriptor_buffer_callback;
MatglossOtherBufferFunc alloc_matgloss_other_buffer_callback;
DFHACK_EXPORT int Materials_ReadInorganicMaterials(DFHackObject* mat);
DFHACK_EXPORT int Materials_ReadOrganicMaterials(DFHackObject* mat);
DFHACK_EXPORT int Materials_ReadWoodMaterials(DFHackObject* mat);
@ -64,11 +68,11 @@ DFHACK_EXPORT int Materials_getRaceExSize(DFHackObject* mat);
DFHACK_EXPORT int Materials_getColorSize(DFHackObject* mat);
DFHACK_EXPORT int Materials_getOtherSize(DFHackObject* mat);
DFHACK_EXPORT int Materials_getInorganic(DFHackObject* mat, MatglossBufferFunc callback);
DFHACK_EXPORT int Materials_getOrganic(DFHackObject* mat, MatglossBufferFunc callback);
DFHACK_EXPORT int Materials_getTree(DFHackObject* mat, MatglossBufferFunc callback);
DFHACK_EXPORT int Materials_getPlant(DFHackObject* mat, MatglossBufferFunc callback);
DFHACK_EXPORT int Materials_getRace(DFHackObject* mat, MatglossBufferFunc callback);
DFHACK_EXPORT int Materials_getInorganic(DFHackObject* mat);
DFHACK_EXPORT int Materials_getOrganic(DFHackObject* mat);
DFHACK_EXPORT int Materials_getTree(DFHackObject* mat);
DFHACK_EXPORT int Materials_getPlant(DFHackObject* mat);
DFHACK_EXPORT int Materials_getRace(DFHackObject* mat);
/*doomchild:
I haven't done getRaceEx yet, because I'm not sure about the best way to make the t_creaturetype struct
@ -76,8 +80,8 @@ DFHACK_EXPORT int Materials_getRace(DFHackObject* mat, MatglossBufferFunc callba
*/
//DFHACK_EXPORT int Materials_getRaceEx(DFHackObject* mat, c_creaturetype* (*c_creaturetype_buffer_create)(c_creaturetype_descriptor*, int));
DFHACK_EXPORT int Materials_getColor(DFHackObject* mat, DescriptorColorBufferFunc callback);
DFHACK_EXPORT int Materials_getOther(DFHackObject* mat, MatglossOtherBufferFunc callback);
DFHACK_EXPORT int Materials_getColor(DFHackObject* mat);
DFHACK_EXPORT int Materials_getOther(DFHackObject* mat);
#ifdef __cplusplus
}

@ -225,7 +225,7 @@ int Materials_getOtherSize(DFHackObject* mat)
//vector getters
int Materials_getInorganic(DFHackObject* mat, MatglossBufferFunc callback)
int Materials_getInorganic(DFHackObject* mat)
{
if(mat != NULL)
{
@ -233,7 +233,7 @@ int Materials_getInorganic(DFHackObject* mat, MatglossBufferFunc callback)
if(materials->inorganic.size() > 0)
{
t_matgloss* buf = ((*callback)(materials->inorganic.size()));
t_matgloss* buf = ((*alloc_matgloss_buffer_callback)(materials->inorganic.size()));
if(buf != NULL)
{
@ -251,7 +251,7 @@ int Materials_getInorganic(DFHackObject* mat, MatglossBufferFunc callback)
return -1;
}
int Materials_getOrganic(DFHackObject* mat, MatglossBufferFunc callback)
int Materials_getOrganic(DFHackObject* mat)
{
if(mat != NULL)
{
@ -259,7 +259,7 @@ int Materials_getOrganic(DFHackObject* mat, MatglossBufferFunc callback)
if(materials->organic.size() > 0)
{
t_matgloss* buf = ((*callback)(materials->organic.size()));
t_matgloss* buf = ((*alloc_matgloss_buffer_callback)(materials->organic.size()));
if(buf != NULL)
{
@ -277,7 +277,7 @@ int Materials_getOrganic(DFHackObject* mat, MatglossBufferFunc callback)
return -1;
}
int Materials_getTree(DFHackObject* mat, MatglossBufferFunc callback)
int Materials_getTree(DFHackObject* mat)
{
if(mat != NULL)
{
@ -285,7 +285,7 @@ int Materials_getTree(DFHackObject* mat, MatglossBufferFunc callback)
if(materials->tree.size() > 0)
{
t_matgloss* buf = ((*callback)(materials->tree.size()));
t_matgloss* buf = ((*alloc_matgloss_buffer_callback)(materials->tree.size()));
if(buf != NULL)
{
@ -303,7 +303,7 @@ int Materials_getTree(DFHackObject* mat, MatglossBufferFunc callback)
return -1;
}
int Materials_getPlant(DFHackObject* mat, MatglossBufferFunc callback)
int Materials_getPlant(DFHackObject* mat)
{
if(mat != NULL)
{
@ -311,7 +311,7 @@ int Materials_getPlant(DFHackObject* mat, MatglossBufferFunc callback)
if(materials->plant.size() > 0)
{
t_matgloss* buf = ((*callback)(materials->plant.size()));
t_matgloss* buf = ((*alloc_matgloss_buffer_callback)(materials->plant.size()));
if(buf != NULL)
{
@ -329,7 +329,7 @@ int Materials_getPlant(DFHackObject* mat, MatglossBufferFunc callback)
return -1;
}
int Materials_getRace(DFHackObject* mat, MatglossBufferFunc callback)
int Materials_getRace(DFHackObject* mat)
{
if(mat != NULL)
{
@ -337,7 +337,7 @@ int Materials_getRace(DFHackObject* mat, MatglossBufferFunc callback)
if(materials->race.size() > 0)
{
t_matgloss* buf = ((*callback)(materials->race.size()));
t_matgloss* buf = ((*alloc_matgloss_buffer_callback)(materials->race.size()));
if(buf != NULL)
{
@ -397,7 +397,7 @@ int Materials_getRace(DFHackObject* mat, MatglossBufferFunc callback)
// return -1;
// }
int Materials_getColor(DFHackObject* mat, DescriptorColorBufferFunc callback)
int Materials_getColor(DFHackObject* mat)
{
if(mat != NULL)
{
@ -405,7 +405,7 @@ int Materials_getColor(DFHackObject* mat, DescriptorColorBufferFunc callback)
if(materials->color.size() > 0)
{
t_descriptor_color* buf = ((*callback)(materials->color.size()));
t_descriptor_color* buf = ((*alloc_descriptor_buffer_callback)(materials->color.size()));
if(buf != NULL)
{
@ -423,7 +423,7 @@ int Materials_getColor(DFHackObject* mat, DescriptorColorBufferFunc callback)
return -1;
}
int Materials_getOther(DFHackObject* mat, MatglossOtherBufferFunc callback)
int Materials_getOther(DFHackObject* mat)
{
if(mat != NULL)
{
@ -431,7 +431,7 @@ int Materials_getOther(DFHackObject* mat, MatglossOtherBufferFunc callback)
if(materials->other.size() > 0)
{
t_matglossOther* buf = ((*callback)(materials->other.size()));
t_matglossOther* buf = ((*alloc_matgloss_other_buffer_callback)(materials->other.size()));
if(buf != NULL)
{