… | |
… | |
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 | |
134 | void |
136 | void |
135 | attachable::optimise () |
137 | attachable::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 |
144 | void |
147 | void |
… | |
… | |
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 | |
170 | void |
174 | void |
171 | attachable::destroy () |
175 | attachable::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 | |
611 | void cfperl_main () |
625 | void 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 | |
|
|
1730 | bool |
|
|
1731 | load_regions (const char *filename) |
|
|
1732 | CODE: |
|
|
1733 | RETVAL = loader_region ().load (filename); |
|
|
1734 | OUTPUT: RETVAL |
|
|
1735 | |
1716 | MODULE = cf PACKAGE = cf::attachable |
1736 | MODULE = cf PACKAGE = cf::attachable |
1717 | |
1737 | |
1718 | int |
1738 | int |
1719 | valid (SV *obj) |
1739 | valid (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 | |
|
|
1745 | void |
|
|
1746 | debug_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 | |
1725 | int mortals_size () |
1752 | int 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 | |
2058 | void cf_player_move (player *pl, int dir) |
2085 | void cf_player_move (player *pl, int dir) |
2059 | |
2086 | |
2060 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2087 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2061 | |
|
|
2062 | player *first () |
|
|
2063 | CODE: |
|
|
2064 | RETVAL = first_player; |
|
|
2065 | OUTPUT: RETVAL |
|
|
2066 | |
2088 | |
2067 | bool |
2089 | bool |
2068 | cell_visible (player *pl, int dx, int dy) |
2090 | cell_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 | |
2373 | INCLUDE: $PERL genacc partylist ../include/player.h | |
2395 | INCLUDE: $PERL genacc partylist ../include/player.h | |
2374 | |
2396 | |
2375 | MODULE = cf PACKAGE = cf::region |
2397 | MODULE = cf PACKAGE = cf::region |
2376 | |
2398 | |
2377 | region *first () |
2399 | void |
2378 | PROTOTYPE: |
2400 | list () |
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 | |
2383 | region *find (char *name) |
2405 | region *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 | |
|
|
2411 | region *find_fuzzy (char *name) |
|
|
2412 | PROTOTYPE: $ |
|
|
2413 | CODE: |
|
|
2414 | RETVAL = region::find_fuzzy (name); |
|
|
2415 | OUTPUT: RETVAL |
|
|
2416 | |
2389 | INCLUDE: $PERL genacc region ../include/map.h | |
2417 | INCLUDE: $PERL genacc region ../include/map.h | |
2390 | |
2418 | |
2391 | MODULE = cf PACKAGE = cf::living |
2419 | MODULE = cf PACKAGE = cf::living |
2392 | |
2420 | |
2393 | INCLUDE: $PERL genacc living ../include/living.h | |
2421 | INCLUDE: $PERL genacc living ../include/living.h | |