… | |
… | |
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 | static HV *obj_cache; |
|
|
57 | static PerlInterpreter *perl; |
56 | static PerlInterpreter *perl; |
58 | |
57 | |
59 | static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; |
58 | static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; |
60 | |
|
|
61 | #define PUSHcfapi(type,value) PUSHs (sv_2mortal (newSVcfapi (CFAPI_ ## type, (value)))) |
|
|
62 | #define PUSHcfapi_va(type,ctype) PUSHcfapi (type, va_arg (args, ctype)) |
|
|
63 | #define PUSH_OB PUSHcfapi_va(POBJECT, object *) |
|
|
64 | #define PUSH_PL PUSHcfapi_va(PPLAYER, player *) |
|
|
65 | #define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) |
|
|
66 | #define PUSH_PV PUSHcfapi_va(STRING, const char *) |
|
|
67 | #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) |
|
|
68 | |
59 | |
69 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
70 | |
61 | |
71 | static SV * |
62 | static SV * |
72 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
63 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
… | |
… | |
89 | |
80 | |
90 | if (!obj->self) |
81 | if (!obj->self) |
91 | obj->self = newSVptr (obj, klass); |
82 | obj->self = newSVptr (obj, klass); |
92 | |
83 | |
93 | return newSVsv (obj->self); |
84 | return newSVsv (obj->self); |
94 | } |
|
|
95 | |
|
|
96 | static void |
|
|
97 | SVptr_cache_set (void *ptr, SV *sv) |
|
|
98 | { |
|
|
99 | hv_store (obj_cache, (char *)&ptr, sizeof (ptr), sv, 0); |
|
|
100 | } |
|
|
101 | |
|
|
102 | static SV * |
|
|
103 | SVptr_cache_get (void *ptr) |
|
|
104 | { |
|
|
105 | SV **he = hv_fetch (obj_cache, (char *)&ptr, sizeof (ptr), 0); |
|
|
106 | |
|
|
107 | return he ? *he : 0; |
|
|
108 | } |
|
|
109 | |
|
|
110 | static SV * |
|
|
111 | newSVptr_cached (void *ptr, const char *klass) |
|
|
112 | { |
|
|
113 | SV *sv; |
|
|
114 | |
|
|
115 | if (!ptr) |
|
|
116 | return &PL_sv_undef; |
|
|
117 | |
|
|
118 | sv = SVptr_cache_get (ptr); |
|
|
119 | |
|
|
120 | if (!sv) |
|
|
121 | { |
|
|
122 | HV *hv = newHV (); |
|
|
123 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
|
|
124 | sv = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
125 | |
|
|
126 | SVptr_cache_set (ptr, sv); |
|
|
127 | } |
|
|
128 | |
|
|
129 | return newSVsv (sv); |
|
|
130 | } |
85 | } |
131 | |
86 | |
132 | static void |
87 | static void |
133 | clearSVptr (SV *sv) |
88 | clearSVptr (SV *sv) |
134 | { |
89 | { |
… | |
… | |
171 | inline SV *to_sv (unsigned short v) { return newSVuv (v); } |
126 | inline SV *to_sv (unsigned short v) { return newSVuv (v); } |
172 | inline SV *to_sv ( signed int v) { return newSViv (v); } |
127 | inline SV *to_sv ( signed int v) { return newSViv (v); } |
173 | inline SV *to_sv (unsigned int v) { return newSVuv (v); } |
128 | inline SV *to_sv (unsigned int v) { return newSVuv (v); } |
174 | inline SV *to_sv ( signed long v) { return newSViv (v); } |
129 | inline SV *to_sv ( signed long v) { return newSViv (v); } |
175 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
130 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
|
|
131 | inline SV *to_sv ( signed long long v) { return newSVval64 (v); } |
|
|
132 | inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
176 | inline SV *to_sv (float v) { return newSVnv (v); } |
133 | inline SV *to_sv (float v) { return newSVnv (v); } |
177 | inline SV *to_sv (double v) { return newSVnv (v); } |
134 | inline SV *to_sv (double v) { return newSVnv (v); } |
178 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
135 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
179 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
136 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
180 | inline SV *to_sv (mapstruct * v) { return newSVattachable (v, "cf::map::wrap"); } |
137 | inline SV *to_sv (maptile * v) { return newSVattachable (v, "cf::map::wrap"); } |
181 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::archetype::wrap"); } |
138 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); } |
182 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
139 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
183 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
140 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
184 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
141 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
185 | |
142 | |
186 | inline SV *to_sv (object & v) { return to_sv (&v); } |
143 | inline SV *to_sv (object & v) { return to_sv (&v); } |
… | |
… | |
188 | |
145 | |
189 | //TODO: |
146 | //TODO: |
190 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
147 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
191 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
148 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
192 | |
149 | |
|
|
150 | inline SV *to_sv (UUID v) |
|
|
151 | { |
|
|
152 | char buf[128]; |
|
|
153 | snprintf (buf, 128, "<1,%llx>", (unsigned long long)v.seq); |
|
|
154 | return newSVpv (buf, 0); |
|
|
155 | } |
|
|
156 | |
193 | inline void sv_to (SV *sv, shstr &v) { v = SvPV_nolen (sv); } |
157 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
194 | inline void sv_to (SV *sv, char * &v) { v = strdup (SvPV_nolen (sv)); } //TODO: verify that all simple pointers are strdup-managed |
158 | 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); } |
159 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
196 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
160 | 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); } |
161 | 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); } |
162 | 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); } |
163 | 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); } |
164 | 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); } |
165 | 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); } |
166 | 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); } |
167 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
|
|
168 | inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
|
|
169 | inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
204 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
170 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
205 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
171 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
206 | inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } |
172 | inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } |
207 | inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } |
173 | inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } |
208 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::archetype"); } |
174 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); } |
209 | inline void sv_to (SV *sv, mapstruct * &v) { v = (mapstruct *)SvPTR_ornull (sv, "cf::map"); } |
175 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)SvPTR_ornull (sv, "cf::map"); } |
210 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
176 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
211 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
177 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
212 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
178 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
213 | |
179 | |
214 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
180 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
215 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
181 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
216 | |
182 | |
|
|
183 | template<class T> |
|
|
184 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
|
|
185 | |
217 | template<int N> |
186 | template<int N> |
218 | inline void sv_to (SV *sv, char (&v)[N]) { snprintf (v, N, "%s", SvPV_nolen (sv)); } |
187 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
|
|
188 | |
|
|
189 | inline void sv_to (SV *sv, UUID &v) |
|
|
190 | { |
|
|
191 | unsigned int version; |
|
|
192 | unsigned long long seq; |
|
|
193 | |
|
|
194 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%llx>", &version, &seq) || 1 != version) |
|
|
195 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
|
|
196 | |
|
|
197 | v.seq = seq; |
|
|
198 | } |
219 | |
199 | |
220 | static SV * |
200 | static SV * |
221 | newSVdt_va (va_list &ap, data_type type) |
201 | newSVdt_va (va_list &ap, data_type type) |
222 | { |
202 | { |
223 | SV *sv; |
203 | SV *sv; |
… | |
… | |
255 | sv = to_sv (va_arg (ap, object *)); |
235 | sv = to_sv (va_arg (ap, object *)); |
256 | break; |
236 | break; |
257 | |
237 | |
258 | case DT_MAP: |
238 | case DT_MAP: |
259 | // va_arg (object *) when void * is passed is an XSI extension |
239 | // va_arg (object *) when void * is passed is an XSI extension |
260 | sv = to_sv (va_arg (ap, mapstruct *)); |
240 | sv = to_sv (va_arg (ap, maptile *)); |
261 | break; |
241 | break; |
262 | |
242 | |
263 | case DT_PLAYER: |
243 | case DT_PLAYER: |
264 | sv = to_sv (va_arg (ap, player *)); |
244 | sv = to_sv (va_arg (ap, player *)); |
265 | break; |
245 | break; |
… | |
… | |
342 | { |
322 | { |
343 | if (cb) |
323 | if (cb) |
344 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
324 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
345 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
325 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
346 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
326 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
347 | INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); |
327 | INVOKE_MAP (DESTROY, static_cast<maptile *>(this)); |
348 | |
328 | |
349 | // disconnect Perl from C, to avoid crashes |
329 | // disconnect Perl from C, to avoid crashes |
350 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
330 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
351 | |
331 | |
352 | // clear the perl hash, might or might not be a good idea |
332 | // clear the perl hash, might or might not be a good idea |
… | |
… | |
480 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
460 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
481 | FREETMPS; |
461 | FREETMPS; |
482 | LEAVE; |
462 | LEAVE; |
483 | } |
463 | } |
484 | |
464 | |
|
|
465 | char *object_freezer::as_string () |
|
|
466 | { |
|
|
467 | dSP; |
|
|
468 | ENTER; |
|
|
469 | SAVETMPS; |
|
|
470 | PUSHMARK (SP); |
|
|
471 | EXTEND (SP, 3); |
|
|
472 | PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ())))); |
|
|
473 | PUSHs (sv_2mortal (newRV_inc ((SV *)av))); |
|
|
474 | PUTBACK; |
|
|
475 | |
|
|
476 | char *res = call_pv ("cf::object_freezer_as_string", G_SCALAR | G_EVAL) > 0 |
|
|
477 | ? strdup (SvPVbyte_nolen (POPs)) |
|
|
478 | : strdup ("[fatal error]"); |
|
|
479 | |
|
|
480 | FREETMPS; |
|
|
481 | LEAVE; |
|
|
482 | |
|
|
483 | return res; |
|
|
484 | } |
|
|
485 | |
485 | int fprintf (object_freezer &freezer, const char *format, ...) |
486 | int fprintf (object_freezer &freezer, const char *format, ...) |
486 | { |
487 | { |
487 | va_list ap; |
488 | va_list ap; |
488 | |
489 | |
489 | va_start (ap, format); |
490 | va_start (ap, format); |
… | |
… | |
498 | |
499 | |
499 | int fputs (const char *s, object_freezer &freezer) |
500 | int fputs (const char *s, object_freezer &freezer) |
500 | { |
501 | { |
501 | freezer.add (s); |
502 | freezer.add (s); |
502 | } |
503 | } |
|
|
504 | |
|
|
505 | static const char thawer_eof[] = "\n\n\n\0\0\0"; |
503 | |
506 | |
504 | object_thawer::object_thawer (const char *filename) |
507 | object_thawer::object_thawer (const char *filename) |
505 | { |
508 | { |
506 | static const char eof[] = "\n\n\n\0\0\0"; |
509 | static const char eof[] = "\n\n\n\0\0\0"; |
507 | |
510 | |
… | |
… | |
545 | |
548 | |
546 | PUTBACK; |
549 | PUTBACK; |
547 | FREETMPS; |
550 | FREETMPS; |
548 | LEAVE; |
551 | LEAVE; |
549 | } |
552 | } |
|
|
553 | } |
|
|
554 | |
|
|
555 | object_thawer::object_thawer (const char *data, AV *perlav) |
|
|
556 | { |
|
|
557 | av = perlav; |
|
|
558 | text = newSVpv (data, 0); |
|
|
559 | sv_catpv (text, thawer_eof); |
|
|
560 | line = SvPVbyte_nolen (text); |
550 | } |
561 | } |
551 | |
562 | |
552 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
563 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
553 | { |
564 | { |
554 | if (!av || oid < 0) // this is actually an error of sorts |
565 | if (!av || oid < 0) // this is actually an error of sorts |
… | |
… | |
870 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
881 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
871 | { |
882 | { |
872 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
883 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
873 | exit (EXIT_FAILURE); |
884 | exit (EXIT_FAILURE); |
874 | } |
885 | } |
875 | |
|
|
876 | obj_cache = newHV (); |
|
|
877 | } |
886 | } |
878 | |
887 | |
879 | void cfperl_main () |
888 | void cfperl_main () |
880 | { |
889 | { |
881 | dSP; |
890 | dSP; |
… | |
… | |
932 | |
941 | |
933 | AV *callbacks = 0; |
942 | AV *callbacks = 0; |
934 | |
943 | |
935 | object *op; |
944 | object *op; |
936 | player *pl; |
945 | player *pl; |
937 | mapstruct *map; |
946 | maptile *map; |
938 | |
947 | |
939 | // callback call ordering is: |
948 | // callback call ordering is: |
940 | // 1. per-object callback (NYI) |
949 | // 1. per-object callback (NYI) |
941 | // 2. per-class object |
950 | // 2. per-class object |
942 | // 2a. per-type callback |
951 | // 2a. per-type callback |
… | |
… | |
992 | break; |
1001 | break; |
993 | |
1002 | |
994 | case KLASS_MAP: |
1003 | case KLASS_MAP: |
995 | dt = (data_type) va_arg (ap, int); |
1004 | dt = (data_type) va_arg (ap, int); |
996 | assert (("first argument must be of type object", dt == DT_MAP)); |
1005 | assert (("first argument must be of type object", dt == DT_MAP)); |
997 | map = va_arg (ap, mapstruct *); |
1006 | map = va_arg (ap, maptile *); |
998 | |
1007 | |
999 | if (map->cb) |
1008 | if (map->cb) |
1000 | gather_callbacks (callbacks, map->cb, event); |
1009 | gather_callbacks (callbacks, map->cb, event); |
1001 | |
1010 | |
1002 | gather_callbacks (callbacks, cb_map, event); |
1011 | gather_callbacks (callbacks, cb_map, event); |
… | |
… | |
1082 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1091 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1083 | |
1092 | |
1084 | BOOT: |
1093 | BOOT: |
1085 | { |
1094 | { |
1086 | HV *stash = gv_stashpv ("cf", 1); |
1095 | HV *stash = gv_stashpv ("cf", 1); |
|
|
1096 | |
|
|
1097 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1087 | |
1098 | |
1088 | static const struct { |
1099 | static const struct { |
1089 | const char *name; |
1100 | const char *name; |
1090 | IV iv; |
1101 | IV iv; |
1091 | } *civ, const_iv[] = { |
1102 | } *civ, const_iv[] = { |
… | |
… | |
1254 | const_iv (AT_BLIND) |
1265 | const_iv (AT_BLIND) |
1255 | const_iv (AT_INTERNAL) |
1266 | const_iv (AT_INTERNAL) |
1256 | const_iv (AT_LIFE_STEALING) |
1267 | const_iv (AT_LIFE_STEALING) |
1257 | const_iv (AT_DISEASE) |
1268 | const_iv (AT_DISEASE) |
1258 | |
1269 | |
1259 | const_iv (QUEST_IN_PROGRESS) |
|
|
1260 | const_iv (QUEST_DONE_QUEST) |
|
|
1261 | const_iv (QUEST_DONE_TASK) |
|
|
1262 | const_iv (QUEST_START_QUEST) |
|
|
1263 | const_iv (QUEST_END_QUEST) |
|
|
1264 | const_iv (QUEST_START_TASK) |
|
|
1265 | const_iv (QUEST_END_TASK) |
|
|
1266 | const_iv (QUEST_OVERRIDE) |
|
|
1267 | const_iv (QUEST_ON_ACTIVATE) |
|
|
1268 | |
|
|
1269 | const_iv (WEAP_HIT) |
1270 | const_iv (WEAP_HIT) |
1270 | const_iv (WEAP_SLASH) |
1271 | const_iv (WEAP_SLASH) |
1271 | const_iv (WEAP_PIERCE) |
1272 | const_iv (WEAP_PIERCE) |
1272 | const_iv (WEAP_CLEAVE) |
1273 | const_iv (WEAP_CLEAVE) |
1273 | const_iv (WEAP_SLICE) |
1274 | const_iv (WEAP_SLICE) |
… | |
… | |
1394 | const_iv (NDI_MAX_COLOR) |
1395 | const_iv (NDI_MAX_COLOR) |
1395 | const_iv (NDI_COLOR_MASK) |
1396 | const_iv (NDI_COLOR_MASK) |
1396 | const_iv (NDI_UNIQUE) |
1397 | const_iv (NDI_UNIQUE) |
1397 | const_iv (NDI_ALL) |
1398 | const_iv (NDI_ALL) |
1398 | |
1399 | |
|
|
1400 | const_iv (UPD_LOCATION) |
|
|
1401 | const_iv (UPD_FLAGS) |
|
|
1402 | const_iv (UPD_WEIGHT) |
|
|
1403 | const_iv (UPD_FACE) |
|
|
1404 | const_iv (UPD_NAME) |
|
|
1405 | const_iv (UPD_ANIM) |
|
|
1406 | const_iv (UPD_ANIMSPEED) |
|
|
1407 | const_iv (UPD_NROF) |
|
|
1408 | |
|
|
1409 | const_iv (UPD_SP_MANA) |
|
|
1410 | const_iv (UPD_SP_GRACE) |
|
|
1411 | const_iv (UPD_SP_DAMAGE) |
|
|
1412 | |
1399 | const_iv (F_APPLIED) |
1413 | const_iv (F_APPLIED) |
1400 | const_iv (F_LOCATION) |
1414 | const_iv (F_LOCATION) |
1401 | const_iv (F_UNPAID) |
1415 | const_iv (F_UNPAID) |
1402 | const_iv (F_MAGIC) |
1416 | const_iv (F_MAGIC) |
1403 | const_iv (F_CURSED) |
1417 | const_iv (F_CURSED) |
… | |
… | |
1601 | } |
1615 | } |
1602 | |
1616 | |
1603 | //I_EVENT_API (PACKAGE); |
1617 | //I_EVENT_API (PACKAGE); |
1604 | } |
1618 | } |
1605 | |
1619 | |
1606 | void _reload_1 () |
1620 | void _init_vars () |
1607 | CODE: |
1621 | CODE: |
1608 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1622 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1609 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1623 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1610 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1624 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1611 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1625 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1612 | cb_map = get_av ("cf::CB_MAP" , 1); |
1626 | cb_map = get_av ("cf::CB_MAP" , 1); |
1613 | |
1627 | |
1614 | void _reload_2 () |
1628 | void _global_reattach () |
1615 | CODE: |
1629 | CODE: |
1616 | { |
1630 | { |
1617 | // reattach to all attachable objects in the game. |
1631 | // reattach to all attachable objects in the game. |
1618 | for (player *pl = first_player; pl; pl = pl->next) |
1632 | for (player *pl = first_player; pl; pl = pl->next) |
1619 | reattach (pl); |
1633 | reattach (pl); |
1620 | |
1634 | |
1621 | for (mapstruct *map = first_map; map; map = map->next) |
1635 | for (maptile *map = first_map; map; map = map->next) |
1622 | reattach (map); |
1636 | reattach (map); |
1623 | |
1637 | |
1624 | for (object *op = objects; op; op = op->next) |
1638 | for (object *op = object::first; op; op = op->next) |
1625 | reattach (op); |
1639 | reattach (op); |
1626 | } |
1640 | } |
1627 | |
1641 | |
1628 | NV floor (NV x) |
1642 | NV floor (NV x) |
1629 | |
1643 | |
… | |
… | |
1677 | case 5: RETVAL = settings.playerdir; break; |
1691 | case 5: RETVAL = settings.playerdir; break; |
1678 | case 6: RETVAL = settings.datadir ; break; |
1692 | case 6: RETVAL = settings.datadir ; break; |
1679 | } |
1693 | } |
1680 | OUTPUT: RETVAL |
1694 | OUTPUT: RETVAL |
1681 | |
1695 | |
1682 | int |
1696 | void _exit (int status = 0) |
|
|
1697 | |
1683 | cf_find_animation (char *text) |
1698 | int cf_find_animation (char *text) |
1684 | PROTOTYPE: $ |
1699 | PROTOTYPE: $ |
1685 | |
1700 | |
1686 | int random_roll(int min, int max, object *op, int goodbad); |
1701 | int random_roll(int min, int max, object *op, int goodbad); |
1687 | |
1702 | |
1688 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1703 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
… | |
… | |
1741 | OUTPUT: |
1756 | OUTPUT: |
1742 | RETVAL |
1757 | RETVAL |
1743 | |
1758 | |
1744 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1759 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1745 | |
1760 | |
|
|
1761 | INCLUDE: $PERL genacc object ../include/object.h | |
|
|
1762 | |
1746 | int invoke (object *op, int event, ...) |
1763 | int invoke (object *op, int event, ...) |
1747 | CODE: |
1764 | CODE: |
1748 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1765 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1749 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1766 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1750 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1767 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
… | |
… | |
1755 | CODE: |
1772 | CODE: |
1756 | RETVAL = registry_of (op); |
1773 | RETVAL = registry_of (op); |
1757 | OUTPUT: |
1774 | OUTPUT: |
1758 | RETVAL |
1775 | RETVAL |
1759 | |
1776 | |
1760 | INCLUDE: $PERL genacc object ../include/object.h | |
1777 | void mortals () |
|
|
1778 | PPCODE: |
|
|
1779 | EXTEND (SP, object::mortals.size ()); |
|
|
1780 | for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i) |
|
|
1781 | PUSHs (to_sv (*i)); |
|
|
1782 | |
|
|
1783 | object *first () |
|
|
1784 | CODE: |
|
|
1785 | RETVAL = object::first; |
|
|
1786 | OUTPUT: RETVAL |
1761 | |
1787 | |
1762 | # missing properties |
1788 | # missing properties |
1763 | |
|
|
1764 | void |
|
|
1765 | set_attacktype (object *obj, U32 attacktype) |
|
|
1766 | CODE: |
|
|
1767 | obj->attacktype = attacktype; |
|
|
1768 | |
|
|
1769 | U32 |
|
|
1770 | get_attacktype (object *obj) |
|
|
1771 | ALIAS: |
|
|
1772 | attacktype = 0 |
|
|
1773 | CODE: |
|
|
1774 | RETVAL = obj->attacktype; |
|
|
1775 | OUTPUT: RETVAL |
|
|
1776 | |
1789 | |
1777 | int flag (object *op, int flag, int value = 1) |
1790 | int flag (object *op, int flag, int value = 1) |
1778 | PROTOTYPE: $$;$ |
1791 | PROTOTYPE: $$;$ |
1779 | CODE: |
1792 | CODE: |
1780 | RETVAL = QUERY_FLAG (op, flag); |
1793 | RETVAL = QUERY_FLAG (op, flag); |
… | |
… | |
1783 | SET_FLAG (op, flag); |
1796 | SET_FLAG (op, flag); |
1784 | else |
1797 | else |
1785 | CLEAR_FLAG (op, flag); |
1798 | CLEAR_FLAG (op, flag); |
1786 | OUTPUT: RETVAL |
1799 | OUTPUT: RETVAL |
1787 | |
1800 | |
|
|
1801 | object *head (object *op) |
|
|
1802 | PROTOTYPE: $ |
|
|
1803 | CODE: |
|
|
1804 | RETVAL = op->head ? op->head : op; |
|
|
1805 | OUTPUT: RETVAL |
|
|
1806 | |
|
|
1807 | int is_head (object *op) |
|
|
1808 | PROTOTYPE: $ |
|
|
1809 | CODE: |
|
|
1810 | RETVAL = !op->head; |
|
|
1811 | OUTPUT: RETVAL |
|
|
1812 | |
1788 | void |
1813 | void |
1789 | inv (object *obj) |
1814 | inv (object *obj) |
1790 | PROTOTYPE: $ |
1815 | PROTOTYPE: $ |
1791 | PPCODE: |
1816 | PPCODE: |
1792 | { |
1817 | { |
1793 | object *o; |
1818 | object *o; |
1794 | for (o = obj->inv; o; o = o->below) |
1819 | for (o = obj->inv; o; o = o->below) |
1795 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1820 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1796 | } |
1821 | } |
1797 | |
1822 | |
|
|
1823 | object *find_best_object_match (object *op, const char *match) |
|
|
1824 | |
|
|
1825 | object *find_marked_object (object *op) |
|
|
1826 | |
1798 | int cf_object_get_resistance (object *op, int rtype) |
1827 | int cf_object_get_resistance (object *op, int rtype) |
1799 | ALIAS: resistance = 0 |
1828 | ALIAS: resistance = 0 |
1800 | |
1829 | |
1801 | int need_identify (const object *obj); |
1830 | int need_identify (const object *obj); |
1802 | |
1831 | |
… | |
… | |
1818 | |
1847 | |
1819 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1848 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1820 | |
1849 | |
1821 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1850 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1822 | |
1851 | |
1823 | int cf_object_change_map (object *op, int x, int y, mapstruct *map) |
1852 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1824 | |
1853 | |
1825 | object *cf_object_clone (object *op, int clonetype = 0) |
1854 | object *cf_object_clone (object *op, int clonetype = 0) |
1826 | |
1855 | |
1827 | int cf_object_pay_item (object *op, object *buyer) |
1856 | int cf_object_pay_item (object *op, object *buyer) |
1828 | |
1857 | |
… | |
… | |
1860 | |
1889 | |
1861 | object *cf_object_insert_object (object *op, object *container) |
1890 | object *cf_object_insert_object (object *op, object *container) |
1862 | |
1891 | |
1863 | object *cf_object_insert_in_ob (object *ob, object *where) |
1892 | object *cf_object_insert_in_ob (object *ob, object *where) |
1864 | |
1893 | |
1865 | int cf_object_teleport (object *op, mapstruct *map, int x, int y) |
1894 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1866 | |
1895 | |
1867 | void cf_object_update (object *op, int flags) |
1896 | void cf_object_update (object *op, int flags) |
1868 | |
1897 | |
1869 | void cf_object_pickup (object *op, object *what) |
1898 | void cf_object_pickup (object *op, object *what) |
1870 | |
1899 | |
… | |
… | |
1880 | |
1909 | |
1881 | void push_button (object *op); |
1910 | void push_button (object *op); |
1882 | |
1911 | |
1883 | void use_trigger (object *op); |
1912 | void use_trigger (object *op); |
1884 | |
1913 | |
1885 | void add_button_link (object *button, mapstruct *map, int connected); |
1914 | void add_button_link (object *button, maptile *map, int connected); |
1886 | |
1915 | |
1887 | void remove_button_link (object *op); |
1916 | void remove_button_link (object *op); |
1888 | |
1917 | |
1889 | void |
1918 | void |
1890 | cf_object_set_resistance (object *op, int rtype, int val) |
1919 | cf_object_set_resistance (object *op, int rtype, int val) |
… | |
… | |
1908 | CODE: |
1937 | CODE: |
1909 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
1938 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
1910 | OUTPUT: |
1939 | OUTPUT: |
1911 | RETVAL |
1940 | RETVAL |
1912 | |
1941 | |
1913 | object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) |
1942 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
1914 | PROTOTYPE: $$$$$$ |
1943 | PROTOTYPE: $$$$$$ |
1915 | CODE: |
1944 | CODE: |
1916 | { |
1945 | { |
1917 | int unused_type; |
1946 | int unused_type; |
1918 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
1947 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
… | |
… | |
1956 | bool on_same_map_as (object *ob, object *other) |
1985 | bool on_same_map_as (object *ob, object *other) |
1957 | CODE: |
1986 | CODE: |
1958 | RETVAL = on_same_map (ob, other); |
1987 | RETVAL = on_same_map (ob, other); |
1959 | OUTPUT: RETVAL |
1988 | OUTPUT: RETVAL |
1960 | |
1989 | |
1961 | char * |
1990 | const char * |
1962 | base_name (object *ob, int plural) |
1991 | base_name (object *op, int plural = op->nrof > 1) |
1963 | CODE: |
1992 | CODE: |
1964 | RETVAL = cf_query_base_name (ob, plural); |
1993 | RETVAL = query_base_name (op, plural); |
1965 | OUTPUT: RETVAL |
1994 | OUTPUT: RETVAL |
1966 | |
1995 | |
1967 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
1996 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
1968 | |
1997 | |
1969 | player *player (object *op) |
1998 | player *player (object *op) |
… | |
… | |
1988 | |
2017 | |
1989 | void cf_player_set_party (object *op, partylist *party) |
2018 | void cf_player_set_party (object *op, partylist *party) |
1990 | |
2019 | |
1991 | void kill_player (object *op) |
2020 | void kill_player (object *op) |
1992 | |
2021 | |
|
|
2022 | void esrv_update_item (object *op, int what, object *item) |
|
|
2023 | C_ARGS: what, op, item |
|
|
2024 | |
|
|
2025 | void clear_los (object *op) |
|
|
2026 | |
|
|
2027 | int command_reset (object *op, char *params) |
|
|
2028 | |
|
|
2029 | int command_teleport (object *op, char *params) |
|
|
2030 | |
|
|
2031 | int command_summon (object *op, char *params) |
|
|
2032 | |
|
|
2033 | int command_arrest (object *op, char *params) |
|
|
2034 | |
|
|
2035 | int command_kick (object *op, char *params) |
|
|
2036 | |
|
|
2037 | int command_banish (object *op, char *params) |
|
|
2038 | |
|
|
2039 | |
1993 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2040 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
|
|
2041 | |
|
|
2042 | INCLUDE: $PERL genacc player ../include/newserver.h ../include/player.h | |
|
|
2043 | |
|
|
2044 | char * |
|
|
2045 | client (player *pl) |
|
|
2046 | CODE: |
|
|
2047 | RETVAL = pl->socket.client; |
|
|
2048 | OUTPUT: |
|
|
2049 | RETVAL |
|
|
2050 | |
|
|
2051 | char * |
|
|
2052 | host (player *pl) |
|
|
2053 | CODE: |
|
|
2054 | RETVAL = pl->socket.host; |
|
|
2055 | OUTPUT: |
|
|
2056 | RETVAL |
1994 | |
2057 | |
1995 | int invoke (player *pl, int event, ...) |
2058 | int invoke (player *pl, int event, ...) |
1996 | CODE: |
2059 | CODE: |
1997 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2060 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
1998 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2061 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
… | |
… | |
2011 | |
2074 | |
2012 | void cf_player_move (player *pl, int dir) |
2075 | void cf_player_move (player *pl, int dir) |
2013 | |
2076 | |
2014 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2077 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2015 | |
2078 | |
2016 | # nonstandard |
|
|
2017 | object *ob (player *pl) |
|
|
2018 | CODE: |
|
|
2019 | RETVAL = pl->ob; |
|
|
2020 | OUTPUT: RETVAL |
|
|
2021 | |
|
|
2022 | player *first () |
2079 | player *first () |
2023 | CODE: |
2080 | CODE: |
2024 | RETVAL = first_player; |
2081 | RETVAL = first_player; |
2025 | OUTPUT: RETVAL |
2082 | OUTPUT: RETVAL |
2026 | |
2083 | |
… | |
… | |
2032 | bool |
2089 | bool |
2033 | cell_visible (player *pl, int dx, int dy) |
2090 | cell_visible (player *pl, int dx, int dy) |
2034 | CODE: |
2091 | CODE: |
2035 | RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 |
2092 | RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 |
2036 | && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; |
2093 | && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; |
2037 | OUTPUT: |
|
|
2038 | RETVAL |
|
|
2039 | |
|
|
2040 | char * |
|
|
2041 | client (player *pl) |
|
|
2042 | CODE: |
|
|
2043 | RETVAL = pl->socket.client; |
|
|
2044 | OUTPUT: |
|
|
2045 | RETVAL |
|
|
2046 | |
|
|
2047 | char * |
|
|
2048 | host (player *pl) |
|
|
2049 | CODE: |
|
|
2050 | RETVAL = pl->socket.host; |
|
|
2051 | OUTPUT: |
|
|
2052 | RETVAL |
|
|
2053 | |
|
|
2054 | char * |
|
|
2055 | killer (player *pl, char *killer = 0) |
|
|
2056 | CODE: |
|
|
2057 | if (killer) |
|
|
2058 | snprintf (pl->killer, sizeof (pl->killer), "%s", killer); |
|
|
2059 | RETVAL = pl->killer; |
|
|
2060 | OUTPUT: |
2094 | OUTPUT: |
2061 | RETVAL |
2095 | RETVAL |
2062 | |
2096 | |
2063 | void |
2097 | void |
2064 | buggy_mapscroll (player *pl, int value = 1) |
2098 | buggy_mapscroll (player *pl, int value = 1) |
… | |
… | |
2082 | if (new_value >= 0) |
2116 | if (new_value >= 0) |
2083 | pl->listening = new_value; |
2117 | pl->listening = new_value; |
2084 | OUTPUT: |
2118 | OUTPUT: |
2085 | RETVAL |
2119 | RETVAL |
2086 | |
2120 | |
2087 | void savebed (player *pl, char *map_path = 0, int x = -1, int y = -1) |
2121 | void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) |
2088 | PROTOTYPE: $;$$$ |
2122 | PROTOTYPE: $;$$$ |
2089 | ALIAS: |
|
|
2090 | savebed = 0 |
|
|
2091 | PPCODE: |
2123 | PPCODE: |
2092 | if (GIMME_V != G_VOID) |
2124 | if (GIMME_V != G_VOID) |
2093 | { |
2125 | { |
2094 | EXTEND (SP, 3); |
2126 | EXTEND (SP, 3); |
2095 | PUSHs (sv_2mortal (newSVpv (pl->savebed_map, 0))); |
2127 | PUSHs (sv_2mortal (newSVpv (pl->savebed_map, 0))); |
2096 | PUSHs (sv_2mortal (newSViv (pl->bed_x))); |
2128 | PUSHs (sv_2mortal (newSViv (pl->bed_x))); |
2097 | PUSHs (sv_2mortal (newSViv (pl->bed_y))); |
2129 | PUSHs (sv_2mortal (newSViv (pl->bed_y))); |
2098 | } |
2130 | } |
2099 | if (map_path) strcpy (pl->savebed_map, map_path); |
2131 | if (map_path) sv_to (map_path, pl->savebed_map); |
2100 | if (x >= 0) pl->bed_x = x; |
2132 | if (x) sv_to (x, pl->bed_x); |
2101 | if (y >= 0) pl->bed_y = y; |
2133 | if (y) sv_to (y, pl->bed_y); |
2102 | |
2134 | |
2103 | void |
2135 | void |
2104 | list () |
2136 | list () |
2105 | PPCODE: |
2137 | PPCODE: |
2106 | { |
2138 | { |
… | |
… | |
2132 | OUTPUT: RETVAL |
2164 | OUTPUT: RETVAL |
2133 | |
2165 | |
2134 | |
2166 | |
2135 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2167 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2136 | |
2168 | |
2137 | mapstruct *first () |
2169 | maptile *first () |
2138 | PROTOTYPE: |
2170 | PROTOTYPE: |
2139 | CODE: |
2171 | CODE: |
2140 | RETVAL = first_map; |
2172 | RETVAL = first_map; |
2141 | OUTPUT: RETVAL |
2173 | OUTPUT: RETVAL |
2142 | |
2174 | |
2143 | int invoke (mapstruct *map, int event, ...) |
2175 | int invoke (maptile *map, int event, ...) |
2144 | CODE: |
2176 | CODE: |
2145 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
2177 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
2146 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2178 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2147 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2179 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2148 | RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); |
2180 | RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); |
2149 | OUTPUT: RETVAL |
2181 | OUTPUT: RETVAL |
2150 | |
2182 | |
2151 | SV *registry (mapstruct *map) |
2183 | SV *registry (maptile *map) |
2152 | CODE: |
2184 | CODE: |
2153 | RETVAL = registry_of (map); |
2185 | RETVAL = registry_of (map); |
2154 | OUTPUT: |
2186 | OUTPUT: |
2155 | RETVAL |
2187 | RETVAL |
2156 | |
2188 | |
2157 | INCLUDE: $PERL genacc mapstruct ../include/map.h | |
2189 | INCLUDE: $PERL genacc maptile ../include/map.h | |
2158 | |
2190 | |
2159 | mapstruct *new (int width, int height) |
2191 | maptile *new (int width, int height) |
2160 | PROTOTYPE: |
2192 | PROTOTYPE: |
2161 | CODE: |
2193 | CODE: |
2162 | { |
2194 | { |
2163 | RETVAL = get_empty_map (width, height); |
2195 | RETVAL = get_empty_map (width, height); |
2164 | } |
2196 | } |
2165 | OUTPUT: |
2197 | OUTPUT: |
2166 | RETVAL |
2198 | RETVAL |
2167 | |
2199 | |
2168 | void delete_map (mapstruct *map) |
2200 | void delete_map (maptile *map) |
2169 | |
2201 | |
2170 | void clean_tmp_map (mapstruct *map) |
2202 | void clean_tmp_map (maptile *map) |
2171 | |
2203 | |
2172 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
2204 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
2173 | |
2205 | |
2174 | mapstruct *tile_map (mapstruct *map, unsigned int dir) |
2206 | maptile *tile_map (maptile *map, unsigned int dir) |
2175 | CODE: |
2207 | CODE: |
2176 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
2208 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
2177 | OUTPUT: |
2209 | OUTPUT: |
2178 | RETVAL |
2210 | RETVAL |
2179 | |
2211 | |
2180 | char *tile_path (mapstruct *map, unsigned int dir) |
2212 | char *tile_path (maptile *map, unsigned int dir) |
2181 | CODE: |
2213 | CODE: |
2182 | if (dir >= 4) |
2214 | if (dir >= 4) |
2183 | XSRETURN_UNDEF; |
2215 | XSRETURN_UNDEF; |
2184 | RETVAL = map->tile_path [dir]; |
2216 | RETVAL = map->tile_path [dir]; |
2185 | OUTPUT: |
2217 | OUTPUT: |
2186 | RETVAL |
2218 | RETVAL |
2187 | |
2219 | |
2188 | mapstruct *ready_map_name (char *name, int flags = 0) |
2220 | maptile *ready_map_name (char *name, int flags = 0) |
2189 | PROTOTYPE: $;$ |
2221 | PROTOTYPE: $;$ |
2190 | ALIAS: |
2222 | ALIAS: |
2191 | find = 0 |
2223 | find = 0 |
2192 | get_map = 1 |
2224 | get_map = 1 |
2193 | |
2225 | |
2194 | mapstruct *has_been_loaded (char *name) |
2226 | maptile *has_been_loaded (char *name) |
2195 | PROTOTYPE: $ |
2227 | PROTOTYPE: $ |
2196 | |
2228 | |
2197 | int in_memory (mapstruct *map) |
2229 | int in_memory (maptile *map) |
2198 | CODE: |
2230 | CODE: |
2199 | RETVAL = map->in_memory; |
2231 | RETVAL = map->in_memory; |
2200 | OUTPUT: |
2232 | OUTPUT: |
2201 | RETVAL |
2233 | RETVAL |
2202 | |
2234 | |
2203 | bool unique (mapstruct *map) |
|
|
2204 | CODE: |
|
|
2205 | RETVAL = map->unique; |
|
|
2206 | OUTPUT: |
|
|
2207 | RETVAL |
|
|
2208 | |
|
|
2209 | void set_unique (mapstruct *map, bool unique) |
|
|
2210 | CODE: |
|
|
2211 | map->unique = unique; |
|
|
2212 | |
|
|
2213 | void |
2235 | void |
2214 | trigger (mapstruct *map, long connection, bool state = true) |
2236 | trigger (maptile *map, long connection, bool state = true) |
2215 | CODE: |
2237 | CODE: |
2216 | activate_connection (map, connection, state); |
2238 | activate_connection (map, connection, state); |
2217 | |
2239 | |
2218 | void |
2240 | void |
2219 | get_connection (mapstruct *map, long connection) |
2241 | get_connection (maptile *map, long connection) |
2220 | PPCODE: |
2242 | PPCODE: |
2221 | oblinkpt *obp = get_connection_links (map, connection); |
2243 | oblinkpt *obp = get_connection_links (map, connection); |
2222 | if (obp) |
2244 | if (obp) |
2223 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2245 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2224 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); |
2246 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, (object *)ol->ob))); |
2225 | |
2247 | |
2226 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
2248 | object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags) |
2227 | |
2249 | |
2228 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
2250 | object *cf_map_insert_object (maptile *where, object* op, int x, int y) |
2229 | |
2251 | |
2230 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
2252 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2231 | C_ARGS: str, map, nx, ny |
2253 | C_ARGS: str, map, nx, ny |
2232 | |
2254 | |
2233 | void |
2255 | void |
2234 | cf_map_normalise (mapstruct *map, int x, int y) |
2256 | cf_map_normalise (maptile *map, int x, int y) |
2235 | PPCODE: |
2257 | PPCODE: |
2236 | { |
2258 | { |
2237 | mapstruct *nmap = 0; |
2259 | maptile *nmap = 0; |
2238 | I16 nx = 0, ny = 0; |
2260 | I16 nx = 0, ny = 0; |
2239 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2261 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2240 | |
2262 | |
2241 | EXTEND (SP, 4); |
2263 | EXTEND (SP, 4); |
2242 | PUSHs (sv_2mortal (newSViv (flags))); |
2264 | PUSHs (sv_2mortal (newSViv (flags))); |
… | |
… | |
2248 | PUSHs (sv_2mortal (newSViv (ny))); |
2270 | PUSHs (sv_2mortal (newSViv (ny))); |
2249 | } |
2271 | } |
2250 | } |
2272 | } |
2251 | |
2273 | |
2252 | void |
2274 | void |
2253 | at (mapstruct *map, unsigned int x, unsigned int y) |
2275 | at (maptile *map, unsigned int x, unsigned int y) |
2254 | PROTOTYPE: $$$ |
2276 | PROTOTYPE: $$$ |
2255 | PPCODE: |
2277 | PPCODE: |
2256 | { |
2278 | { |
2257 | object *o; |
2279 | object *o; |
2258 | mapstruct *nmap = 0; |
2280 | maptile *nmap = 0; |
2259 | I16 nx, ny; |
2281 | I16 nx, ny; |
2260 | |
2282 | |
2261 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2283 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2262 | |
2284 | |
2263 | if (nmap) |
2285 | if (nmap) |
2264 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2286 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2265 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2287 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2266 | } |
2288 | } |
2267 | |
2289 | |
2268 | SV * |
2290 | SV * |
2269 | bot_at (mapstruct *obj, unsigned int x, unsigned int y) |
2291 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2270 | PROTOTYPE: $$$ |
2292 | PROTOTYPE: $$$ |
2271 | ALIAS: |
2293 | ALIAS: |
2272 | top_at = 1 |
2294 | top_at = 1 |
2273 | flags_at = 2 |
2295 | flags_at = 2 |
2274 | light_at = 3 |
2296 | light_at = 3 |
… | |
… | |
2291 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2313 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2292 | } |
2314 | } |
2293 | OUTPUT: |
2315 | OUTPUT: |
2294 | RETVAL |
2316 | RETVAL |
2295 | |
2317 | |
|
|
2318 | void fix_walls (maptile *map, int x, int y) |
|
|
2319 | |
|
|
2320 | void fix_walls_around (maptile *map, int x, int y) |
2296 | |
2321 | |
2297 | MODULE = cf PACKAGE = cf::arch |
2322 | MODULE = cf PACKAGE = cf::arch |
2298 | |
2323 | |
2299 | archetype *find (const char *name) |
2324 | archetype *find (const char *name) |
2300 | CODE: |
2325 | CODE: |
2301 | RETVAL = find_archetype (name); |
2326 | RETVAL = archetype::find (name); |
2302 | OUTPUT: |
2327 | OUTPUT: |
2303 | RETVAL |
2328 | RETVAL |
2304 | |
2329 | |
2305 | archetype *first() |
2330 | archetype *first() |
2306 | PROTOTYPE: |
2331 | PROTOTYPE: |