… | |
… | |
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 "EventAPI.h" |
50 | #include "perlxsi.c" |
51 | #include "perlxsi.c" |
51 | |
52 | |
52 | typedef object object_ornull; |
53 | typedef object object_ornull; |
53 | typedef mapstruct mapstruct_ornull; |
54 | typedef mapstruct mapstruct_ornull; |
54 | |
55 | |
… | |
… | |
84 | #define PUSH_OB PUSHcfapi_va(POBJECT, object *) |
85 | #define PUSH_OB PUSHcfapi_va(POBJECT, object *) |
85 | #define PUSH_PL PUSHcfapi_va(PPLAYER, player *) |
86 | #define PUSH_PL PUSHcfapi_va(PPLAYER, player *) |
86 | #define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) |
87 | #define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) |
87 | #define PUSH_PV PUSHcfapi_va(STRING, const char *) |
88 | #define PUSH_PV PUSHcfapi_va(STRING, const char *) |
88 | #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) |
89 | #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) |
|
|
90 | |
|
|
91 | extern void pay_player(object *op, uint64 amount); |
|
|
92 | extern uint64 pay_player_arch(object *op, const char *arch, uint64 amount); |
89 | |
93 | |
90 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
94 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
91 | |
95 | |
92 | // garbage collect some perl objects, if possible |
96 | // garbage collect some perl objects, if possible |
93 | // all objects no longer referenced and empty are |
97 | // all objects no longer referenced and empty are |
… | |
… | |
488 | if (sv) |
492 | if (sv) |
489 | clearSVptr (sv); |
493 | clearSVptr (sv); |
490 | |
494 | |
491 | rv = 0; |
495 | rv = 0; |
492 | } |
496 | } |
|
|
497 | else if (event_code == EVENT_CLOCK) |
|
|
498 | { |
|
|
499 | dSP; |
|
|
500 | int i, count; |
|
|
501 | |
|
|
502 | clean_obj_cache (); |
|
|
503 | |
|
|
504 | ENTER; |
|
|
505 | SAVETMPS; |
|
|
506 | |
|
|
507 | // service up to 8 events per tick better would be |
|
|
508 | // to check for elapsed time and stop processing after |
|
|
509 | // 0.25 * server_tick or so |
|
|
510 | for (i = 9; --i; ) |
|
|
511 | { |
|
|
512 | PUSHMARK (SP); |
|
|
513 | XPUSHs (sv_2mortal (newSViv (0))); |
|
|
514 | PUTBACK; |
|
|
515 | count = call_pv ("Event::one_event", G_SCALAR | G_EVAL); |
|
|
516 | SPAGAIN; |
|
|
517 | |
|
|
518 | if (!count || !POPi) |
|
|
519 | break; |
|
|
520 | } |
|
|
521 | |
|
|
522 | FREETMPS; |
|
|
523 | LEAVE; |
|
|
524 | } |
493 | else |
525 | else |
494 | { |
526 | { |
495 | dSP; |
527 | dSP; |
496 | |
528 | |
497 | ENTER; |
529 | ENTER; |
… | |
… | |
552 | { |
584 | { |
553 | char *buf = va_arg (args, char *); |
585 | char *buf = va_arg (args, char *); |
554 | int len = va_arg (args, int); |
586 | int len = va_arg (args, int); |
555 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
587 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
556 | } |
588 | } |
557 | break; |
|
|
558 | |
|
|
559 | case EVENT_CLOCK: |
|
|
560 | clean_obj_cache (); |
|
|
561 | break; |
589 | break; |
562 | |
590 | |
563 | case EVENT_TELL: |
591 | case EVENT_TELL: |
564 | break; |
592 | break; |
565 | } |
593 | } |
… | |
… | |
1166 | const_event (CLOSE) |
1194 | const_event (CLOSE) |
1167 | const_event (TIMER) |
1195 | const_event (TIMER) |
1168 | const_event (MOVE) |
1196 | const_event (MOVE) |
1169 | |
1197 | |
1170 | const_event (BORN) |
1198 | const_event (BORN) |
1171 | const_event (CLOCK) |
1199 | //const_event (CLOCK) |
1172 | const_event (CRASH) |
1200 | const_event (CRASH) |
1173 | const_event (PLAYER_DEATH) |
1201 | const_event (PLAYER_DEATH) |
1174 | const_event (PLAYER_LOAD) |
1202 | const_event (PLAYER_LOAD) |
1175 | const_event (PLAYER_SAVE) |
1203 | const_event (PLAYER_SAVE) |
1176 | const_event (GKILL) |
1204 | const_event (GKILL) |
… | |
… | |
1330 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1358 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1331 | { |
1359 | { |
1332 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1360 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1333 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1361 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1334 | } |
1362 | } |
|
|
1363 | |
|
|
1364 | //I_EVENT_API (PACKAGE); |
1335 | } |
1365 | } |
1336 | |
1366 | |
1337 | void |
1367 | void |
1338 | LOG (int level, char *msg) |
1368 | LOG (int level, char *msg) |
1339 | PROTOTYPE: $$ |
1369 | PROTOTYPE: $$ |
… | |
… | |
1524 | |
1554 | |
1525 | object *cf_create_object_by_name (const char *name) |
1555 | object *cf_create_object_by_name (const char *name) |
1526 | |
1556 | |
1527 | void change_exp (object *op, double exp, const char *skill_name = 0, int flag = 0) |
1557 | void change_exp (object *op, double exp, const char *skill_name = 0, int flag = 0) |
1528 | |
1558 | |
|
|
1559 | void pay_player (object *op, double amount) |
|
|
1560 | |
|
|
1561 | double pay_player_arch (object *op, const char *arch, double amount) |
|
|
1562 | |
1529 | void player_lvl_adj (object *who, object *skill = 0) |
1563 | void player_lvl_adj (object *who, object *skill = 0) |
1530 | |
1564 | |
1531 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1565 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1532 | |
1566 | |
1533 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1567 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
… | |
… | |
1772 | void delete_map (mapstruct *map) |
1806 | void delete_map (mapstruct *map) |
1773 | |
1807 | |
1774 | void clean_tmp_map (mapstruct *map) |
1808 | void clean_tmp_map (mapstruct *map) |
1775 | |
1809 | |
1776 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
1810 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
|
|
1811 | |
|
|
1812 | mapstruct *tile_map (mapstruct *map, unsigned int dir) |
|
|
1813 | CODE: |
|
|
1814 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
|
|
1815 | OUTPUT: |
|
|
1816 | RETVAL |
|
|
1817 | |
|
|
1818 | char *tile_path (mapstruct *map, unsigned int dir) |
|
|
1819 | CODE: |
|
|
1820 | if (dir >= 4) |
|
|
1821 | XSRETURN_UNDEF; |
|
|
1822 | RETVAL = map->tile_path [dir]; |
|
|
1823 | OUTPUT: |
|
|
1824 | RETVAL |
1777 | |
1825 | |
1778 | mapstruct *cf_map_get_map (char *name) |
1826 | mapstruct *cf_map_get_map (char *name) |
1779 | PROTOTYPE: $ |
1827 | PROTOTYPE: $ |
1780 | ALIAS: map = 0 |
1828 | ALIAS: map = 0 |
1781 | |
1829 | |