--- deliantra/server/plugins/cfperl/cfperl.xs 2006/07/20 07:22:41 1.63 +++ deliantra/server/plugins/cfperl/cfperl.xs 2006/08/15 06:04:15 1.70 @@ -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); @@ -422,6 +418,7 @@ //registerGlobalEvent (NULL, EVENT_CRASH, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_FIND_UNARMED_SKILL, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_PLAYER_USE_SKILL, PLUGIN_NAME, globalEventListener); + registerGlobalEvent (NULL, EVENT_CAST_SPELL, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_MONSTER_USE_SKILL, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_PLAYER_DEATH, PLUGIN_NAME, globalEventListener); registerGlobalEvent (NULL, EVENT_GKILL, PLUGIN_NAME, globalEventListener); @@ -484,7 +481,7 @@ int event_code; if (!perl) - return; + return NULL; va_start (args, type); event_code = va_arg (args, int); @@ -594,6 +591,7 @@ case EVENT_PLAYER_USE_SKILL: case EVENT_MONSTER_USE_SKILL: + case EVENT_CAST_SPELL: PUSH_OB; PUSH_OB; PUSH_OB; @@ -633,8 +631,7 @@ return &rv; } -void * -eventListener (int *type, ...) +extern "C" void * eventListener (int *type, ...) { static int rv; va_list args; @@ -643,7 +640,7 @@ char *message, *extension, *options; if (!perl) - return; + return NULL; va_start (args, type); who = va_arg (args, object *); @@ -679,15 +676,16 @@ case EVENT_TIMER: // $ob break; - case EVENT_APPLY: // $ob, $who - case EVENT_DROP: // $ob, $who - case EVENT_CLOSE: // $ob, $who - case EVENT_DEATH: // $ob[, $killer] - case EVENT_MOVE: // $ob, $enemy - case EVENT_THROW: // $ob, $thrower + case EVENT_APPLY: // $ob, $who + case EVENT_DROP: // $ob, $who + case EVENT_CLOSE: // $ob, $who + case EVENT_DEATH: // $ob[, $killer] + case EVENT_MOVE: // $ob, $enemy + case EVENT_THROW: // $ob, $thrower PUSHcfapi (POBJECT, activator); break; + case EVENT_DROP_ON: // $ob, $who, $what case EVENT_ATTACK: // $ob, $who, $victim (?? please god enlighten me) PUSHcfapi (POBJECT, activator); PUSHcfapi (POBJECT, third); @@ -726,8 +724,7 @@ return &rv; } -int -closePlugin () +extern "C" int closePlugin () { printf (PLUGIN_VERSION " closing\n"); @@ -1065,6 +1062,10 @@ const_iv (F_NOPICK) const_iv (F_LOCKED) + const_iv (F_BUY) + const_iv (F_SHOP) + const_iv (F_SELL) + const_iv (P_BLOCKSVIEW) const_iv (P_NO_MAGIC) const_iv (P_IS_ALIVE) @@ -1237,6 +1238,7 @@ const_event (ATTACK) const_event (DEATH) const_event (DROP) + const_event (DROP_ON) const_event (PICKUP) const_event (SAY) const_event (STOP) @@ -1270,6 +1272,7 @@ const_event (KICK) const_event (PLAYER_USE_SKILL) const_event (MONSTER_USE_SKILL) + const_event (CAST_SPELL) const_event (FIND_UNARMED_SKILL) const_event (EXTCMD) //const_event (FREE_OB) @@ -1419,10 +1422,14 @@ //I_EVENT_API (PACKAGE); } +NV floor (NV x) + +NV ceil (NV x) + 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: $$ @@ -1464,6 +1471,8 @@ int random_roll(int min, int max, object *op, int goodbad); +const char *cost_string_from_value(uint64 cost, int approx = 0) + int exp_to_level (val64 exp) CODE: @@ -1520,7 +1529,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: { @@ -1588,6 +1597,10 @@ void cf_object_set_flag (object *op, int flag, int value) +int need_identify (const object *obj); + +int apply_shop_mat (object *shop_mat, object *op); + void cf_object_move (object *op, int dir, object *originator = op) void cf_object_apply (object *op, object *author, int flags = 0) @@ -1608,7 +1621,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, uint64 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) @@ -1655,11 +1672,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 pay_player (object *op, val64 amount) - -val64 pay_player_arch (object *op, const char *arch, val64 amount) +void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) void player_lvl_adj (object *who, object *skill = 0) @@ -1784,8 +1797,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_ @@ -1916,7 +1927,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 @@ -2136,6 +2147,9 @@ const char *cf_archetype_get_name (archetype *arch) ALIAS: name = 0 +object *cf_archetype_get_clone (archetype *arch) + ALIAS: clone = 0 + MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ partylist *cf_party_get_first () @@ -2204,7 +2218,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);