diff --git a/src/helpers.c b/src/helpers.c index 25079c549..7591dba9f 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -311,8 +311,8 @@ void register_tolua_helpers(void) callbacks.cast_spell = lua_callspell; callbacks.use_item = use_item_lua; - res_produce_fun = produce_resource_lua; - res_limit_fun = limit_resource_lua; + callbacks.produce_resource = produce_resource_lua; + callbacks.limit_resource = limit_resource_lua; register_function((pf_generic)lua_changeresource, "lua_changeresource"); register_item_give(lua_giveitem, "lua_giveitem"); diff --git a/src/kernel/callbacks.h b/src/kernel/callbacks.h index 0aa71daca..dcdf6ac90 100644 --- a/src/kernel/callbacks.h +++ b/src/kernel/callbacks.h @@ -26,13 +26,16 @@ extern "C" { struct castorder; struct order; struct unit; + struct region; struct item_type; + struct resource_type; struct callback_struct { int (*cast_spell)(struct castorder *co, const char *fname); int (*use_item)(struct unit *u, const struct item_type *itype, int amount, struct order *ord); - + void(*produce_resource)(struct region *, const struct resource_type *, int); + int(*limit_resource)(const struct region *, const struct resource_type *); }; extern struct callback_struct callbacks; diff --git a/src/kernel/resources.c b/src/kernel/resources.c index fe18ae640..842cb83ba 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -11,10 +11,11 @@ */ #include -#include #include "resources.h" /* kernel includes */ +#include +#include #include "build.h" #include "item.h" #include "region.h" @@ -213,14 +214,11 @@ struct rawmaterial_type *rmt_create(struct resource_type *rtype) return rmtype; } -int(*res_limit_fun)(const struct region *, const struct resource_type *); -void(*res_produce_fun)(struct region *, const struct resource_type *, int); - int limit_resource(const struct region *r, const resource_type *rtype) { assert(!rtype->raw); - if (res_limit_fun) { - return res_limit_fun(r, rtype); + if (callbacks.limit_resource) { + return callbacks.limit_resource(r, rtype); } return -1; } @@ -228,7 +226,7 @@ int limit_resource(const struct region *r, const resource_type *rtype) void produce_resource(struct region *r, const struct resource_type *rtype, int amount) { assert(!rtype->raw); - if (res_produce_fun) { - res_produce_fun(r, rtype, amount); + if (callbacks.produce_resource) { + callbacks.produce_resource(r, rtype, amount); } } diff --git a/src/kernel/resources.h b/src/kernel/resources.h index e7a232d27..2daa44dd8 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -15,8 +15,11 @@ extern "C" { #endif +#include + struct building_type; struct race; + struct region; enum { RM_USED = 1 << 0, /* resource has been used */ @@ -71,8 +74,6 @@ extern "C" { int base, int divisor, const struct resource_type *rtype); struct rawmaterial_type *rmt_create(struct resource_type *rtype); - extern int(*res_limit_fun)(const struct region *, const struct resource_type *); - extern void(*res_produce_fun)(struct region *, const struct resource_type *, int); int limit_resource(const struct region *r, const struct resource_type *rtype); void produce_resource(struct region *r, const struct resource_type *rtype, int amount);