ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/cfperl/cfperl.xs
(Generate patch)

Comparing deliantra/server/plugins/cfperl/cfperl.xs (file contents):
Revision 1.65 by elmex, Sat Aug 12 11:51:38 2006 UTC vs.
Revision 1.66 by elmex, Sun Aug 13 17:16:02 2006 UTC

45#include <plugin_common.h> 45#include <plugin_common.h>
46#include <sounds.h> 46#include <sounds.h>
47 47
48#include <stdarg.h> 48#include <stdarg.h>
49 49
50#include <sproto.h>
51
50//#include "EventAPI.h" 52//#include "EventAPI.h"
51#include "perlxsi.c" 53#include "perlxsi.c"
52 54
53extern sint64 *levels; // the experience table 55extern sint64 *levels; // the experience table
54 56
92#define PUSH_PL PUSHcfapi_va(PPLAYER, player *) 94#define PUSH_PL PUSHcfapi_va(PPLAYER, player *)
93#define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) 95#define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *)
94#define PUSH_PV PUSHcfapi_va(STRING, const char *) 96#define PUSH_PV PUSHcfapi_va(STRING, const char *)
95#define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) 97#define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int))))
96 98
97extern void pay_player(object *op, uint64 amount);
98extern uint64 pay_player_arch(object *op, const char *arch, uint64 amount);
99
100////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 99//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
101 100
102// garbage collect some perl objects, if possible 101// garbage collect some perl objects, if possible
103// all objects no longer referenced and empty are 102// all objects no longer referenced and empty are
104// eligible for destruction. 103// eligible for destruction.
304 return sv; 303 return sv;
305} 304}
306 305
307///////////////////////////////////////////////////////////////////////////// 306/////////////////////////////////////////////////////////////////////////////
308 307
309int
310initPlugin (const char *iversion, f_plug_api gethooksptr) 308extern "C" int initPlugin (const char *iversion, f_plug_api gethooksptr)
311{ 309{
312 gethook = gethooksptr; 310 gethook = gethooksptr;
313 printf (PLUGIN_VERSION " init\n"); 311 printf (PLUGIN_VERSION " init\n");
314 312
315 return 0; 313 return 0;
348 LEAVE; 346 LEAVE;
349 347
350 return returnvalue; 348 return returnvalue;
351} 349}
352 350
353void *
354getPluginProperty (int *type, ...) 351extern "C" void *getPluginProperty (int *type, ...)
355{ 352{
356 va_list args; 353 va_list args;
357 char *propname; 354 char *propname;
358 int i; 355 int i;
359 va_start (args, type); 356 va_start (args, type);
382 } 379 }
383 } 380 }
384 else if (!strcmp (propname, "Identification")) 381 else if (!strcmp (propname, "Identification"))
385 { 382 {
386 va_end (args); 383 va_end (args);
387 return PLUGIN_NAME; 384 return (void*) PLUGIN_NAME;
388 } 385 }
389 else if (!strcmp (propname, "FullName")) 386 else if (!strcmp (propname, "FullName"))
390 { 387 {
391 va_end (args); 388 va_end (args);
392 return PLUGIN_VERSION; 389 return (void*) PLUGIN_VERSION;
393 } 390 }
394 else 391 else
395 va_end (args); 392 va_end (args);
396 393
397 return NULL; 394 return NULL;
398} 395}
399 396
400void *globalEventListener (int *type, ...); 397void *globalEventListener (int *type, ...);
401 398
402int 399extern "C" int postInitPlugin ()
403postInitPlugin ()
404{ 400{
405 int hooktype = 1; 401 int hooktype = 1;
406 int rtype = 0; 402 int rtype = 0;
407 403
408 printf (PLUGIN_VERSION " post init\n"); 404 printf (PLUGIN_VERSION " post init\n");
409 405
410 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); 406 registerGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_register_global_event");
411 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); 407 unregisterGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_unregister_global_event");
412 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); 408 systemDirectory = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_directory");
413 object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property"); 409 object_set_property = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_set_property");
414 map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map"); 410 map_get_map = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_map_get_map");
415 object_insert = gethook (&rtype, hooktype, "cfapi_object_insert"); 411 object_insert = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_insert");
416 412
417 cf_init_plugin (gethook); 413 cf_init_plugin (gethook);
418 414
419 /* Pick the global events you want to monitor from this plugin */ 415 /* Pick the global events you want to monitor from this plugin */
420 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); 416 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener);
483 va_list args; 479 va_list args;
484 static int rv; 480 static int rv;
485 int event_code; 481 int event_code;
486 482
487 if (!perl) 483 if (!perl)
488 return; 484 return NULL;
489 485
490 va_start (args, type); 486 va_start (args, type);
491 event_code = va_arg (args, int); 487 event_code = va_arg (args, int);
492 488
493 if (event_code == EVENT_FREE_OB) 489 if (event_code == EVENT_FREE_OB)
633 } 629 }
634 630
635 return &rv; 631 return &rv;
636} 632}
637 633
638void *
639eventListener (int *type, ...) 634extern "C" void * eventListener (int *type, ...)
640{ 635{
641 static int rv; 636 static int rv;
642 va_list args; 637 va_list args;
643 int event_code; 638 int event_code;
644 object *who, *activator, *third, *event; 639 object *who, *activator, *third, *event;
645 char *message, *extension, *options; 640 char *message, *extension, *options;
646 641
647 if (!perl) 642 if (!perl)
648 return; 643 return NULL;
649 644
650 va_start (args, type); 645 va_start (args, type);
651 who = va_arg (args, object *); 646 who = va_arg (args, object *);
652 event_code = va_arg (args, int); 647 event_code = va_arg (args, int);
653 activator = va_arg (args, object *); 648 activator = va_arg (args, object *);
726 } 721 }
727 722
728 return &rv; 723 return &rv;
729} 724}
730 725
731int 726extern "C" int closePlugin ()
732closePlugin ()
733{ 727{
734 printf (PLUGIN_VERSION " closing\n"); 728 printf (PLUGIN_VERSION " closing\n");
735 729
736 if (perl) 730 if (perl)
737 { 731 {
1423} 1417}
1424 1418
1425void 1419void
1426LOG (int level, char *msg) 1420LOG (int level, char *msg)
1427 PROTOTYPE: $$ 1421 PROTOTYPE: $$
1428 C_ARGS: level, "%s", msg 1422 C_ARGS: (LogLevel)level, "%s", msg
1429 1423
1430char *path_combine (char *base, char *path) 1424char *path_combine (char *base, char *path)
1431 PROTOTYPE: $$ 1425 PROTOTYPE: $$
1432 1426
1433char *path_combine_and_normalize (char *base, char *path) 1427char *path_combine_and_normalize (char *base, char *path)
1521 { 1515 {
1522 case CFAPI_INT: 1516 case CFAPI_INT:
1523 cf_object_set_int_property (obj, idx, SvIV (newval)); 1517 cf_object_set_int_property (obj, idx, SvIV (newval));
1524 break; 1518 break;
1525 case CFAPI_LONG: 1519 case CFAPI_LONG:
1526 cf_object_set_long_property (obj, idx, SvVAL64 (newval)); 1520 cf_object_set_long_property (obj, idx, (long) SvVAL64 (newval));
1527 break; 1521 break;
1528 case CFAPI_DOUBLE: 1522 case CFAPI_DOUBLE:
1529 { 1523 {
1530 int unused_type; 1524 int unused_type;
1531 object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); 1525 object_set_property (&unused_type, obj, idx, (double)SvNV (newval));
1609 1603
1610object *cf_object_clone (object *op, int clonetype = 0) 1604object *cf_object_clone (object *op, int clonetype = 0)
1611 1605
1612int cf_object_pay_item (object *op, object *buyer) 1606int cf_object_pay_item (object *op, object *buyer)
1613 1607
1614int cf_object_pay_amount (object *op, val64 amount) 1608int cf_object_pay_amount (object *op, uint64 amount)
1615 1609
1616void pay_player (object *op, val64 amount) 1610void pay_player (object *op, uint64 amount)
1617 1611
1618val64 pay_player_arch (object *op, const char *arch, val64 amount) 1612val64 pay_player_arch (object *op, const char *arch, uint64 amount)
1619 1613
1620int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0) 1614int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0)
1621 1615
1622int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *stringarg = 0) 1616int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *stringarg = 0)
1623 1617
1660 1654
1661void cf_object_pickup (object *op, object *what) 1655void cf_object_pickup (object *op, object *what)
1662 1656
1663object *cf_create_object_by_name (const char *name) 1657object *cf_create_object_by_name (const char *name)
1664 1658
1665void change_exp (object *op, val64 exp, const char *skill_name = 0, int flag = 0) 1659void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0)
1666 1660
1667void player_lvl_adj (object *who, object *skill = 0) 1661void player_lvl_adj (object *who, object *skill = 0)
1668 1662
1669int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 1663int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
1670 1664
1784 1778
1785partylist *cf_player_get_party (object *op) 1779partylist *cf_player_get_party (object *op)
1786 ALIAS: party = 0 1780 ALIAS: party = 0
1787 1781
1788void cf_player_set_party (object *op, partylist *party) 1782void cf_player_set_party (object *op, partylist *party)
1789
1790void change_skill (object *op, val64 exp, char *skill_name = 0, int flag = 0)
1791 1783
1792void kill_player (object *op) 1784void kill_player (object *op)
1793 1785
1794MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ 1786MODULE = cf PACKAGE = cf::object::map PREFIX = cf_
1795 1787
1917mapstruct *new (int width, int height) 1909mapstruct *new (int width, int height)
1918 PROTOTYPE: 1910 PROTOTYPE:
1919 CODE: 1911 CODE:
1920{ 1912{
1921 int unused_type; 1913 int unused_type;
1922 RETVAL = map_get_map (&unused_type, 0, width, height); 1914 RETVAL = (mapstruct*) map_get_map (&unused_type, 0, width, height);
1923} 1915}
1924 OUTPUT: 1916 OUTPUT:
1925 RETVAL 1917 RETVAL
1926 1918
1927void delete_map (mapstruct *map) 1919void delete_map (mapstruct *map)
2208 maxgrace = 15 2200 maxgrace = 15
2209 food = 16 2201 food = 16
2210 dam = 17 2202 dam = 17
2211 luck = 18 2203 luck = 18
2212 CODE: 2204 CODE:
2213# define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = new_val; break 2205# define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = (sint64)new_val; break
2214 switch (ix) 2206 switch (ix)
2215 { 2207 {
2216 LIVING_ACC (exp , 0); 2208 LIVING_ACC (exp , 0);
2217 LIVING_ACC (Str , 1); 2209 LIVING_ACC (Str , 1);
2218 LIVING_ACC (Dex , 2); 2210 LIVING_ACC (Dex , 2);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines