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.166 by root, Tue Feb 13 19:25:45 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 |= (obj->flags & 0xc0) << 8;
276 obj->flags &= ~0xc0;//D
277 obj->flags |= 0x10;//D
271 278
272 // now bless the object _once_ 279 // now bless the object _once_
273 return sv_bless (newRV_inc ((SV *)obj->self), stash); 280 return sv_bless (newRV_inc ((SV *)obj->self), stash);
274 } 281 }
275 else 282 else
604 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) 611 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
605 { 612 {
606 printf ("unable to initialize perl-interpreter, aborting.\n"); 613 printf ("unable to initialize perl-interpreter, aborting.\n");
607 exit (EXIT_FAILURE); 614 exit (EXIT_FAILURE);
608 } 615 }
616
617 {
618 dSP;
619
620 PUSHMARK (SP);
621 PUTBACK;
622 call_pv ("cf::init", G_DISCARD | G_VOID);
623 }
609} 624}
610 625
611void cfperl_main () 626void cfperl_main ()
612{ 627{
613 dSP; 628 dSP;
831void 846void
832cfperl_emergency_save () 847cfperl_emergency_save ()
833{ 848{
834 CALL_BEGIN (0); 849 CALL_BEGIN (0);
835 CALL_CALL ("cf::emergency_save", G_VOID); 850 CALL_CALL ("cf::emergency_save", G_VOID);
851 CALL_END;
852}
853
854void
855cfperl_cleanup (int make_core)
856{
857 CALL_BEGIN (1);
858 CALL_ARG (make_core);
859 CALL_CALL ("cf::post_cleanup", G_VOID);
836 CALL_END; 860 CALL_END;
837} 861}
838 862
839maptile * 863maptile *
840maptile::find_sync (const char *path, maptile *origin) 864maptile::find_sync (const char *path, maptile *origin)
1711 RETVAL = newSVpv (resist_plus[atnr], 0); 1735 RETVAL = newSVpv (resist_plus[atnr], 0);
1712 else 1736 else
1713 XSRETURN_UNDEF; 1737 XSRETURN_UNDEF;
1714 OUTPUT: RETVAL 1738 OUTPUT: RETVAL
1715 1739
1740bool
1741load_regions (const char *filename)
1742 CODE:
1743 RETVAL = loader_region ().load (filename);
1744 OUTPUT: RETVAL
1745
1716MODULE = cf PACKAGE = cf::attachable 1746MODULE = cf PACKAGE = cf::attachable
1717 1747
1718int 1748int
1719valid (SV *obj) 1749valid (SV *obj)
1720 CODE: 1750 CODE:
1721 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1751 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1722 OUTPUT: 1752 OUTPUT:
1723 RETVAL 1753 RETVAL
1754
1755void
1756debug_trace (attachable *obj, bool on = true)
1757 CODE:
1758 obj->flags &= ~attachable::F_DEBUG_TRACE;
1759 if (on)
1760 obj->flags |= attachable::F_DEBUG_TRACE;
1724 1761
1725int mortals_size () 1762int mortals_size ()
1726 CODE: 1763 CODE:
1727 RETVAL = attachable::mortals.size (); 1764 RETVAL = attachable::mortals.size ();
1728 OUTPUT: RETVAL 1765 OUTPUT: RETVAL
2056 pl->orig_stats = pl->ob->stats; 2093 pl->orig_stats = pl->ob->stats;
2057 2094
2058void cf_player_move (player *pl, int dir) 2095void cf_player_move (player *pl, int dir)
2059 2096
2060void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2097void 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 2098
2067bool 2099bool
2068cell_visible (player *pl, int dx, int dy) 2100cell_visible (player *pl, int dx, int dy)
2069 CODE: 2101 CODE:
2070 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 2102 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2
2372 2404
2373INCLUDE: $PERL genacc partylist ../include/player.h | 2405INCLUDE: $PERL genacc partylist ../include/player.h |
2374 2406
2375MODULE = cf PACKAGE = cf::region 2407MODULE = cf PACKAGE = cf::region
2376 2408
2377region *first () 2409void
2378 PROTOTYPE: 2410list ()
2379 CODE: 2411 PPCODE:
2380 RETVAL = first_region; 2412 for_all_regions (rgn)
2381 OUTPUT: RETVAL 2413 XPUSHs (sv_2mortal (to_sv (rgn)));
2382 2414
2383region *find (char *name) 2415region *find (char *name)
2384 PROTOTYPE: $ 2416 PROTOTYPE: $
2385 CODE: 2417 CODE:
2386 RETVAL = region::find (name); 2418 RETVAL = region::find (name);
2387 OUTPUT: RETVAL 2419 OUTPUT: RETVAL
2388 2420
2421region *find_fuzzy (char *name)
2422 PROTOTYPE: $
2423 CODE:
2424 RETVAL = region::find_fuzzy (name);
2425 OUTPUT: RETVAL
2426
2389INCLUDE: $PERL genacc region ../include/map.h | 2427INCLUDE: $PERL genacc region ../include/map.h |
2390 2428
2391MODULE = cf PACKAGE = cf::living 2429MODULE = cf PACKAGE = cf::living
2392 2430
2393INCLUDE: $PERL genacc living ../include/living.h | 2431INCLUDE: $PERL genacc living ../include/living.h |

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines