… | |
… | |
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 | |
… | |
… | |
443 | }; |
444 | }; |
444 | |
445 | |
445 | perl = perl_alloc (); |
446 | perl = perl_alloc (); |
446 | perl_construct (perl); |
447 | perl_construct (perl); |
447 | |
448 | |
|
|
449 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
|
|
450 | |
448 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
451 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
449 | { |
452 | { |
450 | printf ("unable to initialize perl-interpreter, continuing without.\n"); |
453 | printf ("unable to initialize perl-interpreter, continuing without.\n"); |
451 | |
454 | |
452 | perl_destruct (perl); |
455 | perl_destruct (perl); |
… | |
… | |
486 | if (sv) |
489 | if (sv) |
487 | clearSVptr (sv); |
490 | clearSVptr (sv); |
488 | |
491 | |
489 | rv = 0; |
492 | rv = 0; |
490 | } |
493 | } |
|
|
494 | else if (event_code == EVENT_CLOCK) |
|
|
495 | { |
|
|
496 | dSP; |
|
|
497 | int i, count; |
|
|
498 | |
|
|
499 | clean_obj_cache (); |
|
|
500 | |
|
|
501 | ENTER; |
|
|
502 | SAVETMPS; |
|
|
503 | |
|
|
504 | // service up to 8 events per tick better would be |
|
|
505 | // to check for elapsed time and stop processing after |
|
|
506 | // 0.25 * server_tick or so |
|
|
507 | for (i = 9; --i; ) |
|
|
508 | { |
|
|
509 | PUSHMARK (SP); |
|
|
510 | XPUSHs (sv_2mortal (newSViv (0))); |
|
|
511 | PUTBACK; |
|
|
512 | count = call_pv ("Event::one_event", G_SCALAR | G_EVAL); |
|
|
513 | SPAGAIN; |
|
|
514 | |
|
|
515 | if (!count || !POPi) |
|
|
516 | break; |
|
|
517 | } |
|
|
518 | |
|
|
519 | FREETMPS; |
|
|
520 | LEAVE; |
|
|
521 | } |
491 | else |
522 | else |
492 | { |
523 | { |
493 | dSP; |
524 | dSP; |
494 | |
525 | |
495 | ENTER; |
526 | ENTER; |
… | |
… | |
550 | { |
581 | { |
551 | char *buf = va_arg (args, char *); |
582 | char *buf = va_arg (args, char *); |
552 | int len = va_arg (args, int); |
583 | int len = va_arg (args, int); |
553 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
584 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
554 | } |
585 | } |
555 | break; |
|
|
556 | |
|
|
557 | case EVENT_CLOCK: |
|
|
558 | clean_obj_cache (); |
|
|
559 | break; |
586 | break; |
560 | |
587 | |
561 | case EVENT_TELL: |
588 | case EVENT_TELL: |
562 | break; |
589 | break; |
563 | } |
590 | } |
… | |
… | |
1127 | const_iv (SOUND_CLOCK) |
1154 | const_iv (SOUND_CLOCK) |
1128 | const_iv (SOUND_TURN_HANDLE) |
1155 | const_iv (SOUND_TURN_HANDLE) |
1129 | const_iv (SOUND_FALL_HOLE) |
1156 | const_iv (SOUND_FALL_HOLE) |
1130 | const_iv (SOUND_DRINK_POISON) |
1157 | const_iv (SOUND_DRINK_POISON) |
1131 | const_iv (SOUND_CAST_SPELL_0) |
1158 | const_iv (SOUND_CAST_SPELL_0) |
|
|
1159 | |
|
|
1160 | const_iv (MAP_FLUSH) |
|
|
1161 | const_iv (MAP_PLAYER_UNIQUE) |
|
|
1162 | const_iv (MAP_BLOCK) |
|
|
1163 | const_iv (MAP_STYLE) |
|
|
1164 | const_iv (MAP_OVERLAY) |
|
|
1165 | |
|
|
1166 | const_iv (MAP_IN_MEMORY) |
|
|
1167 | const_iv (MAP_SWAPPED) |
|
|
1168 | const_iv (MAP_LOADING) |
|
|
1169 | const_iv (MAP_SAVING) |
1132 | }; |
1170 | }; |
1133 | |
1171 | |
1134 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1172 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1135 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1173 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1136 | |
1174 | |
… | |
… | |
1153 | const_event (CLOSE) |
1191 | const_event (CLOSE) |
1154 | const_event (TIMER) |
1192 | const_event (TIMER) |
1155 | const_event (MOVE) |
1193 | const_event (MOVE) |
1156 | |
1194 | |
1157 | const_event (BORN) |
1195 | const_event (BORN) |
1158 | const_event (CLOCK) |
1196 | //const_event (CLOCK) |
1159 | const_event (CRASH) |
1197 | const_event (CRASH) |
1160 | const_event (PLAYER_DEATH) |
1198 | const_event (PLAYER_DEATH) |
1161 | const_event (PLAYER_LOAD) |
1199 | const_event (PLAYER_LOAD) |
1162 | const_event (PLAYER_SAVE) |
1200 | const_event (PLAYER_SAVE) |
1163 | const_event (GKILL) |
1201 | const_event (GKILL) |
… | |
… | |
1317 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1355 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1318 | { |
1356 | { |
1319 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1357 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1320 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1358 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1321 | } |
1359 | } |
|
|
1360 | |
|
|
1361 | //I_EVENT_API (PACKAGE); |
1322 | } |
1362 | } |
1323 | |
1363 | |
1324 | void |
1364 | void |
1325 | LOG (int level, char *msg) |
1365 | LOG (int level, char *msg) |
1326 | PROTOTYPE: $$ |
1366 | PROTOTYPE: $$ |
1327 | C_ARGS: level, "%s", msg |
1367 | C_ARGS: level, "%s", msg |
|
|
1368 | |
|
|
1369 | char *path_combine (char *base, char *path) |
|
|
1370 | PROTOTYPE: $$ |
|
|
1371 | |
|
|
1372 | char *path_combine_and_normalize (char *base, char *path) |
|
|
1373 | PROTOTYPE: $$ |
1328 | |
1374 | |
1329 | char * |
1375 | char * |
1330 | cf_get_maps_directory (char *path) |
1376 | cf_get_maps_directory (char *path) |
1331 | PROTOTYPE: $ |
1377 | PROTOTYPE: $ |
1332 | ALIAS: maps_directory = 0 |
1378 | ALIAS: maps_directory = 0 |
… | |
… | |
1754 | |
1800 | |
1755 | void clean_tmp_map (mapstruct *map) |
1801 | void clean_tmp_map (mapstruct *map) |
1756 | |
1802 | |
1757 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
1803 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
1758 | |
1804 | |
|
|
1805 | mapstruct *tile_map (mapstruct *map, unsigned int dir) |
|
|
1806 | CODE: |
|
|
1807 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
|
|
1808 | OUTPUT: |
|
|
1809 | RETVAL |
|
|
1810 | |
|
|
1811 | char *tile_path (mapstruct *map, unsigned int dir) |
|
|
1812 | CODE: |
|
|
1813 | if (dir >= 4) |
|
|
1814 | XSRETURN_UNDEF; |
|
|
1815 | RETVAL = map->tile_path [dir]; |
|
|
1816 | OUTPUT: |
|
|
1817 | RETVAL |
|
|
1818 | |
1759 | mapstruct *cf_map_get_map (char *name) |
1819 | mapstruct *cf_map_get_map (char *name) |
1760 | PROTOTYPE: $ |
1820 | PROTOTYPE: $ |
1761 | ALIAS: map = 0 |
1821 | ALIAS: map = 0 |
1762 | |
1822 | |
|
|
1823 | mapstruct *has_been_loaded (char *name) |
|
|
1824 | PROTOTYPE: $ |
|
|
1825 | |
1763 | mapstruct *cf_map_get_first () |
1826 | mapstruct *cf_map_get_first () |
1764 | PROTOTYPE: |
1827 | PROTOTYPE: |
1765 | ALIAS: first = 0 |
1828 | ALIAS: first = 0 |
1766 | |
1829 | |
1767 | # whoever "designed" the plug-in api should have wasted |
1830 | # whoever "designed" the plug-in api should have wasted |
1768 | # his/her time with staying away form the project - would have |
1831 | # his/her time with staying away from the project - would have |
1769 | # saved others a lot of time, without doubt. |
1832 | # saved others a lot of time, without doubt. |
1770 | void set_path (mapstruct *where, char *path) |
1833 | void set_path (mapstruct *where, char *path) |
1771 | CODE: |
1834 | CODE: |
1772 | strcpy (where->path, path); |
1835 | strcpy (where->path, path); |
|
|
1836 | |
|
|
1837 | int in_memory (mapstruct *map) |
|
|
1838 | CODE: |
|
|
1839 | RETVAL = map->in_memory; |
|
|
1840 | OUTPUT: |
|
|
1841 | RETVAL |
1773 | |
1842 | |
1774 | bool unique (mapstruct *map) |
1843 | bool unique (mapstruct *map) |
1775 | CODE: |
1844 | CODE: |
1776 | RETVAL = map->unique; |
1845 | RETVAL = map->unique; |
1777 | OUTPUT: |
1846 | OUTPUT: |