--- deliantra/server/plugins/cfperl/cfperl.xs 2006/08/12 11:51:38 1.65 +++ deliantra/server/plugins/cfperl/cfperl.xs 2006/08/13 17:16:02 1.66 @@ -47,6 +47,8 @@ #include +#include + //#include "EventAPI.h" #include "perlxsi.c" @@ -94,9 +96,6 @@ #define PUSH_PV PUSHcfapi_va(STRING, const char *) #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) -extern void pay_player(object *op, uint64 amount); -extern uint64 pay_player_arch(object *op, const char *arch, uint64 amount); - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // garbage collect some perl objects, if possible @@ -306,8 +305,7 @@ ///////////////////////////////////////////////////////////////////////////// -int -initPlugin (const char *iversion, f_plug_api gethooksptr) +extern "C" int initPlugin (const char *iversion, f_plug_api gethooksptr) { gethook = gethooksptr; printf (PLUGIN_VERSION " init\n"); @@ -350,8 +348,7 @@ return returnvalue; } -void * -getPluginProperty (int *type, ...) +extern "C" void *getPluginProperty (int *type, ...) { va_list args; char *propname; @@ -384,12 +381,12 @@ else if (!strcmp (propname, "Identification")) { va_end (args); - return PLUGIN_NAME; + return (void*) PLUGIN_NAME; } else if (!strcmp (propname, "FullName")) { va_end (args); - return PLUGIN_VERSION; + return (void*) PLUGIN_VERSION; } else va_end (args); @@ -399,20 +396,19 @@ void *globalEventListener (int *type, ...); -int -postInitPlugin () +extern "C" int postInitPlugin () { int hooktype = 1; int rtype = 0; printf (PLUGIN_VERSION " post init\n"); - registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); - unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); - systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); - object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property"); - map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map"); - object_insert = gethook (&rtype, hooktype, "cfapi_object_insert"); + registerGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_register_global_event"); + unregisterGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); + systemDirectory = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_directory"); + object_set_property = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_set_property"); + map_get_map = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_map_get_map"); + object_insert = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_insert"); cf_init_plugin (gethook); @@ -485,7 +481,7 @@ int event_code; if (!perl) - return; + return NULL; va_start (args, type); event_code = va_arg (args, int); @@ -635,8 +631,7 @@ return &rv; } -void * -eventListener (int *type, ...) +extern "C" void * eventListener (int *type, ...) { static int rv; va_list args; @@ -645,7 +640,7 @@ char *message, *extension, *options; if (!perl) - return; + return NULL; va_start (args, type); who = va_arg (args, object *); @@ -728,8 +723,7 @@ return &rv; } -int -closePlugin () +extern "C" int closePlugin () { printf (PLUGIN_VERSION " closing\n"); @@ -1425,7 +1419,7 @@ void LOG (int level, char *msg) PROTOTYPE: $$ - C_ARGS: level, "%s", msg + C_ARGS: (LogLevel)level, "%s", msg char *path_combine (char *base, char *path) PROTOTYPE: $$ @@ -1523,7 +1517,7 @@ cf_object_set_int_property (obj, idx, SvIV (newval)); break; case CFAPI_LONG: - cf_object_set_long_property (obj, idx, SvVAL64 (newval)); + cf_object_set_long_property (obj, idx, (long) SvVAL64 (newval)); break; case CFAPI_DOUBLE: { @@ -1611,11 +1605,11 @@ int cf_object_pay_item (object *op, object *buyer) -int cf_object_pay_amount (object *op, val64 amount) +int cf_object_pay_amount (object *op, uint64 amount) -void pay_player (object *op, val64 amount) +void pay_player (object *op, uint64 amount) -val64 pay_player_arch (object *op, const char *arch, val64 amount) +val64 pay_player_arch (object *op, const char *arch, uint64 amount) int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0) @@ -1662,7 +1656,7 @@ object *cf_create_object_by_name (const char *name) -void change_exp (object *op, val64 exp, const char *skill_name = 0, int flag = 0) +void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) void player_lvl_adj (object *who, object *skill = 0) @@ -1787,8 +1781,6 @@ void cf_player_set_party (object *op, partylist *party) -void change_skill (object *op, val64 exp, char *skill_name = 0, int flag = 0) - void kill_player (object *op) MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ @@ -1919,7 +1911,7 @@ CODE: { int unused_type; - RETVAL = map_get_map (&unused_type, 0, width, height); + RETVAL = (mapstruct*) map_get_map (&unused_type, 0, width, height); } OUTPUT: RETVAL @@ -2210,7 +2202,7 @@ dam = 17 luck = 18 CODE: -# define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = new_val; break +# define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = (sint64)new_val; break switch (ix) { LIVING_ACC (exp , 0);