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

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.160 by elmex, Wed Jan 31 14:11:02 2007 UTC vs.
Revision 1.164 by root, Sun Feb 11 01:38:49 2007 UTC

29#include <plugin_common.h> 29#include <plugin_common.h>
30#include <sounds.h> 30#include <sounds.h>
31#include <cstdarg> 31#include <cstdarg>
32#include <sproto.h> 32#include <sproto.h>
33 33
34#include "loader.h"
34#include "cfperl.h" 35#include "cfperl.h"
35#include "shstr.h" 36#include "shstr.h"
36 37
37#include <unistd.h> 38#include <unistd.h>
38#if _POSIX_MEMLOCK 39#if _POSIX_MEMLOCK
126 sv_unmagic ((SV *)self, PERL_MAGIC_ext); 127 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
127 SvREFCNT_dec (self); 128 SvREFCNT_dec (self);
128 129
129 // self *must* be null now because thats sv_unmagic's job. 130 // self *must* be null now because thats sv_unmagic's job.
130 assert (!this->self); 131 assert (!this->self);
132 flags |= 0x80; // severed //D
131 } 133 }
132} 134}
133 135
134void 136void
135attachable::optimise () 137attachable::optimise ()
136{ 138{
137 if (self 139 if (self
138 && SvREFCNT (self) == 1 140 && SvREFCNT (self) == 1
139 && !HvTOTALKEYS (self)) 141 && !HvTOTALKEYS (self))
142 flags |= 0x40,//D
140 sever_self (); 143 sever_self ();
141} 144}
142 145
143// check wether the object really is dead 146// check wether the object really is dead
144void 147void
162 } 165 }
163 166
164 if (self) 167 if (self)
165 sever_self (); 168 sever_self ();
166 169
170 flags |= 0x20; //D
167 mortals.push_back (this); 171 mortals.push_back (this);
168} 172}
169 173
170void 174void
171attachable::destroy () 175attachable::destroy ()
266 270
267 if (!obj->self) 271 if (!obj->self)
268 { 272 {
269 obj->self = newHV (); 273 obj->self = newHV ();
270 sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); 274 sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0);
275 obj->flags &= ~0xc0;//D
276 obj->flags |= 0x10;//D
271 277
272 // now bless the object _once_ 278 // now bless the object _once_
273 return sv_bless (newRV_inc ((SV *)obj->self), stash); 279 return sv_bless (newRV_inc ((SV *)obj->self), stash);
274 } 280 }
275 else 281 else
604 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) 610 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
605 { 611 {
606 printf ("unable to initialize perl-interpreter, aborting.\n"); 612 printf ("unable to initialize perl-interpreter, aborting.\n");
607 exit (EXIT_FAILURE); 613 exit (EXIT_FAILURE);
608 } 614 }
615
616 {
617 dSP;
618
619 PUSHMARK (SP);
620 PUTBACK;
621 call_pv ("cf::init", G_DISCARD | G_VOID);
622 }
609} 623}
610 624
611void cfperl_main () 625void cfperl_main ()
612{ 626{
613 dSP; 627 dSP;
1711 RETVAL = newSVpv (resist_plus[atnr], 0); 1725 RETVAL = newSVpv (resist_plus[atnr], 0);
1712 else 1726 else
1713 XSRETURN_UNDEF; 1727 XSRETURN_UNDEF;
1714 OUTPUT: RETVAL 1728 OUTPUT: RETVAL
1715 1729
1730bool
1731load_regions (const char *filename)
1732 CODE:
1733 RETVAL = loader_region ().load (filename);
1734 OUTPUT: RETVAL
1735
1716MODULE = cf PACKAGE = cf::attachable 1736MODULE = cf PACKAGE = cf::attachable
1717 1737
1718int 1738int
1719valid (SV *obj) 1739valid (SV *obj)
1720 CODE: 1740 CODE:
1721 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1741 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1722 OUTPUT: 1742 OUTPUT:
1723 RETVAL 1743 RETVAL
1744
1745void
1746debug_trace (attachable *obj, bool on = true)
1747 CODE:
1748 obj->flags &= ~attachable::F_DEBUG_TRACE;
1749 if (on)
1750 obj->flags |= attachable::F_DEBUG_TRACE;
1724 1751
1725int mortals_size () 1752int mortals_size ()
1726 CODE: 1753 CODE:
1727 RETVAL = attachable::mortals.size (); 1754 RETVAL = attachable::mortals.size ();
1728 OUTPUT: RETVAL 1755 OUTPUT: RETVAL
2056 pl->orig_stats = pl->ob->stats; 2083 pl->orig_stats = pl->ob->stats;
2057 2084
2058void cf_player_move (player *pl, int dir) 2085void cf_player_move (player *pl, int dir)
2059 2086
2060void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2087void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
2061
2062player *first ()
2063 CODE:
2064 RETVAL = first_player;
2065 OUTPUT: RETVAL
2066 2088
2067bool 2089bool
2068cell_visible (player *pl, int dx, int dy) 2090cell_visible (player *pl, int dx, int dy)
2069 CODE: 2091 CODE:
2070 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 2092 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2
2372 2394
2373INCLUDE: $PERL genacc partylist ../include/player.h | 2395INCLUDE: $PERL genacc partylist ../include/player.h |
2374 2396
2375MODULE = cf PACKAGE = cf::region 2397MODULE = cf PACKAGE = cf::region
2376 2398
2377region *first () 2399void
2378 PROTOTYPE: 2400list ()
2379 CODE: 2401 PPCODE:
2380 RETVAL = first_region; 2402 for_all_regions (rgn)
2381 OUTPUT: RETVAL 2403 XPUSHs (sv_2mortal (to_sv (rgn)));
2382 2404
2383region *find (char *name) 2405region *find (char *name)
2384 PROTOTYPE: $ 2406 PROTOTYPE: $
2385 CODE: 2407 CODE:
2386 RETVAL = region::find (name); 2408 RETVAL = region::find (name);
2387 OUTPUT: RETVAL 2409 OUTPUT: RETVAL
2388 2410
2411region *find_fuzzy (char *name)
2412 PROTOTYPE: $
2413 CODE:
2414 RETVAL = region::find_fuzzy (name);
2415 OUTPUT: RETVAL
2416
2389INCLUDE: $PERL genacc region ../include/map.h | 2417INCLUDE: $PERL genacc region ../include/map.h |
2390 2418
2391MODULE = cf PACKAGE = cf::living 2419MODULE = cf PACKAGE = cf::living
2392 2420
2393INCLUDE: $PERL genacc living ../include/living.h | 2421INCLUDE: $PERL genacc living ../include/living.h |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines