… | |
… | |
4 | |
4 | |
5 | /* |
5 | /* |
6 | * This code is placed under the GNU General Public Licence (GPL) |
6 | * This code is placed under the GNU General Public Licence (GPL) |
7 | * |
7 | * |
8 | * Copyright (C) 2001-2005 by Chachkoff Yann |
8 | * Copyright (C) 2001-2005 by Chachkoff Yann |
9 | * Copyright (C) 2006 by Marc Lehmann <cf@schmorpd.e> |
9 | * Copyright (C) 2006 by Marc Lehmann <cf@schmorp.de> |
10 | * |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or |
13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. |
14 | * (at your option) any later version. |
… | |
… | |
40 | |
40 | |
41 | #include "perlxsi.c" |
41 | #include "perlxsi.c" |
42 | |
42 | |
43 | extern sint64 *levels; // the experience table |
43 | extern sint64 *levels; // the experience table |
44 | |
44 | |
45 | typedef object object_ornull; |
45 | typedef object object_ornull; |
46 | typedef mapstruct mapstruct_ornull; |
46 | typedef maptile maptile_ornull; |
47 | |
47 | |
48 | typedef double val64; |
48 | typedef double val64; |
49 | #define newSVval64 newSVnv |
49 | #define newSVval64 newSVnv |
50 | #define SvVAL64 SvNV |
50 | #define SvVAL64 SvNV |
51 | |
51 | |
52 | static f_plug_api gethook = cfapi_get_hooks; |
52 | static f_plug_api gethook = cfapi_get_hooks; |
53 | static f_plug_api object_set_property = cfapi_object_set_property; |
53 | static f_plug_api object_set_property = cfapi_object_set_property; |
54 | static f_plug_api object_insert = cfapi_object_insert; |
54 | static f_plug_api object_insert = cfapi_object_insert; |
55 | |
55 | |
56 | /* this is a stupid way to do things, and awkward to use for plug-in authors */ |
|
|
57 | typedef struct |
|
|
58 | { |
|
|
59 | object* who; |
|
|
60 | object* activator; |
|
|
61 | object* third; |
|
|
62 | object* event; |
|
|
63 | mapstruct* map; |
|
|
64 | char message[1024]; |
|
|
65 | int fix; // seems to be python-only, and should not be part of the API |
|
|
66 | int event_code; |
|
|
67 | char extension[1024]; // name field, should invoke specific perl extension |
|
|
68 | char options[1024]; // slaying field of event_connectors |
|
|
69 | int returnvalue; |
|
|
70 | } CFPContext; |
|
|
71 | |
|
|
72 | static HV *obj_cache; |
56 | static HV *obj_cache; |
73 | static PerlInterpreter *perl; |
57 | static PerlInterpreter *perl; |
74 | |
58 | |
75 | static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; |
59 | static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; |
76 | |
|
|
77 | #define PUSHcfapi(type,value) PUSHs (sv_2mortal (newSVcfapi (CFAPI_ ## type, (value)))) |
|
|
78 | #define PUSHcfapi_va(type,ctype) PUSHcfapi (type, va_arg (args, ctype)) |
|
|
79 | #define PUSH_OB PUSHcfapi_va(POBJECT, object *) |
|
|
80 | #define PUSH_PL PUSHcfapi_va(PPLAYER, player *) |
|
|
81 | #define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) |
|
|
82 | #define PUSH_PV PUSHcfapi_va(STRING, const char *) |
|
|
83 | #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) |
|
|
84 | |
60 | |
85 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
61 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
86 | |
62 | |
87 | static SV * |
63 | static SV * |
88 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
64 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
… | |
… | |
174 | { |
150 | { |
175 | if (SvOK (sv)) |
151 | if (SvOK (sv)) |
176 | return SvPTR (sv, klass); |
152 | return SvPTR (sv, klass); |
177 | else |
153 | else |
178 | return 0; |
154 | return 0; |
|
|
155 | } |
|
|
156 | |
|
|
157 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn ((const char *)v, v.length ()) : &PL_sv_undef; } |
|
|
158 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
|
|
159 | inline SV *to_sv (bool v) { return newSViv (v); } |
|
|
160 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
|
|
161 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
|
|
162 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
|
|
163 | inline SV *to_sv (unsigned short v) { return newSVuv (v); } |
|
|
164 | inline SV *to_sv ( signed int v) { return newSViv (v); } |
|
|
165 | inline SV *to_sv (unsigned int v) { return newSVuv (v); } |
|
|
166 | inline SV *to_sv ( signed long v) { return newSViv (v); } |
|
|
167 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
|
|
168 | inline SV *to_sv ( signed long long v) { return newSVval64 (v); } |
|
|
169 | inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
|
|
170 | inline SV *to_sv (float v) { return newSVnv (v); } |
|
|
171 | inline SV *to_sv (double v) { return newSVnv (v); } |
|
|
172 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
|
|
173 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
|
|
174 | inline SV *to_sv (maptile * v) { return newSVattachable (v, "cf::map::wrap"); } |
|
|
175 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); } |
|
|
176 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
|
|
177 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
|
|
178 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
|
|
179 | |
|
|
180 | inline SV *to_sv (object & v) { return to_sv (&v); } |
|
|
181 | inline SV *to_sv (living & v) { return to_sv (&v); } |
|
|
182 | |
|
|
183 | //TODO: |
|
|
184 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
|
|
185 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
|
|
186 | |
|
|
187 | inline SV *to_sv (UUID v) { |
|
|
188 | char buf[128]; |
|
|
189 | snprintf (buf, 128, "<1,%llx>", (unsigned long long)v.seq + UUID_SKIP * 2); |
|
|
190 | return newSVpv (buf, 0); |
|
|
191 | } |
|
|
192 | |
|
|
193 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
|
|
194 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } //TODO: verify that all simple pointers are strdup-managed |
|
|
195 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
|
|
196 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
|
|
197 | inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } |
|
|
198 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
|
|
199 | inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } |
|
|
200 | inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } |
|
|
201 | inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } |
|
|
202 | inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } |
|
|
203 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
|
|
204 | inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
|
|
205 | inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
|
|
206 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
|
|
207 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
|
|
208 | inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } |
|
|
209 | inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } |
|
|
210 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); } |
|
|
211 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)SvPTR_ornull (sv, "cf::map"); } |
|
|
212 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
|
|
213 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
|
|
214 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
|
|
215 | |
|
|
216 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
|
|
217 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
|
|
218 | |
|
|
219 | template<class T> |
|
|
220 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
|
|
221 | |
|
|
222 | template<int N> |
|
|
223 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
|
|
224 | |
|
|
225 | inline void sv_to (SV *sv, UUID &v) { |
|
|
226 | char *sv_str = SvOK (sv) ? SvPV_nolen (sv) : 0; |
|
|
227 | unsigned int version = 0; |
|
|
228 | unsigned long long seq = 0; |
|
|
229 | |
|
|
230 | if (!sv_str) |
|
|
231 | return; |
|
|
232 | |
|
|
233 | if (2 == sscanf (sv_str, "<%d.%llx>", &version, &seq) && version == 1) |
|
|
234 | { |
|
|
235 | v.seq = seq; |
|
|
236 | } |
|
|
237 | |
|
|
238 | return; |
179 | } |
239 | } |
180 | |
240 | |
181 | static SV * |
241 | static SV * |
182 | newSVdt_va (va_list &ap, data_type type) |
242 | newSVdt_va (va_list &ap, data_type type) |
183 | { |
243 | { |
… | |
… | |
211 | sv = str ? newSVpv (str, len) : &PL_sv_undef; |
271 | sv = str ? newSVpv (str, len) : &PL_sv_undef; |
212 | } |
272 | } |
213 | break; |
273 | break; |
214 | |
274 | |
215 | case DT_OBJECT: |
275 | case DT_OBJECT: |
216 | { |
276 | sv = to_sv (va_arg (ap, object *)); |
217 | object *obj = va_arg (ap, object *); |
|
|
218 | sv = newSVattachable (obj, obj && obj->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); |
|
|
219 | } |
|
|
220 | break; |
277 | break; |
221 | |
278 | |
222 | case DT_MAP: |
279 | case DT_MAP: |
223 | // va_arg (object *) when void * is passed is an XSI extension |
280 | // va_arg (object *) when void * is passed is an XSI extension |
224 | sv = newSVattachable (va_arg (ap, mapstruct *), "cf::map::wrap"); |
281 | sv = to_sv (va_arg (ap, maptile *)); |
225 | break; |
282 | break; |
226 | |
283 | |
227 | case DT_PLAYER: |
284 | case DT_PLAYER: |
228 | sv = newSVattachable (va_arg (ap, player *), "cf::player::wrap"); |
285 | sv = to_sv (va_arg (ap, player *)); |
229 | break; |
286 | break; |
230 | |
287 | |
231 | case DT_ARCH: |
288 | case DT_ARCH: |
232 | sv = newSVptr (va_arg (ap, archetype *), "cf::arch::wrap"); |
289 | sv = to_sv (va_arg (ap, archetype *)); |
233 | break; |
290 | break; |
234 | |
291 | |
235 | case DT_PARTY: |
292 | case DT_PARTY: |
236 | sv = newSVptr (va_arg (ap, partylist *), "cf::party::wrap"); |
293 | sv = to_sv (va_arg (ap, partylist *)); |
237 | break; |
294 | break; |
238 | |
295 | |
239 | case DT_REGION: |
296 | case DT_REGION: |
240 | sv = newSVptr (va_arg (ap, region *), "cf::region::wrap"); |
297 | sv = to_sv (va_arg (ap, region *)); |
241 | break; |
298 | break; |
242 | |
299 | |
243 | default: |
300 | default: |
244 | assert (("unhandled type in newSVdt_va", 0)); |
301 | assert (("unhandled type in newSVdt_va", 0)); |
245 | } |
302 | } |
… | |
… | |
306 | { |
363 | { |
307 | if (cb) |
364 | if (cb) |
308 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
365 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
309 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
366 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
310 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
367 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
311 | INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); |
368 | INVOKE_MAP (DESTROY, static_cast<maptile *>(this)); |
312 | |
369 | |
313 | // disconnect Perl from C, to avoid crashes |
370 | // disconnect Perl from C, to avoid crashes |
314 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
371 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
315 | |
372 | |
316 | // clear the perl hash, might or might not be a good idea |
373 | // clear the perl hash, might or might not be a good idea |
… | |
… | |
444 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
501 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
445 | FREETMPS; |
502 | FREETMPS; |
446 | LEAVE; |
503 | LEAVE; |
447 | } |
504 | } |
448 | |
505 | |
|
|
506 | char *object_freezer::as_string () |
|
|
507 | { |
|
|
508 | dSP; |
|
|
509 | ENTER; |
|
|
510 | SAVETMPS; |
|
|
511 | PUSHMARK (SP); |
|
|
512 | EXTEND (SP, 3); |
|
|
513 | PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ())))); |
|
|
514 | PUSHs (sv_2mortal (newRV_inc ((SV *)av))); |
|
|
515 | PUTBACK; |
|
|
516 | |
|
|
517 | char *res = call_pv ("cf::object_freezer_as_string", G_SCALAR | G_EVAL) > 0 |
|
|
518 | ? strdup (SvPVbyte_nolen (POPs)) |
|
|
519 | : strdup ("[fatal error]"); |
|
|
520 | |
|
|
521 | FREETMPS; |
|
|
522 | LEAVE; |
|
|
523 | |
|
|
524 | return res; |
|
|
525 | } |
|
|
526 | |
449 | int fprintf (object_freezer &freezer, const char *format, ...) |
527 | int fprintf (object_freezer &freezer, const char *format, ...) |
450 | { |
528 | { |
451 | va_list ap; |
529 | va_list ap; |
452 | |
530 | |
453 | va_start (ap, format); |
531 | va_start (ap, format); |
… | |
… | |
462 | |
540 | |
463 | int fputs (const char *s, object_freezer &freezer) |
541 | int fputs (const char *s, object_freezer &freezer) |
464 | { |
542 | { |
465 | freezer.add (s); |
543 | freezer.add (s); |
466 | } |
544 | } |
|
|
545 | |
|
|
546 | static const char thawer_eof[] = "\n\n\n\0\0\0"; |
467 | |
547 | |
468 | object_thawer::object_thawer (const char *filename) |
548 | object_thawer::object_thawer (const char *filename) |
469 | { |
549 | { |
470 | static const char eof[] = "\n\n\n\0\0\0"; |
550 | static const char eof[] = "\n\n\n\0\0\0"; |
471 | |
551 | |
… | |
… | |
511 | FREETMPS; |
591 | FREETMPS; |
512 | LEAVE; |
592 | LEAVE; |
513 | } |
593 | } |
514 | } |
594 | } |
515 | |
595 | |
|
|
596 | object_thawer::object_thawer (const char *data, AV *perlav) |
|
|
597 | { |
|
|
598 | av = perlav; |
|
|
599 | text = newSVpv (data, 0); |
|
|
600 | sv_catpv (text, thawer_eof); |
|
|
601 | line = SvPVbyte_nolen (text); |
|
|
602 | } |
|
|
603 | |
516 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
604 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
517 | { |
605 | { |
518 | if (!av || oid < 0) // this is actually an error of sorts |
606 | if (!av || oid < 0) // this is actually an error of sorts |
519 | return; |
607 | return; |
520 | |
608 | |
… | |
… | |
585 | int klen = p - line; |
673 | int klen = p - line; |
586 | |
674 | |
587 | if (*p++ != '\n') |
675 | if (*p++ != '\n') |
588 | { |
676 | { |
589 | // parse value |
677 | // parse value |
590 | while (*p <= ' ' && *p != '\n') // skip 0x01 .. 0x20 |
678 | while (*(unsigned char *)p <= ' ' && *p != '\n') // skip 0x01 .. 0x20 |
591 | ++p; |
679 | ++p; |
592 | |
680 | |
593 | last_value = p; |
681 | last_value = p; |
594 | |
682 | |
595 | while (*p != '\n') |
683 | while (*p != '\n') |
… | |
… | |
633 | |
721 | |
634 | void object_thawer::get_ml (keyword kend, shstr &sh) |
722 | void object_thawer::get_ml (keyword kend, shstr &sh) |
635 | { |
723 | { |
636 | char kw[128]; |
724 | char kw[128]; |
637 | |
725 | |
638 | // multi-line strings are delimited by "\nendXXX\n" |
726 | int klen = keyword_len [kend]; |
|
|
727 | |
639 | kw [0] = '\n'; |
728 | kw [0] = '\n'; |
640 | strcpy (kw + 1, keyword_str [kend]); |
729 | memcpy (kw + 1, keyword_str [kend], klen); |
|
|
730 | kw [klen + 1] = '\n'; |
|
|
731 | kw [klen + 2] = 0; |
641 | |
732 | |
642 | char *end = strstr (line, kw); |
733 | // first test for completely empty msg... "endXXX\n" |
643 | |
734 | if (!strncmp (line, kw + 1, klen + 1)) |
644 | if (!end) |
|
|
645 | { |
735 | { |
646 | sh = 0; |
736 | sh = 0; |
|
|
737 | |
|
|
738 | line += klen + 1; |
|
|
739 | |
647 | return; |
740 | return; |
648 | } |
741 | } |
|
|
742 | else |
|
|
743 | { |
|
|
744 | // multi-line strings are delimited by "\nendXXX\n" or "endXXX\n" (NULL) |
649 | |
745 | |
|
|
746 | char *end = strstr (line, kw); |
|
|
747 | |
|
|
748 | if (!end) |
|
|
749 | { |
|
|
750 | sh = 0; |
|
|
751 | return; |
|
|
752 | } |
|
|
753 | |
650 | *end = 0; |
754 | *end = 0; |
651 | sh = line; |
755 | sh = line; |
652 | |
756 | |
653 | line = end + keyword_len [kend] + 1; |
757 | line = end + keyword_len [kend] + 1; |
654 | |
758 | |
655 | while (*line++ != '\n') |
759 | while (*line++ != '\n') |
|
|
760 | ; |
656 | ; |
761 | } |
657 | } |
762 | } |
658 | |
763 | |
659 | sint32 object_thawer::get_sint32 () const |
764 | sint32 object_thawer::get_sint32 () const |
660 | { |
765 | { |
661 | char *p = last_value; |
766 | char *p = last_value; |
… | |
… | |
879 | |
984 | |
880 | AV *callbacks = 0; |
985 | AV *callbacks = 0; |
881 | |
986 | |
882 | object *op; |
987 | object *op; |
883 | player *pl; |
988 | player *pl; |
884 | mapstruct *map; |
989 | maptile *map; |
885 | |
990 | |
886 | // callback call ordering is: |
991 | // callback call ordering is: |
887 | // 1. per-object callback (NYI) |
992 | // 1. per-object callback (NYI) |
888 | // 2. per-class object |
993 | // 2. per-class object |
889 | // 2a. per-type callback |
994 | // 2a. per-type callback |
… | |
… | |
939 | break; |
1044 | break; |
940 | |
1045 | |
941 | case KLASS_MAP: |
1046 | case KLASS_MAP: |
942 | dt = (data_type) va_arg (ap, int); |
1047 | dt = (data_type) va_arg (ap, int); |
943 | assert (("first argument must be of type object", dt == DT_MAP)); |
1048 | assert (("first argument must be of type object", dt == DT_MAP)); |
944 | map = va_arg (ap, mapstruct *); |
1049 | map = va_arg (ap, maptile *); |
945 | |
1050 | |
946 | if (map->cb) |
1051 | if (map->cb) |
947 | gather_callbacks (callbacks, map->cb, event); |
1052 | gather_callbacks (callbacks, map->cb, event); |
948 | |
1053 | |
949 | gather_callbacks (callbacks, cb_map, event); |
1054 | gather_callbacks (callbacks, cb_map, event); |
… | |
… | |
1029 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1134 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1030 | |
1135 | |
1031 | BOOT: |
1136 | BOOT: |
1032 | { |
1137 | { |
1033 | HV *stash = gv_stashpv ("cf", 1); |
1138 | HV *stash = gv_stashpv ("cf", 1); |
|
|
1139 | |
|
|
1140 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1034 | |
1141 | |
1035 | static const struct { |
1142 | static const struct { |
1036 | const char *name; |
1143 | const char *name; |
1037 | IV iv; |
1144 | IV iv; |
1038 | } *civ, const_iv[] = { |
1145 | } *civ, const_iv[] = { |
… | |
… | |
1201 | const_iv (AT_BLIND) |
1308 | const_iv (AT_BLIND) |
1202 | const_iv (AT_INTERNAL) |
1309 | const_iv (AT_INTERNAL) |
1203 | const_iv (AT_LIFE_STEALING) |
1310 | const_iv (AT_LIFE_STEALING) |
1204 | const_iv (AT_DISEASE) |
1311 | const_iv (AT_DISEASE) |
1205 | |
1312 | |
1206 | const_iv (QUEST_IN_PROGRESS) |
|
|
1207 | const_iv (QUEST_DONE_QUEST) |
|
|
1208 | const_iv (QUEST_DONE_TASK) |
|
|
1209 | const_iv (QUEST_START_QUEST) |
|
|
1210 | const_iv (QUEST_END_QUEST) |
|
|
1211 | const_iv (QUEST_START_TASK) |
|
|
1212 | const_iv (QUEST_END_TASK) |
|
|
1213 | const_iv (QUEST_OVERRIDE) |
|
|
1214 | const_iv (QUEST_ON_ACTIVATE) |
|
|
1215 | |
|
|
1216 | const_iv (WEAP_HIT) |
1313 | const_iv (WEAP_HIT) |
1217 | const_iv (WEAP_SLASH) |
1314 | const_iv (WEAP_SLASH) |
1218 | const_iv (WEAP_PIERCE) |
1315 | const_iv (WEAP_PIERCE) |
1219 | const_iv (WEAP_CLEAVE) |
1316 | const_iv (WEAP_CLEAVE) |
1220 | const_iv (WEAP_SLICE) |
1317 | const_iv (WEAP_SLICE) |
… | |
… | |
1341 | const_iv (NDI_MAX_COLOR) |
1438 | const_iv (NDI_MAX_COLOR) |
1342 | const_iv (NDI_COLOR_MASK) |
1439 | const_iv (NDI_COLOR_MASK) |
1343 | const_iv (NDI_UNIQUE) |
1440 | const_iv (NDI_UNIQUE) |
1344 | const_iv (NDI_ALL) |
1441 | const_iv (NDI_ALL) |
1345 | |
1442 | |
|
|
1443 | const_iv (UPD_LOCATION) |
|
|
1444 | const_iv (UPD_FLAGS) |
|
|
1445 | const_iv (UPD_WEIGHT) |
|
|
1446 | const_iv (UPD_FACE) |
|
|
1447 | const_iv (UPD_NAME) |
|
|
1448 | const_iv (UPD_ANIM) |
|
|
1449 | const_iv (UPD_ANIMSPEED) |
|
|
1450 | const_iv (UPD_NROF) |
|
|
1451 | |
|
|
1452 | const_iv (UPD_SP_MANA) |
|
|
1453 | const_iv (UPD_SP_GRACE) |
|
|
1454 | const_iv (UPD_SP_DAMAGE) |
|
|
1455 | |
1346 | const_iv (F_APPLIED) |
1456 | const_iv (F_APPLIED) |
1347 | const_iv (F_LOCATION) |
1457 | const_iv (F_LOCATION) |
1348 | const_iv (F_UNPAID) |
1458 | const_iv (F_UNPAID) |
1349 | const_iv (F_MAGIC) |
1459 | const_iv (F_MAGIC) |
1350 | const_iv (F_CURSED) |
1460 | const_iv (F_CURSED) |
… | |
… | |
1545 | av_push (event, newSViv (eiv->klass)); |
1655 | av_push (event, newSViv (eiv->klass)); |
1546 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1656 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1547 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1657 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1548 | } |
1658 | } |
1549 | |
1659 | |
1550 | static const struct { |
|
|
1551 | int dtype; |
|
|
1552 | const char *name; |
|
|
1553 | IV idx; |
|
|
1554 | } *cprop, prop_table[] = { |
|
|
1555 | # define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, |
|
|
1556 | prop (CFAPI_INT, MAP_PROP_FLAGS) |
|
|
1557 | prop (CFAPI_INT, MAP_PROP_DIFFICULTY) |
|
|
1558 | prop (CFAPI_STRING, MAP_PROP_PATH) |
|
|
1559 | prop (CFAPI_STRING, MAP_PROP_TMPNAME) |
|
|
1560 | prop (CFAPI_STRING, MAP_PROP_NAME) |
|
|
1561 | prop (CFAPI_INT, MAP_PROP_RESET_TIME) |
|
|
1562 | prop (CFAPI_INT, MAP_PROP_RESET_TIMEOUT) |
|
|
1563 | prop (CFAPI_INT, MAP_PROP_PLAYERS) |
|
|
1564 | prop (CFAPI_INT, MAP_PROP_DARKNESS) |
|
|
1565 | prop (CFAPI_INT, MAP_PROP_WIDTH) |
|
|
1566 | prop (CFAPI_INT, MAP_PROP_HEIGHT) |
|
|
1567 | prop (CFAPI_INT, MAP_PROP_ENTER_X) |
|
|
1568 | prop (CFAPI_INT, MAP_PROP_ENTER_Y) |
|
|
1569 | prop (CFAPI_INT, MAP_PROP_TEMPERATURE) |
|
|
1570 | prop (CFAPI_INT, MAP_PROP_PRESSURE) |
|
|
1571 | prop (CFAPI_INT, MAP_PROP_HUMIDITY) |
|
|
1572 | prop (CFAPI_INT, MAP_PROP_WINDSPEED) |
|
|
1573 | prop (CFAPI_INT, MAP_PROP_WINDDIR) |
|
|
1574 | prop (CFAPI_INT, MAP_PROP_SKY) |
|
|
1575 | prop (CFAPI_INT, MAP_PROP_WPARTX) |
|
|
1576 | prop (CFAPI_INT, MAP_PROP_WPARTY) |
|
|
1577 | prop (CFAPI_STRING, MAP_PROP_MESSAGE) |
|
|
1578 | prop (CFAPI_PREGION, MAP_PROP_REGION) |
|
|
1579 | prop (CFAPI_POBJECT, OBJECT_PROP_NEXT_ACTIVE_OB) |
|
|
1580 | prop (CFAPI_POBJECT, OBJECT_PROP_PREV_ACTIVE_OB) |
|
|
1581 | prop (CFAPI_POBJECT, OBJECT_PROP_INVENTORY) |
|
|
1582 | prop (CFAPI_POBJECT, OBJECT_PROP_ENVIRONMENT) |
|
|
1583 | prop (CFAPI_POBJECT, OBJECT_PROP_CONTAINER) |
|
|
1584 | prop (CFAPI_PMAP, OBJECT_PROP_MAP) |
|
|
1585 | prop (CFAPI_INT, OBJECT_PROP_COUNT) |
|
|
1586 | prop (CFAPI_INT, OBJECT_PROP_REFCOUNT) |
|
|
1587 | prop (CFAPI_STRING, OBJECT_PROP_NAME) |
|
|
1588 | prop (CFAPI_STRING, OBJECT_PROP_NAME_PLURAL) |
|
|
1589 | prop (CFAPI_STRING, OBJECT_PROP_TITLE) |
|
|
1590 | prop (CFAPI_STRING, OBJECT_PROP_RACE) |
|
|
1591 | prop (CFAPI_STRING, OBJECT_PROP_SLAYING) |
|
|
1592 | prop (CFAPI_STRING, OBJECT_PROP_SKILL) |
|
|
1593 | prop (CFAPI_STRING, OBJECT_PROP_MESSAGE) |
|
|
1594 | prop (CFAPI_STRING, OBJECT_PROP_LORE) |
|
|
1595 | prop (CFAPI_INT, OBJECT_PROP_X) |
|
|
1596 | prop (CFAPI_INT, OBJECT_PROP_Y) |
|
|
1597 | prop (CFAPI_DOUBLE, OBJECT_PROP_SPEED) |
|
|
1598 | prop (CFAPI_DOUBLE, OBJECT_PROP_SPEED_LEFT) |
|
|
1599 | prop (CFAPI_INT, OBJECT_PROP_NROF) |
|
|
1600 | prop (CFAPI_INT, OBJECT_PROP_DIRECTION) |
|
|
1601 | prop (CFAPI_INT, OBJECT_PROP_FACING) |
|
|
1602 | prop (CFAPI_INT, OBJECT_PROP_TYPE) |
|
|
1603 | prop (CFAPI_INT, OBJECT_PROP_SUBTYPE) |
|
|
1604 | prop (CFAPI_INT, OBJECT_PROP_CLIENT_TYPE) |
|
|
1605 | prop (CFAPI_INT, OBJECT_PROP_ATTACK_TYPE) |
|
|
1606 | prop (CFAPI_INT, OBJECT_PROP_PATH_ATTUNED) |
|
|
1607 | prop (CFAPI_INT, OBJECT_PROP_PATH_REPELLED) |
|
|
1608 | prop (CFAPI_INT, OBJECT_PROP_PATH_DENIED) |
|
|
1609 | prop (CFAPI_INT, OBJECT_PROP_MATERIAL) |
|
|
1610 | prop (CFAPI_STRING, OBJECT_PROP_MATERIAL_NAME) |
|
|
1611 | prop (CFAPI_INT, OBJECT_PROP_MAGIC) |
|
|
1612 | prop (CFAPI_INT, OBJECT_PROP_VALUE) |
|
|
1613 | prop (CFAPI_INT, OBJECT_PROP_LEVEL) |
|
|
1614 | prop (CFAPI_INT, OBJECT_PROP_LAST_HEAL) |
|
|
1615 | prop (CFAPI_INT, OBJECT_PROP_LAST_SP) |
|
|
1616 | prop (CFAPI_INT, OBJECT_PROP_LAST_GRACE) |
|
|
1617 | prop (CFAPI_INT, OBJECT_PROP_LAST_EAT) |
|
|
1618 | prop (CFAPI_INT, OBJECT_PROP_INVISIBLE_TIME) |
|
|
1619 | prop (CFAPI_INT, OBJECT_PROP_PICK_UP) |
|
|
1620 | prop (CFAPI_INT, OBJECT_PROP_ITEM_POWER) |
|
|
1621 | prop (CFAPI_INT, OBJECT_PROP_GEN_SP_ARMOUR) |
|
|
1622 | prop (CFAPI_INT, OBJECT_PROP_WEIGHT) |
|
|
1623 | prop (CFAPI_INT, OBJECT_PROP_WEIGHT_LIMIT) |
|
|
1624 | prop (CFAPI_INT, OBJECT_PROP_CARRYING) |
|
|
1625 | prop (CFAPI_INT, OBJECT_PROP_GLOW_RADIUS) |
|
|
1626 | prop (CFAPI_LONG, OBJECT_PROP_PERM_EXP) |
|
|
1627 | prop (CFAPI_POBJECT, OBJECT_PROP_CURRENT_WEAPON) |
|
|
1628 | prop (CFAPI_POBJECT, OBJECT_PROP_ENEMY) |
|
|
1629 | prop (CFAPI_POBJECT, OBJECT_PROP_ATTACKED_BY) |
|
|
1630 | prop (CFAPI_INT, OBJECT_PROP_RUN_AWAY) |
|
|
1631 | prop (CFAPI_POBJECT, OBJECT_PROP_CHOSEN_SKILL) |
|
|
1632 | prop (CFAPI_INT, OBJECT_PROP_HIDDEN) |
|
|
1633 | prop (CFAPI_INT, OBJECT_PROP_MOVE_STATUS) |
|
|
1634 | prop (CFAPI_INT, OBJECT_PROP_MOVE_TYPE) |
|
|
1635 | prop (CFAPI_POBJECT, OBJECT_PROP_SPELL_ITEM) |
|
|
1636 | prop (CFAPI_DOUBLE, OBJECT_PROP_EXP_MULTIPLIER) |
|
|
1637 | prop (CFAPI_PARCH, OBJECT_PROP_ARCHETYPE) |
|
|
1638 | prop (CFAPI_PARCH, OBJECT_PROP_OTHER_ARCH) |
|
|
1639 | prop (CFAPI_STRING, OBJECT_PROP_CUSTOM_NAME) |
|
|
1640 | prop (CFAPI_INT, OBJECT_PROP_ANIM_SPEED) |
|
|
1641 | prop (CFAPI_INT, OBJECT_PROP_FRIENDLY) |
|
|
1642 | prop (CFAPI_STRING, OBJECT_PROP_SHORT_NAME) |
|
|
1643 | prop (CFAPI_INT, OBJECT_PROP_MAGICAL) |
|
|
1644 | prop (CFAPI_INT, OBJECT_PROP_LUCK) |
|
|
1645 | prop (CFAPI_POBJECT, OBJECT_PROP_OWNER) |
|
|
1646 | prop (CFAPI_POBJECT, OBJECT_PROP_PRESENT) |
|
|
1647 | prop (CFAPI_INT, OBJECT_PROP_CHEATER) |
|
|
1648 | prop (CFAPI_INT, OBJECT_PROP_MERGEABLE) |
|
|
1649 | prop (CFAPI_INT, OBJECT_PROP_PICKABLE) |
|
|
1650 | prop (CFAPI_INT, OBJECT_PROP_STR) |
|
|
1651 | prop (CFAPI_INT, OBJECT_PROP_DEX) |
|
|
1652 | prop (CFAPI_INT, OBJECT_PROP_CON) |
|
|
1653 | prop (CFAPI_INT, OBJECT_PROP_WIS) |
|
|
1654 | prop (CFAPI_INT, OBJECT_PROP_INT) |
|
|
1655 | prop (CFAPI_INT, OBJECT_PROP_POW) |
|
|
1656 | prop (CFAPI_INT, OBJECT_PROP_CHA) |
|
|
1657 | prop (CFAPI_INT, OBJECT_PROP_WC) |
|
|
1658 | prop (CFAPI_INT, OBJECT_PROP_AC) |
|
|
1659 | prop (CFAPI_INT, OBJECT_PROP_HP) |
|
|
1660 | prop (CFAPI_INT, OBJECT_PROP_SP) |
|
|
1661 | prop (CFAPI_INT, OBJECT_PROP_GP) |
|
|
1662 | prop (CFAPI_INT, OBJECT_PROP_FP) |
|
|
1663 | prop (CFAPI_INT, OBJECT_PROP_MAXHP) |
|
|
1664 | prop (CFAPI_INT, OBJECT_PROP_MAXSP) |
|
|
1665 | prop (CFAPI_INT, OBJECT_PROP_MAXGP) |
|
|
1666 | prop (CFAPI_INT, OBJECT_PROP_DAM) |
|
|
1667 | prop (CFAPI_STRING, OBJECT_PROP_GOD) |
|
|
1668 | prop (CFAPI_STRING, OBJECT_PROP_ARCH_NAME) |
|
|
1669 | prop (CFAPI_INT, OBJECT_PROP_INVISIBLE) |
|
|
1670 | prop (CFAPI_INT, OBJECT_PROP_FACE) |
|
|
1671 | }; |
|
|
1672 | |
|
|
1673 | HV *prop_type = get_hv ("cf::PROP_TYPE", 1); |
|
|
1674 | HV *prop_idx = get_hv ("cf::PROP_IDX", 1); |
|
|
1675 | |
|
|
1676 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
|
|
1677 | { |
|
|
1678 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
|
|
1679 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
|
|
1680 | } |
|
|
1681 | |
|
|
1682 | //I_EVENT_API (PACKAGE); |
1660 | //I_EVENT_API (PACKAGE); |
1683 | } |
1661 | } |
1684 | |
1662 | |
1685 | void _reload_1 () |
1663 | void _init_vars () |
1686 | CODE: |
1664 | CODE: |
1687 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1665 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1688 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1666 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1689 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1667 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1690 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1668 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1691 | cb_map = get_av ("cf::CB_MAP" , 1); |
1669 | cb_map = get_av ("cf::CB_MAP" , 1); |
1692 | |
1670 | |
1693 | void _reload_2 () |
1671 | void _global_reattach () |
1694 | CODE: |
1672 | CODE: |
1695 | { |
1673 | { |
1696 | // reattach to all attachable objects in the game. |
1674 | // reattach to all attachable objects in the game. |
1697 | for (player *pl = first_player; pl; pl = pl->next) |
1675 | for (player *pl = first_player; pl; pl = pl->next) |
1698 | reattach (pl); |
1676 | reattach (pl); |
1699 | |
1677 | |
1700 | for (mapstruct *map = first_map; map; map = map->next) |
1678 | for (maptile *map = first_map; map; map = map->next) |
1701 | reattach (map); |
1679 | reattach (map); |
1702 | |
1680 | |
1703 | for (object *op = objects; op; op = op->next) |
1681 | for (object *op = object::first; op; op = op->next) |
1704 | reattach (op); |
1682 | reattach (op); |
1705 | } |
1683 | } |
1706 | |
1684 | |
1707 | NV floor (NV x) |
1685 | NV floor (NV x) |
1708 | |
1686 | |
… | |
… | |
1756 | case 5: RETVAL = settings.playerdir; break; |
1734 | case 5: RETVAL = settings.playerdir; break; |
1757 | case 6: RETVAL = settings.datadir ; break; |
1735 | case 6: RETVAL = settings.datadir ; break; |
1758 | } |
1736 | } |
1759 | OUTPUT: RETVAL |
1737 | OUTPUT: RETVAL |
1760 | |
1738 | |
1761 | int |
1739 | void _exit (int status = 0) |
|
|
1740 | |
1762 | cf_find_animation (char *text) |
1741 | int cf_find_animation (char *text) |
1763 | PROTOTYPE: $ |
1742 | PROTOTYPE: $ |
1764 | |
1743 | |
1765 | int random_roll(int min, int max, object *op, int goodbad); |
1744 | int random_roll(int min, int max, object *op, int goodbad); |
1766 | |
1745 | |
1767 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1746 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
… | |
… | |
1820 | OUTPUT: |
1799 | OUTPUT: |
1821 | RETVAL |
1800 | RETVAL |
1822 | |
1801 | |
1823 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1802 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1824 | |
1803 | |
|
|
1804 | INCLUDE: $PERL genacc object ../include/object.h | |
|
|
1805 | |
1825 | int invoke (object *op, int event, ...) |
1806 | int invoke (object *op, int event, ...) |
1826 | CODE: |
1807 | CODE: |
1827 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1808 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1828 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1809 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1829 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1810 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
… | |
… | |
1834 | CODE: |
1815 | CODE: |
1835 | RETVAL = registry_of (op); |
1816 | RETVAL = registry_of (op); |
1836 | OUTPUT: |
1817 | OUTPUT: |
1837 | RETVAL |
1818 | RETVAL |
1838 | |
1819 | |
|
|
1820 | void mortals () |
|
|
1821 | PPCODE: |
|
|
1822 | EXTEND (SP, object::mortals.size ()); |
|
|
1823 | for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i) |
|
|
1824 | PUSHs (to_sv (*i)); |
|
|
1825 | |
|
|
1826 | object *first () |
|
|
1827 | CODE: |
|
|
1828 | RETVAL = object::first; |
|
|
1829 | OUTPUT: RETVAL |
|
|
1830 | |
|
|
1831 | # missing properties |
|
|
1832 | |
|
|
1833 | int flag (object *op, int flag, int value = 1) |
|
|
1834 | PROTOTYPE: $$;$ |
|
|
1835 | CODE: |
|
|
1836 | RETVAL = QUERY_FLAG (op, flag); |
|
|
1837 | if (items >= 3) |
|
|
1838 | if (value) |
|
|
1839 | SET_FLAG (op, flag); |
|
|
1840 | else |
|
|
1841 | CLEAR_FLAG (op, flag); |
|
|
1842 | OUTPUT: RETVAL |
|
|
1843 | |
1839 | object *head (object *op) |
1844 | object *head (object *op) |
1840 | PROTOTYPE: $ |
1845 | PROTOTYPE: $ |
1841 | ALIAS: |
|
|
1842 | more = 1 |
|
|
1843 | above = 2 |
|
|
1844 | below = 3 |
|
|
1845 | CODE: |
1846 | CODE: |
1846 | switch (ix) |
|
|
1847 | { |
|
|
1848 | case 0: RETVAL = op->head ? op->head : op; break; // DOH! |
1847 | RETVAL = op->head ? op->head : op; |
1849 | case 1: RETVAL = op->more; break; |
|
|
1850 | case 2: RETVAL = op->above; break; |
|
|
1851 | case 3: RETVAL = op->below; break; |
|
|
1852 | } |
|
|
1853 | OUTPUT: |
|
|
1854 | RETVAL |
1848 | OUTPUT: RETVAL |
1855 | |
1849 | |
1856 | SV * |
1850 | int is_head (object *op) |
1857 | get_property (object *obj, int type, int idx) |
1851 | PROTOTYPE: $ |
1858 | CODE: |
1852 | CODE: |
1859 | RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); |
|
|
1860 | OUTPUT: RETVAL |
|
|
1861 | |
|
|
1862 | SV * |
|
|
1863 | set_property (object *obj, int type, int idx, SV *newval) |
|
|
1864 | CODE: |
|
|
1865 | switch (type) |
|
|
1866 | { |
|
|
1867 | case CFAPI_INT: |
|
|
1868 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
|
|
1869 | break; |
|
|
1870 | case CFAPI_LONG: |
|
|
1871 | cf_object_set_long_property (obj, idx, (long) SvVAL64 (newval)); |
|
|
1872 | break; |
|
|
1873 | case CFAPI_DOUBLE: |
|
|
1874 | { |
|
|
1875 | int unused_type; |
|
|
1876 | object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); |
|
|
1877 | } |
|
|
1878 | break; |
|
|
1879 | case CFAPI_STRING: |
|
|
1880 | cf_object_set_string_property (obj, idx, SvOK (newval) ? SvPV_nolen (newval) : 0); |
|
|
1881 | break; |
|
|
1882 | case CFAPI_POBJECT: |
|
|
1883 | { |
|
|
1884 | int unused_type; |
|
|
1885 | object_set_property (&unused_type, obj, idx, (object *)SvPTR_ornull (newval, "cf::object")); |
|
|
1886 | } |
|
|
1887 | break; |
|
|
1888 | default: |
|
|
1889 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
|
|
1890 | } |
|
|
1891 | |
|
|
1892 | # missing properties |
|
|
1893 | |
|
|
1894 | void |
|
|
1895 | set_attacktype (object *obj, U32 attacktype) |
|
|
1896 | CODE: |
|
|
1897 | obj->attacktype = attacktype; |
|
|
1898 | |
|
|
1899 | U32 |
|
|
1900 | get_attacktype (object *obj) |
|
|
1901 | ALIAS: |
|
|
1902 | attacktype = 0 |
|
|
1903 | CODE: |
|
|
1904 | RETVAL = obj->attacktype; |
|
|
1905 | OUTPUT: RETVAL |
|
|
1906 | |
|
|
1907 | # missing in plug-in api, of course |
|
|
1908 | void |
|
|
1909 | set_food (object *obj, int food) |
|
|
1910 | CODE: |
|
|
1911 | obj->stats.food = food; |
|
|
1912 | |
|
|
1913 | int |
|
|
1914 | get_food (object *obj) |
|
|
1915 | ALIAS: |
|
|
1916 | food = 0 |
|
|
1917 | CODE: |
|
|
1918 | RETVAL = obj->stats.food; |
1853 | RETVAL = !op->head; |
1919 | OUTPUT: RETVAL |
1854 | OUTPUT: RETVAL |
1920 | |
1855 | |
1921 | void |
1856 | void |
1922 | inv (object *obj) |
1857 | inv (object *obj) |
1923 | PROTOTYPE: $ |
1858 | PROTOTYPE: $ |
1924 | PPCODE: |
1859 | PPCODE: |
… | |
… | |
1926 | object *o; |
1861 | object *o; |
1927 | for (o = obj->inv; o; o = o->below) |
1862 | for (o = obj->inv; o; o = o->below) |
1928 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1863 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1929 | } |
1864 | } |
1930 | |
1865 | |
|
|
1866 | object *find_best_object_match (object *op, const char *match) |
|
|
1867 | |
|
|
1868 | object *find_marked_object (object *op) |
|
|
1869 | |
1931 | int cf_object_get_resistance (object *op, int rtype) |
1870 | int cf_object_get_resistance (object *op, int rtype) |
1932 | ALIAS: resistance = 0 |
1871 | ALIAS: resistance = 0 |
1933 | |
|
|
1934 | int cf_object_get_flag (object *op, int flag) |
|
|
1935 | ALIAS: flag = 0 |
|
|
1936 | |
|
|
1937 | void cf_object_set_flag (object *op, int flag, int value) |
|
|
1938 | |
1872 | |
1939 | int need_identify (const object *obj); |
1873 | int need_identify (const object *obj); |
1940 | |
1874 | |
1941 | int apply_shop_mat (object *shop_mat, object *op); |
1875 | int apply_shop_mat (object *shop_mat, object *op); |
1942 | |
1876 | |
… | |
… | |
1956 | |
1890 | |
1957 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1891 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1958 | |
1892 | |
1959 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1893 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1960 | |
1894 | |
1961 | int cf_object_change_map (object *op, int x, int y, mapstruct *map) |
1895 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1962 | |
1896 | |
1963 | object *cf_object_clone (object *op, int clonetype = 0) |
1897 | object *cf_object_clone (object *op, int clonetype = 0) |
1964 | |
1898 | |
1965 | int cf_object_pay_item (object *op, object *buyer) |
1899 | int cf_object_pay_item (object *op, object *buyer) |
1966 | |
1900 | |
… | |
… | |
1996 | |
1930 | |
1997 | void cf_object_take (object *op, object *author) |
1931 | void cf_object_take (object *op, object *author) |
1998 | |
1932 | |
1999 | object *cf_object_insert_object (object *op, object *container) |
1933 | object *cf_object_insert_object (object *op, object *container) |
2000 | |
1934 | |
2001 | const char *cf_object_get_msg (object *ob) |
|
|
2002 | ALIAS: msg = 0 |
|
|
2003 | |
|
|
2004 | object *cf_object_insert_in_ob (object *ob, object *where) |
1935 | object *cf_object_insert_in_ob (object *ob, object *where) |
2005 | |
1936 | |
2006 | int cf_object_teleport (object *op, mapstruct *map, int x, int y) |
1937 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
2007 | |
1938 | |
2008 | void cf_object_update (object *op, int flags) |
1939 | void cf_object_update (object *op, int flags) |
2009 | |
1940 | |
2010 | void cf_object_pickup (object *op, object *what) |
1941 | void cf_object_pickup (object *op, object *what) |
2011 | |
1942 | |
… | |
… | |
2021 | |
1952 | |
2022 | void push_button (object *op); |
1953 | void push_button (object *op); |
2023 | |
1954 | |
2024 | void use_trigger (object *op); |
1955 | void use_trigger (object *op); |
2025 | |
1956 | |
2026 | void add_button_link (object *button, mapstruct *map, int connected); |
1957 | void add_button_link (object *button, maptile *map, int connected); |
2027 | |
1958 | |
2028 | void remove_button_link (object *op); |
1959 | void remove_button_link (object *op); |
2029 | |
1960 | |
2030 | void |
1961 | void |
2031 | cf_object_set_resistance (object *op, int rtype, int val) |
1962 | cf_object_set_resistance (object *op, int rtype, int val) |
… | |
… | |
2049 | CODE: |
1980 | CODE: |
2050 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
1981 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
2051 | OUTPUT: |
1982 | OUTPUT: |
2052 | RETVAL |
1983 | RETVAL |
2053 | |
1984 | |
2054 | object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) |
1985 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
2055 | PROTOTYPE: $$$$$$ |
1986 | PROTOTYPE: $$$$$$ |
2056 | CODE: |
1987 | CODE: |
2057 | { |
1988 | { |
2058 | int unused_type; |
1989 | int unused_type; |
2059 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
1990 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
… | |
… | |
2097 | bool on_same_map_as (object *ob, object *other) |
2028 | bool on_same_map_as (object *ob, object *other) |
2098 | CODE: |
2029 | CODE: |
2099 | RETVAL = on_same_map (ob, other); |
2030 | RETVAL = on_same_map (ob, other); |
2100 | OUTPUT: RETVAL |
2031 | OUTPUT: RETVAL |
2101 | |
2032 | |
2102 | char * |
2033 | const char * |
2103 | base_name (object *ob, int plural) |
2034 | base_name (object *op, int plural = op->nrof > 1) |
2104 | CODE: |
2035 | CODE: |
2105 | RETVAL = cf_query_base_name (ob, plural); |
2036 | RETVAL = query_base_name (op, plural); |
2106 | OUTPUT: RETVAL |
2037 | OUTPUT: RETVAL |
2107 | |
|
|
2108 | living * |
|
|
2109 | stats (object *ob) |
|
|
2110 | CODE: |
|
|
2111 | RETVAL = &ob->stats; |
|
|
2112 | OUTPUT: RETVAL |
|
|
2113 | |
|
|
2114 | |
2038 | |
2115 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
2039 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
2116 | |
2040 | |
2117 | player *player (object *op) |
2041 | player *player (object *op) |
2118 | CODE: |
2042 | CODE: |
… | |
… | |
2136 | |
2060 | |
2137 | void cf_player_set_party (object *op, partylist *party) |
2061 | void cf_player_set_party (object *op, partylist *party) |
2138 | |
2062 | |
2139 | void kill_player (object *op) |
2063 | void kill_player (object *op) |
2140 | |
2064 | |
|
|
2065 | void esrv_update_item (object *op, int what, object *item) |
|
|
2066 | C_ARGS: what, op, item |
|
|
2067 | |
|
|
2068 | void clear_los (object *op) |
|
|
2069 | |
|
|
2070 | int command_reset (object *op, char *params) |
|
|
2071 | |
|
|
2072 | int command_teleport (object *op, char *params) |
|
|
2073 | |
|
|
2074 | int command_summon (object *op, char *params) |
|
|
2075 | |
|
|
2076 | int command_arrest (object *op, char *params) |
|
|
2077 | |
|
|
2078 | int command_kick (object *op, char *params) |
|
|
2079 | |
|
|
2080 | int command_banish (object *op, char *params) |
|
|
2081 | |
|
|
2082 | |
2141 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2083 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
|
|
2084 | |
|
|
2085 | INCLUDE: $PERL genacc player ../include/newserver.h ../include/player.h | |
|
|
2086 | |
|
|
2087 | char * |
|
|
2088 | client (player *pl) |
|
|
2089 | CODE: |
|
|
2090 | RETVAL = pl->socket.client; |
|
|
2091 | OUTPUT: |
|
|
2092 | RETVAL |
|
|
2093 | |
|
|
2094 | char * |
|
|
2095 | host (player *pl) |
|
|
2096 | CODE: |
|
|
2097 | RETVAL = pl->socket.host; |
|
|
2098 | OUTPUT: |
|
|
2099 | RETVAL |
2142 | |
2100 | |
2143 | int invoke (player *pl, int event, ...) |
2101 | int invoke (player *pl, int event, ...) |
2144 | CODE: |
2102 | CODE: |
2145 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2103 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2146 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2104 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
… | |
… | |
2159 | |
2117 | |
2160 | void cf_player_move (player *pl, int dir) |
2118 | void cf_player_move (player *pl, int dir) |
2161 | |
2119 | |
2162 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2120 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2163 | |
2121 | |
2164 | # nonstandard |
|
|
2165 | object *ob (player *pl) |
|
|
2166 | CODE: |
|
|
2167 | RETVAL = pl->ob; |
|
|
2168 | OUTPUT: RETVAL |
|
|
2169 | |
|
|
2170 | player *first () |
2122 | player *first () |
2171 | CODE: |
2123 | CODE: |
2172 | RETVAL = first_player; |
2124 | RETVAL = first_player; |
2173 | OUTPUT: RETVAL |
2125 | OUTPUT: RETVAL |
2174 | |
2126 | |
… | |
… | |
2180 | bool |
2132 | bool |
2181 | cell_visible (player *pl, int dx, int dy) |
2133 | cell_visible (player *pl, int dx, int dy) |
2182 | CODE: |
2134 | CODE: |
2183 | RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 |
2135 | RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 |
2184 | && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; |
2136 | && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; |
2185 | OUTPUT: |
|
|
2186 | RETVAL |
|
|
2187 | |
|
|
2188 | char * |
|
|
2189 | client (player *pl) |
|
|
2190 | CODE: |
|
|
2191 | RETVAL = pl->socket.client; |
|
|
2192 | OUTPUT: |
|
|
2193 | RETVAL |
|
|
2194 | |
|
|
2195 | char * |
|
|
2196 | host (player *pl) |
|
|
2197 | CODE: |
|
|
2198 | RETVAL = pl->socket.host; |
|
|
2199 | OUTPUT: |
|
|
2200 | RETVAL |
|
|
2201 | |
|
|
2202 | char * |
|
|
2203 | killer (player *pl, char *killer = 0) |
|
|
2204 | CODE: |
|
|
2205 | if (killer) |
|
|
2206 | snprintf (pl->killer, sizeof (pl->killer), "%s", killer); |
|
|
2207 | RETVAL = pl->killer; |
|
|
2208 | OUTPUT: |
2137 | OUTPUT: |
2209 | RETVAL |
2138 | RETVAL |
2210 | |
2139 | |
2211 | void |
2140 | void |
2212 | buggy_mapscroll (player *pl, int value = 1) |
2141 | buggy_mapscroll (player *pl, int value = 1) |
… | |
… | |
2230 | if (new_value >= 0) |
2159 | if (new_value >= 0) |
2231 | pl->listening = new_value; |
2160 | pl->listening = new_value; |
2232 | OUTPUT: |
2161 | OUTPUT: |
2233 | RETVAL |
2162 | RETVAL |
2234 | |
2163 | |
2235 | void get_savebed (player *pl) |
2164 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2236 | ALIAS: |
2165 | PROTOTYPE: $;$$$ |
2237 | savebed = 0 |
|
|
2238 | PPCODE: |
2166 | PPCODE: |
|
|
2167 | if (GIMME_V != G_VOID) |
|
|
2168 | { |
2239 | EXTEND (SP, 3); |
2169 | EXTEND (SP, 3); |
2240 | PUSHs (sv_2mortal (newSVpv (pl->savebed_map, 0))); |
2170 | PUSHs (sv_2mortal (newSVpv (pl->savebed_map, 0))); |
2241 | PUSHs (sv_2mortal (newSViv (pl->bed_x))); |
2171 | PUSHs (sv_2mortal (newSViv (pl->bed_x))); |
2242 | PUSHs (sv_2mortal (newSViv (pl->bed_y))); |
2172 | PUSHs (sv_2mortal (newSViv (pl->bed_y))); |
2243 | |
2173 | } |
2244 | void set_savebed (player *pl, char *map_path, int x, int y) |
2174 | if (map_path) sv_to (map_path, pl->savebed_map); |
2245 | CODE: |
2175 | if (x) sv_to (x, pl->bed_x); |
2246 | strcpy (pl->savebed_map, map_path); |
2176 | if (y) sv_to (y, pl->bed_y); |
2247 | pl->bed_x = x; |
|
|
2248 | pl->bed_y = y; |
|
|
2249 | |
2177 | |
2250 | void |
2178 | void |
2251 | list () |
2179 | list () |
2252 | PPCODE: |
2180 | PPCODE: |
2253 | { |
2181 | { |
… | |
… | |
2279 | OUTPUT: RETVAL |
2207 | OUTPUT: RETVAL |
2280 | |
2208 | |
2281 | |
2209 | |
2282 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2210 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2283 | |
2211 | |
2284 | mapstruct *first () |
2212 | maptile *first () |
2285 | PROTOTYPE: |
2213 | PROTOTYPE: |
2286 | CODE: |
2214 | CODE: |
2287 | RETVAL = first_map; |
2215 | RETVAL = first_map; |
2288 | OUTPUT: RETVAL |
2216 | OUTPUT: RETVAL |
2289 | |
2217 | |
2290 | mapstruct *next (mapstruct *map) |
|
|
2291 | PROTOTYPE: |
|
|
2292 | CODE: |
|
|
2293 | RETVAL = map->next; |
|
|
2294 | OUTPUT: RETVAL |
|
|
2295 | |
|
|
2296 | int invoke (mapstruct *map, int event, ...) |
2218 | int invoke (maptile *map, int event, ...) |
2297 | CODE: |
2219 | CODE: |
2298 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
2220 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
2299 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2221 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2300 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2222 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2301 | RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); |
2223 | RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); |
2302 | OUTPUT: RETVAL |
2224 | OUTPUT: RETVAL |
2303 | |
2225 | |
2304 | SV *registry (mapstruct *map) |
2226 | SV *registry (maptile *map) |
2305 | CODE: |
2227 | CODE: |
2306 | RETVAL = registry_of (map); |
2228 | RETVAL = registry_of (map); |
2307 | OUTPUT: |
2229 | OUTPUT: |
2308 | RETVAL |
2230 | RETVAL |
2309 | |
2231 | |
2310 | SV * |
2232 | INCLUDE: $PERL genacc maptile ../include/map.h | |
2311 | get_property (mapstruct *obj, int type, int idx) |
|
|
2312 | CODE: |
|
|
2313 | RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); |
|
|
2314 | OUTPUT: RETVAL |
|
|
2315 | |
2233 | |
2316 | SV * |
|
|
2317 | set_property (mapstruct *obj, int type, int idx, SV *newval) |
|
|
2318 | CODE: |
|
|
2319 | switch (type) |
|
|
2320 | { |
|
|
2321 | case CFAPI_INT: |
|
|
2322 | cf_map_set_int_property (obj, idx, SvIV (newval)); |
|
|
2323 | break; |
|
|
2324 | default: |
|
|
2325 | croak ("unhandled type '%d' in set_property '%d'", type, idx); |
|
|
2326 | } |
|
|
2327 | |
|
|
2328 | mapstruct *new (int width, int height) |
2234 | maptile *new (int width, int height) |
2329 | PROTOTYPE: |
2235 | PROTOTYPE: |
2330 | CODE: |
2236 | CODE: |
2331 | { |
2237 | { |
2332 | RETVAL = get_empty_map (width, height); |
2238 | RETVAL = get_empty_map (width, height); |
2333 | } |
2239 | } |
2334 | OUTPUT: |
2240 | OUTPUT: |
2335 | RETVAL |
2241 | RETVAL |
2336 | |
2242 | |
2337 | void delete_map (mapstruct *map) |
2243 | void delete_map (maptile *map) |
2338 | |
2244 | |
2339 | void clean_tmp_map (mapstruct *map) |
2245 | void clean_tmp_map (maptile *map) |
2340 | |
2246 | |
2341 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
2247 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
2342 | |
2248 | |
2343 | mapstruct *tile_map (mapstruct *map, unsigned int dir) |
2249 | maptile *tile_map (maptile *map, unsigned int dir) |
2344 | CODE: |
2250 | CODE: |
2345 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
2251 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
2346 | OUTPUT: |
2252 | OUTPUT: |
2347 | RETVAL |
2253 | RETVAL |
2348 | |
2254 | |
2349 | char *tile_path (mapstruct *map, unsigned int dir) |
2255 | char *tile_path (maptile *map, unsigned int dir) |
2350 | CODE: |
2256 | CODE: |
2351 | if (dir >= 4) |
2257 | if (dir >= 4) |
2352 | XSRETURN_UNDEF; |
2258 | XSRETURN_UNDEF; |
2353 | RETVAL = map->tile_path [dir]; |
2259 | RETVAL = map->tile_path [dir]; |
2354 | OUTPUT: |
2260 | OUTPUT: |
2355 | RETVAL |
2261 | RETVAL |
2356 | |
2262 | |
2357 | mapstruct *ready_map_name (char *name, int flags = 0) |
2263 | maptile *ready_map_name (char *name, int flags = 0) |
2358 | PROTOTYPE: $;$ |
2264 | PROTOTYPE: $;$ |
2359 | ALIAS: |
2265 | ALIAS: |
2360 | find = 0 |
2266 | find = 0 |
2361 | get_map = 1 |
2267 | get_map = 1 |
2362 | |
2268 | |
2363 | mapstruct *has_been_loaded (char *name) |
2269 | maptile *has_been_loaded (char *name) |
2364 | PROTOTYPE: $ |
2270 | PROTOTYPE: $ |
2365 | |
2271 | |
2366 | # whoever "designed" the plug-in api should have wasted |
|
|
2367 | # his/her time with staying away from the project - would have |
|
|
2368 | # saved others a lot of time, without doubt. |
|
|
2369 | void set_path (mapstruct *where, char *path) |
|
|
2370 | CODE: |
|
|
2371 | strcpy (where->path, path); |
|
|
2372 | |
|
|
2373 | int in_memory (mapstruct *map) |
2272 | int in_memory (maptile *map) |
2374 | CODE: |
2273 | CODE: |
2375 | RETVAL = map->in_memory; |
2274 | RETVAL = map->in_memory; |
2376 | OUTPUT: |
2275 | OUTPUT: |
2377 | RETVAL |
2276 | RETVAL |
2378 | |
2277 | |
2379 | bool unique (mapstruct *map) |
|
|
2380 | CODE: |
|
|
2381 | RETVAL = map->unique; |
|
|
2382 | OUTPUT: |
|
|
2383 | RETVAL |
|
|
2384 | |
|
|
2385 | void set_unique (mapstruct *map, bool unique) |
|
|
2386 | CODE: |
|
|
2387 | map->unique = unique; |
|
|
2388 | |
|
|
2389 | void |
2278 | void |
2390 | trigger (mapstruct *map, long connection, bool state = true) |
2279 | trigger (maptile *map, long connection, bool state = true) |
2391 | CODE: |
2280 | CODE: |
2392 | activate_connection (map, connection, state); |
2281 | activate_connection (map, connection, state); |
2393 | |
2282 | |
2394 | void |
2283 | void |
2395 | get_connection (mapstruct *map, long connection) |
2284 | get_connection (maptile *map, long connection) |
2396 | PPCODE: |
2285 | PPCODE: |
2397 | oblinkpt *obp = get_connection_links (map, connection); |
2286 | oblinkpt *obp = get_connection_links (map, connection); |
2398 | if (obp) |
2287 | if (obp) |
2399 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2288 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2400 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); |
2289 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, (object *)ol->ob))); |
2401 | |
2290 | |
2402 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
2291 | object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags) |
2403 | |
2292 | |
2404 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
2293 | object *cf_map_insert_object (maptile *where, object* op, int x, int y) |
2405 | |
2294 | |
2406 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
2295 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2407 | C_ARGS: str, map, nx, ny |
2296 | C_ARGS: str, map, nx, ny |
2408 | |
2297 | |
2409 | void |
2298 | void |
2410 | cf_map_normalise (mapstruct *map, int x, int y) |
2299 | cf_map_normalise (maptile *map, int x, int y) |
2411 | PPCODE: |
2300 | PPCODE: |
2412 | { |
2301 | { |
2413 | mapstruct *nmap = 0; |
2302 | maptile *nmap = 0; |
2414 | I16 nx = 0, ny = 0; |
2303 | I16 nx = 0, ny = 0; |
2415 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2304 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2416 | |
2305 | |
2417 | EXTEND (SP, 4); |
2306 | EXTEND (SP, 4); |
2418 | PUSHs (sv_2mortal (newSViv (flags))); |
2307 | PUSHs (sv_2mortal (newSViv (flags))); |
… | |
… | |
2424 | PUSHs (sv_2mortal (newSViv (ny))); |
2313 | PUSHs (sv_2mortal (newSViv (ny))); |
2425 | } |
2314 | } |
2426 | } |
2315 | } |
2427 | |
2316 | |
2428 | void |
2317 | void |
2429 | at (mapstruct *map, unsigned int x, unsigned int y) |
2318 | at (maptile *map, unsigned int x, unsigned int y) |
2430 | PROTOTYPE: $$$ |
2319 | PROTOTYPE: $$$ |
2431 | PPCODE: |
2320 | PPCODE: |
2432 | { |
2321 | { |
2433 | object *o; |
2322 | object *o; |
2434 | mapstruct *nmap = 0; |
2323 | maptile *nmap = 0; |
2435 | I16 nx, ny; |
2324 | I16 nx, ny; |
2436 | |
2325 | |
2437 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2326 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2438 | |
2327 | |
2439 | if (nmap) |
2328 | if (nmap) |
2440 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2329 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2441 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2330 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2442 | } |
2331 | } |
2443 | |
2332 | |
2444 | SV * |
2333 | SV * |
2445 | bot_at (mapstruct *obj, unsigned int x, unsigned int y) |
2334 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2446 | PROTOTYPE: $$$ |
2335 | PROTOTYPE: $$$ |
2447 | ALIAS: |
2336 | ALIAS: |
2448 | top_at = 1 |
2337 | top_at = 1 |
2449 | flags_at = 2 |
2338 | flags_at = 2 |
2450 | light_at = 3 |
2339 | light_at = 3 |
… | |
… | |
2472 | |
2361 | |
2473 | MODULE = cf PACKAGE = cf::arch |
2362 | MODULE = cf PACKAGE = cf::arch |
2474 | |
2363 | |
2475 | archetype *find (const char *name) |
2364 | archetype *find (const char *name) |
2476 | CODE: |
2365 | CODE: |
2477 | RETVAL = find_archetype (name); |
2366 | RETVAL = archetype::find (name); |
2478 | OUTPUT: |
2367 | OUTPUT: |
2479 | RETVAL |
2368 | RETVAL |
2480 | |
2369 | |
2481 | archetype *first() |
2370 | archetype *first() |
2482 | PROTOTYPE: |
2371 | PROTOTYPE: |
2483 | CODE: |
2372 | CODE: |
2484 | RETVAL = first_archetype; |
2373 | RETVAL = first_archetype; |
2485 | OUTPUT: RETVAL |
2374 | OUTPUT: RETVAL |
2486 | |
2375 | |
2487 | archetype *next (archetype *arch) |
2376 | INCLUDE: $PERL genacc archetype ../include/object.h | |
2488 | CODE: |
|
|
2489 | RETVAL = arch->next; |
|
|
2490 | OUTPUT: RETVAL |
|
|
2491 | |
|
|
2492 | archetype *head (archetype *arch) |
|
|
2493 | CODE: |
|
|
2494 | RETVAL = arch->head; |
|
|
2495 | OUTPUT: RETVAL |
|
|
2496 | |
|
|
2497 | archetype *more (archetype *arch) |
|
|
2498 | CODE: |
|
|
2499 | RETVAL = arch->more; |
|
|
2500 | OUTPUT: RETVAL |
|
|
2501 | |
|
|
2502 | const char *name (archetype *arch) |
|
|
2503 | CODE: |
|
|
2504 | RETVAL = arch->name; |
|
|
2505 | OUTPUT: RETVAL |
|
|
2506 | |
|
|
2507 | object *clone (archetype *arch) |
|
|
2508 | CODE: |
|
|
2509 | RETVAL = &arch->clone; |
|
|
2510 | OUTPUT: RETVAL |
|
|
2511 | |
2377 | |
2512 | MODULE = cf PACKAGE = cf::party |
2378 | MODULE = cf PACKAGE = cf::party |
2513 | |
2379 | |
2514 | partylist *first () |
2380 | partylist *first () |
2515 | PROTOTYPE: |
2381 | PROTOTYPE: |
… | |
… | |
2565 | RETVAL = reg->msg; |
2431 | RETVAL = reg->msg; |
2566 | OUTPUT: RETVAL |
2432 | OUTPUT: RETVAL |
2567 | |
2433 | |
2568 | MODULE = cf PACKAGE = cf::living |
2434 | MODULE = cf PACKAGE = cf::living |
2569 | |
2435 | |
2570 | val64 |
2436 | INCLUDE: $PERL genacc living ../include/living.h | |
2571 | exp (living *liv, val64 new_val = 0) |
|
|
2572 | PROTOTYPE: $;$ |
|
|
2573 | ALIAS: |
|
|
2574 | Str = 1 |
|
|
2575 | Dex = 2 |
|
|
2576 | Con = 3 |
|
|
2577 | Wis = 4 |
|
|
2578 | Cha = 5 |
|
|
2579 | Int = 6 |
|
|
2580 | Pow = 7 |
|
|
2581 | wc = 8 |
|
|
2582 | ac = 9 |
|
|
2583 | hp = 10 |
|
|
2584 | maxhp = 11 |
|
|
2585 | sp = 12 |
|
|
2586 | maxsp = 13 |
|
|
2587 | grace = 14 |
|
|
2588 | maxgrace = 15 |
|
|
2589 | food = 16 |
|
|
2590 | dam = 17 |
|
|
2591 | luck = 18 |
|
|
2592 | CODE: |
|
|
2593 | # define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = (sint64)new_val; break |
|
|
2594 | switch (ix) |
|
|
2595 | { |
|
|
2596 | LIVING_ACC (exp , 0); |
|
|
2597 | LIVING_ACC (Str , 1); |
|
|
2598 | LIVING_ACC (Dex , 2); |
|
|
2599 | LIVING_ACC (Con , 3); |
|
|
2600 | LIVING_ACC (Wis , 4); |
|
|
2601 | LIVING_ACC (Cha , 5); |
|
|
2602 | LIVING_ACC (Int , 6); |
|
|
2603 | LIVING_ACC (Pow , 7); |
|
|
2604 | LIVING_ACC (wc , 8); |
|
|
2605 | LIVING_ACC (ac , 9); |
|
|
2606 | LIVING_ACC (hp , 10); |
|
|
2607 | LIVING_ACC (maxhp , 11); |
|
|
2608 | LIVING_ACC (sp , 12); |
|
|
2609 | LIVING_ACC (maxsp , 13); |
|
|
2610 | LIVING_ACC (grace , 14); |
|
|
2611 | LIVING_ACC (maxgrace, 15); |
|
|
2612 | LIVING_ACC (food , 16); |
|
|
2613 | LIVING_ACC (dam , 17); |
|
|
2614 | LIVING_ACC (luck , 18); |
|
|
2615 | } |
|
|
2616 | # undef LIVING_ACC |
|
|
2617 | OUTPUT: |
|
|
2618 | RETVAL |
|
|
2619 | |
2437 | |