… | |
… | |
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 | #if IVSIZE >= 8 |
|
|
49 | typedef IV val64; |
|
|
50 | # define newSVval64 newSViv |
|
|
51 | # define SvVAL64 SvIV |
|
|
52 | #else |
48 | typedef double val64; |
53 | typedef double val64; |
49 | #define newSVval64 newSVnv |
54 | # define newSVval64 newSVnv |
50 | #define SvVAL64 SvNV |
55 | # define SvVAL64 SvNV |
|
|
56 | #endif |
51 | |
57 | |
52 | static f_plug_api gethook = cfapi_get_hooks; |
58 | static f_plug_api gethook = cfapi_get_hooks; |
53 | static f_plug_api object_set_property = cfapi_object_set_property; |
59 | static f_plug_api object_set_property = cfapi_object_set_property; |
54 | static f_plug_api object_insert = cfapi_object_insert; |
60 | static f_plug_api object_insert = cfapi_object_insert; |
55 | |
61 | |
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; |
|
|
73 | static PerlInterpreter *perl; |
62 | static PerlInterpreter *perl; |
74 | |
63 | |
75 | static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; |
64 | static AV *cb_global, *cb_object, *cb_player, *cb_client, *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 | |
65 | |
85 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
66 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
86 | |
67 | |
87 | static SV * |
68 | static SV * |
88 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
69 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
… | |
… | |
105 | |
86 | |
106 | if (!obj->self) |
87 | if (!obj->self) |
107 | obj->self = newSVptr (obj, klass); |
88 | obj->self = newSVptr (obj, klass); |
108 | |
89 | |
109 | return newSVsv (obj->self); |
90 | return newSVsv (obj->self); |
110 | } |
|
|
111 | |
|
|
112 | static void |
|
|
113 | SVptr_cache_set (void *ptr, SV *sv) |
|
|
114 | { |
|
|
115 | hv_store (obj_cache, (char *)&ptr, sizeof (ptr), sv, 0); |
|
|
116 | } |
|
|
117 | |
|
|
118 | static SV * |
|
|
119 | SVptr_cache_get (void *ptr) |
|
|
120 | { |
|
|
121 | SV **he = hv_fetch (obj_cache, (char *)&ptr, sizeof (ptr), 0); |
|
|
122 | |
|
|
123 | return he ? *he : 0; |
|
|
124 | } |
|
|
125 | |
|
|
126 | static SV * |
|
|
127 | newSVptr_cached (void *ptr, const char *klass) |
|
|
128 | { |
|
|
129 | SV *sv; |
|
|
130 | |
|
|
131 | if (!ptr) |
|
|
132 | return &PL_sv_undef; |
|
|
133 | |
|
|
134 | sv = SVptr_cache_get (ptr); |
|
|
135 | |
|
|
136 | if (!sv) |
|
|
137 | { |
|
|
138 | HV *hv = newHV (); |
|
|
139 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
|
|
140 | sv = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
141 | |
|
|
142 | SVptr_cache_set (ptr, sv); |
|
|
143 | } |
|
|
144 | |
|
|
145 | return newSVsv (sv); |
|
|
146 | } |
91 | } |
147 | |
92 | |
148 | static void |
93 | static void |
149 | clearSVptr (SV *sv) |
94 | clearSVptr (SV *sv) |
150 | { |
95 | { |
… | |
… | |
174 | { |
119 | { |
175 | if (SvOK (sv)) |
120 | if (SvOK (sv)) |
176 | return SvPTR (sv, klass); |
121 | return SvPTR (sv, klass); |
177 | else |
122 | else |
178 | return 0; |
123 | return 0; |
|
|
124 | } |
|
|
125 | |
|
|
126 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn ((const char *)v, v.length ()) : &PL_sv_undef; } |
|
|
127 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
|
|
128 | inline SV *to_sv (bool v) { return newSViv (v); } |
|
|
129 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
|
|
130 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
|
|
131 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
|
|
132 | inline SV *to_sv (unsigned short v) { return newSVuv (v); } |
|
|
133 | inline SV *to_sv ( signed int v) { return newSViv (v); } |
|
|
134 | inline SV *to_sv (unsigned int v) { return newSVuv (v); } |
|
|
135 | inline SV *to_sv ( signed long v) { return newSViv (v); } |
|
|
136 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
|
|
137 | inline SV *to_sv ( signed long long v) { return newSVval64 (v); } |
|
|
138 | inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
|
|
139 | inline SV *to_sv (float v) { return newSVnv (v); } |
|
|
140 | inline SV *to_sv (double v) { return newSVnv (v); } |
|
|
141 | inline SV *to_sv (client * v) { return newSVattachable (v, "cf::client::wrap"); } |
|
|
142 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
|
|
143 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
|
|
144 | inline SV *to_sv (maptile * v) { return newSVattachable (v, "cf::map::wrap"); } |
|
|
145 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); } |
|
|
146 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
|
|
147 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
|
|
148 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
|
|
149 | |
|
|
150 | inline SV *to_sv (object & v) { return to_sv (&v); } |
|
|
151 | inline SV *to_sv (living & v) { return to_sv (&v); } |
|
|
152 | |
|
|
153 | //TODO: |
|
|
154 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
|
|
155 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
|
|
156 | |
|
|
157 | inline SV *to_sv (UUID v) |
|
|
158 | { |
|
|
159 | char buf[128]; |
|
|
160 | snprintf (buf, 128, "<1,%" PRIx64 ">", v.seq); |
|
|
161 | return newSVpv (buf, 0); |
|
|
162 | } |
|
|
163 | |
|
|
164 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
|
|
165 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
|
|
166 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
|
|
167 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
|
|
168 | inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } |
|
|
169 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
|
|
170 | inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } |
|
|
171 | inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } |
|
|
172 | inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } |
|
|
173 | inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } |
|
|
174 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
|
|
175 | inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
|
|
176 | inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
|
|
177 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
|
|
178 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
|
|
179 | inline void sv_to (SV *sv, client * &v) { v = (client *)SvPTR_ornull (sv, "cf::client"); } |
|
|
180 | inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } |
|
|
181 | inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } |
|
|
182 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); } |
|
|
183 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)SvPTR_ornull (sv, "cf::map"); } |
|
|
184 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
|
|
185 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
|
|
186 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
|
|
187 | |
|
|
188 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
|
|
189 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
|
|
190 | |
|
|
191 | template<class T> |
|
|
192 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
|
|
193 | |
|
|
194 | template<int N> |
|
|
195 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
|
|
196 | |
|
|
197 | inline void sv_to (SV *sv, UUID &v) |
|
|
198 | { |
|
|
199 | unsigned int version; |
|
|
200 | |
|
|
201 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
|
|
202 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
179 | } |
203 | } |
180 | |
204 | |
181 | static SV * |
205 | static SV * |
182 | newSVdt_va (va_list &ap, data_type type) |
206 | newSVdt_va (va_list &ap, data_type type) |
183 | { |
207 | { |
… | |
… | |
211 | sv = str ? newSVpv (str, len) : &PL_sv_undef; |
235 | sv = str ? newSVpv (str, len) : &PL_sv_undef; |
212 | } |
236 | } |
213 | break; |
237 | break; |
214 | |
238 | |
215 | case DT_OBJECT: |
239 | case DT_OBJECT: |
216 | { |
240 | 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; |
241 | break; |
221 | |
242 | |
222 | case DT_MAP: |
243 | case DT_MAP: |
223 | // va_arg (object *) when void * is passed is an XSI extension |
244 | // va_arg (object *) when void * is passed is an XSI extension |
224 | sv = newSVattachable (va_arg (ap, mapstruct *), "cf::map::wrap"); |
245 | sv = to_sv (va_arg (ap, maptile *)); |
225 | break; |
246 | break; |
226 | |
247 | |
|
|
248 | case DT_CLIENT: |
|
|
249 | sv = to_sv (va_arg (ap, client *)); |
|
|
250 | break; |
|
|
251 | |
227 | case DT_PLAYER: |
252 | case DT_PLAYER: |
228 | sv = newSVattachable (va_arg (ap, player *), "cf::player::wrap"); |
253 | sv = to_sv (va_arg (ap, player *)); |
229 | break; |
254 | break; |
230 | |
255 | |
231 | case DT_ARCH: |
256 | case DT_ARCH: |
232 | sv = newSVptr (va_arg (ap, archetype *), "cf::arch::wrap"); |
257 | sv = to_sv (va_arg (ap, archetype *)); |
233 | break; |
258 | break; |
234 | |
259 | |
235 | case DT_PARTY: |
260 | case DT_PARTY: |
236 | sv = newSVptr (va_arg (ap, partylist *), "cf::party::wrap"); |
261 | sv = to_sv (va_arg (ap, partylist *)); |
237 | break; |
262 | break; |
238 | |
263 | |
239 | case DT_REGION: |
264 | case DT_REGION: |
240 | sv = newSVptr (va_arg (ap, region *), "cf::region::wrap"); |
265 | sv = to_sv (va_arg (ap, region *)); |
241 | break; |
266 | break; |
242 | |
267 | |
243 | default: |
268 | default: |
244 | assert (("unhandled type in newSVdt_va", 0)); |
269 | assert (("unhandled type in newSVdt_va", 0)); |
245 | } |
270 | } |
… | |
… | |
290 | } |
315 | } |
291 | |
316 | |
292 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
317 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
293 | |
318 | |
294 | SV * |
319 | SV * |
295 | registry_of (attachable_base *ext) |
320 | registry (attachable_base *ext) |
296 | { |
321 | { |
297 | if (!ext->cb) |
322 | if (!ext->cb) |
298 | ext->cb = newAV (); |
323 | ext->cb = newAV (); |
299 | |
324 | |
300 | return newRV_inc ((SV *)ext->cb); |
325 | return newRV_inc ((SV *)ext->cb); |
… | |
… | |
306 | { |
331 | { |
307 | if (cb) |
332 | if (cb) |
308 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
333 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
309 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
334 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
310 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
335 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
311 | INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); |
336 | INVOKE_MAP (DESTROY, static_cast<maptile *>(this)); |
312 | |
337 | |
313 | // disconnect Perl from C, to avoid crashes |
338 | // disconnect Perl from C, to avoid crashes |
314 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
339 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
315 | |
340 | |
316 | // clear the perl hash, might or might not be a good idea |
341 | // clear the perl hash, might or might not be a good idea |
… | |
… | |
387 | |
412 | |
388 | switch (type) |
413 | switch (type) |
389 | { |
414 | { |
390 | case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; |
415 | case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; |
391 | case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; |
416 | case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; |
|
|
417 | case DT_CLIENT: INVOKE_CLIENT (REATTACH, obj); break; |
392 | case DT_MAP: INVOKE_MAP (REATTACH, obj); break; |
418 | case DT_MAP: INVOKE_MAP (REATTACH, obj); break; |
393 | } |
419 | } |
394 | } |
420 | } |
395 | |
421 | |
396 | template<class subclass> |
422 | template<class subclass> |
… | |
… | |
444 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
470 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
445 | FREETMPS; |
471 | FREETMPS; |
446 | LEAVE; |
472 | LEAVE; |
447 | } |
473 | } |
448 | |
474 | |
|
|
475 | char *object_freezer::as_string () |
|
|
476 | { |
|
|
477 | dSP; |
|
|
478 | ENTER; |
|
|
479 | SAVETMPS; |
|
|
480 | PUSHMARK (SP); |
|
|
481 | EXTEND (SP, 3); |
|
|
482 | PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ())))); |
|
|
483 | PUSHs (sv_2mortal (newRV_inc ((SV *)av))); |
|
|
484 | PUTBACK; |
|
|
485 | |
|
|
486 | char *res = call_pv ("cf::object_freezer_as_string", G_SCALAR | G_EVAL) > 0 |
|
|
487 | ? strdup (SvPVbyte_nolen (POPs)) |
|
|
488 | : strdup ("[fatal error]"); |
|
|
489 | |
|
|
490 | FREETMPS; |
|
|
491 | LEAVE; |
|
|
492 | |
|
|
493 | return res; |
|
|
494 | } |
|
|
495 | |
449 | int fprintf (object_freezer &freezer, const char *format, ...) |
496 | int fprintf (object_freezer &freezer, const char *format, ...) |
450 | { |
497 | { |
451 | va_list ap; |
498 | va_list ap; |
452 | |
499 | |
453 | va_start (ap, format); |
500 | va_start (ap, format); |
… | |
… | |
462 | |
509 | |
463 | int fputs (const char *s, object_freezer &freezer) |
510 | int fputs (const char *s, object_freezer &freezer) |
464 | { |
511 | { |
465 | freezer.add (s); |
512 | freezer.add (s); |
466 | } |
513 | } |
|
|
514 | |
|
|
515 | static const char thawer_eof[] = "\n\n\n\0\0\0"; |
467 | |
516 | |
468 | object_thawer::object_thawer (const char *filename) |
517 | object_thawer::object_thawer (const char *filename) |
469 | { |
518 | { |
470 | static const char eof[] = "\n\n\n\0\0\0"; |
519 | static const char eof[] = "\n\n\n\0\0\0"; |
471 | |
520 | |
… | |
… | |
511 | FREETMPS; |
560 | FREETMPS; |
512 | LEAVE; |
561 | LEAVE; |
513 | } |
562 | } |
514 | } |
563 | } |
515 | |
564 | |
|
|
565 | object_thawer::object_thawer (const char *data, AV *perlav) |
|
|
566 | { |
|
|
567 | av = perlav; |
|
|
568 | text = newSVpv (data, 0); |
|
|
569 | sv_catpv (text, thawer_eof); |
|
|
570 | line = SvPVbyte_nolen (text); |
|
|
571 | } |
|
|
572 | |
516 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
573 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
517 | { |
574 | { |
518 | if (!av || oid < 0) // this is actually an error of sorts |
575 | if (!av || oid < 0) // this is actually an error of sorts |
519 | return; |
576 | return; |
520 | |
577 | |
… | |
… | |
585 | int klen = p - line; |
642 | int klen = p - line; |
586 | |
643 | |
587 | if (*p++ != '\n') |
644 | if (*p++ != '\n') |
588 | { |
645 | { |
589 | // parse value |
646 | // parse value |
590 | while (*p <= ' ' && *p != '\n') // skip 0x01 .. 0x20 |
647 | while (*(unsigned char *)p <= ' ' && *p != '\n') // skip 0x01 .. 0x20 |
591 | ++p; |
648 | ++p; |
592 | |
649 | |
593 | last_value = p; |
650 | last_value = p; |
594 | |
651 | |
595 | while (*p != '\n') |
652 | while (*p != '\n') |
… | |
… | |
633 | |
690 | |
634 | void object_thawer::get_ml (keyword kend, shstr &sh) |
691 | void object_thawer::get_ml (keyword kend, shstr &sh) |
635 | { |
692 | { |
636 | char kw[128]; |
693 | char kw[128]; |
637 | |
694 | |
638 | // multi-line strings are delimited by "\nendXXX\n" |
695 | int klen = keyword_len [kend]; |
|
|
696 | |
639 | kw [0] = '\n'; |
697 | kw [0] = '\n'; |
640 | strcpy (kw + 1, keyword_str [kend]); |
698 | memcpy (kw + 1, keyword_str [kend], klen); |
|
|
699 | kw [klen + 1] = '\n'; |
|
|
700 | kw [klen + 2] = 0; |
641 | |
701 | |
642 | char *end = strstr (line, kw); |
702 | // first test for completely empty msg... "endXXX\n" |
643 | |
703 | if (!strncmp (line, kw + 1, klen + 1)) |
644 | if (!end) |
|
|
645 | { |
704 | { |
646 | sh = 0; |
705 | sh = 0; |
|
|
706 | |
|
|
707 | line += klen + 1; |
|
|
708 | |
647 | return; |
709 | return; |
648 | } |
710 | } |
|
|
711 | else |
|
|
712 | { |
|
|
713 | // multi-line strings are delimited by "\nendXXX\n" or "endXXX\n" (NULL) |
649 | |
714 | |
|
|
715 | char *end = strstr (line, kw); |
|
|
716 | |
|
|
717 | if (!end) |
|
|
718 | { |
|
|
719 | sh = 0; |
|
|
720 | return; |
|
|
721 | } |
|
|
722 | |
650 | *end = 0; |
723 | *end = 0; |
651 | sh = line; |
724 | sh = line; |
652 | |
725 | |
653 | line = end + keyword_len [kend] + 1; |
726 | line = end + keyword_len [kend] + 1; |
654 | |
727 | |
655 | while (*line++ != '\n') |
728 | while (*line++ != '\n') |
|
|
729 | ; |
656 | ; |
730 | } |
657 | } |
731 | } |
658 | |
732 | |
659 | sint32 object_thawer::get_sint32 () const |
733 | sint32 object_thawer::get_sint32 () const |
660 | { |
734 | { |
661 | char *p = last_value; |
735 | char *p = last_value; |
… | |
… | |
704 | static CommArray_s rtn_cmd; |
778 | static CommArray_s rtn_cmd; |
705 | |
779 | |
706 | static int |
780 | static int |
707 | runPluginCommand (object *obj, char *params) |
781 | runPluginCommand (object *obj, char *params) |
708 | { |
782 | { |
709 | dSP; |
783 | return -1; |
710 | |
|
|
711 | ENTER; |
|
|
712 | SAVETMPS; |
|
|
713 | |
|
|
714 | PUSHMARK (SP); |
|
|
715 | |
|
|
716 | EXTEND (SP, 3); |
|
|
717 | PUSHs (sv_2mortal (newSVpv (rtn_cmd.name, 0))); |
|
|
718 | PUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, obj))); |
|
|
719 | |
|
|
720 | if (params) |
|
|
721 | PUSHs (sv_2mortal (newSVpv (params, 0))); |
|
|
722 | |
|
|
723 | PUTBACK; |
|
|
724 | int count = call_pv ("cf::inject_command", G_SCALAR | G_EVAL); |
|
|
725 | SPAGAIN; |
|
|
726 | |
|
|
727 | if (SvTRUE (ERRSV)) |
|
|
728 | LOG (llevError, "command '%s' callback evaluation error: %s", rtn_cmd.name, SvPV_nolen (ERRSV)); |
|
|
729 | |
|
|
730 | int returnvalue = count > 0 ? POPi : -1; |
|
|
731 | |
|
|
732 | PUTBACK; |
|
|
733 | FREETMPS; |
|
|
734 | LEAVE; |
|
|
735 | |
|
|
736 | return returnvalue; |
|
|
737 | } |
784 | } |
738 | |
785 | |
739 | extern "C" void *cfperl_getPluginProperty (int *type, ...) |
786 | extern "C" void *cfperl_getPluginProperty (int *type, ...) |
740 | { |
787 | { |
741 | va_list args; |
788 | va_list args; |
… | |
… | |
744 | va_start (args, type); |
791 | va_start (args, type); |
745 | propname = va_arg (args, char *); |
792 | propname = va_arg (args, char *); |
746 | //printf ("Property name: %s\n", propname); |
793 | //printf ("Property name: %s\n", propname); |
747 | |
794 | |
748 | if (!strcmp (propname, "command?")) |
795 | if (!strcmp (propname, "command?")) |
749 | { |
|
|
750 | if (!perl) |
|
|
751 | return NULL; |
796 | return NULL; |
752 | |
797 | else if (!strcmp (propname, "Identification")) |
753 | const char *cmdname = va_arg (args, const char *); |
798 | { |
754 | HV *hv = get_hv ("cf::COMMAND", 1); |
|
|
755 | SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0); |
|
|
756 | |
|
|
757 | va_end (args); |
799 | va_end (args); |
758 | |
800 | return (void *)PLUGIN_NAME; |
759 | if (svp) |
|
|
760 | { |
|
|
761 | // this is totaly broken, should stash it into %COMMAND |
|
|
762 | rtn_cmd.name = cmdname; |
|
|
763 | rtn_cmd.time = SvNV (*svp); |
|
|
764 | rtn_cmd.func = runPluginCommand; |
|
|
765 | |
|
|
766 | return &rtn_cmd; |
|
|
767 | } |
|
|
768 | } |
801 | } |
769 | else if (!strcmp (propname, "Identification")) |
802 | else if (!strcmp (propname, "FullName")) |
770 | { |
803 | { |
771 | va_end (args); |
804 | va_end (args); |
772 | return (void*) PLUGIN_NAME; |
|
|
773 | } |
|
|
774 | else if (!strcmp (propname, "FullName")) |
|
|
775 | { |
|
|
776 | va_end (args); |
|
|
777 | return (void*) PLUGIN_VERSION; |
805 | return (void *)PLUGIN_VERSION; |
778 | } |
806 | } |
779 | else |
807 | else |
780 | va_end (args); |
808 | va_end (args); |
781 | |
809 | |
782 | return NULL; |
810 | return NULL; |
… | |
… | |
807 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
835 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
808 | |
836 | |
809 | char *argv[] = { |
837 | char *argv[] = { |
810 | "", |
838 | "", |
811 | "-e" |
839 | "-e" |
812 | "cf->bootstrap;" |
840 | "use Event;" // required for bootstrap |
|
|
841 | "cf->bootstrap;" // required for datadir :*> |
813 | "unshift @INC, cf::datadir ();" |
842 | "unshift @INC, cf::datadir ();" |
814 | "require cf;" |
843 | "require cf;" |
815 | }; |
844 | }; |
816 | |
845 | |
817 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
846 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
818 | { |
847 | { |
819 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
848 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
820 | exit (EXIT_FAILURE); |
849 | exit (EXIT_FAILURE); |
821 | } |
850 | } |
822 | |
|
|
823 | obj_cache = newHV (); |
|
|
824 | } |
851 | } |
825 | |
852 | |
826 | void cfperl_main () |
853 | void cfperl_main () |
827 | { |
854 | { |
828 | dSP; |
855 | dSP; |
… | |
… | |
879 | |
906 | |
880 | AV *callbacks = 0; |
907 | AV *callbacks = 0; |
881 | |
908 | |
882 | object *op; |
909 | object *op; |
883 | player *pl; |
910 | player *pl; |
884 | mapstruct *map; |
911 | maptile *map; |
|
|
912 | client *ns; |
885 | |
913 | |
886 | // callback call ordering is: |
914 | // callback call ordering is: |
887 | // 1. per-object callback (NYI) |
915 | // 1. per-object callback |
888 | // 2. per-class object |
916 | // 2. per-class object |
889 | // 2a. per-type callback |
917 | // 3. per-type callback |
890 | // 4. global callbacks |
918 | // 4. global callbacks |
891 | |
919 | |
892 | gather_callbacks (callbacks, cb_global, event); |
920 | gather_callbacks (callbacks, cb_global, event); |
893 | |
921 | |
894 | switch (KLASS_OF (event)) |
922 | switch (KLASS_OF (event)) |
… | |
… | |
939 | break; |
967 | break; |
940 | |
968 | |
941 | case KLASS_MAP: |
969 | case KLASS_MAP: |
942 | dt = (data_type) va_arg (ap, int); |
970 | dt = (data_type) va_arg (ap, int); |
943 | assert (("first argument must be of type object", dt == DT_MAP)); |
971 | assert (("first argument must be of type object", dt == DT_MAP)); |
944 | map = va_arg (ap, mapstruct *); |
972 | map = va_arg (ap, maptile *); |
945 | |
973 | |
946 | if (map->cb) |
974 | if (map->cb) |
947 | gather_callbacks (callbacks, map->cb, event); |
975 | gather_callbacks (callbacks, map->cb, event); |
948 | |
976 | |
949 | gather_callbacks (callbacks, cb_map, event); |
977 | gather_callbacks (callbacks, cb_map, event); |
|
|
978 | break; |
|
|
979 | |
|
|
980 | case KLASS_CLIENT: |
|
|
981 | dt = (data_type) va_arg (ap, int); |
|
|
982 | assert (("first argument must be of type client", dt == DT_CLIENT)); |
|
|
983 | ns = va_arg (ap, client *); |
|
|
984 | |
|
|
985 | if (ns->cb) |
|
|
986 | gather_callbacks (callbacks, ns->cb, event); |
|
|
987 | |
|
|
988 | gather_callbacks (callbacks, cb_client, event); |
950 | break; |
989 | break; |
951 | |
990 | |
952 | default: |
991 | default: |
953 | assert (("unsupported event klass in cfperl_invoke", 0)); |
992 | assert (("unsupported event klass in cfperl_invoke", 0)); |
954 | } |
993 | } |
… | |
… | |
969 | |
1008 | |
970 | switch (KLASS_OF (event)) |
1009 | switch (KLASS_OF (event)) |
971 | { |
1010 | { |
972 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
1011 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
973 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
1012 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
|
|
1013 | case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, pl))); break; |
974 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
1014 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
975 | } |
1015 | } |
976 | |
1016 | |
977 | for (;;) |
1017 | for (;;) |
978 | { |
1018 | { |
… | |
… | |
1024 | cfperl_result_INT (int idx) |
1064 | cfperl_result_INT (int idx) |
1025 | { |
1065 | { |
1026 | return SvIV (cfperl_result (idx)); |
1066 | return SvIV (cfperl_result (idx)); |
1027 | } |
1067 | } |
1028 | |
1068 | |
|
|
1069 | double |
|
|
1070 | cfperl_result_DOUBLE (int idx) |
|
|
1071 | { |
|
|
1072 | return SvNV (cfperl_result (idx)); |
|
|
1073 | } |
|
|
1074 | |
|
|
1075 | ///////////////////////////////////////////////////////////////////////////// |
|
|
1076 | |
|
|
1077 | struct EventAPI *watcher_base::GEventAPI; |
|
|
1078 | |
|
|
1079 | static void iw_dispatch (pe_event *ev) |
|
|
1080 | { |
|
|
1081 | iw *w = (iw *)ev->ext_data; |
|
|
1082 | w->call (*w); |
|
|
1083 | } |
|
|
1084 | |
|
|
1085 | void |
|
|
1086 | iw::alloc () |
|
|
1087 | { |
|
|
1088 | pe = GEventAPI->new_idle (0, 0); |
|
|
1089 | |
|
|
1090 | pe->base.callback = (void *)iw_dispatch; |
|
|
1091 | pe->base.ext_data = (void *)this; |
|
|
1092 | } |
|
|
1093 | |
|
|
1094 | static void iow_dispatch (pe_event *ev) |
|
|
1095 | { |
|
|
1096 | iow *w = (iow *)ev->ext_data; |
|
|
1097 | w->call (*w, ((pe_ioevent *)ev)->got); |
|
|
1098 | } |
|
|
1099 | |
|
|
1100 | void |
|
|
1101 | iow::alloc () |
|
|
1102 | { |
|
|
1103 | pe = GEventAPI->new_io (0, 0); |
|
|
1104 | |
|
|
1105 | pe->base.callback = (void *)iow_dispatch; |
|
|
1106 | pe->base.ext_data = (void *)this; |
|
|
1107 | |
|
|
1108 | pe->fd = -1; |
|
|
1109 | pe->poll = 0; |
|
|
1110 | } |
|
|
1111 | |
|
|
1112 | void |
|
|
1113 | iow::fd (int fd) |
|
|
1114 | { |
|
|
1115 | pe->fd = fd; |
|
|
1116 | } |
|
|
1117 | |
|
|
1118 | int |
|
|
1119 | iow::poll () |
|
|
1120 | { |
|
|
1121 | return pe->poll; |
|
|
1122 | } |
|
|
1123 | |
|
|
1124 | void |
|
|
1125 | iow::poll (int events) |
|
|
1126 | { |
|
|
1127 | if (pe->poll != events) |
|
|
1128 | { |
|
|
1129 | if (pe->poll) stop (); |
|
|
1130 | pe->poll = events; |
|
|
1131 | if (pe->poll) start (); |
|
|
1132 | } |
|
|
1133 | } |
|
|
1134 | |
1029 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1135 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1030 | |
1136 | |
1031 | BOOT: |
1137 | BOOT: |
1032 | { |
1138 | { |
1033 | HV *stash = gv_stashpv ("cf", 1); |
1139 | HV *stash = gv_stashpv ("cf", 1); |
|
|
1140 | |
|
|
1141 | I_EVENT_API (PACKAGE); |
|
|
1142 | watcher_base::GEventAPI = GEventAPI; |
|
|
1143 | |
|
|
1144 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1034 | |
1145 | |
1035 | static const struct { |
1146 | static const struct { |
1036 | const char *name; |
1147 | const char *name; |
1037 | IV iv; |
1148 | IV iv; |
1038 | } *civ, const_iv[] = { |
1149 | } *civ, const_iv[] = { |
… | |
… | |
1050 | const_iv (POTION) |
1161 | const_iv (POTION) |
1051 | const_iv (FOOD) |
1162 | const_iv (FOOD) |
1052 | const_iv (POISON) |
1163 | const_iv (POISON) |
1053 | const_iv (BOOK) |
1164 | const_iv (BOOK) |
1054 | const_iv (CLOCK) |
1165 | const_iv (CLOCK) |
1055 | const_iv (LIGHTNING) |
|
|
1056 | const_iv (ARROW) |
1166 | const_iv (ARROW) |
1057 | const_iv (BOW) |
1167 | const_iv (BOW) |
1058 | const_iv (WEAPON) |
1168 | const_iv (WEAPON) |
1059 | const_iv (ARMOUR) |
1169 | const_iv (ARMOUR) |
1060 | const_iv (PEDESTAL) |
1170 | const_iv (PEDESTAL) |
… | |
… | |
1080 | const_iv (AMULET) |
1190 | const_iv (AMULET) |
1081 | const_iv (PLAYERMOVER) |
1191 | const_iv (PLAYERMOVER) |
1082 | const_iv (TELEPORTER) |
1192 | const_iv (TELEPORTER) |
1083 | const_iv (CREATOR) |
1193 | const_iv (CREATOR) |
1084 | const_iv (SKILL) |
1194 | const_iv (SKILL) |
1085 | const_iv (EXPERIENCE) |
|
|
1086 | const_iv (EARTHWALL) |
1195 | const_iv (EARTHWALL) |
1087 | const_iv (GOLEM) |
1196 | const_iv (GOLEM) |
1088 | const_iv (THROWN_OBJ) |
1197 | const_iv (THROWN_OBJ) |
1089 | const_iv (BLINDNESS) |
1198 | const_iv (BLINDNESS) |
1090 | const_iv (GOD) |
1199 | const_iv (GOD) |
… | |
… | |
1110 | const_iv (FLOOR) |
1219 | const_iv (FLOOR) |
1111 | const_iv (FLESH) |
1220 | const_iv (FLESH) |
1112 | const_iv (INORGANIC) |
1221 | const_iv (INORGANIC) |
1113 | const_iv (SKILL_TOOL) |
1222 | const_iv (SKILL_TOOL) |
1114 | const_iv (LIGHTER) |
1223 | const_iv (LIGHTER) |
1115 | const_iv (TRAP_PART) |
|
|
1116 | const_iv (WALL) |
1224 | const_iv (BUILDABLE_WALL) |
1117 | const_iv (LIGHT_SOURCE) |
|
|
1118 | const_iv (MISC_OBJECT) |
1225 | const_iv (MISC_OBJECT) |
1119 | const_iv (MONSTER) |
|
|
1120 | const_iv (SPAWN_GENERATOR) |
|
|
1121 | const_iv (LAMP) |
1226 | const_iv (LAMP) |
1122 | const_iv (DUPLICATOR) |
1227 | const_iv (DUPLICATOR) |
1123 | const_iv (TOOL) |
|
|
1124 | const_iv (SPELLBOOK) |
1228 | const_iv (SPELLBOOK) |
1125 | const_iv (BUILDFAC) |
|
|
1126 | const_iv (CLOAK) |
1229 | const_iv (CLOAK) |
1127 | const_iv (SPINNER) |
1230 | const_iv (SPINNER) |
1128 | const_iv (GATE) |
1231 | const_iv (GATE) |
1129 | const_iv (BUTTON) |
1232 | const_iv (BUTTON) |
1130 | const_iv (CF_HANDLE) |
1233 | const_iv (CF_HANDLE) |
… | |
… | |
1137 | const_iv (SPELL_EFFECT) |
1240 | const_iv (SPELL_EFFECT) |
1138 | const_iv (CONVERTER) |
1241 | const_iv (CONVERTER) |
1139 | const_iv (BRACERS) |
1242 | const_iv (BRACERS) |
1140 | const_iv (POISONING) |
1243 | const_iv (POISONING) |
1141 | const_iv (SAVEBED) |
1244 | const_iv (SAVEBED) |
1142 | const_iv (POISONCLOUD) |
|
|
1143 | const_iv (FIREHOLES) |
|
|
1144 | const_iv (WAND) |
1245 | const_iv (WAND) |
1145 | const_iv (SCROLL) |
1246 | const_iv (SCROLL) |
1146 | const_iv (DIRECTOR) |
1247 | const_iv (DIRECTOR) |
1147 | const_iv (GIRDLE) |
1248 | const_iv (GIRDLE) |
1148 | const_iv (FORCE) |
1249 | const_iv (FORCE) |
… | |
… | |
1163 | const_iv (DISEASE) |
1264 | const_iv (DISEASE) |
1164 | const_iv (SYMPTOM) |
1265 | const_iv (SYMPTOM) |
1165 | const_iv (BUILDER) |
1266 | const_iv (BUILDER) |
1166 | const_iv (MATERIAL) |
1267 | const_iv (MATERIAL) |
1167 | const_iv (ITEM_TRANSFORMER) |
1268 | const_iv (ITEM_TRANSFORMER) |
1168 | const_iv (QUEST) |
|
|
1169 | |
1269 | |
1170 | const_iv (NUM_SUBTYPES) |
1270 | const_iv (NUM_SUBTYPES) |
1171 | |
1271 | |
1172 | const_iv (ST_BD_BUILD) |
1272 | const_iv (ST_BD_BUILD) |
1173 | const_iv (ST_BD_REMOVE) |
1273 | const_iv (ST_BD_REMOVE) |
… | |
… | |
1201 | const_iv (AT_BLIND) |
1301 | const_iv (AT_BLIND) |
1202 | const_iv (AT_INTERNAL) |
1302 | const_iv (AT_INTERNAL) |
1203 | const_iv (AT_LIFE_STEALING) |
1303 | const_iv (AT_LIFE_STEALING) |
1204 | const_iv (AT_DISEASE) |
1304 | const_iv (AT_DISEASE) |
1205 | |
1305 | |
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) |
1306 | const_iv (WEAP_HIT) |
1217 | const_iv (WEAP_SLASH) |
1307 | const_iv (WEAP_SLASH) |
1218 | const_iv (WEAP_PIERCE) |
1308 | const_iv (WEAP_PIERCE) |
1219 | const_iv (WEAP_CLEAVE) |
1309 | const_iv (WEAP_CLEAVE) |
1220 | const_iv (WEAP_SLICE) |
1310 | const_iv (WEAP_SLICE) |
… | |
… | |
1236 | const_iv (FLAG_MONSTER) |
1326 | const_iv (FLAG_MONSTER) |
1237 | const_iv (FLAG_FRIENDLY) |
1327 | const_iv (FLAG_FRIENDLY) |
1238 | const_iv (FLAG_GENERATOR) |
1328 | const_iv (FLAG_GENERATOR) |
1239 | const_iv (FLAG_IS_THROWN) |
1329 | const_iv (FLAG_IS_THROWN) |
1240 | const_iv (FLAG_AUTO_APPLY) |
1330 | const_iv (FLAG_AUTO_APPLY) |
1241 | const_iv (FLAG_TREASURE) |
|
|
1242 | const_iv (FLAG_PLAYER_SOLD) |
1331 | const_iv (FLAG_PLAYER_SOLD) |
1243 | const_iv (FLAG_SEE_INVISIBLE) |
1332 | const_iv (FLAG_SEE_INVISIBLE) |
1244 | const_iv (FLAG_CAN_ROLL) |
1333 | const_iv (FLAG_CAN_ROLL) |
1245 | const_iv (FLAG_OVERLAY_FLOOR) |
1334 | const_iv (FLAG_OVERLAY_FLOOR) |
1246 | const_iv (FLAG_IS_TURNABLE) |
1335 | const_iv (FLAG_IS_TURNABLE) |
… | |
… | |
1341 | const_iv (NDI_MAX_COLOR) |
1430 | const_iv (NDI_MAX_COLOR) |
1342 | const_iv (NDI_COLOR_MASK) |
1431 | const_iv (NDI_COLOR_MASK) |
1343 | const_iv (NDI_UNIQUE) |
1432 | const_iv (NDI_UNIQUE) |
1344 | const_iv (NDI_ALL) |
1433 | const_iv (NDI_ALL) |
1345 | |
1434 | |
|
|
1435 | const_iv (UPD_LOCATION) |
|
|
1436 | const_iv (UPD_FLAGS) |
|
|
1437 | const_iv (UPD_WEIGHT) |
|
|
1438 | const_iv (UPD_FACE) |
|
|
1439 | const_iv (UPD_NAME) |
|
|
1440 | const_iv (UPD_ANIM) |
|
|
1441 | const_iv (UPD_ANIMSPEED) |
|
|
1442 | const_iv (UPD_NROF) |
|
|
1443 | |
|
|
1444 | const_iv (UPD_SP_MANA) |
|
|
1445 | const_iv (UPD_SP_GRACE) |
|
|
1446 | const_iv (UPD_SP_DAMAGE) |
|
|
1447 | |
1346 | const_iv (F_APPLIED) |
1448 | const_iv (F_APPLIED) |
1347 | const_iv (F_LOCATION) |
1449 | const_iv (F_LOCATION) |
1348 | const_iv (F_UNPAID) |
1450 | const_iv (F_UNPAID) |
1349 | const_iv (F_MAGIC) |
1451 | const_iv (F_MAGIC) |
1350 | const_iv (F_CURSED) |
1452 | const_iv (F_CURSED) |
… | |
… | |
1356 | const_iv (F_BUY) |
1458 | const_iv (F_BUY) |
1357 | const_iv (F_SHOP) |
1459 | const_iv (F_SHOP) |
1358 | const_iv (F_SELL) |
1460 | const_iv (F_SELL) |
1359 | |
1461 | |
1360 | const_iv (P_BLOCKSVIEW) |
1462 | const_iv (P_BLOCKSVIEW) |
|
|
1463 | const_iv (P_PLAYER) |
1361 | const_iv (P_NO_MAGIC) |
1464 | const_iv (P_NO_MAGIC) |
1362 | const_iv (P_IS_ALIVE) |
1465 | const_iv (P_IS_ALIVE) |
1363 | const_iv (P_NO_CLERIC) |
1466 | const_iv (P_NO_CLERIC) |
1364 | const_iv (P_NEED_UPDATE) |
1467 | const_iv (P_NEED_UPDATE) |
1365 | const_iv (P_NO_ERROR) |
|
|
1366 | const_iv (P_OUT_OF_MAP) |
1468 | const_iv (P_OUT_OF_MAP) |
1367 | const_iv (P_NEW_MAP) |
1469 | const_iv (P_NEW_MAP) |
1368 | |
1470 | |
1369 | const_iv (UP_OBJ_INSERT) |
1471 | const_iv (UP_OBJ_INSERT) |
1370 | const_iv (UP_OBJ_REMOVE) |
1472 | const_iv (UP_OBJ_REMOVE) |
… | |
… | |
1516 | const_iv (MAP_LOADING) |
1618 | const_iv (MAP_LOADING) |
1517 | const_iv (MAP_SAVING) |
1619 | const_iv (MAP_SAVING) |
1518 | |
1620 | |
1519 | const_iv (KLASS_GLOBAL) |
1621 | const_iv (KLASS_GLOBAL) |
1520 | const_iv (KLASS_OBJECT) |
1622 | const_iv (KLASS_OBJECT) |
|
|
1623 | const_iv (KLASS_CLIENT) |
1521 | const_iv (KLASS_PLAYER) |
1624 | const_iv (KLASS_PLAYER) |
1522 | const_iv (KLASS_MAP) |
1625 | const_iv (KLASS_MAP) |
1523 | }; |
1626 | }; |
1524 | |
1627 | |
1525 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1628 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
… | |
… | |
1544 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1647 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1545 | av_push (event, newSViv (eiv->klass)); |
1648 | av_push (event, newSViv (eiv->klass)); |
1546 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1649 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1547 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1650 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1548 | } |
1651 | } |
1549 | |
|
|
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); |
|
|
1683 | } |
1652 | } |
1684 | |
1653 | |
1685 | void _reload_1 () |
1654 | void _init_vars () |
1686 | CODE: |
1655 | CODE: |
1687 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1656 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1688 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1657 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1689 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1658 | cb_player = get_av ("cf::CB_PLAYER", 1); |
|
|
1659 | cb_client = get_av ("cf::CB_CLIENT", 1); |
1690 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1660 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1691 | cb_map = get_av ("cf::CB_MAP" , 1); |
1661 | cb_map = get_av ("cf::CB_MAP" , 1); |
1692 | |
1662 | |
1693 | void _reload_2 () |
1663 | void _global_reattach () |
1694 | CODE: |
1664 | CODE: |
1695 | { |
1665 | { |
1696 | // reattach to all attachable objects in the game. |
1666 | // reattach to all attachable objects in the game. |
|
|
1667 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
|
|
1668 | reattach (*i); |
|
|
1669 | |
1697 | for (player *pl = first_player; pl; pl = pl->next) |
1670 | for (player *pl = first_player; pl; pl = pl->next) |
1698 | reattach (pl); |
1671 | reattach (pl); |
1699 | |
1672 | |
1700 | for (mapstruct *map = first_map; map; map = map->next) |
1673 | for (maptile *map = first_map; map; map = map->next) |
1701 | reattach (map); |
1674 | reattach (map); |
1702 | |
1675 | |
1703 | for (object *op = objects; op; op = op->next) |
1676 | for (object *op = object::first; op; op = op->next) |
1704 | reattach (op); |
1677 | reattach (op); |
1705 | } |
1678 | } |
1706 | |
1679 | |
1707 | NV floor (NV x) |
1680 | NV floor (NV x) |
1708 | |
1681 | |
… | |
… | |
1756 | case 5: RETVAL = settings.playerdir; break; |
1729 | case 5: RETVAL = settings.playerdir; break; |
1757 | case 6: RETVAL = settings.datadir ; break; |
1730 | case 6: RETVAL = settings.datadir ; break; |
1758 | } |
1731 | } |
1759 | OUTPUT: RETVAL |
1732 | OUTPUT: RETVAL |
1760 | |
1733 | |
1761 | int |
1734 | void _exit (int status = 0) |
|
|
1735 | |
1762 | cf_find_animation (char *text) |
1736 | int find_animation (char *text) |
1763 | PROTOTYPE: $ |
1737 | PROTOTYPE: $ |
1764 | |
1738 | |
1765 | int random_roll(int min, int max, object *op, int goodbad); |
1739 | int random_roll (int min, int max, object *op, int goodbad); |
1766 | |
1740 | |
1767 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1741 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1768 | |
1742 | |
1769 | int invoke (int event, ...) |
1743 | int invoke (int event, ...) |
1770 | CODE: |
1744 | CODE: |
… | |
… | |
1820 | OUTPUT: |
1794 | OUTPUT: |
1821 | RETVAL |
1795 | RETVAL |
1822 | |
1796 | |
1823 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1797 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1824 | |
1798 | |
|
|
1799 | INCLUDE: $PERL genacc object ../include/object.h | |
|
|
1800 | |
1825 | int invoke (object *op, int event, ...) |
1801 | int invoke (object *op, int event, ...) |
1826 | CODE: |
1802 | CODE: |
1827 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1803 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1828 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1804 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1829 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1805 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1830 | RETVAL = INVOKE_((event_type)event, ARG_OBJECT (op), ARG_AV (av)); |
1806 | RETVAL = INVOKE_((event_type)event, ARG_OBJECT (op), ARG_AV (av)); |
1831 | OUTPUT: RETVAL |
1807 | OUTPUT: RETVAL |
1832 | |
1808 | |
1833 | SV *registry (object *op) |
1809 | SV *registry (object *op) |
|
|
1810 | |
|
|
1811 | void mortals () |
1834 | CODE: |
1812 | PPCODE: |
1835 | RETVAL = registry_of (op); |
1813 | EXTEND (SP, object::mortals.size ()); |
|
|
1814 | for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i) |
|
|
1815 | PUSHs (to_sv (*i)); |
|
|
1816 | |
|
|
1817 | object *first () |
|
|
1818 | CODE: |
|
|
1819 | RETVAL = object::first; |
|
|
1820 | OUTPUT: RETVAL |
|
|
1821 | |
|
|
1822 | # missing properties |
|
|
1823 | |
|
|
1824 | int flag (object *op, int flag, int value = 1) |
|
|
1825 | PROTOTYPE: $$;$ |
|
|
1826 | CODE: |
|
|
1827 | RETVAL = QUERY_FLAG (op, flag); |
|
|
1828 | if (items >= 3) |
|
|
1829 | if (value) |
|
|
1830 | SET_FLAG (op, flag); |
|
|
1831 | else |
|
|
1832 | CLEAR_FLAG (op, flag); |
1836 | OUTPUT: |
1833 | OUTPUT: RETVAL |
1837 | RETVAL |
|
|
1838 | |
1834 | |
1839 | object *head (object *op) |
1835 | object *head (object *op) |
1840 | PROTOTYPE: $ |
1836 | PROTOTYPE: $ |
1841 | ALIAS: |
|
|
1842 | more = 1 |
|
|
1843 | above = 2 |
|
|
1844 | below = 3 |
|
|
1845 | CODE: |
1837 | CODE: |
1846 | switch (ix) |
|
|
1847 | { |
|
|
1848 | case 0: RETVAL = op->head ? op->head : op; break; // DOH! |
1838 | 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 |
1839 | OUTPUT: RETVAL |
1855 | |
1840 | |
1856 | SV * |
1841 | int is_head (object *op) |
1857 | get_property (object *obj, int type, int idx) |
1842 | PROTOTYPE: $ |
1858 | CODE: |
1843 | 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; |
1844 | RETVAL = !op->head; |
1919 | OUTPUT: RETVAL |
1845 | OUTPUT: RETVAL |
1920 | |
1846 | |
1921 | void |
1847 | void |
1922 | inv (object *obj) |
1848 | inv (object *obj) |
1923 | PROTOTYPE: $ |
1849 | PROTOTYPE: $ |
1924 | PPCODE: |
1850 | PPCODE: |
… | |
… | |
1926 | object *o; |
1852 | object *o; |
1927 | for (o = obj->inv; o; o = o->below) |
1853 | for (o = obj->inv; o; o = o->below) |
1928 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1854 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1929 | } |
1855 | } |
1930 | |
1856 | |
1931 | int cf_object_get_resistance (object *op, int rtype) |
1857 | object *find_best_object_match (object *op, const char *match) |
1932 | ALIAS: resistance = 0 |
|
|
1933 | |
1858 | |
1934 | int cf_object_get_flag (object *op, int flag) |
1859 | object *find_marked_object (object *op) |
1935 | ALIAS: flag = 0 |
|
|
1936 | |
1860 | |
1937 | void cf_object_set_flag (object *op, int flag, int value) |
1861 | int resistance (object *op, int rtype, int newval = 0) |
|
|
1862 | CODE: |
|
|
1863 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1864 | croak ("resistance out of bounds"); |
|
|
1865 | RETVAL = op->resist [rtype]; |
|
|
1866 | if (items >= 3) |
|
|
1867 | op->resist [rtype] = newval; |
|
|
1868 | OUTPUT: RETVAL |
|
|
1869 | |
|
|
1870 | void set_resistance (object *op, int rtype, int val) |
|
|
1871 | CODE: |
|
|
1872 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1873 | op->resist[rtype] = val; |
1938 | |
1874 | |
1939 | int need_identify (const object *obj); |
1875 | int need_identify (const object *obj); |
1940 | |
1876 | |
1941 | int apply_shop_mat (object *shop_mat, object *op); |
1877 | int apply_shop_mat (object *shop_mat, object *op); |
1942 | |
1878 | |
… | |
… | |
1944 | CODE: |
1880 | CODE: |
1945 | RETVAL = move_ob (op, dir, originator); |
1881 | RETVAL = move_ob (op, dir, originator); |
1946 | OUTPUT: |
1882 | OUTPUT: |
1947 | RETVAL |
1883 | RETVAL |
1948 | |
1884 | |
1949 | void cf_object_apply (object *op, object *author, int flags = 0) |
1885 | void apply (object *applier, object *applied, int flags = 0) |
|
|
1886 | CODE: |
|
|
1887 | manual_apply (applied, applier, flags); |
1950 | |
1888 | |
1951 | void cf_object_apply_below (object *op) |
1889 | void apply_below (object *op) |
|
|
1890 | CODE: |
|
|
1891 | player_apply_below (op); |
1952 | |
1892 | |
1953 | void cf_object_remove (object *op) |
1893 | void remove (object *op) |
|
|
1894 | CODE: |
|
|
1895 | op->remove (); |
1954 | |
1896 | |
1955 | void cf_object_free (object *op) |
1897 | void |
|
|
1898 | object::destroy (int recursive = 0) |
1956 | |
1899 | |
1957 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1900 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1958 | |
1901 | |
1959 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1902 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1960 | |
1903 | |
1961 | int cf_object_change_map (object *op, int x, int y, mapstruct *map) |
1904 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1962 | |
1905 | |
1963 | object *cf_object_clone (object *op, int clonetype = 0) |
1906 | object *clone (object *op, int recursive = 0) |
|
|
1907 | CODE: |
|
|
1908 | if (recursive) |
|
|
1909 | RETVAL = object_create_clone (op); |
|
|
1910 | else |
|
|
1911 | { |
|
|
1912 | RETVAL = object::create (); |
|
|
1913 | op->copy_to (RETVAL); |
|
|
1914 | } |
|
|
1915 | OUTPUT: RETVAL |
1964 | |
1916 | |
1965 | int cf_object_pay_item (object *op, object *buyer) |
1917 | int pay_item (object *op, object *buyer) |
|
|
1918 | CODE: |
|
|
1919 | RETVAL = pay_for_item (op, buyer); |
|
|
1920 | OUTPUT: RETVAL |
1966 | |
1921 | |
1967 | int cf_object_pay_amount (object *op, uint64 amount) |
1922 | int pay_amount (object *op, uint64 amount) |
|
|
1923 | CODE: |
|
|
1924 | RETVAL = pay_for_amount (amount, op); |
|
|
1925 | OUTPUT: RETVAL |
1968 | |
1926 | |
1969 | void pay_player (object *op, uint64 amount) |
1927 | void pay_player (object *op, uint64 amount) |
1970 | |
1928 | |
1971 | val64 pay_player_arch (object *op, const char *arch, uint64 amount) |
1929 | val64 pay_player_arch (object *op, const char *arch, uint64 amount) |
1972 | |
1930 | |
1973 | int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0) |
1931 | int cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg = 0) |
1974 | |
1932 | |
1975 | int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *stringarg = 0) |
1933 | void learn_spell (object *op, object *sp, int special_prayer = 0) |
|
|
1934 | CODE: |
|
|
1935 | do_learn_spell (op, sp, special_prayer); |
1976 | |
1936 | |
1977 | void cf_object_learn_spell (object *op, object *sp) |
|
|
1978 | |
|
|
1979 | void cf_object_forget_spell (object *op, object *sp) |
1937 | void forget_spell (object *op, object *sp) |
|
|
1938 | CODE: |
|
|
1939 | do_forget_spell (op, query_name (sp)); |
1980 | |
1940 | |
1981 | object *cf_object_check_for_spell (object *op, char *spellname) |
1941 | object *check_for_spell (object *op, char *spellname) |
|
|
1942 | CODE: |
|
|
1943 | RETVAL = check_spell_known (op, spellname); |
|
|
1944 | OUTPUT: RETVAL |
1982 | |
1945 | |
1983 | int cf_object_query_money (object *op) |
1946 | int query_money (object *op) |
1984 | ALIAS: money = 0 |
1947 | ALIAS: money = 0 |
1985 | |
1948 | |
1986 | int cf_object_query_cost (object *op, object *who, int flags) |
1949 | int query_cost (object *op, object *who, int flags) |
1987 | ALIAS: cost = 0 |
1950 | ALIAS: cost = 0 |
1988 | |
1951 | |
1989 | void cf_object_activate_rune (object *op , object *victim) |
1952 | void spring_trap (object *op, object *victim) |
1990 | |
1953 | |
1991 | int cf_object_check_trigger (object *op, object *cause) |
1954 | int check_trigger (object *op, object *cause) |
1992 | |
1955 | |
1993 | int cf_object_out_of_map (object *op, int x, int y) |
|
|
1994 | |
|
|
1995 | void cf_object_drop (object *op, object *author) |
1956 | void drop (object *who, object *op) |
1996 | |
1957 | |
1997 | void cf_object_take (object *op, object *author) |
1958 | void pick_up (object *who, object *op) |
1998 | |
1959 | |
1999 | object *cf_object_insert_object (object *op, object *container) |
1960 | object *cf_object_insert_object (object *op, object *container) |
2000 | |
1961 | |
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) |
1962 | object *cf_object_insert_in_ob (object *ob, object *where) |
2005 | |
1963 | |
2006 | int cf_object_teleport (object *op, mapstruct *map, int x, int y) |
1964 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
2007 | |
1965 | |
2008 | void cf_object_update (object *op, int flags) |
1966 | void update (object *op, int action) |
2009 | |
1967 | CODE: |
2010 | void cf_object_pickup (object *op, object *what) |
1968 | update_object (op, action); |
2011 | |
1969 | |
2012 | object *cf_create_object_by_name (const char *name) |
1970 | object *cf_create_object_by_name (const char *name) |
2013 | |
1971 | |
2014 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1972 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
2015 | |
1973 | |
… | |
… | |
2021 | |
1979 | |
2022 | void push_button (object *op); |
1980 | void push_button (object *op); |
2023 | |
1981 | |
2024 | void use_trigger (object *op); |
1982 | void use_trigger (object *op); |
2025 | |
1983 | |
2026 | void add_button_link (object *button, mapstruct *map, int connected); |
1984 | void add_button_link (object *button, maptile *map, int connected); |
2027 | |
1985 | |
2028 | void remove_button_link (object *op); |
1986 | void remove_button_link (object *op); |
2029 | |
|
|
2030 | void |
|
|
2031 | cf_object_set_resistance (object *op, int rtype, int val) |
|
|
2032 | CODE: |
|
|
2033 | if (rtype >= 0 && rtype < NROFATTACKS) |
|
|
2034 | op->resist[rtype] = val; |
|
|
2035 | |
1987 | |
2036 | |
1988 | |
2037 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1989 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2038 | |
1990 | |
2039 | void cf_fix_object (object *pl) |
1991 | void cf_fix_object (object *pl) |
… | |
… | |
2049 | CODE: |
2001 | CODE: |
2050 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
2002 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
2051 | OUTPUT: |
2003 | OUTPUT: |
2052 | RETVAL |
2004 | RETVAL |
2053 | |
2005 | |
2054 | object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) |
2006 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
2055 | PROTOTYPE: $$$$$$ |
2007 | PROTOTYPE: $$$$$$ |
2056 | CODE: |
2008 | CODE: |
2057 | { |
2009 | { |
2058 | int unused_type; |
2010 | int unused_type; |
2059 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
2011 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
… | |
… | |
2097 | bool on_same_map_as (object *ob, object *other) |
2049 | bool on_same_map_as (object *ob, object *other) |
2098 | CODE: |
2050 | CODE: |
2099 | RETVAL = on_same_map (ob, other); |
2051 | RETVAL = on_same_map (ob, other); |
2100 | OUTPUT: RETVAL |
2052 | OUTPUT: RETVAL |
2101 | |
2053 | |
2102 | char * |
2054 | const char * |
2103 | base_name (object *ob, int plural) |
2055 | base_name (object *op, int plural = op->nrof > 1) |
2104 | CODE: |
2056 | CODE: |
2105 | RETVAL = cf_query_base_name (ob, plural); |
2057 | RETVAL = query_base_name (op, plural); |
2106 | OUTPUT: RETVAL |
2058 | OUTPUT: RETVAL |
2107 | |
2059 | |
2108 | living * |
2060 | object *decrease_ob_nr (object *op, unsigned long i) |
2109 | stats (object *ob) |
|
|
2110 | CODE: |
|
|
2111 | RETVAL = &ob->stats; |
|
|
2112 | OUTPUT: RETVAL |
|
|
2113 | |
|
|
2114 | |
2061 | |
2115 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
2062 | MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
2116 | |
2063 | |
2117 | player *player (object *op) |
2064 | player *player (object *op) |
2118 | CODE: |
2065 | CODE: |
… | |
… | |
2136 | |
2083 | |
2137 | void cf_player_set_party (object *op, partylist *party) |
2084 | void cf_player_set_party (object *op, partylist *party) |
2138 | |
2085 | |
2139 | void kill_player (object *op) |
2086 | void kill_player (object *op) |
2140 | |
2087 | |
|
|
2088 | void esrv_update_item (object *op, int what, object *item) |
|
|
2089 | C_ARGS: what, op, item |
|
|
2090 | |
|
|
2091 | void clear_los (object *op) |
|
|
2092 | |
|
|
2093 | int command_reset (object *op, char *params) |
|
|
2094 | |
|
|
2095 | int command_teleport (object *op, char *params) |
|
|
2096 | |
|
|
2097 | int command_summon (object *op, char *params) |
|
|
2098 | |
|
|
2099 | int command_arrest (object *op, char *params) |
|
|
2100 | |
|
|
2101 | int command_kick (object *op, char *params) |
|
|
2102 | |
|
|
2103 | int command_banish (object *op, char *params) |
|
|
2104 | |
|
|
2105 | |
2141 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2106 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
|
|
2107 | |
|
|
2108 | INCLUDE: $PERL genacc player ../include/player.h | |
2142 | |
2109 | |
2143 | int invoke (player *pl, int event, ...) |
2110 | int invoke (player *pl, int event, ...) |
2144 | CODE: |
2111 | CODE: |
2145 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2112 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2146 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2113 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2147 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2114 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2148 | RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); |
2115 | RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); |
2149 | OUTPUT: RETVAL |
2116 | OUTPUT: RETVAL |
2150 | |
2117 | |
2151 | SV *registry (player *pl) |
2118 | SV *registry (player *pl) |
|
|
2119 | |
|
|
2120 | player *cf_player_find (char *name) |
|
|
2121 | PROTOTYPE: $ |
|
|
2122 | |
|
|
2123 | void cf_player_move (player *pl, int dir) |
|
|
2124 | |
|
|
2125 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
|
|
2126 | |
|
|
2127 | player *first () |
2152 | CODE: |
2128 | CODE: |
2153 | RETVAL = registry_of (pl); |
2129 | RETVAL = first_player; |
|
|
2130 | OUTPUT: RETVAL |
|
|
2131 | |
|
|
2132 | player *next (player *pl) |
|
|
2133 | CODE: |
|
|
2134 | RETVAL = pl->next; |
|
|
2135 | OUTPUT: RETVAL |
|
|
2136 | |
|
|
2137 | bool |
|
|
2138 | cell_visible (player *pl, int dx, int dy) |
|
|
2139 | CODE: |
|
|
2140 | RETVAL = FABS (dx) <= pl->socket->mapx / 2 && FABS (dy) <= pl->socket->mapy / 2 |
|
|
2141 | && !pl->blocked_los [dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]; |
2154 | OUTPUT: |
2142 | OUTPUT: |
2155 | RETVAL |
2143 | RETVAL |
2156 | |
2144 | |
2157 | player *cf_player_find (char *name) |
|
|
2158 | PROTOTYPE: $ |
|
|
2159 | |
|
|
2160 | void cf_player_move (player *pl, int dir) |
|
|
2161 | |
|
|
2162 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
|
|
2163 | |
|
|
2164 | # nonstandard |
|
|
2165 | object *ob (player *pl) |
|
|
2166 | CODE: |
|
|
2167 | RETVAL = pl->ob; |
|
|
2168 | OUTPUT: RETVAL |
|
|
2169 | |
|
|
2170 | player *first () |
|
|
2171 | CODE: |
|
|
2172 | RETVAL = first_player; |
|
|
2173 | OUTPUT: RETVAL |
|
|
2174 | |
|
|
2175 | player *next (player *pl) |
|
|
2176 | CODE: |
|
|
2177 | RETVAL = pl->next; |
|
|
2178 | OUTPUT: RETVAL |
|
|
2179 | |
|
|
2180 | bool |
|
|
2181 | cell_visible (player *pl, int dx, int dy) |
|
|
2182 | CODE: |
|
|
2183 | 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]; |
|
|
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: |
|
|
2209 | RETVAL |
|
|
2210 | |
|
|
2211 | void |
|
|
2212 | buggy_mapscroll (player *pl, int value = 1) |
|
|
2213 | CODE: |
|
|
2214 | pl->socket.buggy_mapscroll = value; |
|
|
2215 | |
|
|
2216 | void |
2145 | void |
2217 | send (player *pl, SV *packet) |
2146 | send (player *pl, SV *packet) |
2218 | CODE: |
2147 | CODE: |
2219 | { |
2148 | { |
2220 | STRLEN len; |
2149 | STRLEN len; |
2221 | char *buf = SvPVbyte (packet, len); |
2150 | char *buf = SvPVbyte (packet, len); |
2222 | |
2151 | |
2223 | Write_String_To_Socket (&pl->socket, buf, len); |
2152 | pl->socket->send_packet (buf, len); |
2224 | } |
2153 | } |
2225 | |
2154 | |
2226 | int |
2155 | int |
2227 | listening (player *pl, int new_value = -1) |
2156 | listening (player *pl, int new_value = -1) |
2228 | CODE: |
2157 | CODE: |
… | |
… | |
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: |
|
|
2306 | RETVAL = registry_of (map); |
|
|
2307 | OUTPUT: |
|
|
2308 | RETVAL |
|
|
2309 | |
2227 | |
2310 | SV * |
2228 | 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 | |
2229 | |
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) |
2230 | maptile *new (int width, int height) |
2329 | PROTOTYPE: |
2231 | PROTOTYPE: |
2330 | CODE: |
2232 | CODE: |
2331 | { |
2233 | { |
2332 | RETVAL = get_empty_map (width, height); |
2234 | RETVAL = get_empty_map (width, height); |
2333 | } |
2235 | } |
2334 | OUTPUT: |
2236 | OUTPUT: |
2335 | RETVAL |
2237 | RETVAL |
2336 | |
2238 | |
2337 | void delete_map (mapstruct *map) |
2239 | void delete_map (maptile *map) |
2338 | |
2240 | |
2339 | void clean_tmp_map (mapstruct *map) |
2241 | void clean_tmp_map (maptile *map) |
2340 | |
2242 | |
2341 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
2243 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
2342 | |
2244 | |
|
|
2245 | int out_of_map (maptile *map, int x, int y) |
|
|
2246 | |
2343 | mapstruct *tile_map (mapstruct *map, unsigned int dir) |
2247 | maptile *tile_map (maptile *map, unsigned int dir) |
2344 | CODE: |
2248 | CODE: |
2345 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
2249 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
2346 | OUTPUT: |
2250 | OUTPUT: |
2347 | RETVAL |
2251 | RETVAL |
2348 | |
2252 | |
2349 | char *tile_path (mapstruct *map, unsigned int dir) |
2253 | char *tile_path (maptile *map, unsigned int dir) |
2350 | CODE: |
2254 | CODE: |
2351 | if (dir >= 4) |
2255 | if (dir >= 4) |
2352 | XSRETURN_UNDEF; |
2256 | XSRETURN_UNDEF; |
2353 | RETVAL = map->tile_path [dir]; |
2257 | RETVAL = map->tile_path [dir]; |
2354 | OUTPUT: |
2258 | OUTPUT: |
2355 | RETVAL |
2259 | RETVAL |
2356 | |
2260 | |
2357 | mapstruct *ready_map_name (char *name, int flags = 0) |
2261 | maptile *ready_map_name (char *name, int flags = 0) |
2358 | PROTOTYPE: $;$ |
2262 | PROTOTYPE: $;$ |
2359 | ALIAS: |
2263 | ALIAS: |
2360 | find = 0 |
2264 | find = 0 |
2361 | get_map = 1 |
2265 | get_map = 1 |
2362 | |
2266 | |
2363 | mapstruct *has_been_loaded (char *name) |
2267 | maptile *has_been_loaded (char *name) |
2364 | PROTOTYPE: $ |
2268 | PROTOTYPE: $ |
2365 | |
2269 | |
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) |
2270 | int in_memory (maptile *map) |
2374 | CODE: |
2271 | CODE: |
2375 | RETVAL = map->in_memory; |
2272 | RETVAL = map->in_memory; |
2376 | OUTPUT: |
2273 | OUTPUT: |
2377 | RETVAL |
2274 | RETVAL |
2378 | |
2275 | |
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 |
2276 | void |
2390 | trigger (mapstruct *map, long connection, bool state = true) |
2277 | trigger (maptile *map, long connection, bool state = true) |
2391 | CODE: |
2278 | CODE: |
2392 | activate_connection (map, connection, state); |
2279 | activate_connection (map, connection, state); |
2393 | |
2280 | |
2394 | void |
2281 | void |
2395 | get_connection (mapstruct *map, long connection) |
2282 | get_connection (maptile *map, long connection) |
2396 | PPCODE: |
2283 | PPCODE: |
2397 | oblinkpt *obp = get_connection_links (map, connection); |
2284 | oblinkpt *obp = get_connection_links (map, connection); |
2398 | if (obp) |
2285 | if (obp) |
2399 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2286 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
2400 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); |
2287 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, (object *)ol->ob))); |
2401 | |
2288 | |
2402 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
2289 | object *cf_map_insert_object_there (maptile *where, object *op, object *originator, int flags) |
2403 | |
2290 | |
2404 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
2291 | object *cf_map_insert_object (maptile *where, object* op, int x, int y) |
2405 | |
2292 | |
2406 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
2293 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2407 | C_ARGS: str, map, nx, ny |
2294 | C_ARGS: str, map, nx, ny |
2408 | |
2295 | |
2409 | void |
2296 | void |
2410 | cf_map_normalise (mapstruct *map, int x, int y) |
2297 | cf_map_normalise (maptile *map, int x, int y) |
2411 | PPCODE: |
2298 | PPCODE: |
2412 | { |
2299 | { |
2413 | mapstruct *nmap = 0; |
2300 | maptile *nmap = 0; |
2414 | I16 nx = 0, ny = 0; |
2301 | I16 nx = 0, ny = 0; |
2415 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2302 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2416 | |
2303 | |
2417 | EXTEND (SP, 4); |
2304 | EXTEND (SP, 4); |
2418 | PUSHs (sv_2mortal (newSViv (flags))); |
2305 | PUSHs (sv_2mortal (newSViv (flags))); |
… | |
… | |
2424 | PUSHs (sv_2mortal (newSViv (ny))); |
2311 | PUSHs (sv_2mortal (newSViv (ny))); |
2425 | } |
2312 | } |
2426 | } |
2313 | } |
2427 | |
2314 | |
2428 | void |
2315 | void |
2429 | at (mapstruct *map, unsigned int x, unsigned int y) |
2316 | at (maptile *map, unsigned int x, unsigned int y) |
2430 | PROTOTYPE: $$$ |
2317 | PROTOTYPE: $$$ |
2431 | PPCODE: |
2318 | PPCODE: |
2432 | { |
2319 | { |
2433 | object *o; |
2320 | object *o; |
2434 | mapstruct *nmap = 0; |
2321 | maptile *nmap = 0; |
2435 | I16 nx, ny; |
2322 | I16 nx, ny; |
2436 | |
2323 | |
2437 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2324 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2438 | |
2325 | |
2439 | if (nmap) |
2326 | if (nmap) |
2440 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2327 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2441 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2328 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2442 | } |
2329 | } |
2443 | |
2330 | |
2444 | SV * |
2331 | SV * |
2445 | bot_at (mapstruct *obj, unsigned int x, unsigned int y) |
2332 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2446 | PROTOTYPE: $$$ |
2333 | PROTOTYPE: $$$ |
2447 | ALIAS: |
2334 | ALIAS: |
2448 | top_at = 1 |
2335 | top_at = 1 |
2449 | flags_at = 2 |
2336 | flags_at = 2 |
2450 | light_at = 3 |
2337 | light_at = 3 |
… | |
… | |
2467 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2354 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2468 | } |
2355 | } |
2469 | OUTPUT: |
2356 | OUTPUT: |
2470 | RETVAL |
2357 | RETVAL |
2471 | |
2358 | |
|
|
2359 | void fix_walls (maptile *map, int x, int y) |
|
|
2360 | |
|
|
2361 | void fix_walls_around (maptile *map, int x, int y) |
2472 | |
2362 | |
2473 | MODULE = cf PACKAGE = cf::arch |
2363 | MODULE = cf PACKAGE = cf::arch |
2474 | |
2364 | |
2475 | archetype *find (const char *name) |
2365 | archetype *find (const char *name) |
2476 | CODE: |
2366 | CODE: |
2477 | RETVAL = find_archetype (name); |
2367 | RETVAL = archetype::find (name); |
2478 | OUTPUT: |
2368 | OUTPUT: |
2479 | RETVAL |
2369 | RETVAL |
2480 | |
2370 | |
2481 | archetype *first() |
2371 | archetype *first() |
2482 | PROTOTYPE: |
2372 | PROTOTYPE: |
2483 | CODE: |
2373 | CODE: |
2484 | RETVAL = first_archetype; |
2374 | RETVAL = first_archetype; |
2485 | OUTPUT: RETVAL |
2375 | OUTPUT: RETVAL |
2486 | |
2376 | |
2487 | archetype *next (archetype *arch) |
2377 | 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 | |
2378 | |
2512 | MODULE = cf PACKAGE = cf::party |
2379 | MODULE = cf PACKAGE = cf::party |
2513 | |
2380 | |
2514 | partylist *first () |
2381 | partylist *first () |
2515 | PROTOTYPE: |
2382 | PROTOTYPE: |
… | |
… | |
2565 | RETVAL = reg->msg; |
2432 | RETVAL = reg->msg; |
2566 | OUTPUT: RETVAL |
2433 | OUTPUT: RETVAL |
2567 | |
2434 | |
2568 | MODULE = cf PACKAGE = cf::living |
2435 | MODULE = cf PACKAGE = cf::living |
2569 | |
2436 | |
2570 | val64 |
2437 | INCLUDE: $PERL genacc living ../include/living.h | |
2571 | exp (living *liv, val64 new_val = 0) |
2438 | |
2572 | PROTOTYPE: $;$ |
2439 | MODULE = cf PACKAGE = cf::settings |
2573 | ALIAS: |
2440 | |
2574 | Str = 1 |
2441 | INCLUDE: $PERL genacc Settings ../include/global.h | |
2575 | Dex = 2 |
2442 | |
2576 | Con = 3 |
2443 | MODULE = cf PACKAGE = cf::client |
2577 | Wis = 4 |
2444 | |
2578 | Cha = 5 |
2445 | INCLUDE: $PERL genacc client ../include/client.h | |
2579 | Int = 6 |
2446 | |
2580 | Pow = 7 |
2447 | int invoke (client *ns, int event, ...) |
2581 | wc = 8 |
2448 | CODE: |
2582 | ac = 9 |
2449 | if (KLASS_OF (event) != KLASS_CLIENT) croak ("event class must be CLIENT"); |
2583 | hp = 10 |
2450 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2584 | maxhp = 11 |
2451 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2585 | sp = 12 |
2452 | RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); |
2586 | maxsp = 13 |
2453 | OUTPUT: RETVAL |
2587 | grace = 14 |
2454 | |
2588 | maxgrace = 15 |
2455 | SV *registry (client *ns) |
2589 | food = 16 |
2456 | |
2590 | dam = 17 |
2457 | client * |
2591 | luck = 18 |
2458 | create (int fd, const char *peername) |
2592 | CODE: |
2459 | CODE: |
2593 | # define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = (sint64)new_val; break |
2460 | RETVAL = client::create (fd, peername); |
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: |
2461 | OUTPUT: |
2618 | RETVAL |
2462 | RETVAL |
2619 | |
2463 | |
|
|
2464 | void |
|
|
2465 | client::destroy () |
|
|
2466 | |