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.54 by root, Mon Jun 12 13:25:27 2006 UTC vs.
Revision 1.57 by root, Tue Jul 11 15:25:00 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 "EventAPI.h"
50#include "perlxsi.c" 51#include "perlxsi.c"
51 52
52typedef object object_ornull; 53typedef object object_ornull;
53typedef mapstruct mapstruct_ornull; 54typedef 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
1324void 1364void
1325LOG (int level, char *msg) 1365LOG (int level, char *msg)
1326 PROTOTYPE: $$ 1366 PROTOTYPE: $$
1327 C_ARGS: level, "%s", msg 1367 C_ARGS: level, "%s", msg
1368
1369char *path_combine (char *base, char *path)
1370 PROTOTYPE: $$
1371
1372char *path_combine_and_normalize (char *base, char *path)
1373 PROTOTYPE: $$
1328 1374
1329char * 1375char *
1330cf_get_maps_directory (char *path) 1376cf_get_maps_directory (char *path)
1331 PROTOTYPE: $ 1377 PROTOTYPE: $
1332 ALIAS: maps_directory = 0 1378 ALIAS: maps_directory = 0
1754 1800
1755void clean_tmp_map (mapstruct *map) 1801void clean_tmp_map (mapstruct *map)
1756 1802
1757void play_sound_map (mapstruct *map, int x, int y, int sound_num) 1803void play_sound_map (mapstruct *map, int x, int y, int sound_num)
1758 1804
1805mapstruct *tile_map (mapstruct *map, unsigned int dir)
1806 CODE:
1807 RETVAL = dir < 4 ? map->tile_map [dir] : 0;
1808 OUTPUT:
1809 RETVAL
1810
1811char *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
1759mapstruct *cf_map_get_map (char *name) 1819mapstruct *cf_map_get_map (char *name)
1760 PROTOTYPE: $ 1820 PROTOTYPE: $
1761 ALIAS: map = 0 1821 ALIAS: map = 0
1762 1822
1823mapstruct *has_been_loaded (char *name)
1824 PROTOTYPE: $
1825
1763mapstruct *cf_map_get_first () 1826mapstruct *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.
1770void set_path (mapstruct *where, char *path) 1833void set_path (mapstruct *where, char *path)
1771 CODE: 1834 CODE:
1772 strcpy (where->path, path); 1835 strcpy (where->path, path);
1836
1837int in_memory (mapstruct *map)
1838 CODE:
1839 RETVAL = map->in_memory;
1840 OUTPUT:
1841 RETVAL
1773 1842
1774bool unique (mapstruct *map) 1843bool unique (mapstruct *map)
1775 CODE: 1844 CODE:
1776 RETVAL = map->unique; 1845 RETVAL = map->unique;
1777 OUTPUT: 1846 OUTPUT:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines