… | |
… | |
21 | * You should have received a copy of the GNU General Public License |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | */ |
24 | */ |
25 | |
25 | |
|
|
26 | #define PLUGIN_NAME "perl" |
|
|
27 | #define PLUGIN_VERSION "cfperl 0.5" |
|
|
28 | |
|
|
29 | #include <plugin_common.h> |
|
|
30 | #include <sounds.h> |
|
|
31 | #include <cstdarg> |
|
|
32 | #include <sproto.h> |
|
|
33 | |
|
|
34 | #include "cfperl.h" |
|
|
35 | #include "shstr.h" |
|
|
36 | |
26 | #include <EXTERN.h> |
37 | #include <EXTERN.h> |
27 | #include <perl.h> |
38 | #include <perl.h> |
28 | #include <XSUB.h> |
39 | #include <XSUB.h> |
29 | |
40 | |
30 | #undef save_long // clashes with libproto.h |
|
|
31 | |
|
|
32 | #define PLUGIN_NAME "perl" |
|
|
33 | #define PLUGIN_VERSION "cfperl 0.3" |
|
|
34 | |
|
|
35 | #ifndef __CEXTRACT__ |
|
|
36 | #include <plugin.h> |
|
|
37 | #endif |
|
|
38 | |
|
|
39 | #undef MODULEAPI |
|
|
40 | #ifdef WIN32 |
|
|
41 | #else |
|
|
42 | #define MODULEAPI |
|
|
43 | #endif |
|
|
44 | |
|
|
45 | #include <plugin_common.h> |
|
|
46 | #include <sounds.h> |
|
|
47 | |
|
|
48 | #include <stdarg.h> |
|
|
49 | |
|
|
50 | #include <sproto.h> |
|
|
51 | |
|
|
52 | //#include "EventAPI.h" |
|
|
53 | #include "perlxsi.c" |
41 | #include "perlxsi.c" |
54 | |
|
|
55 | static void *globalEventListener (int *type, ...); |
|
|
56 | |
42 | |
57 | extern sint64 *levels; // the experience table |
43 | extern sint64 *levels; // the experience table |
58 | |
44 | |
59 | typedef object object_ornull; |
45 | typedef object object_ornull; |
60 | typedef mapstruct mapstruct_ornull; |
46 | typedef mapstruct mapstruct_ornull; |
61 | |
47 | |
62 | typedef double val64; |
48 | typedef double val64; |
63 | #define newSVval64 newSVnv |
49 | #define newSVval64 newSVnv |
64 | #define SvVAL64 SvNV |
50 | #define SvVAL64 SvNV |
65 | |
51 | |
66 | static f_plug_api gethook; |
52 | static f_plug_api gethook = cfapi_get_hooks; |
67 | static f_plug_api registerGlobalEvent; |
53 | static f_plug_api object_set_property = cfapi_object_set_property; |
68 | static f_plug_api unregisterGlobalEvent; |
54 | static f_plug_api object_insert = cfapi_object_insert; |
69 | static f_plug_api systemDirectory; |
55 | |
70 | static f_plug_api object_set_property; |
56 | static bool perl_booted; |
71 | static f_plug_api map_get_map; |
|
|
72 | static f_plug_api object_insert; |
|
|
73 | |
57 | |
74 | /* this is a stupid way to do things, and awkward to use for plug-in authors */ |
58 | /* this is a stupid way to do things, and awkward to use for plug-in authors */ |
75 | typedef struct |
59 | typedef struct |
76 | { |
60 | { |
77 | object* who; |
61 | object* who; |
… | |
… | |
88 | } CFPContext; |
72 | } CFPContext; |
89 | |
73 | |
90 | static HV *obj_cache; |
74 | static HV *obj_cache; |
91 | static PerlInterpreter *perl; |
75 | static PerlInterpreter *perl; |
92 | |
76 | |
|
|
77 | static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; |
|
|
78 | |
93 | #define PUSHcfapi(type,value) PUSHs (sv_2mortal (newSVcfapi (CFAPI_ ## type, (value)))) |
79 | #define PUSHcfapi(type,value) PUSHs (sv_2mortal (newSVcfapi (CFAPI_ ## type, (value)))) |
94 | #define PUSHcfapi_va(type,ctype) PUSHcfapi (type, va_arg (args, ctype)) |
80 | #define PUSHcfapi_va(type,ctype) PUSHcfapi (type, va_arg (args, ctype)) |
95 | #define PUSH_OB PUSHcfapi_va(POBJECT, object *) |
81 | #define PUSH_OB PUSHcfapi_va(POBJECT, object *) |
96 | #define PUSH_PL PUSHcfapi_va(PPLAYER, player *) |
82 | #define PUSH_PL PUSHcfapi_va(PPLAYER, player *) |
97 | #define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) |
83 | #define PUSH_MAP PUSHcfapi_va(PMAP, mapstruct *) |
98 | #define PUSH_PV PUSHcfapi_va(STRING, const char *) |
84 | #define PUSH_PV PUSHcfapi_va(STRING, const char *) |
99 | #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) |
85 | #define PUSH_IV PUSHs (sv_2mortal (newSViv (va_arg (args, int)))) |
100 | |
86 | |
101 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
87 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
102 | |
88 | |
103 | // garbage collect some perl objects, if possible |
|
|
104 | // all objects no longer referenced and empty are |
|
|
105 | // eligible for destruction. |
|
|
106 | static void |
|
|
107 | clean_obj_cache () |
|
|
108 | { |
|
|
109 | static int count; |
|
|
110 | |
|
|
111 | if (++count & 7) |
|
|
112 | return; |
|
|
113 | |
|
|
114 | int todo = 1000; |
|
|
115 | do |
|
|
116 | { |
|
|
117 | I32 klen; |
|
|
118 | char *key; |
|
|
119 | HE *he = hv_iternext (obj_cache); |
|
|
120 | |
|
|
121 | if (he) |
|
|
122 | { |
|
|
123 | SV *sv = hv_iterval (obj_cache, he); |
|
|
124 | |
|
|
125 | // empty and unreferenced? nuke it |
|
|
126 | if (SvREFCNT (sv) == 1 && SvREFCNT (SvRV (sv)) == 1 && !HvFILL ((HV *)(SvRV (sv)))) |
|
|
127 | { |
|
|
128 | hv_delete (obj_cache, HeKEY (he), HeKLEN (he), G_DISCARD); |
|
|
129 | todo++; |
|
|
130 | } |
|
|
131 | } |
|
|
132 | else |
|
|
133 | break; |
|
|
134 | } |
|
|
135 | while (--todo); |
|
|
136 | } |
|
|
137 | |
|
|
138 | static SV * |
89 | static SV * |
139 | newSVptr (void *ptr, const char *klass) |
90 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
140 | { |
91 | { |
141 | SV *sv; |
92 | SV *sv; |
142 | |
93 | |
143 | if (!ptr) |
94 | if (!ptr) |
144 | return &PL_sv_undef; |
95 | return &PL_sv_undef; |
145 | |
96 | |
146 | sv = newSV (0); |
|
|
147 | sv_magic (sv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
97 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
148 | return sv_bless (newRV_noinc (sv), gv_stashpv (klass, 1)); |
98 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
99 | } |
|
|
100 | |
|
|
101 | template<class attachable> |
|
|
102 | SV * |
|
|
103 | newSVattachable (attachable *obj, const char *klass) |
|
|
104 | { |
|
|
105 | if (!obj) |
|
|
106 | return &PL_sv_undef; |
|
|
107 | |
|
|
108 | if (!obj->self) |
|
|
109 | obj->self = newSVptr (obj, klass); |
|
|
110 | |
|
|
111 | return newSVsv (obj->self); |
149 | } |
112 | } |
150 | |
113 | |
151 | static void |
114 | static void |
152 | SVptr_cache_set (void *ptr, SV *sv) |
115 | SVptr_cache_set (void *ptr, SV *sv) |
153 | { |
116 | { |
… | |
… | |
216 | else |
179 | else |
217 | return 0; |
180 | return 0; |
218 | } |
181 | } |
219 | |
182 | |
220 | static SV * |
183 | static SV * |
221 | newSVcfapi (int type, ...) |
184 | newSVdt_va (va_list &ap, data_type type) |
222 | { |
185 | { |
223 | SV *sv; |
186 | SV *sv; |
224 | |
|
|
225 | va_list args; |
|
|
226 | va_start (args, type); |
|
|
227 | |
187 | |
228 | switch (type) |
188 | switch (type) |
229 | { |
189 | { |
230 | #if 0 |
|
|
231 | case CFAPI_INT16: |
190 | case DT_INT: |
232 | sv = newSViv (*va_arg (args, sint16_t *)); |
191 | sv = newSViv (va_arg (ap, int)); |
233 | break; |
192 | break; |
234 | #endif |
|
|
235 | |
193 | |
236 | case CFAPI_INT: |
194 | case DT_INT64: |
237 | sv = newSViv (*va_arg (args, int *)); |
195 | sv = newSVval64 ((val64)va_arg (ap, sint64)); |
238 | break; |
196 | break; |
239 | |
197 | |
240 | case CFAPI_LONG: |
198 | case DT_DOUBLE: |
241 | sv = newSVval64 ((val64)*va_arg (args, sint64 *)); |
199 | sv = newSVnv (va_arg (ap, double)); |
242 | break; |
200 | break; |
243 | |
201 | |
244 | case CFAPI_DOUBLE: |
|
|
245 | sv = newSVnv (*va_arg (args, double *)); |
|
|
246 | break; |
|
|
247 | |
|
|
248 | case CFAPI_STRING: |
202 | case DT_STRING: |
249 | { |
203 | { |
250 | char *str = va_arg (args, char *); |
204 | char *str = (char *)va_arg (ap, const char *); |
251 | sv = str ? newSVpv (str, 0) : &PL_sv_undef; |
205 | sv = str ? newSVpv (str, 0) : &PL_sv_undef; |
252 | } |
206 | } |
253 | break; |
207 | break; |
254 | |
208 | |
255 | case CFAPI_POBJECT: |
209 | case DT_DATA: |
256 | { |
210 | { |
257 | object *obj = va_arg (args, object *); |
211 | char *str = (char *)va_arg (ap, const void *); |
258 | |
212 | int len = va_arg (ap, int); |
259 | if (!obj) |
213 | sv = str ? newSVpv (str, len) : &PL_sv_undef; |
260 | sv = &PL_sv_undef; |
|
|
261 | else |
|
|
262 | switch (obj->type) |
|
|
263 | { |
|
|
264 | case MAP: |
|
|
265 | sv = newSVptr_cached (obj, "cf::object::map::wrap"); |
|
|
266 | break; |
|
|
267 | |
|
|
268 | case PLAYER: |
|
|
269 | sv = newSVptr_cached (obj, "cf::object::player::wrap"); |
|
|
270 | break; |
|
|
271 | |
|
|
272 | default: |
|
|
273 | sv = newSVptr_cached (obj, "cf::object::wrap"); |
|
|
274 | break; |
|
|
275 | } |
|
|
276 | } |
214 | } |
277 | break; |
215 | break; |
278 | |
216 | |
279 | case CFAPI_PMAP: |
217 | case DT_OBJECT: |
280 | sv = newSVptr (va_arg (args, mapstruct *), "cf::map::wrap"); |
218 | { |
|
|
219 | object *obj = va_arg (ap, object *); |
|
|
220 | sv = newSVattachable (obj, obj && obj->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); |
|
|
221 | } |
281 | break; |
222 | break; |
282 | |
223 | |
283 | case CFAPI_PPLAYER: |
224 | case DT_MAP: |
284 | sv = newSVptr (va_arg (args, player *), "cf::player::wrap"); |
225 | // va_arg (object *) when void * is passed is an XSI extension |
|
|
226 | sv = newSVattachable (va_arg (ap, mapstruct *), "cf::map::wrap"); |
285 | break; |
227 | break; |
286 | |
228 | |
287 | case CFAPI_PARCH: |
229 | case DT_PLAYER: |
288 | sv = newSVptr (va_arg (args, archetype *), "cf::arch::wrap"); |
230 | sv = newSVattachable (va_arg (ap, player *), "cf::player::wrap"); |
289 | break; |
231 | break; |
290 | |
232 | |
291 | case CFAPI_PPARTY: |
233 | case DT_ARCH: |
292 | sv = newSVptr (va_arg (args, partylist *), "cf::party::wrap"); |
234 | sv = newSVptr (va_arg (ap, archetype *), "cf::arch::wrap"); |
293 | break; |
235 | break; |
294 | |
236 | |
295 | case CFAPI_PREGION: |
237 | case DT_PARTY: |
296 | sv = newSVptr (va_arg (args, region *), "cf::region::wrap"); |
238 | sv = newSVptr (va_arg (ap, partylist *), "cf::party::wrap"); |
297 | break; |
239 | break; |
|
|
240 | |
|
|
241 | case DT_REGION: |
|
|
242 | sv = newSVptr (va_arg (ap, region *), "cf::region::wrap"); |
|
|
243 | break; |
|
|
244 | |
|
|
245 | default: |
|
|
246 | assert (("unhandled type in newSVdt_va", 0)); |
|
|
247 | } |
|
|
248 | |
|
|
249 | return sv; |
|
|
250 | } |
|
|
251 | |
|
|
252 | static SV * |
|
|
253 | newSVdt (data_type type, ...) |
|
|
254 | { |
|
|
255 | va_list ap; |
|
|
256 | |
|
|
257 | va_start (ap, type); |
|
|
258 | SV *sv = newSVdt_va (ap, type); |
|
|
259 | va_end (ap); |
|
|
260 | |
|
|
261 | return sv; |
|
|
262 | } |
|
|
263 | |
|
|
264 | static SV * |
|
|
265 | newSVcfapi (int type, ...) |
|
|
266 | { |
|
|
267 | SV *sv; |
|
|
268 | |
|
|
269 | va_list ap; |
|
|
270 | va_start (ap, type); |
|
|
271 | |
|
|
272 | switch (type) |
|
|
273 | { |
|
|
274 | case CFAPI_INT: sv = newSViv (*va_arg (ap, int * )); break; |
|
|
275 | case CFAPI_LONG: sv = newSVval64 (*va_arg (ap, sint64 *)); break; |
|
|
276 | case CFAPI_DOUBLE: sv = newSVnv (*va_arg (ap, double *)); break; |
|
|
277 | case CFAPI_STRING: sv = newSVdt_va (ap, DT_STRING); break; |
|
|
278 | case CFAPI_POBJECT: sv = newSVdt_va (ap, DT_OBJECT); break; |
|
|
279 | case CFAPI_PMAP: sv = newSVdt_va (ap, DT_MAP ); break; |
|
|
280 | case CFAPI_PPLAYER: sv = newSVdt_va (ap, DT_PLAYER); break; |
|
|
281 | case CFAPI_PARCH: sv = newSVdt_va (ap, DT_ARCH ); break; |
|
|
282 | case CFAPI_PPARTY: sv = newSVdt_va (ap, DT_PARTY ); break; |
|
|
283 | case CFAPI_PREGION: sv = newSVdt_va (ap, DT_REGION); break; |
298 | |
284 | |
299 | default: |
285 | default: |
300 | assert (("unhandled type in newSVcfapi", 0)); |
286 | assert (("unhandled type in newSVcfapi", 0)); |
301 | } |
287 | } |
302 | |
288 | |
303 | va_end (args); |
289 | va_end (ap); |
304 | |
290 | |
305 | return sv; |
291 | return sv; |
306 | } |
292 | } |
307 | |
293 | |
|
|
294 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
295 | |
|
|
296 | SV * |
|
|
297 | registry_of (attachable_base *ext) |
|
|
298 | { |
|
|
299 | if (!ext->cb) |
|
|
300 | ext->cb = newAV (); |
|
|
301 | |
|
|
302 | return newRV_inc ((SV *)ext->cb); |
|
|
303 | } |
|
|
304 | |
|
|
305 | void attachable_base::clear () |
|
|
306 | { |
|
|
307 | if (self) |
|
|
308 | { |
|
|
309 | if (cb) |
|
|
310 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
|
|
311 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
|
|
312 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
|
|
313 | INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); |
|
|
314 | |
|
|
315 | // disconnect Perl from C, to avoid crashes |
|
|
316 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
|
|
317 | |
|
|
318 | // clear the perl hash, might or might not be a good idea |
|
|
319 | hv_clear ((HV *)SvRV ((SV *)self)); |
|
|
320 | |
|
|
321 | SvREFCNT_dec (self); |
|
|
322 | self = 0; |
|
|
323 | } |
|
|
324 | |
|
|
325 | if (cb) |
|
|
326 | { |
|
|
327 | SvREFCNT_dec (cb); |
|
|
328 | cb = 0; |
|
|
329 | } |
|
|
330 | |
|
|
331 | if (attach) |
|
|
332 | { |
|
|
333 | free_string (attach); |
|
|
334 | attach = 0; |
|
|
335 | } |
|
|
336 | } |
|
|
337 | |
|
|
338 | void attachable_base::optimise () |
|
|
339 | { |
|
|
340 | if (!self) |
|
|
341 | return; |
|
|
342 | |
|
|
343 | HV *hv = (HV *)SvRV ((SV *)self); |
|
|
344 | |
|
|
345 | if (SvREFCNT ((SV *)self) == 1 |
|
|
346 | && SvREFCNT ((SV *)hv) == 1 |
|
|
347 | && !HvKEYS (hv)) |
|
|
348 | { |
|
|
349 | SvREFCNT_dec ((SV *)self); |
|
|
350 | self = 0; |
|
|
351 | } |
|
|
352 | } |
|
|
353 | |
|
|
354 | void attachable_base::instantiate (data_type type, void *obj) |
|
|
355 | { |
|
|
356 | dSP; |
|
|
357 | ENTER; |
|
|
358 | SAVETMPS; |
|
|
359 | PUSHMARK (SP); |
|
|
360 | EXTEND (SP, 2); |
|
|
361 | PUSHs (sv_2mortal (newSVdt (type, obj))); |
|
|
362 | PUSHs (sv_2mortal (newSVpv (attach, 0))); |
|
|
363 | |
|
|
364 | free_string (attach); |
|
|
365 | attach = 0; |
|
|
366 | |
|
|
367 | PUTBACK; |
|
|
368 | call_pv ("cf::instantiate", G_DISCARD | G_VOID | G_EVAL); |
|
|
369 | FREETMPS; |
|
|
370 | LEAVE; |
|
|
371 | |
|
|
372 | switch (type) |
|
|
373 | { |
|
|
374 | case DT_OBJECT: INVOKE_OBJECT (INSTANTIATE, obj); break; |
|
|
375 | case DT_MAP: INVOKE_MAP (INSTANTIATE, obj); break; |
|
|
376 | } |
|
|
377 | } |
|
|
378 | |
308 | ///////////////////////////////////////////////////////////////////////////// |
379 | ///////////////////////////////////////////////////////////////////////////// |
309 | |
380 | |
|
|
381 | void reattach (data_type type, void *obj) |
|
|
382 | { |
|
|
383 | //TODO only do this when the object has _attachment's |
|
|
384 | |
|
|
385 | dSP; |
|
|
386 | ENTER; |
|
|
387 | SAVETMPS; |
|
|
388 | PUSHMARK (SP); |
|
|
389 | XPUSHs (sv_2mortal (newSVdt (type, obj))); |
|
|
390 | PUTBACK; |
|
|
391 | call_pv ("cf::reattach", G_DISCARD | G_VOID | G_EVAL); |
|
|
392 | FREETMPS; |
|
|
393 | LEAVE; |
|
|
394 | |
|
|
395 | switch (type) |
|
|
396 | { |
|
|
397 | case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; |
|
|
398 | case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; |
|
|
399 | case DT_MAP: INVOKE_MAP (REATTACH, obj); break; |
|
|
400 | } |
|
|
401 | } |
|
|
402 | |
|
|
403 | template<class subclass> |
|
|
404 | void reattach (attachable<subclass> *obj) |
|
|
405 | { |
|
|
406 | obj->optimise (); |
|
|
407 | |
|
|
408 | if (obj->self) |
|
|
409 | reattach ((data_type) cftype<subclass>::dt, (subclass *)obj); |
|
|
410 | } |
|
|
411 | |
|
|
412 | #include "kw_hash.h" |
|
|
413 | |
|
|
414 | object_freezer::object_freezer () |
|
|
415 | : dynbuf (128 * 1024, 64 * 1024) |
|
|
416 | { |
|
|
417 | av = newAV (); |
|
|
418 | } |
|
|
419 | |
|
|
420 | object_freezer::~object_freezer () |
|
|
421 | { |
|
|
422 | SvREFCNT_dec (av); |
|
|
423 | } |
|
|
424 | |
|
|
425 | void object_freezer::put (attachable_base *ext) |
|
|
426 | { |
|
|
427 | ext->optimise (); |
|
|
428 | |
|
|
429 | if (ext->self) |
|
|
430 | { |
|
|
431 | int idx = AvFILLp ((AV *)av) + 1; |
|
|
432 | av_store (av, idx, SvREFCNT_inc (ext->self)); |
|
|
433 | |
|
|
434 | add ((void *)"oid ", 4); |
|
|
435 | add ((sint32)idx); |
|
|
436 | add ('\n'); |
|
|
437 | } |
|
|
438 | } |
|
|
439 | |
|
|
440 | bool object_freezer::save (const char *filename) |
|
|
441 | { |
|
|
442 | dSP; |
|
|
443 | ENTER; |
|
|
444 | SAVETMPS; |
|
|
445 | PUSHMARK (SP); |
|
|
446 | EXTEND (SP, 3); |
|
|
447 | PUSHs (sv_2mortal (newSVpv (filename, 0))); |
|
|
448 | PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ())))); |
|
|
449 | PUSHs (sv_2mortal (newRV_inc ((SV *)av))); |
|
|
450 | PUTBACK; |
|
|
451 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
|
|
452 | FREETMPS; |
|
|
453 | LEAVE; |
|
|
454 | } |
|
|
455 | |
|
|
456 | int fprintf (object_freezer &freezer, const char *format, ...) |
|
|
457 | { |
|
|
458 | va_list ap; |
|
|
459 | |
|
|
460 | va_start (ap, format); |
|
|
461 | |
|
|
462 | int len = vsnprintf ((char *)freezer.force (1024), 1024, format, ap); |
|
|
463 | |
|
|
464 | if (len >= 0) |
|
|
465 | freezer.alloc (len); |
|
|
466 | |
|
|
467 | va_end (ap); |
|
|
468 | } |
|
|
469 | |
|
|
470 | int fputs (const char *s, object_freezer &freezer) |
|
|
471 | { |
|
|
472 | freezer.add (s); |
|
|
473 | } |
|
|
474 | |
|
|
475 | object_thawer::object_thawer (const char *filename) |
|
|
476 | { |
|
|
477 | av = 0; |
|
|
478 | fp = 0; |
|
|
479 | |
|
|
480 | if (!filename) |
|
|
481 | return; |
|
|
482 | |
|
|
483 | fp = fopen (filename, "r"); |
|
|
484 | if (!fp) |
|
|
485 | { |
|
|
486 | LOG (llevError, "object_thawer: unable to open '%s': %s.\n", filename, strerror (errno)); |
|
|
487 | return; |
|
|
488 | } |
|
|
489 | |
|
|
490 | if (perl_booted) |
|
|
491 | { |
|
|
492 | dSP; |
|
|
493 | ENTER; |
|
|
494 | SAVETMPS; |
|
|
495 | PUSHMARK (SP); |
|
|
496 | XPUSHs (sv_2mortal (newSVpv (filename, 0))); |
|
|
497 | PUTBACK; |
|
|
498 | |
|
|
499 | if (0 < call_pv ("cf::object_thawer_load", G_SCALAR | G_EVAL)) |
|
|
500 | { |
|
|
501 | SPAGAIN; |
|
|
502 | SV *sv = POPs; |
|
|
503 | if (SvROK (sv)) |
|
|
504 | av = (AV *)SvREFCNT_inc (SvRV (sv)); |
|
|
505 | } |
|
|
506 | |
|
|
507 | FREETMPS; |
|
|
508 | LEAVE; |
|
|
509 | } |
|
|
510 | } |
|
|
511 | |
|
|
512 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
|
|
513 | { |
|
|
514 | if (!av || oid < 0) // this is actually an error of sorts |
|
|
515 | return; |
|
|
516 | |
|
|
517 | // we have to "re-instantiate"/reattach to an object, so nuke ext->attach |
|
|
518 | ext->clear (); |
|
|
519 | |
|
|
520 | SV **svp = av_fetch ((AV *)av, oid, 0); |
|
|
521 | |
|
|
522 | if (!svp || !SvROK (*svp)) |
|
|
523 | { |
|
|
524 | printf ("trying to thaw duplicate or never-issued oid %d, ignoring.\n", oid); |
|
|
525 | return; |
|
|
526 | } |
|
|
527 | |
|
|
528 | ext->self = *svp; *svp = &PL_sv_undef; |
|
|
529 | sv_magic (SvRV (ext->self), 0, PERL_MAGIC_ext, (char *)obj, 0); |
|
|
530 | |
|
|
531 | reattach (type, obj); |
|
|
532 | } |
|
|
533 | |
|
|
534 | object_thawer::~object_thawer () |
|
|
535 | { |
|
|
536 | if (fp) fclose (fp); |
|
|
537 | if (av) SvREFCNT_dec ((AV *)av); |
|
|
538 | } |
|
|
539 | |
|
|
540 | token object_thawer::get_token () |
|
|
541 | { |
|
|
542 | #if 0 |
|
|
543 | for (;;) |
|
|
544 | { |
|
|
545 | if (!fgets (line, sizeof (line), fp)) |
|
|
546 | return token (KW_eof); |
|
|
547 | |
|
|
548 | unsigned char *p = (unsigned char *)line; |
|
|
549 | |
|
|
550 | while (*p > ' ') |
|
|
551 | p++; |
|
|
552 | |
|
|
553 | int len = p - (unsigned char *)line; |
|
|
554 | |
|
|
555 | while ((*p - 1) < ' ') |
|
|
556 | p++; |
|
|
557 | |
|
|
558 | if (*p) |
|
|
559 | { |
|
|
560 | char *v = p; |
|
|
561 | |
|
|
562 | while (*p && *p != '\n') |
|
|
563 | p++; |
|
|
564 | |
|
|
565 | *p = 0; |
|
|
566 | |
|
|
567 | return token (k, v); |
|
|
568 | } |
|
|
569 | else |
|
|
570 | return token (k); |
|
|
571 | } |
|
|
572 | #endif |
|
|
573 | } |
|
|
574 | |
|
|
575 | ///////////////////////////////////////////////////////////////////////////// |
|
|
576 | |
310 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
577 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
311 | { |
578 | { |
312 | gethook = gethooksptr; |
|
|
313 | printf (PLUGIN_VERSION " init\n"); |
|
|
314 | |
|
|
315 | return 0; |
579 | return 0; |
316 | } |
580 | } |
317 | |
581 | |
318 | static CommArray_s rtn_cmd; |
582 | static CommArray_s rtn_cmd; |
319 | |
583 | |
… | |
… | |
399 | extern "C" int cfperl_postInitPlugin () |
663 | extern "C" int cfperl_postInitPlugin () |
400 | { |
664 | { |
401 | int hooktype = 1; |
665 | int hooktype = 1; |
402 | int rtype = 0; |
666 | int rtype = 0; |
403 | |
667 | |
404 | printf (PLUGIN_VERSION " post init\n"); |
|
|
405 | |
|
|
406 | registerGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
|
|
407 | unregisterGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
|
|
408 | systemDirectory = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_directory"); |
|
|
409 | object_set_property = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_set_property"); |
|
|
410 | map_get_map = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_map_get_map"); |
|
|
411 | object_insert = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_insert"); |
|
|
412 | |
|
|
413 | cf_init_plugin (gethook); |
668 | cf_init_plugin (gethook); |
414 | |
669 | |
415 | /* Pick the global events you want to monitor from this plugin */ |
670 | return 0; |
416 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
671 | } |
417 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
672 | |
418 | //registerGlobalEvent (NULL, EVENT_CRASH, PLUGIN_NAME, globalEventListener); |
673 | extern "C" int cfperl_closePlugin () |
419 | registerGlobalEvent (NULL, EVENT_FIND_UNARMED_SKILL, PLUGIN_NAME, globalEventListener); |
674 | { |
420 | registerGlobalEvent (NULL, EVENT_PLAYER_USE_SKILL, PLUGIN_NAME, globalEventListener); |
675 | return 0; |
421 | registerGlobalEvent (NULL, EVENT_CAST_SPELL, PLUGIN_NAME, globalEventListener); |
676 | } |
422 | registerGlobalEvent (NULL, EVENT_MONSTER_USE_SKILL, PLUGIN_NAME, globalEventListener); |
677 | |
423 | registerGlobalEvent (NULL, EVENT_PLAYER_DEATH, PLUGIN_NAME, globalEventListener); |
678 | void |
424 | registerGlobalEvent (NULL, EVENT_GKILL, PLUGIN_NAME, globalEventListener); |
679 | cfperl_init () |
425 | registerGlobalEvent (NULL, EVENT_LOGIN, PLUGIN_NAME, globalEventListener); |
680 | { |
426 | registerGlobalEvent (NULL, EVENT_LOGOUT, PLUGIN_NAME, globalEventListener); |
681 | PERL_SYS_INIT3 (&settings.argc, &settings.argv, 0); |
427 | registerGlobalEvent (NULL, EVENT_MAPENTER, PLUGIN_NAME, globalEventListener); |
682 | perl = perl_alloc (); |
428 | registerGlobalEvent (NULL, EVENT_MAPLEAVE, PLUGIN_NAME, globalEventListener); |
683 | perl_construct (perl); |
429 | registerGlobalEvent (NULL, EVENT_MAPRESET, PLUGIN_NAME, globalEventListener); |
684 | |
430 | registerGlobalEvent (NULL, EVENT_MAPLOAD, PLUGIN_NAME, globalEventListener); |
685 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
431 | registerGlobalEvent (NULL, EVENT_MAPOUT, PLUGIN_NAME, globalEventListener); |
|
|
432 | registerGlobalEvent (NULL, EVENT_MAPIN, PLUGIN_NAME, globalEventListener); |
|
|
433 | registerGlobalEvent (NULL, EVENT_MAPCLEAN, PLUGIN_NAME, globalEventListener); |
|
|
434 | registerGlobalEvent (NULL, EVENT_REMOVE, PLUGIN_NAME, globalEventListener); |
|
|
435 | registerGlobalEvent (NULL, EVENT_SHOUT, PLUGIN_NAME, globalEventListener); |
|
|
436 | registerGlobalEvent (NULL, EVENT_TELL, PLUGIN_NAME, globalEventListener); |
|
|
437 | registerGlobalEvent (NULL, EVENT_MUZZLE, PLUGIN_NAME, globalEventListener); |
|
|
438 | registerGlobalEvent (NULL, EVENT_KICK, PLUGIN_NAME, globalEventListener); |
|
|
439 | registerGlobalEvent (NULL, EVENT_FREE_OB, PLUGIN_NAME, globalEventListener); |
|
|
440 | registerGlobalEvent (NULL, EVENT_PLAYER_LOAD, PLUGIN_NAME, globalEventListener); |
|
|
441 | registerGlobalEvent (NULL, EVENT_PLAYER_SAVE, PLUGIN_NAME, globalEventListener); |
|
|
442 | registerGlobalEvent (NULL, EVENT_EXTCMD, PLUGIN_NAME, globalEventListener); |
|
|
443 | |
686 | |
444 | char *argv[] = { |
687 | char *argv[] = { |
445 | "", |
688 | "", |
446 | "-e" |
689 | "-e" |
447 | "BEGIN {" |
|
|
448 | " cf->bootstrap;" |
690 | "cf->bootstrap;" |
449 | " unshift @INC, cf::datadir ();" |
691 | "unshift @INC, cf::datadir ();" |
450 | "}" |
|
|
451 | "" |
|
|
452 | "use cf;" |
|
|
453 | }; |
692 | }; |
454 | |
|
|
455 | perl = perl_alloc (); |
|
|
456 | perl_construct (perl); |
|
|
457 | |
|
|
458 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
|
|
459 | |
693 | |
460 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
694 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
461 | { |
695 | { |
462 | printf ("unable to initialize perl-interpreter, continuing without.\n"); |
696 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
463 | |
697 | exit (EXIT_FAILURE); |
464 | perl_destruct (perl); |
|
|
465 | perl_free (perl); |
|
|
466 | perl = 0; |
|
|
467 | } |
698 | } |
468 | else |
699 | |
|
|
700 | obj_cache = newHV (); |
|
|
701 | } |
|
|
702 | |
|
|
703 | void cfperl_boot () |
|
|
704 | { |
|
|
705 | perl_booted = true; |
|
|
706 | |
|
|
707 | eval_pv ("require cf", 1); |
|
|
708 | } |
|
|
709 | |
|
|
710 | void cfperl_main () |
|
|
711 | { |
|
|
712 | dSP; |
|
|
713 | |
|
|
714 | PUSHMARK (SP); |
|
|
715 | PUTBACK; |
|
|
716 | call_pv ("cf::main", G_DISCARD | G_VOID); |
|
|
717 | } |
|
|
718 | |
|
|
719 | static event_klass klass_of[NUM_EVENT_TYPES] = { |
|
|
720 | # define def(type,name) KLASS_ ## type, |
|
|
721 | # include "eventinc.h" |
|
|
722 | # undef def |
|
|
723 | }; |
|
|
724 | |
|
|
725 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
|
|
726 | |
|
|
727 | static void |
|
|
728 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
|
|
729 | { |
|
|
730 | // event must be in array |
|
|
731 | if (event >= 0 && event <= AvFILLp (registry)) |
469 | { |
732 | { |
470 | obj_cache = newHV (); |
733 | SV *cbs_ = AvARRAY (registry)[event]; |
|
|
734 | |
|
|
735 | // element must be list of callback entries |
|
|
736 | if (cbs_ && SvROK (cbs_) && SvTYPE (SvRV (cbs_)) == SVt_PVAV) |
|
|
737 | { |
|
|
738 | AV *cbs = (AV *)SvRV (cbs_); |
|
|
739 | |
|
|
740 | // no callback entries, no callbacks to call |
|
|
741 | if (AvFILLp (cbs) >= 0) |
|
|
742 | { |
|
|
743 | if (!callbacks) |
|
|
744 | { |
|
|
745 | callbacks = newAV (); |
|
|
746 | av_extend (callbacks, 16); |
|
|
747 | } |
|
|
748 | |
|
|
749 | // never use SvREFCNT_inc to copy values, but its ok here :) |
|
|
750 | for (int i = 0; i <= AvFILLp (cbs); ++i) |
|
|
751 | av_push (callbacks, SvREFCNT_inc (AvARRAY (cbs)[i])); |
|
|
752 | } |
|
|
753 | } |
471 | } |
754 | } |
472 | |
|
|
473 | return 0; |
|
|
474 | } |
755 | } |
475 | |
756 | |
476 | static void * |
757 | bool cfperl_invoke (event_type event, ...) |
477 | globalEventListener (int *type, ...) |
|
|
478 | { |
758 | { |
|
|
759 | data_type dt; |
479 | va_list args; |
760 | va_list ap; |
480 | static int rv; |
|
|
481 | int event_code; |
|
|
482 | |
761 | |
483 | if (!perl) |
|
|
484 | return NULL; |
|
|
485 | |
|
|
486 | va_start (args, type); |
762 | va_start (ap, event); |
487 | event_code = va_arg (args, int); |
|
|
488 | |
763 | |
489 | if (event_code == EVENT_FREE_OB) |
764 | AV *callbacks = 0; |
|
|
765 | |
|
|
766 | object *op; |
|
|
767 | player *pl; |
|
|
768 | mapstruct *map; |
|
|
769 | |
|
|
770 | // callback call ordering is: |
|
|
771 | // 1. per-object callback (NYI) |
|
|
772 | // 2. per-class object |
|
|
773 | // 2a. per-type callback |
|
|
774 | // 4. global callbacks |
|
|
775 | |
|
|
776 | gather_callbacks (callbacks, cb_global, event); |
|
|
777 | |
|
|
778 | switch (KLASS_OF (event)) |
490 | { |
779 | { |
491 | player *pl; |
780 | case KLASS_GLOBAL: |
492 | object *op; |
781 | break; |
493 | SV *sv; |
|
|
494 | |
782 | |
|
|
783 | case KLASS_OBJECT: |
|
|
784 | dt = (data_type) va_arg (ap, int); |
|
|
785 | assert (("first argument must be of type object", dt == DT_OBJECT)); |
495 | op = va_arg (args, object *); |
786 | op = va_arg (ap, object *); |
496 | sv = hv_delete (obj_cache, (char *)&op, sizeof (void *), 0); |
|
|
497 | |
787 | |
498 | if (sv) |
788 | if (op->cb) |
499 | clearSVptr (sv); |
789 | gather_callbacks (callbacks, op->cb, event); |
500 | |
790 | |
501 | rv = 0; |
791 | if (op->type) |
|
|
792 | { |
|
|
793 | if (op->subtype && op->type + op->subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) |
|
|
794 | { |
|
|
795 | SV *registry = AvARRAY (cb_type)[op->type + op->subtype * NUM_SUBTYPES]; |
|
|
796 | |
|
|
797 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
798 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
799 | } |
|
|
800 | |
|
|
801 | if (op->type <= AvFILLp (cb_type)) |
|
|
802 | { |
|
|
803 | SV *registry = AvARRAY (cb_type)[op->type]; |
|
|
804 | |
|
|
805 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
806 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
807 | } |
|
|
808 | } |
|
|
809 | |
|
|
810 | gather_callbacks (callbacks, cb_object, event); |
|
|
811 | |
|
|
812 | break; |
|
|
813 | |
|
|
814 | case KLASS_PLAYER: |
|
|
815 | dt = (data_type) va_arg (ap, int); |
|
|
816 | assert (("first argument must be of type player", dt == DT_PLAYER)); |
|
|
817 | pl = va_arg (ap, player *); |
|
|
818 | |
|
|
819 | if (pl->cb) |
|
|
820 | gather_callbacks (callbacks, pl->cb, event); |
|
|
821 | |
|
|
822 | gather_callbacks (callbacks, cb_player, event); |
|
|
823 | break; |
|
|
824 | |
|
|
825 | case KLASS_MAP: |
|
|
826 | dt = (data_type) va_arg (ap, int); |
|
|
827 | assert (("first argument must be of type object", dt == DT_MAP)); |
|
|
828 | map = va_arg (ap, mapstruct *); |
|
|
829 | |
|
|
830 | if (map->cb) |
|
|
831 | gather_callbacks (callbacks, map->cb, event); |
|
|
832 | |
|
|
833 | gather_callbacks (callbacks, cb_map, event); |
|
|
834 | break; |
|
|
835 | |
|
|
836 | default: |
|
|
837 | assert (("unsupported event klass in cfperl_invoke", 0)); |
502 | } |
838 | } |
503 | else if (event_code == EVENT_CLOCK) |
839 | |
|
|
840 | // short-circuit processing if no callbacks found/defined |
|
|
841 | if (!callbacks) |
|
|
842 | return 0; |
|
|
843 | |
|
|
844 | dSP; |
|
|
845 | ENTER; |
|
|
846 | SAVETMPS; |
|
|
847 | |
|
|
848 | PUSHMARK (SP); |
|
|
849 | EXTEND (SP, 3); |
|
|
850 | |
|
|
851 | PUSHs (sv_2mortal (newSViv (event))); // only used for debugging nowadays |
|
|
852 | PUSHs (sv_2mortal (newRV_noinc ((SV *)callbacks))); |
|
|
853 | |
|
|
854 | switch (KLASS_OF (event)) |
504 | { |
855 | { |
505 | dSP; |
856 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
506 | int i, count; |
857 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
|
|
858 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
|
|
859 | } |
507 | |
860 | |
508 | clean_obj_cache (); |
861 | for (;;) |
|
|
862 | { |
|
|
863 | dt = (data_type) va_arg (ap, int); |
509 | |
864 | |
510 | ENTER; |
865 | if (dt == DT_END) |
511 | SAVETMPS; |
866 | break; |
512 | |
867 | |
513 | // service up to 8 events per tick better would be |
868 | if (dt == DT_AV) |
514 | // to check for elapsed time and stop processing after |
|
|
515 | // 0.25 * server_tick or so |
|
|
516 | for (i = 9; --i; ) |
|
|
517 | { |
869 | { |
518 | PUSHMARK (SP); |
870 | AV *av = va_arg (ap, AV *); |
519 | XPUSHs (sv_2mortal (newSViv (0))); |
|
|
520 | PUTBACK; |
|
|
521 | count = call_pv ("Event::one_event", G_SCALAR | G_EVAL); |
|
|
522 | SPAGAIN; |
|
|
523 | |
871 | |
524 | if (!count || !POPi) |
872 | for (int i = 0; i <= av_len (av); ++i) |
525 | break; |
873 | XPUSHs (*av_fetch (av, i, 1)); |
526 | } |
874 | } |
527 | |
875 | else |
528 | FREETMPS; |
876 | XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); |
529 | LEAVE; |
|
|
530 | } |
877 | } |
531 | else |
|
|
532 | { |
|
|
533 | dSP; |
|
|
534 | |
878 | |
535 | ENTER; |
|
|
536 | SAVETMPS; |
|
|
537 | |
|
|
538 | PUSHMARK (SP); |
|
|
539 | |
|
|
540 | EXTEND (SP, 10); |
|
|
541 | PUSHs (sv_2mortal (newSViv (event_code))); |
|
|
542 | |
|
|
543 | switch (event_code) |
|
|
544 | { |
|
|
545 | case EVENT_CRASH: |
|
|
546 | break; |
|
|
547 | |
|
|
548 | case EVENT_PLAYER_LOAD: |
|
|
549 | case EVENT_PLAYER_SAVE: |
|
|
550 | PUSH_OB; |
|
|
551 | PUSH_PV; |
|
|
552 | break; |
|
|
553 | |
|
|
554 | case EVENT_MAPLOAD: |
|
|
555 | case EVENT_MAPOUT: |
|
|
556 | case EVENT_MAPIN: |
|
|
557 | case EVENT_MAPCLEAN: |
|
|
558 | case EVENT_MAPRESET: |
|
|
559 | PUSH_MAP; |
|
|
560 | break; |
|
|
561 | |
|
|
562 | case EVENT_MAPENTER: |
|
|
563 | case EVENT_MAPLEAVE: |
|
|
564 | case EVENT_BORN: |
|
|
565 | case EVENT_REMOVE: |
|
|
566 | case EVENT_PLAYER_DEATH: |
|
|
567 | PUSH_OB; |
|
|
568 | break; |
|
|
569 | |
|
|
570 | case EVENT_GKILL: |
|
|
571 | PUSH_OB; |
|
|
572 | PUSH_OB; |
|
|
573 | break; |
|
|
574 | |
|
|
575 | case EVENT_LOGIN: |
|
|
576 | case EVENT_LOGOUT: |
|
|
577 | PUSH_PL; |
|
|
578 | PUSH_PV; |
|
|
579 | break; |
|
|
580 | |
|
|
581 | case EVENT_SHOUT: |
|
|
582 | case EVENT_MUZZLE: |
|
|
583 | case EVENT_KICK: |
|
|
584 | PUSH_OB; |
|
|
585 | PUSH_PV; |
|
|
586 | break; |
|
|
587 | |
|
|
588 | case EVENT_FIND_UNARMED_SKILL: |
|
|
589 | PUSH_OB; |
|
|
590 | break; |
|
|
591 | |
|
|
592 | case EVENT_PLAYER_USE_SKILL: |
|
|
593 | case EVENT_MONSTER_USE_SKILL: |
|
|
594 | case EVENT_CAST_SPELL: |
|
|
595 | PUSH_OB; |
|
|
596 | PUSH_OB; |
|
|
597 | PUSH_OB; |
|
|
598 | PUSH_IV; |
|
|
599 | PUSH_PV; |
|
|
600 | break; |
|
|
601 | |
|
|
602 | case EVENT_EXTCMD: |
|
|
603 | PUSH_PL; |
|
|
604 | { |
|
|
605 | char *buf = va_arg (args, char *); |
|
|
606 | int len = va_arg (args, int); |
|
|
607 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
|
|
608 | } |
|
|
609 | break; |
|
|
610 | |
|
|
611 | case EVENT_TELL: |
|
|
612 | break; |
|
|
613 | } |
|
|
614 | |
|
|
615 | va_end (args); |
|
|
616 | |
|
|
617 | PUTBACK; |
|
|
618 | int count = call_pv ("cf::inject_global_event", G_SCALAR | G_EVAL); |
|
|
619 | SPAGAIN; |
|
|
620 | |
|
|
621 | if (SvTRUE (ERRSV)) |
|
|
622 | LOG (llevError, "global event '%d' callback evaluation error: %s", event_code, SvPV_nolen (ERRSV)); |
|
|
623 | |
|
|
624 | rv = count > 0 ? POPi : 0; |
|
|
625 | |
|
|
626 | PUTBACK; |
|
|
627 | FREETMPS; |
|
|
628 | LEAVE; |
|
|
629 | } |
|
|
630 | |
|
|
631 | return &rv; |
|
|
632 | } |
|
|
633 | |
|
|
634 | extern "C" void *cfperl_eventListener (int *type, ...) |
|
|
635 | { |
|
|
636 | static int rv; |
|
|
637 | va_list args; |
|
|
638 | int event_code; |
|
|
639 | object *who, *activator, *third, *event; |
|
|
640 | char *message, *extension, *options; |
|
|
641 | |
|
|
642 | if (!perl) |
|
|
643 | return NULL; |
|
|
644 | |
|
|
645 | va_start (args, type); |
|
|
646 | who = va_arg (args, object *); |
|
|
647 | event_code = va_arg (args, int); |
|
|
648 | activator = va_arg (args, object *); |
|
|
649 | third = va_arg (args, object *); |
|
|
650 | message = va_arg (args, char *); |
|
|
651 | va_arg (args, int); // fix yourself |
|
|
652 | extension = va_arg (args, char *); |
|
|
653 | options = va_arg (args, char *); |
|
|
654 | event = va_arg (args, object *); |
|
|
655 | va_end (args); |
879 | va_end (ap); |
656 | |
880 | |
657 | { |
|
|
658 | dSP; |
|
|
659 | |
|
|
660 | ENTER; |
|
|
661 | SAVETMPS; |
|
|
662 | |
|
|
663 | PUSHMARK (SP); |
|
|
664 | EXTEND (SP, 10); |
|
|
665 | |
|
|
666 | PUSHcfapi (STRING, extension); |
|
|
667 | PUSHs (sv_2mortal (newSViv (event_code))); |
|
|
668 | |
|
|
669 | PUSHcfapi (POBJECT, event); |
|
|
670 | PUSHcfapi (POBJECT, who); |
|
|
671 | |
|
|
672 | switch (event_code) |
|
|
673 | { |
|
|
674 | case EVENT_STOP: // $ob (e.g. arrow) |
|
|
675 | case EVENT_TIME: // $ob |
|
|
676 | case EVENT_TIMER: // $ob |
|
|
677 | break; |
|
|
678 | |
|
|
679 | case EVENT_APPLY: // $ob, $who |
|
|
680 | case EVENT_DROP: // $ob, $who |
|
|
681 | case EVENT_CLOSE: // $ob, $who |
|
|
682 | case EVENT_DEATH: // $ob[, $killer] |
|
|
683 | case EVENT_MOVE: // $ob, $enemy |
|
|
684 | case EVENT_THROW: // $ob, $thrower |
|
|
685 | PUSHcfapi (POBJECT, activator); |
|
|
686 | break; |
|
|
687 | |
|
|
688 | case EVENT_DROP_ON: // $ob, $who, $what |
|
|
689 | case EVENT_ATTACK: // $ob, $who, $victim (?? please god enlighten me) |
|
|
690 | PUSHcfapi (POBJECT, activator); |
|
|
691 | PUSHcfapi (POBJECT, third); |
|
|
692 | break; |
|
|
693 | |
|
|
694 | case EVENT_TRIGGER: // $ob, $originator, [$victim], [$msg] |
|
|
695 | PUSHcfapi (POBJECT, activator); |
|
|
696 | PUSHcfapi (POBJECT, third); |
|
|
697 | PUSHcfapi (POBJECT, message); |
|
|
698 | break; |
|
|
699 | |
|
|
700 | case EVENT_SAY: // $ob, $who, $msg |
|
|
701 | PUSHcfapi (POBJECT, activator); |
|
|
702 | PUSHcfapi (STRING, message); |
|
|
703 | break; |
|
|
704 | |
|
|
705 | default: |
|
|
706 | LOG (llevError, "perl plugin called for unsupported event type %d", event_code); |
|
|
707 | break; |
|
|
708 | } |
|
|
709 | |
|
|
710 | PUTBACK; |
881 | PUTBACK; |
711 | int count = call_pv ("cf::inject_event", G_SCALAR | G_EVAL); |
882 | int count = call_pv ("cf::do_invoke", G_SCALAR | G_EVAL); |
712 | SPAGAIN; |
883 | SPAGAIN; |
713 | |
884 | |
714 | if (SvTRUE (ERRSV)) |
|
|
715 | LOG (llevError, "event '%d' callback evaluation error: %s", event_code, SvPV_nolen (ERRSV)); |
|
|
716 | |
|
|
717 | rv = count > 0 ? POPi : 0; |
885 | count = count > 0 ? POPi : 0; |
718 | |
886 | |
719 | PUTBACK; |
|
|
720 | FREETMPS; |
887 | FREETMPS; |
721 | LEAVE; |
888 | LEAVE; |
722 | } |
889 | |
723 | |
890 | return count; |
|
|
891 | } |
|
|
892 | |
|
|
893 | SV * |
|
|
894 | cfperl_result (int idx) |
|
|
895 | { |
|
|
896 | AV *av = get_av ("cfperl::invoke_results", 0); |
|
|
897 | if (!av) |
|
|
898 | return &PL_sv_undef; |
|
|
899 | |
|
|
900 | SV **sv = av_fetch (av, idx, 0); |
|
|
901 | if (!sv) |
|
|
902 | return &PL_sv_undef; |
|
|
903 | |
724 | return &rv; |
904 | return *sv; |
725 | } |
905 | } |
726 | |
906 | |
727 | extern "C" int cfperl_closePlugin () |
907 | int |
|
|
908 | cfperl_result_INT (int idx) |
728 | { |
909 | { |
729 | printf (PLUGIN_VERSION " closing\n"); |
910 | return SvIV (cfperl_result (idx)); |
730 | |
|
|
731 | if (perl) |
|
|
732 | { |
|
|
733 | perl_destruct (perl); |
|
|
734 | perl_free (perl); |
|
|
735 | perl = 0; |
|
|
736 | } |
|
|
737 | |
|
|
738 | return 0; |
|
|
739 | } |
911 | } |
740 | |
912 | |
741 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
913 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
742 | |
914 | |
743 | BOOT: |
915 | BOOT: |
… | |
… | |
752 | const_iv (llevError) |
924 | const_iv (llevError) |
753 | const_iv (llevInfo) |
925 | const_iv (llevInfo) |
754 | const_iv (llevDebug) |
926 | const_iv (llevDebug) |
755 | const_iv (llevMonster) |
927 | const_iv (llevMonster) |
756 | |
928 | |
|
|
929 | const_iv (MAX_TIME) |
757 | const_iv (PLAYER) |
930 | const_iv (PLAYER) |
758 | const_iv (TRANSPORT) |
931 | const_iv (TRANSPORT) |
759 | const_iv (ROD) |
932 | const_iv (ROD) |
760 | const_iv (TREASURE) |
933 | const_iv (TREASURE) |
761 | const_iv (POTION) |
934 | const_iv (POTION) |
… | |
… | |
876 | const_iv (BUILDER) |
1049 | const_iv (BUILDER) |
877 | const_iv (MATERIAL) |
1050 | const_iv (MATERIAL) |
878 | const_iv (ITEM_TRANSFORMER) |
1051 | const_iv (ITEM_TRANSFORMER) |
879 | const_iv (QUEST) |
1052 | const_iv (QUEST) |
880 | |
1053 | |
|
|
1054 | const_iv (NUM_SUBTYPES) |
|
|
1055 | |
881 | const_iv (ST_BD_BUILD) |
1056 | const_iv (ST_BD_BUILD) |
882 | const_iv (ST_BD_REMOVE) |
1057 | const_iv (ST_BD_REMOVE) |
883 | |
1058 | |
884 | const_iv (ST_MAT_FLOOR) |
1059 | const_iv (ST_MAT_FLOOR) |
885 | const_iv (ST_MAT_WALL) |
1060 | const_iv (ST_MAT_WALL) |
… | |
… | |
1113 | |
1288 | |
1114 | const_iv (SK_EXP_ADD_SKILL) |
1289 | const_iv (SK_EXP_ADD_SKILL) |
1115 | const_iv (SK_EXP_TOTAL) |
1290 | const_iv (SK_EXP_TOTAL) |
1116 | const_iv (SK_EXP_NONE) |
1291 | const_iv (SK_EXP_NONE) |
1117 | const_iv (SK_SUBTRACT_SKILL_EXP) |
1292 | const_iv (SK_SUBTRACT_SKILL_EXP) |
|
|
1293 | const_iv (SK_EXP_SKILL_ONLY) |
1118 | |
1294 | |
1119 | const_iv (SK_LOCKPICKING) |
1295 | const_iv (SK_LOCKPICKING) |
1120 | const_iv (SK_HIDING) |
1296 | const_iv (SK_HIDING) |
1121 | const_iv (SK_SMITHERY) |
1297 | const_iv (SK_SMITHERY) |
1122 | const_iv (SK_BOWYER) |
1298 | const_iv (SK_BOWYER) |
… | |
… | |
1221 | |
1397 | |
1222 | const_iv (MAP_IN_MEMORY) |
1398 | const_iv (MAP_IN_MEMORY) |
1223 | const_iv (MAP_SWAPPED) |
1399 | const_iv (MAP_SWAPPED) |
1224 | const_iv (MAP_LOADING) |
1400 | const_iv (MAP_LOADING) |
1225 | const_iv (MAP_SAVING) |
1401 | const_iv (MAP_SAVING) |
|
|
1402 | |
|
|
1403 | const_iv (KLASS_GLOBAL) |
|
|
1404 | const_iv (KLASS_OBJECT) |
|
|
1405 | const_iv (KLASS_PLAYER) |
|
|
1406 | const_iv (KLASS_MAP) |
1226 | }; |
1407 | }; |
1227 | |
1408 | |
1228 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1409 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1229 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1410 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1230 | |
1411 | |
1231 | static const struct { |
1412 | static const struct { |
1232 | const char *name; |
1413 | const char *name; |
|
|
1414 | int skip; |
|
|
1415 | IV klass; |
1233 | IV iv; |
1416 | IV iv; |
1234 | } *event, event_list[] = { |
1417 | } *eiv, event_iv[] = { |
1235 | # define const_event(name) { # name, (IV)EVENT_ ## name }, |
1418 | # define def(klass,name) { "EVENT_" # klass "_" # name, sizeof ("EVENT_" # klass), (IV)KLASS_ ## klass, (IV)EVENT_ ## klass ## _ ## name }, |
1236 | const_event (NONE) |
1419 | # include "eventinc.h" |
1237 | const_event (APPLY) |
1420 | # undef def |
1238 | const_event (ATTACK) |
|
|
1239 | const_event (DEATH) |
|
|
1240 | const_event (DROP) |
|
|
1241 | const_event (DROP_ON) |
|
|
1242 | const_event (PICKUP) |
|
|
1243 | const_event (SAY) |
|
|
1244 | const_event (STOP) |
|
|
1245 | const_event (TIME) |
|
|
1246 | const_event (THROW) |
|
|
1247 | const_event (TRIGGER) |
|
|
1248 | const_event (CLOSE) |
|
|
1249 | const_event (TIMER) |
|
|
1250 | const_event (MOVE) |
|
|
1251 | |
|
|
1252 | const_event (BORN) |
|
|
1253 | //const_event (CLOCK) |
|
|
1254 | const_event (CRASH) |
|
|
1255 | const_event (PLAYER_DEATH) |
|
|
1256 | const_event (PLAYER_LOAD) |
|
|
1257 | const_event (PLAYER_SAVE) |
|
|
1258 | const_event (GKILL) |
|
|
1259 | const_event (LOGIN) |
|
|
1260 | const_event (LOGOUT) |
|
|
1261 | const_event (MAPENTER) |
|
|
1262 | const_event (MAPLEAVE) |
|
|
1263 | const_event (MAPRESET) |
|
|
1264 | const_event (MAPLOAD) |
|
|
1265 | const_event (MAPOUT) |
|
|
1266 | const_event (MAPIN) |
|
|
1267 | const_event (MAPCLEAN) |
|
|
1268 | const_event (REMOVE) |
|
|
1269 | const_event (SHOUT) |
|
|
1270 | const_event (TELL) |
|
|
1271 | const_event (MUZZLE) |
|
|
1272 | const_event (KICK) |
|
|
1273 | const_event (PLAYER_USE_SKILL) |
|
|
1274 | const_event (MONSTER_USE_SKILL) |
|
|
1275 | const_event (CAST_SPELL) |
|
|
1276 | const_event (FIND_UNARMED_SKILL) |
|
|
1277 | const_event (EXTCMD) |
|
|
1278 | //const_event (FREE_OB) |
|
|
1279 | }; |
1421 | }; |
1280 | |
1422 | |
1281 | AV *av = get_av ("cf::EVENT", 1); |
1423 | AV *av = get_av ("cf::EVENT", 1); |
1282 | |
1424 | |
1283 | for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) |
1425 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1284 | av_store (av, event->iv, newSVpv ((char *)event->name, 0)); |
1426 | { |
|
|
1427 | AV *event = newAV (); |
|
|
1428 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
|
|
1429 | av_push (event, newSViv (eiv->klass)); |
|
|
1430 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
|
|
1431 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
|
|
1432 | } |
1285 | |
1433 | |
1286 | static const struct { |
1434 | static const struct { |
1287 | int dtype; |
1435 | int dtype; |
1288 | const char *name; |
1436 | const char *name; |
1289 | IV idx; |
1437 | IV idx; |
… | |
… | |
1309 | prop (CFAPI_INT, MAP_PROP_WINDDIR) |
1457 | prop (CFAPI_INT, MAP_PROP_WINDDIR) |
1310 | prop (CFAPI_INT, MAP_PROP_SKY) |
1458 | prop (CFAPI_INT, MAP_PROP_SKY) |
1311 | prop (CFAPI_INT, MAP_PROP_WPARTX) |
1459 | prop (CFAPI_INT, MAP_PROP_WPARTX) |
1312 | prop (CFAPI_INT, MAP_PROP_WPARTY) |
1460 | prop (CFAPI_INT, MAP_PROP_WPARTY) |
1313 | prop (CFAPI_STRING, MAP_PROP_MESSAGE) |
1461 | prop (CFAPI_STRING, MAP_PROP_MESSAGE) |
1314 | prop (CFAPI_PMAP, MAP_PROP_NEXT) |
|
|
1315 | prop (CFAPI_PREGION, MAP_PROP_REGION) |
1462 | prop (CFAPI_PREGION, MAP_PROP_REGION) |
1316 | prop (CFAPI_POBJECT, OBJECT_PROP_OB_ABOVE) |
|
|
1317 | prop (CFAPI_POBJECT, OBJECT_PROP_OB_BELOW) |
|
|
1318 | prop (CFAPI_POBJECT, OBJECT_PROP_NEXT_ACTIVE_OB) |
1463 | prop (CFAPI_POBJECT, OBJECT_PROP_NEXT_ACTIVE_OB) |
1319 | prop (CFAPI_POBJECT, OBJECT_PROP_PREV_ACTIVE_OB) |
1464 | prop (CFAPI_POBJECT, OBJECT_PROP_PREV_ACTIVE_OB) |
1320 | prop (CFAPI_POBJECT, OBJECT_PROP_INVENTORY) |
1465 | prop (CFAPI_POBJECT, OBJECT_PROP_INVENTORY) |
1321 | prop (CFAPI_POBJECT, OBJECT_PROP_ENVIRONMENT) |
1466 | prop (CFAPI_POBJECT, OBJECT_PROP_ENVIRONMENT) |
1322 | prop (CFAPI_POBJECT, OBJECT_PROP_HEAD) |
|
|
1323 | prop (CFAPI_POBJECT, OBJECT_PROP_CONTAINER) |
1467 | prop (CFAPI_POBJECT, OBJECT_PROP_CONTAINER) |
1324 | prop (CFAPI_PMAP, OBJECT_PROP_MAP) |
1468 | prop (CFAPI_PMAP, OBJECT_PROP_MAP) |
1325 | prop (CFAPI_INT, OBJECT_PROP_COUNT) |
1469 | prop (CFAPI_INT, OBJECT_PROP_COUNT) |
1326 | prop (CFAPI_INT, OBJECT_PROP_REFCOUNT) |
1470 | prop (CFAPI_INT, OBJECT_PROP_REFCOUNT) |
1327 | prop (CFAPI_STRING, OBJECT_PROP_NAME) |
1471 | prop (CFAPI_STRING, OBJECT_PROP_NAME) |
… | |
… | |
1420 | } |
1564 | } |
1421 | |
1565 | |
1422 | //I_EVENT_API (PACKAGE); |
1566 | //I_EVENT_API (PACKAGE); |
1423 | } |
1567 | } |
1424 | |
1568 | |
|
|
1569 | void _reload_1 () |
|
|
1570 | CODE: |
|
|
1571 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
|
|
1572 | cb_object = get_av ("cf::CB_OBJECT", 1); |
|
|
1573 | cb_player = get_av ("cf::CB_PLAYER", 1); |
|
|
1574 | cb_type = get_av ("cf::CB_TYPE" , 1); |
|
|
1575 | cb_map = get_av ("cf::CB_MAP" , 1); |
|
|
1576 | |
|
|
1577 | void _reload_2 () |
|
|
1578 | CODE: |
|
|
1579 | { |
|
|
1580 | // reattach to all attachable objects in the game. |
|
|
1581 | for (player *pl = first_player; pl; pl = pl->next) |
|
|
1582 | reattach (pl); |
|
|
1583 | |
|
|
1584 | for (mapstruct *map = first_map; map; map = map->next) |
|
|
1585 | reattach (map); |
|
|
1586 | |
|
|
1587 | for (object *op = objects; op; op = op->next) |
|
|
1588 | reattach (op); |
|
|
1589 | } |
|
|
1590 | |
1425 | NV floor (NV x) |
1591 | NV floor (NV x) |
1426 | |
1592 | |
1427 | NV ceil (NV x) |
1593 | NV ceil (NV x) |
|
|
1594 | |
|
|
1595 | void server_tick () |
1428 | |
1596 | |
1429 | void |
1597 | void |
1430 | LOG (int level, char *msg) |
1598 | LOG (int level, char *msg) |
1431 | PROTOTYPE: $$ |
1599 | PROTOTYPE: $$ |
1432 | C_ARGS: (LogLevel)level, "%s", msg |
1600 | C_ARGS: (LogLevel)level, "%s", msg |
… | |
… | |
1435 | PROTOTYPE: $$ |
1603 | PROTOTYPE: $$ |
1436 | |
1604 | |
1437 | char *path_combine_and_normalize (char *base, char *path) |
1605 | char *path_combine_and_normalize (char *base, char *path) |
1438 | PROTOTYPE: $$ |
1606 | PROTOTYPE: $$ |
1439 | |
1607 | |
1440 | char * |
1608 | const char * |
1441 | cf_get_maps_directory (char *path) |
1609 | get_maps_directory (char *path) |
1442 | PROTOTYPE: $ |
1610 | PROTOTYPE: $ |
1443 | ALIAS: maps_directory = 0 |
1611 | ALIAS: maps_directory = 0 |
|
|
1612 | CODE: |
|
|
1613 | RETVAL = create_pathname (path); |
|
|
1614 | OUTPUT: RETVAL |
1444 | |
1615 | |
1445 | void |
1616 | void |
1446 | sub_generation_inc () |
1617 | sub_generation_inc () |
1447 | CODE: |
1618 | CODE: |
1448 | PL_sub_generation++; |
1619 | PL_sub_generation++; |
… | |
… | |
1457 | confdir = 3 |
1628 | confdir = 3 |
1458 | localdir = 4 |
1629 | localdir = 4 |
1459 | playerdir = 5 |
1630 | playerdir = 5 |
1460 | datadir = 6 |
1631 | datadir = 6 |
1461 | CODE: |
1632 | CODE: |
1462 | { |
1633 | switch (ix) |
1463 | int unused_type; |
1634 | { |
1464 | RETVAL = (char *)systemDirectory (&unused_type, ix); |
1635 | case 0: RETVAL = settings.mapdir ; break; |
1465 | } |
1636 | case 1: RETVAL = settings.uniquedir; break; |
|
|
1637 | case 2: RETVAL = settings.tmpdir ; break; |
|
|
1638 | case 3: RETVAL = settings.confdir ; break; |
|
|
1639 | case 4: RETVAL = settings.localdir ; break; |
|
|
1640 | case 5: RETVAL = settings.playerdir; break; |
|
|
1641 | case 6: RETVAL = settings.datadir ; break; |
|
|
1642 | } |
1466 | OUTPUT: RETVAL |
1643 | OUTPUT: RETVAL |
1467 | |
1644 | |
1468 | int |
1645 | int |
1469 | cf_find_animation (char *text) |
1646 | cf_find_animation (char *text) |
1470 | PROTOTYPE: $ |
1647 | PROTOTYPE: $ |
1471 | |
1648 | |
1472 | int random_roll(int min, int max, object *op, int goodbad); |
1649 | int random_roll(int min, int max, object *op, int goodbad); |
1473 | |
1650 | |
1474 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1651 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
|
|
1652 | |
|
|
1653 | int invoke (int event, ...) |
|
|
1654 | CODE: |
|
|
1655 | if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL"); |
|
|
1656 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1657 | for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
1658 | RETVAL = INVOKE_((event_type)event, ARG_AV (av)); |
|
|
1659 | OUTPUT: RETVAL |
1475 | |
1660 | |
1476 | int |
1661 | int |
1477 | exp_to_level (val64 exp) |
1662 | exp_to_level (val64 exp) |
1478 | CODE: |
1663 | CODE: |
1479 | { |
1664 | { |
… | |
… | |
1510 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1695 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1511 | else |
1696 | else |
1512 | XSRETURN_UNDEF; |
1697 | XSRETURN_UNDEF; |
1513 | OUTPUT: RETVAL |
1698 | OUTPUT: RETVAL |
1514 | |
1699 | |
|
|
1700 | int |
|
|
1701 | _valid (SV *obj) |
|
|
1702 | CODE: |
|
|
1703 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
|
|
1704 | OUTPUT: |
|
|
1705 | RETVAL |
|
|
1706 | |
1515 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1707 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
|
|
1708 | |
|
|
1709 | int invoke (object *op, int event, ...) |
|
|
1710 | CODE: |
|
|
1711 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
|
|
1712 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1713 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
1714 | RETVAL = INVOKE_((event_type)event, ARG_OBJECT (op), ARG_AV (av)); |
|
|
1715 | OUTPUT: RETVAL |
|
|
1716 | |
|
|
1717 | SV *registry (object *op) |
|
|
1718 | CODE: |
|
|
1719 | RETVAL = registry_of (op); |
|
|
1720 | OUTPUT: |
|
|
1721 | RETVAL |
|
|
1722 | |
|
|
1723 | object *head (object *op) |
|
|
1724 | PROTOTYPE: $ |
|
|
1725 | ALIAS: |
|
|
1726 | more = 1 |
|
|
1727 | above = 2 |
|
|
1728 | below = 3 |
|
|
1729 | CODE: |
|
|
1730 | switch (ix) |
|
|
1731 | { |
|
|
1732 | case 0: RETVAL = op->head ? op->head : op; break; // DOH! |
|
|
1733 | case 1: RETVAL = op->more; break; |
|
|
1734 | case 2: RETVAL = op->above; break; |
|
|
1735 | case 3: RETVAL = op->below; break; |
|
|
1736 | } |
|
|
1737 | OUTPUT: |
|
|
1738 | RETVAL |
1516 | |
1739 | |
1517 | SV * |
1740 | SV * |
1518 | get_property (object *obj, int type, int idx) |
1741 | get_property (object *obj, int type, int idx) |
1519 | CODE: |
1742 | CODE: |
1520 | RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); |
1743 | RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); |
… | |
… | |
1599 | |
1822 | |
1600 | int need_identify (const object *obj); |
1823 | int need_identify (const object *obj); |
1601 | |
1824 | |
1602 | int apply_shop_mat (object *shop_mat, object *op); |
1825 | int apply_shop_mat (object *shop_mat, object *op); |
1603 | |
1826 | |
1604 | void cf_object_move (object *op, int dir, object *originator = op) |
1827 | int move (object *op, int dir, object *originator = op) |
|
|
1828 | CODE: |
|
|
1829 | RETVAL = move_ob (op, dir, originator); |
|
|
1830 | OUTPUT: |
|
|
1831 | RETVAL |
1605 | |
1832 | |
1606 | void cf_object_apply (object *op, object *author, int flags = 0) |
1833 | void cf_object_apply (object *op, object *author, int flags = 0) |
1607 | |
1834 | |
1608 | void cf_object_apply_below (object *op) |
1835 | void cf_object_apply_below (object *op) |
1609 | |
1836 | |
… | |
… | |
1650 | int cf_object_out_of_map (object *op, int x, int y) |
1877 | int cf_object_out_of_map (object *op, int x, int y) |
1651 | |
1878 | |
1652 | void cf_object_drop (object *op, object *author) |
1879 | void cf_object_drop (object *op, object *author) |
1653 | |
1880 | |
1654 | void cf_object_take (object *op, object *author) |
1881 | void cf_object_take (object *op, object *author) |
1655 | |
|
|
1656 | void cf_object_say (object *op, char *msg) |
|
|
1657 | |
|
|
1658 | void cf_object_speak (object *op, char *msg) |
|
|
1659 | |
1882 | |
1660 | object *cf_object_insert_object (object *op, object *container) |
1883 | object *cf_object_insert_object (object *op, object *container) |
1661 | |
1884 | |
1662 | const char *cf_object_get_msg (object *ob) |
1885 | const char *cf_object_get_msg (object *ob) |
1663 | ALIAS: msg = 0 |
1886 | ALIAS: msg = 0 |
… | |
… | |
1797 | |
2020 | |
1798 | void cf_player_set_party (object *op, partylist *party) |
2021 | void cf_player_set_party (object *op, partylist *party) |
1799 | |
2022 | |
1800 | void kill_player (object *op) |
2023 | void kill_player (object *op) |
1801 | |
2024 | |
1802 | MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ |
|
|
1803 | |
|
|
1804 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2025 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
|
|
2026 | |
|
|
2027 | int invoke (player *pl, int event, ...) |
|
|
2028 | CODE: |
|
|
2029 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
|
|
2030 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
2031 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
2032 | RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); |
|
|
2033 | OUTPUT: RETVAL |
|
|
2034 | |
|
|
2035 | SV *registry (player *pl) |
|
|
2036 | CODE: |
|
|
2037 | RETVAL = registry_of (pl); |
|
|
2038 | OUTPUT: |
|
|
2039 | RETVAL |
1805 | |
2040 | |
1806 | player *cf_player_find (char *name) |
2041 | player *cf_player_find (char *name) |
1807 | PROTOTYPE: $ |
2042 | PROTOTYPE: $ |
1808 | |
2043 | |
1809 | void cf_player_move (player *pl, int dir) |
2044 | void cf_player_move (player *pl, int dir) |
1810 | |
|
|
1811 | void MapNewmapCmd (player *pl) |
|
|
1812 | |
2045 | |
1813 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2046 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
1814 | |
2047 | |
1815 | # nonstandard |
2048 | # nonstandard |
1816 | object *ob (player *pl) |
2049 | object *ob (player *pl) |
… | |
… | |
1833 | CODE: |
2066 | CODE: |
1834 | RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 |
2067 | RETVAL = FABS (dx) <= pl->socket.mapx / 2 && FABS (dy) <= pl->socket.mapy / 2 |
1835 | && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; |
2068 | && !pl->blocked_los [dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]; |
1836 | OUTPUT: |
2069 | OUTPUT: |
1837 | RETVAL |
2070 | RETVAL |
|
|
2071 | |
|
|
2072 | char * |
|
|
2073 | client (player *pl) |
|
|
2074 | CODE: |
|
|
2075 | RETVAL = pl->socket.client; |
|
|
2076 | OUTPUT: |
|
|
2077 | RETVAL |
|
|
2078 | |
|
|
2079 | char * |
|
|
2080 | host (player *pl) |
|
|
2081 | CODE: |
|
|
2082 | RETVAL = pl->socket.host; |
|
|
2083 | OUTPUT: |
|
|
2084 | RETVAL |
|
|
2085 | |
|
|
2086 | char * |
|
|
2087 | killer (player *pl, char *killer = 0) |
|
|
2088 | CODE: |
|
|
2089 | if (killer) |
|
|
2090 | snprintf (pl->killer, sizeof (pl->killer), "%s", killer); |
|
|
2091 | RETVAL = pl->killer; |
|
|
2092 | OUTPUT: |
|
|
2093 | RETVAL |
|
|
2094 | |
|
|
2095 | void |
|
|
2096 | buggy_mapscroll (player *pl, int value = 1) |
|
|
2097 | CODE: |
|
|
2098 | pl->socket.buggy_mapscroll = value; |
1838 | |
2099 | |
1839 | void |
2100 | void |
1840 | send (player *pl, SV *packet) |
2101 | send (player *pl, SV *packet) |
1841 | CODE: |
2102 | CODE: |
1842 | { |
2103 | { |
… | |
… | |
1902 | OUTPUT: RETVAL |
2163 | OUTPUT: RETVAL |
1903 | |
2164 | |
1904 | |
2165 | |
1905 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2166 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
1906 | |
2167 | |
|
|
2168 | mapstruct *first () |
|
|
2169 | PROTOTYPE: |
|
|
2170 | CODE: |
|
|
2171 | RETVAL = first_map; |
|
|
2172 | OUTPUT: RETVAL |
|
|
2173 | |
|
|
2174 | mapstruct *next (mapstruct *map) |
|
|
2175 | PROTOTYPE: |
|
|
2176 | CODE: |
|
|
2177 | RETVAL = map->next; |
|
|
2178 | OUTPUT: RETVAL |
|
|
2179 | |
|
|
2180 | int invoke (mapstruct *map, int event, ...) |
|
|
2181 | CODE: |
|
|
2182 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
|
|
2183 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
2184 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
2185 | RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); |
|
|
2186 | OUTPUT: RETVAL |
|
|
2187 | |
|
|
2188 | SV *registry (mapstruct *map) |
|
|
2189 | CODE: |
|
|
2190 | RETVAL = registry_of (map); |
|
|
2191 | OUTPUT: |
|
|
2192 | RETVAL |
|
|
2193 | |
1907 | SV * |
2194 | SV * |
1908 | get_property (mapstruct *obj, int type, int idx) |
2195 | get_property (mapstruct *obj, int type, int idx) |
1909 | CODE: |
2196 | CODE: |
1910 | RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); |
2197 | RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); |
1911 | OUTPUT: RETVAL |
2198 | OUTPUT: RETVAL |
… | |
… | |
1924 | |
2211 | |
1925 | mapstruct *new (int width, int height) |
2212 | mapstruct *new (int width, int height) |
1926 | PROTOTYPE: |
2213 | PROTOTYPE: |
1927 | CODE: |
2214 | CODE: |
1928 | { |
2215 | { |
1929 | int unused_type; |
2216 | RETVAL = get_empty_map (width, height); |
1930 | RETVAL = (mapstruct*) map_get_map (&unused_type, 0, width, height); |
|
|
1931 | } |
2217 | } |
1932 | OUTPUT: |
2218 | OUTPUT: |
1933 | RETVAL |
2219 | RETVAL |
1934 | |
2220 | |
1935 | void delete_map (mapstruct *map) |
2221 | void delete_map (mapstruct *map) |
… | |
… | |
1950 | XSRETURN_UNDEF; |
2236 | XSRETURN_UNDEF; |
1951 | RETVAL = map->tile_path [dir]; |
2237 | RETVAL = map->tile_path [dir]; |
1952 | OUTPUT: |
2238 | OUTPUT: |
1953 | RETVAL |
2239 | RETVAL |
1954 | |
2240 | |
1955 | mapstruct *cf_map_get_map (char *name) |
2241 | mapstruct *ready_map_name (char *name, int flags = 0) |
1956 | PROTOTYPE: $ |
2242 | PROTOTYPE: $;$ |
1957 | ALIAS: map = 0 |
2243 | ALIAS: |
|
|
2244 | find = 0 |
|
|
2245 | get_map = 1 |
1958 | |
2246 | |
1959 | mapstruct *has_been_loaded (char *name) |
2247 | mapstruct *has_been_loaded (char *name) |
1960 | PROTOTYPE: $ |
2248 | PROTOTYPE: $ |
1961 | |
|
|
1962 | mapstruct *cf_map_get_first () |
|
|
1963 | PROTOTYPE: |
|
|
1964 | ALIAS: first = 0 |
|
|
1965 | |
2249 | |
1966 | # whoever "designed" the plug-in api should have wasted |
2250 | # whoever "designed" the plug-in api should have wasted |
1967 | # his/her time with staying away from the project - would have |
2251 | # his/her time with staying away from the project - would have |
1968 | # saved others a lot of time, without doubt. |
2252 | # saved others a lot of time, without doubt. |
1969 | void set_path (mapstruct *where, char *path) |
2253 | void set_path (mapstruct *where, char *path) |
… | |
… | |
1984 | |
2268 | |
1985 | void set_unique (mapstruct *map, bool unique) |
2269 | void set_unique (mapstruct *map, bool unique) |
1986 | CODE: |
2270 | CODE: |
1987 | map->unique = unique; |
2271 | map->unique = unique; |
1988 | |
2272 | |
|
|
2273 | void |
|
|
2274 | trigger (mapstruct *map, long connection, bool state = true) |
|
|
2275 | CODE: |
|
|
2276 | activate_connection (map, connection, state); |
|
|
2277 | |
|
|
2278 | void |
|
|
2279 | get_connection (mapstruct *map, long connection) |
|
|
2280 | PPCODE: |
|
|
2281 | oblinkpt *obp = get_connection_links (map, connection); |
|
|
2282 | if (obp) |
|
|
2283 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
|
|
2284 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); |
|
|
2285 | |
1989 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
2286 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
1990 | |
2287 | |
1991 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
2288 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
1992 | |
2289 | |
1993 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
2290 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
… | |
… | |
1997 | cf_map_normalise (mapstruct *map, int x, int y) |
2294 | cf_map_normalise (mapstruct *map, int x, int y) |
1998 | PPCODE: |
2295 | PPCODE: |
1999 | { |
2296 | { |
2000 | mapstruct *nmap = 0; |
2297 | mapstruct *nmap = 0; |
2001 | I16 nx = 0, ny = 0; |
2298 | I16 nx = 0, ny = 0; |
2002 | int flags = cf_map_get_flags (map, &nmap, x, y, &nx, &ny); |
2299 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2003 | |
2300 | |
2004 | EXTEND (SP, 4); |
2301 | EXTEND (SP, 4); |
2005 | PUSHs (sv_2mortal (newSViv (flags))); |
2302 | PUSHs (sv_2mortal (newSViv (flags))); |
2006 | |
2303 | |
2007 | if (GIMME_V == G_ARRAY) |
2304 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2019 | { |
2316 | { |
2020 | object *o; |
2317 | object *o; |
2021 | mapstruct *nmap = 0; |
2318 | mapstruct *nmap = 0; |
2022 | I16 nx, ny; |
2319 | I16 nx, ny; |
2023 | |
2320 | |
2024 | cf_map_get_flags (map, &nmap, x, y, &nx, &ny); |
2321 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2025 | |
2322 | |
2026 | if (nmap) |
2323 | if (nmap) |
2027 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2324 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2028 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2325 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2029 | } |
2326 | } |
… | |
… | |
2054 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2351 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2055 | } |
2352 | } |
2056 | OUTPUT: |
2353 | OUTPUT: |
2057 | RETVAL |
2354 | RETVAL |
2058 | |
2355 | |
2059 | # "serialise" map perl data into a ref |
|
|
2060 | void |
|
|
2061 | _get_obs (mapstruct *map) |
|
|
2062 | PPCODE: |
|
|
2063 | { |
|
|
2064 | object *o; |
|
|
2065 | int x, y; |
|
|
2066 | AV *obs = newAV (); |
|
|
2067 | int nonnull = 0; |
|
|
2068 | |
2356 | |
2069 | for (y = 0; y < MAP_HEIGHT (map); y++) |
2357 | MODULE = cf PACKAGE = cf::arch |
2070 | for (x = 0; x < MAP_WIDTH (map); x++) |
|
|
2071 | { |
|
|
2072 | AV *av = newAV (); |
|
|
2073 | |
2358 | |
2074 | for (o = GET_MAP_OB (map, x, y); o; o = o->above) |
2359 | archetype *find (const char *name) |
2075 | { |
2360 | CODE: |
2076 | SV *sv = SVptr_cache_get (o); |
2361 | RETVAL = find_archetype (name); |
|
|
2362 | OUTPUT: |
|
|
2363 | RETVAL |
2077 | |
2364 | |
2078 | if (sv && HvFILL (SvRV (sv))) |
2365 | archetype *first() |
2079 | { |
|
|
2080 | nonnull = 1; |
|
|
2081 | sv = newSVsv (sv); |
|
|
2082 | } |
|
|
2083 | else |
|
|
2084 | sv = &PL_sv_undef; |
|
|
2085 | |
|
|
2086 | av_push (av, sv); |
|
|
2087 | } |
|
|
2088 | |
|
|
2089 | av_store (obs, x + y * MAP_HEIGHT (map), newRV_noinc ((SV *)av)); |
|
|
2090 | } |
|
|
2091 | |
|
|
2092 | if (nonnull) |
|
|
2093 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)obs))); |
|
|
2094 | else |
|
|
2095 | SvREFCNT_dec (obs); |
|
|
2096 | } |
|
|
2097 | |
|
|
2098 | # "deserialise" perl map data into the map |
|
|
2099 | void |
|
|
2100 | _set_obs (mapstruct *map, SV *sv) |
|
|
2101 | CODE: |
|
|
2102 | { |
|
|
2103 | object *o; |
|
|
2104 | AV *av; |
|
|
2105 | int x, y; |
|
|
2106 | AV *obs = (AV *)SvRV (sv); |
|
|
2107 | |
|
|
2108 | for (y = 0; y < MAP_HEIGHT (map); y++) |
|
|
2109 | for (x = 0; x < MAP_WIDTH (map); x++) |
|
|
2110 | { |
|
|
2111 | sv = *av_fetch (obs, x + y * MAP_HEIGHT (map), 1); |
|
|
2112 | |
|
|
2113 | if (!SvROK (sv)) |
|
|
2114 | continue; |
|
|
2115 | |
|
|
2116 | av = (AV *)SvRV (sv); |
|
|
2117 | |
|
|
2118 | for (o = GET_MAP_OB (map, x, y); o; o = o->above) |
|
|
2119 | { |
|
|
2120 | sv = av_shift (av); |
|
|
2121 | |
|
|
2122 | if (SvROK (sv)) |
|
|
2123 | { |
|
|
2124 | sv_magic ((SV *)SvRV (sv), 0, PERL_MAGIC_ext, (char *)o, 0); |
|
|
2125 | SVptr_cache_set (o, sv); |
|
|
2126 | } |
|
|
2127 | } |
|
|
2128 | } |
|
|
2129 | } |
|
|
2130 | |
|
|
2131 | |
|
|
2132 | MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
|
|
2133 | |
|
|
2134 | archetype *cf_archetype_get_first() |
|
|
2135 | PROTOTYPE: |
2366 | PROTOTYPE: |
2136 | ALIAS: first = 0 |
2367 | CODE: |
|
|
2368 | RETVAL = first_archetype; |
|
|
2369 | OUTPUT: RETVAL |
2137 | |
2370 | |
2138 | archetype *cf_archetype_get_next (archetype *arch) |
2371 | archetype *next (archetype *arch) |
2139 | ALIAS: next = 0 |
2372 | CODE: |
|
|
2373 | RETVAL = arch->next; |
|
|
2374 | OUTPUT: RETVAL |
2140 | |
2375 | |
2141 | archetype *cf_archetype_get_head (archetype *arch) |
2376 | archetype *head (archetype *arch) |
2142 | ALIAS: head = 0 |
2377 | CODE: |
|
|
2378 | RETVAL = arch->head; |
|
|
2379 | OUTPUT: RETVAL |
2143 | |
2380 | |
2144 | archetype *cf_archetype_get_more (archetype *arch) |
2381 | archetype *more (archetype *arch) |
2145 | ALIAS: more = 0 |
2382 | CODE: |
|
|
2383 | RETVAL = arch->more; |
|
|
2384 | OUTPUT: RETVAL |
2146 | |
2385 | |
2147 | const char *cf_archetype_get_name (archetype *arch) |
2386 | const char *name (archetype *arch) |
2148 | ALIAS: name = 0 |
2387 | CODE: |
|
|
2388 | RETVAL = arch->name; |
|
|
2389 | OUTPUT: RETVAL |
2149 | |
2390 | |
2150 | object *cf_archetype_get_clone (archetype *arch) |
2391 | object *clone (archetype *arch) |
2151 | ALIAS: clone = 0 |
2392 | CODE: |
|
|
2393 | RETVAL = &arch->clone; |
|
|
2394 | OUTPUT: RETVAL |
2152 | |
2395 | |
2153 | MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ |
2396 | MODULE = cf PACKAGE = cf::party |
2154 | |
2397 | |
2155 | partylist *cf_party_get_first () |
2398 | partylist *first () |
2156 | PROTOTYPE: |
2399 | PROTOTYPE: |
2157 | ALIAS: first = 0 |
2400 | CODE: |
|
|
2401 | RETVAL = get_firstparty (); |
|
|
2402 | OUTPUT: RETVAL |
2158 | |
2403 | |
2159 | partylist *cf_party_get_next (partylist *party) |
2404 | partylist *next (partylist *party) |
2160 | ALIAS: next = 0 |
2405 | CODE: |
|
|
2406 | RETVAL = party->next; |
|
|
2407 | OUTPUT: RETVAL |
2161 | |
2408 | |
2162 | const char *cf_party_get_name (partylist *party) |
2409 | const char *name (partylist *party) |
|
|
2410 | CODE: |
|
|
2411 | RETVAL = party->partyname; |
|
|
2412 | OUTPUT: RETVAL |
2163 | |
2413 | |
2164 | const char *cf_party_get_password (partylist *party) |
2414 | const char *password (partylist *party) |
2165 | ALIAS: password = 0 |
2415 | CODE: |
|
|
2416 | RETVAL = party->passwd; |
|
|
2417 | OUTPUT: RETVAL |
2166 | |
2418 | |
2167 | player *cf_party_get_first_player (partylist *party) |
2419 | MODULE = cf PACKAGE = cf::region |
2168 | ALIAS: first_player = 0 |
|
|
2169 | |
2420 | |
2170 | player *cf_party_get_next_player (partylist *party, player *op) |
2421 | region *first () |
2171 | ALIAS: next_player = 0 |
|
|
2172 | |
|
|
2173 | |
|
|
2174 | MODULE = cf PACKAGE = cf::region PREFIX = cf_region_ |
|
|
2175 | |
|
|
2176 | region *cf_region_get_first () |
|
|
2177 | PROTOTYPE: |
2422 | PROTOTYPE: |
2178 | ALIAS: first = 0 |
2423 | CODE: |
|
|
2424 | RETVAL = first_region; |
|
|
2425 | OUTPUT: RETVAL |
2179 | |
2426 | |
|
|
2427 | region *next (region *reg) |
|
|
2428 | CODE: |
|
|
2429 | RETVAL = reg->next; |
|
|
2430 | OUTPUT: RETVAL |
|
|
2431 | |
|
|
2432 | const char *name (region *reg) |
|
|
2433 | CODE: |
|
|
2434 | RETVAL = reg->name; |
|
|
2435 | OUTPUT: RETVAL |
|
|
2436 | |
|
|
2437 | region *parent (region *reg) |
|
|
2438 | CODE: |
|
|
2439 | RETVAL = reg->parent; |
|
|
2440 | OUTPUT: RETVAL |
|
|
2441 | |
2180 | const char *cf_region_get_name (region *reg) |
2442 | const char *longname (region *reg) |
2181 | ALIAS: name = 0 |
2443 | CODE: |
|
|
2444 | RETVAL = reg->longname; |
|
|
2445 | OUTPUT: RETVAL |
2182 | |
2446 | |
2183 | region *cf_region_get_next (region *reg) |
2447 | const char *msg (region *reg) |
2184 | ALIAS: next = 0 |
2448 | CODE: |
|
|
2449 | RETVAL = reg->msg; |
|
|
2450 | OUTPUT: RETVAL |
2185 | |
2451 | |
2186 | region *cf_region_get_parent (region *reg) |
2452 | MODULE = cf PACKAGE = cf::living |
2187 | ALIAS: parent = 0 |
|
|
2188 | |
|
|
2189 | const char *cf_region_get_longname (region *reg) |
|
|
2190 | ALIAS: longname = 0 |
|
|
2191 | |
|
|
2192 | const char *cf_region_get_message (region *reg) |
|
|
2193 | ALIAS: message = 0 |
|
|
2194 | |
|
|
2195 | |
|
|
2196 | MODULE = cf PACKAGE = cf::living PREFIX = cf_living_ |
|
|
2197 | |
2453 | |
2198 | val64 |
2454 | val64 |
2199 | exp (living *liv, val64 new_val = 0) |
2455 | exp (living *liv, val64 new_val = 0) |
2200 | PROTOTYPE: $;$ |
2456 | PROTOTYPE: $;$ |
2201 | ALIAS: |
2457 | ALIAS: |