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.55 by root, Mon Jun 26 15:40:15 2006 UTC vs.
Revision 1.58 by elmex, Tue Jul 11 16:50:16 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
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
91extern void pay_player(object *op, uint64 amount);
92extern 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
1337void 1367void
1338LOG (int level, char *msg) 1368LOG (int level, char *msg)
1339 PROTOTYPE: $$ 1369 PROTOTYPE: $$
1524 1554
1525object *cf_create_object_by_name (const char *name) 1555object *cf_create_object_by_name (const char *name)
1526 1556
1527void change_exp (object *op, double exp, const char *skill_name = 0, int flag = 0) 1557void change_exp (object *op, double exp, const char *skill_name = 0, int flag = 0)
1528 1558
1559void pay_player (object *op, double amount)
1560
1561double pay_player_arch (object *op, const char *arch, double amount)
1562
1529void player_lvl_adj (object *who, object *skill = 0) 1563void player_lvl_adj (object *who, object *skill = 0)
1530 1564
1531int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 1565int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
1532 1566
1533MODULE = cf PACKAGE = cf::object PREFIX = cf_ 1567MODULE = cf PACKAGE = cf::object PREFIX = cf_
1772void delete_map (mapstruct *map) 1806void delete_map (mapstruct *map)
1773 1807
1774void clean_tmp_map (mapstruct *map) 1808void clean_tmp_map (mapstruct *map)
1775 1809
1776void play_sound_map (mapstruct *map, int x, int y, int sound_num) 1810void play_sound_map (mapstruct *map, int x, int y, int sound_num)
1811
1812mapstruct *tile_map (mapstruct *map, unsigned int dir)
1813 CODE:
1814 RETVAL = dir < 4 ? map->tile_map [dir] : 0;
1815 OUTPUT:
1816 RETVAL
1817
1818char *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
1778mapstruct *cf_map_get_map (char *name) 1826mapstruct *cf_map_get_map (char *name)
1779 PROTOTYPE: $ 1827 PROTOTYPE: $
1780 ALIAS: map = 0 1828 ALIAS: map = 0
1781 1829

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines