… | |
… | |
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 | #include <EXTERN.h> |
|
|
27 | #include <perl.h> |
|
|
28 | #include <XSUB.h> |
|
|
29 | |
|
|
30 | #undef save_long // clashes with libproto.h |
|
|
31 | |
|
|
32 | #define PLUGIN_NAME "perl" |
26 | #define PLUGIN_NAME "perl" |
33 | #define PLUGIN_VERSION "cfperl 0.5" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
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 | |
28 | |
45 | #include <plugin_common.h> |
29 | #include <plugin_common.h> |
46 | #include <sounds.h> |
30 | #include <sounds.h> |
47 | #include <cstdarg> |
31 | #include <cstdarg> |
48 | #include <sproto.h> |
32 | #include <sproto.h> |
49 | |
33 | |
50 | #include "cfperl.h" |
34 | #include "cfperl.h" |
51 | #include "shstr.h" |
35 | #include "shstr.h" |
52 | |
36 | |
|
|
37 | #include <EXTERN.h> |
|
|
38 | #include <perl.h> |
|
|
39 | #include <XSUB.h> |
|
|
40 | |
53 | #include "perlxsi.c" |
41 | #include "perlxsi.c" |
54 | |
42 | |
55 | extern sint64 *levels; // the experience table |
43 | extern sint64 *levels; // the experience table |
56 | |
44 | |
57 | typedef object object_ornull; |
45 | typedef object object_ornull; |
… | |
… | |
59 | |
47 | |
60 | typedef double val64; |
48 | typedef double val64; |
61 | #define newSVval64 newSVnv |
49 | #define newSVval64 newSVnv |
62 | #define SvVAL64 SvNV |
50 | #define SvVAL64 SvNV |
63 | |
51 | |
64 | static f_plug_api gethook; |
52 | static f_plug_api gethook = cfapi_get_hooks; |
65 | static f_plug_api systemDirectory; |
53 | static f_plug_api object_set_property = cfapi_object_set_property; |
66 | static f_plug_api object_set_property; |
54 | static f_plug_api object_insert = cfapi_object_insert; |
67 | static f_plug_api map_get_map; |
|
|
68 | static f_plug_api object_insert; |
|
|
69 | |
55 | |
70 | /* this is a stupid way to do things, and awkward to use for plug-in authors */ |
56 | /* this is a stupid way to do things, and awkward to use for plug-in authors */ |
71 | typedef struct |
57 | typedef struct |
72 | { |
58 | { |
73 | object* who; |
59 | object* who; |
… | |
… | |
108 | |
94 | |
109 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
95 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
110 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
96 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
111 | } |
97 | } |
112 | |
98 | |
113 | template<class extendable> |
99 | template<class attachable> |
114 | SV * |
100 | SV * |
115 | newSVextendable (extendable *obj, const char *klass) |
101 | newSVattachable (attachable *obj, const char *klass) |
116 | { |
102 | { |
117 | if (!obj) |
103 | if (!obj) |
118 | return &PL_sv_undef; |
104 | return &PL_sv_undef; |
119 | |
105 | |
120 | if (!obj->self) |
106 | if (!obj->self) |
121 | obj->self = newSVptr (obj, klass); |
107 | obj->self = newSVptr (obj, klass); |
122 | |
108 | |
123 | return newSVsv (static_cast<SV *>(obj->self)); |
109 | return newSVsv (obj->self); |
124 | } |
110 | } |
125 | |
111 | |
126 | static void |
112 | static void |
127 | SVptr_cache_set (void *ptr, SV *sv) |
113 | SVptr_cache_set (void *ptr, SV *sv) |
128 | { |
114 | { |
… | |
… | |
227 | break; |
213 | break; |
228 | |
214 | |
229 | case DT_OBJECT: |
215 | case DT_OBJECT: |
230 | { |
216 | { |
231 | object *obj = va_arg (ap, object *); |
217 | object *obj = va_arg (ap, object *); |
232 | sv = newSVextendable (obj, obj && obj->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); |
218 | sv = newSVattachable (obj, obj && obj->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); |
233 | } |
219 | } |
234 | break; |
220 | break; |
235 | |
221 | |
236 | case DT_MAP: |
222 | case DT_MAP: |
237 | // va_arg (object *) when void * is passed is an XSI extension |
223 | // va_arg (object *) when void * is passed is an XSI extension |
238 | sv = newSVextendable (va_arg (ap, mapstruct *), "cf::map::wrap"); |
224 | sv = newSVattachable (va_arg (ap, mapstruct *), "cf::map::wrap"); |
239 | break; |
225 | break; |
240 | |
226 | |
241 | case DT_PLAYER: |
227 | case DT_PLAYER: |
242 | sv = newSVextendable (va_arg (ap, player *), "cf::player::wrap"); |
228 | sv = newSVattachable (va_arg (ap, player *), "cf::player::wrap"); |
243 | break; |
229 | break; |
244 | |
230 | |
245 | case DT_ARCH: |
231 | case DT_ARCH: |
246 | sv = newSVptr (va_arg (ap, archetype *), "cf::arch::wrap"); |
232 | sv = newSVptr (va_arg (ap, archetype *), "cf::arch::wrap"); |
247 | break; |
233 | break; |
… | |
… | |
304 | } |
290 | } |
305 | |
291 | |
306 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
292 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
307 | |
293 | |
308 | SV * |
294 | SV * |
309 | registry_of (extendable_base *ext) |
295 | registry_of (attachable_base *ext) |
310 | { |
296 | { |
311 | if (!ext->cb) |
297 | if (!ext->cb) |
312 | ext->cb = newAV (); |
298 | ext->cb = newAV (); |
313 | |
299 | |
314 | return newRV_inc ((SV *)ext->cb); |
300 | return newRV_inc ((SV *)ext->cb); |
315 | } |
301 | } |
316 | |
302 | |
317 | void extendable_base::clear () |
303 | void attachable_base::clear () |
318 | { |
304 | { |
319 | //if (self) fprintf (stderr, "free_ob_self %p %s (%p,%p)\n", this, ((object *)this)->name, self, cb);//D |
305 | if (self) |
|
|
306 | { |
|
|
307 | if (cb) |
|
|
308 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
|
|
309 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
|
|
310 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
|
|
311 | INVOKE_MAP (DESTROY, static_cast<mapstruct *>(this)); |
320 | |
312 | |
|
|
313 | // disconnect Perl from C, to avoid crashes |
|
|
314 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
|
|
315 | |
|
|
316 | // clear the perl hash, might or might not be a good idea |
|
|
317 | hv_clear ((HV *)SvRV ((SV *)self)); |
|
|
318 | |
321 | if (self) SvREFCNT_dec (self); |
319 | SvREFCNT_dec (self); |
|
|
320 | self = 0; |
|
|
321 | } |
|
|
322 | |
|
|
323 | if (cb) |
|
|
324 | { |
322 | if (cb) SvREFCNT_dec (cb); |
325 | SvREFCNT_dec (cb); |
|
|
326 | cb = 0; |
|
|
327 | } |
323 | |
328 | |
324 | if (attach) free_string (attach); |
|
|
325 | |
|
|
326 | self = 0; |
|
|
327 | cb = 0; |
|
|
328 | attach = 0; |
329 | attach = 0; |
329 | } |
330 | } |
330 | |
331 | |
331 | void extendable_base::optimise () |
332 | void attachable_base::optimise () |
332 | { |
333 | { |
333 | if (!self) |
334 | if (!self) |
334 | return; |
335 | return; |
335 | |
336 | |
336 | HV *hv = (HV *)SvRV ((SV *)self); |
337 | HV *hv = (HV *)SvRV ((SV *)self); |
… | |
… | |
342 | SvREFCNT_dec ((SV *)self); |
343 | SvREFCNT_dec ((SV *)self); |
343 | self = 0; |
344 | self = 0; |
344 | } |
345 | } |
345 | } |
346 | } |
346 | |
347 | |
347 | void |
348 | void attachable_base::instantiate (data_type type, void *obj) |
348 | object::instantiate_ () |
|
|
349 | { |
349 | { |
350 | dSP; |
350 | dSP; |
351 | ENTER; |
351 | ENTER; |
352 | SAVETMPS; |
352 | SAVETMPS; |
353 | PUSHMARK (SP); |
353 | PUSHMARK (SP); |
354 | EXTEND (SP, 2); |
354 | EXTEND (SP, 2); |
355 | PUSHs (sv_2mortal (newSVdt (DT_OBJECT, static_cast<object *>(this)))); |
355 | PUSHs (sv_2mortal (newSVdt (type, obj))); |
356 | PUSHs (sv_2mortal (newSVpv (attach, 0))); |
356 | PUSHs (sv_2mortal (newSVpv (attach, 0))); |
|
|
357 | |
|
|
358 | attach = 0; |
|
|
359 | |
357 | PUTBACK; |
360 | PUTBACK; |
358 | call_pv ("cf::instantiate", G_DISCARD | G_VOID | G_EVAL); |
361 | call_pv ("cf::instantiate", G_DISCARD | G_VOID | G_EVAL); |
359 | FREETMPS; |
362 | FREETMPS; |
360 | LEAVE; |
363 | LEAVE; |
|
|
364 | |
|
|
365 | switch (type) |
|
|
366 | { |
|
|
367 | case DT_OBJECT: INVOKE_OBJECT (INSTANTIATE, obj); break; |
|
|
368 | case DT_MAP: INVOKE_MAP (INSTANTIATE, obj); break; |
|
|
369 | } |
361 | } |
370 | } |
362 | |
371 | |
363 | ///////////////////////////////////////////////////////////////////////////// |
372 | ///////////////////////////////////////////////////////////////////////////// |
364 | |
373 | |
365 | object_freezer::object_freezer (const char *filename) |
374 | void reattach (data_type type, void *obj) |
366 | : filename (filename) |
|
|
367 | { |
375 | { |
368 | av = (AV *)newAV (); |
376 | //TODO only do this when the object has _attachment's |
369 | idx = 0; |
|
|
370 | av_extend ((AV *)av, 1024); |
|
|
371 | } |
|
|
372 | |
377 | |
373 | object_freezer::~object_freezer () |
|
|
374 | { |
|
|
375 | dSP; |
378 | dSP; |
376 | ENTER; |
379 | ENTER; |
377 | SAVETMPS; |
380 | SAVETMPS; |
378 | PUSHMARK (SP); |
381 | PUSHMARK (SP); |
|
|
382 | XPUSHs (sv_2mortal (newSVdt (type, obj))); |
|
|
383 | PUTBACK; |
|
|
384 | call_pv ("cf::reattach", G_DISCARD | G_VOID | G_EVAL); |
|
|
385 | FREETMPS; |
|
|
386 | LEAVE; |
|
|
387 | |
|
|
388 | switch (type) |
|
|
389 | { |
|
|
390 | case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; |
|
|
391 | case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; |
|
|
392 | case DT_MAP: INVOKE_MAP (REATTACH, obj); break; |
|
|
393 | } |
|
|
394 | } |
|
|
395 | |
|
|
396 | template<class subclass> |
|
|
397 | void reattach (attachable<subclass> *obj) |
|
|
398 | { |
|
|
399 | obj->optimise (); |
|
|
400 | |
|
|
401 | if (obj->self) |
|
|
402 | reattach ((data_type) cftype<subclass>::dt, (subclass *)obj); |
|
|
403 | } |
|
|
404 | |
|
|
405 | #include "kw_hash.h" |
|
|
406 | |
|
|
407 | object_freezer::object_freezer () |
|
|
408 | : dynbuf (128 * 1024, 64 * 1024) |
|
|
409 | { |
|
|
410 | av = newAV (); |
|
|
411 | } |
|
|
412 | |
|
|
413 | object_freezer::~object_freezer () |
|
|
414 | { |
|
|
415 | SvREFCNT_dec (av); |
|
|
416 | } |
|
|
417 | |
|
|
418 | void object_freezer::put (attachable_base *ext) |
|
|
419 | { |
|
|
420 | ext->optimise (); |
|
|
421 | |
|
|
422 | if (ext->self) |
|
|
423 | { |
|
|
424 | int idx = AvFILLp ((AV *)av) + 1; |
|
|
425 | av_store (av, idx, SvREFCNT_inc (ext->self)); |
|
|
426 | |
|
|
427 | add ((void *)"oid ", 4); |
|
|
428 | add ((sint32)idx); |
|
|
429 | add ('\n'); |
|
|
430 | } |
|
|
431 | } |
|
|
432 | |
|
|
433 | bool object_freezer::save (const char *filename) |
|
|
434 | { |
|
|
435 | dSP; |
|
|
436 | ENTER; |
|
|
437 | SAVETMPS; |
|
|
438 | PUSHMARK (SP); |
|
|
439 | EXTEND (SP, 3); |
379 | XPUSHs (sv_2mortal (newSVpv (filename, 0))); |
440 | PUSHs (sv_2mortal (newSVpv (filename, 0))); |
|
|
441 | PUSHs (sv_2mortal (newRV_noinc (newSVpvn ((char *)linearise (), size ())))); |
380 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
442 | PUSHs (sv_2mortal (newRV_inc ((SV *)av))); |
381 | PUTBACK; |
443 | PUTBACK; |
382 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
444 | call_pv ("cf::object_freezer_save", G_VOID | G_DISCARD | G_EVAL); |
383 | FREETMPS; |
445 | FREETMPS; |
384 | LEAVE; |
446 | LEAVE; |
385 | } |
447 | } |
386 | |
448 | |
387 | void object_freezer::put (extendable_base *ext) |
449 | int fprintf (object_freezer &freezer, const char *format, ...) |
388 | { |
450 | { |
389 | ext->optimise (); |
451 | va_list ap; |
390 | |
452 | |
391 | if (ext->self) |
453 | va_start (ap, format); |
392 | av_store ((AV *)av, idx, SvREFCNT_inc ((SV *)ext->self)); |
|
|
393 | |
454 | |
394 | ++idx; |
455 | int len = vsnprintf ((char *)freezer.force (1024), 1024, format, ap); |
|
|
456 | |
|
|
457 | if (len >= 0) |
|
|
458 | freezer.alloc (len); |
|
|
459 | |
|
|
460 | va_end (ap); |
|
|
461 | } |
|
|
462 | |
|
|
463 | int fputs (const char *s, object_freezer &freezer) |
|
|
464 | { |
|
|
465 | freezer.add (s); |
395 | } |
466 | } |
396 | |
467 | |
397 | object_thawer::object_thawer (const char *filename) |
468 | object_thawer::object_thawer (const char *filename) |
398 | { |
469 | { |
|
|
470 | static const char eof[] = "\n\n\n\0\0\0"; |
|
|
471 | |
399 | av = 0; |
472 | av = 0; |
400 | idx = 0; |
473 | text = 0; |
|
|
474 | line = 0; |
401 | |
475 | |
402 | if (!filename) |
476 | if (filename) |
403 | return; |
|
|
404 | |
|
|
405 | dSP; |
|
|
406 | ENTER; |
|
|
407 | SAVETMPS; |
|
|
408 | PUSHMARK (SP); |
|
|
409 | XPUSHs (sv_2mortal (newSVpv (filename, 0))); |
|
|
410 | PUTBACK; |
|
|
411 | |
|
|
412 | if (0 < call_pv ("cf::object_thawer_load", G_SCALAR | G_EVAL)) |
|
|
413 | { |
477 | { |
414 | SPAGAIN; |
|
|
415 | SV *sv = POPs; |
|
|
416 | if (SvROK (sv)) |
|
|
417 | av = SvREFCNT_inc (SvRV (sv)); |
|
|
418 | } |
|
|
419 | |
|
|
420 | FREETMPS; |
|
|
421 | LEAVE; |
|
|
422 | } |
|
|
423 | |
|
|
424 | void object_thawer::get (data_type type, void *obj, extendable_base *ext) |
|
|
425 | { |
|
|
426 | if (!av) |
|
|
427 | return; |
|
|
428 | |
|
|
429 | // we have to "re-instantiate"/reattach to an object, so nuke ext->attach |
|
|
430 | ext->clear (); |
|
|
431 | |
|
|
432 | SV **svp = av_fetch ((AV *)av, idx, 0); |
|
|
433 | |
|
|
434 | ++idx; |
|
|
435 | |
|
|
436 | if (!svp) |
|
|
437 | return; |
|
|
438 | |
|
|
439 | if (SvROK (*svp)) |
|
|
440 | { |
|
|
441 | ext->self = SvREFCNT_inc (*svp); |
|
|
442 | sv_magic (SvRV ((SV *)ext->self), 0, PERL_MAGIC_ext, (char *)obj, 0); |
|
|
443 | |
|
|
444 | dSP; |
478 | dSP; |
445 | ENTER; |
479 | ENTER; |
446 | SAVETMPS; |
480 | SAVETMPS; |
447 | PUSHMARK (SP); |
481 | PUSHMARK (SP); |
448 | EXTEND (SP, 1); |
|
|
449 | PUSHs (sv_2mortal (newSVdt (type, obj))); |
482 | XPUSHs (sv_2mortal (newSVpv (filename, 0))); |
450 | PUTBACK; |
483 | PUTBACK; |
451 | call_pv ("cf::reattach", G_DISCARD | G_VOID | G_EVAL); |
484 | |
|
|
485 | if (2 == call_pv ("cf::object_thawer_load", G_ARRAY | G_EVAL)) |
|
|
486 | { |
|
|
487 | SPAGAIN; |
|
|
488 | |
|
|
489 | // second value - perl objects |
|
|
490 | { |
|
|
491 | SV *sv = POPs; |
|
|
492 | if (SvROK (sv)) |
|
|
493 | av = (AV *)SvREFCNT_inc (SvRV (sv)); |
|
|
494 | } |
|
|
495 | |
|
|
496 | // first value - text part, pad with 3 zeroes |
|
|
497 | { |
|
|
498 | SV *sv = POPs; |
|
|
499 | STRLEN len; |
|
|
500 | char *sv_ = SvPVbyte (sv, len); |
|
|
501 | text = newSV (len + sizeof (eof)); |
|
|
502 | SvCUR_set (text, len); |
|
|
503 | memcpy (SvPVX (text), sv_, len); |
|
|
504 | memcpy (SvEND (text), eof, sizeof (eof)); // just to be sure |
|
|
505 | |
|
|
506 | line = SvPVX (text); |
|
|
507 | } |
|
|
508 | } |
|
|
509 | |
|
|
510 | PUTBACK; |
452 | FREETMPS; |
511 | FREETMPS; |
453 | LEAVE; |
512 | LEAVE; |
454 | |
|
|
455 | if (ext->cb && type == DT_OBJECT) |
|
|
456 | INVOKE_OBJECT (REATTACH, (object *)obj); |
|
|
457 | } |
513 | } |
458 | } |
514 | } |
459 | |
515 | |
|
|
516 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
|
|
517 | { |
|
|
518 | if (!av || oid < 0) // this is actually an error of sorts |
|
|
519 | return; |
|
|
520 | |
|
|
521 | // we have to "re-instantiate"/reattach to an object, so nuke ext->attach |
|
|
522 | ext->clear (); |
|
|
523 | |
|
|
524 | SV **svp = av_fetch ((AV *)av, oid, 0); |
|
|
525 | |
|
|
526 | if (!svp || !SvROK (*svp)) |
|
|
527 | { |
|
|
528 | printf ("trying to thaw duplicate or never-issued oid %d, ignoring.\n", oid); |
|
|
529 | return; |
|
|
530 | } |
|
|
531 | |
|
|
532 | ext->self = *svp; *svp = &PL_sv_undef; |
|
|
533 | sv_magic (SvRV (ext->self), 0, PERL_MAGIC_ext, (char *)obj, 0); |
|
|
534 | |
|
|
535 | reattach (type, obj); |
|
|
536 | } |
|
|
537 | |
460 | object_thawer::~object_thawer () |
538 | object_thawer::~object_thawer () |
461 | { |
539 | { |
|
|
540 | if (text) SvREFCNT_dec (text); |
|
|
541 | if (av) SvREFCNT_dec (av); |
|
|
542 | } |
|
|
543 | |
|
|
544 | char *fgets (char *s, int n, object_thawer &thawer) |
|
|
545 | { |
|
|
546 | char *p = thawer.line; |
|
|
547 | char *q = s; |
|
|
548 | |
462 | if (av) |
549 | if (!p) |
463 | SvREFCNT_dec ((SV *)av); |
550 | return 0; |
|
|
551 | |
|
|
552 | while (--n) |
|
|
553 | { |
|
|
554 | if (!*p) |
|
|
555 | break; |
|
|
556 | |
|
|
557 | *q++ = *p; |
|
|
558 | |
|
|
559 | if (*p++ == '\n') |
|
|
560 | break; |
|
|
561 | } |
|
|
562 | |
|
|
563 | *q = 0; |
|
|
564 | thawer.line = p; |
|
|
565 | |
|
|
566 | return s == q ? 0 : s; |
|
|
567 | } |
|
|
568 | |
|
|
569 | keyword object_thawer::get_kv () |
|
|
570 | { |
|
|
571 | if (!line) |
|
|
572 | return KW_EOF; |
|
|
573 | |
|
|
574 | for (;;) |
|
|
575 | { |
|
|
576 | char *p = line; |
|
|
577 | |
|
|
578 | if (!*p) |
|
|
579 | return KW_EOF; |
|
|
580 | |
|
|
581 | // parse keyword |
|
|
582 | while (*p > ' ') |
|
|
583 | p++; |
|
|
584 | |
|
|
585 | int klen = p - line; |
|
|
586 | |
|
|
587 | if (*p++ != '\n') |
|
|
588 | { |
|
|
589 | // parse value |
|
|
590 | while (*p <= ' ' && *p != '\n') // skip 0x01 .. 0x20 |
|
|
591 | ++p; |
|
|
592 | |
|
|
593 | last_value = p; |
|
|
594 | |
|
|
595 | while (*p != '\n') |
|
|
596 | p++; |
|
|
597 | |
|
|
598 | *p++ = 0; |
|
|
599 | } |
|
|
600 | else |
|
|
601 | last_value = 0; |
|
|
602 | |
|
|
603 | line [klen] = 0; |
|
|
604 | keyword_idx *kw = kw_lex::match (line, klen); |
|
|
605 | |
|
|
606 | //printf ("KV %d<%s,%s>\n", kw ? kw->index : 0, line, last_value);//D |
|
|
607 | |
|
|
608 | if (kw) |
|
|
609 | { |
|
|
610 | line = p; |
|
|
611 | return kw->index; |
|
|
612 | } |
|
|
613 | else if (!*line || *line == '#') |
|
|
614 | { |
|
|
615 | // empty/comment line |
|
|
616 | line = p; |
|
|
617 | } |
|
|
618 | else |
|
|
619 | return KW_ERROR; |
|
|
620 | } |
|
|
621 | } |
|
|
622 | |
|
|
623 | void object_thawer::get (shstr &sh) const |
|
|
624 | { |
|
|
625 | if (last_value) |
|
|
626 | sh = last_value; |
|
|
627 | else |
|
|
628 | { |
|
|
629 | sh = "<value missing>"; |
|
|
630 | LOG (llevError, "keyword requires value: <%s>\n", line);//TODO: add filename |
|
|
631 | } |
|
|
632 | } |
|
|
633 | |
|
|
634 | void object_thawer::get_ml (keyword kend, shstr &sh) |
|
|
635 | { |
|
|
636 | char kw[128]; |
|
|
637 | |
|
|
638 | // multi-line strings are delimited by "\nendXXX\n" |
|
|
639 | kw [0] = '\n'; |
|
|
640 | strcpy (kw + 1, keyword_str [kend]); |
|
|
641 | |
|
|
642 | char *end = strstr (line, kw); |
|
|
643 | |
|
|
644 | if (!end) |
|
|
645 | { |
|
|
646 | sh = 0; |
|
|
647 | return; |
|
|
648 | } |
|
|
649 | |
|
|
650 | *end = 0; |
|
|
651 | sh = line; |
|
|
652 | |
|
|
653 | line = end + keyword_len [kend] + 1; |
|
|
654 | |
|
|
655 | while (*line++ != '\n') |
|
|
656 | ; |
|
|
657 | } |
|
|
658 | |
|
|
659 | sint32 object_thawer::get_sint32 () const |
|
|
660 | { |
|
|
661 | char *p = last_value; |
|
|
662 | |
|
|
663 | if (!p) |
|
|
664 | return 0; |
|
|
665 | |
|
|
666 | sint32 val = 0; |
|
|
667 | bool negate; |
|
|
668 | |
|
|
669 | if (*p == '-') |
|
|
670 | { |
|
|
671 | negate = true; |
|
|
672 | ++p; |
|
|
673 | } |
|
|
674 | else |
|
|
675 | negate = false; |
|
|
676 | |
|
|
677 | do |
|
|
678 | { |
|
|
679 | val *= 10; |
|
|
680 | val += *p++ - '0'; |
|
|
681 | } |
|
|
682 | while (*p); |
|
|
683 | |
|
|
684 | return negate ? -val : val; |
|
|
685 | } |
|
|
686 | |
|
|
687 | sint64 object_thawer::get_sint64 () const |
|
|
688 | { |
|
|
689 | return last_value ? atoll (last_value) : 0; |
|
|
690 | } |
|
|
691 | |
|
|
692 | double object_thawer::get_double () const |
|
|
693 | { |
|
|
694 | return last_value ? atof (last_value) : 0; |
464 | } |
695 | } |
465 | |
696 | |
466 | ///////////////////////////////////////////////////////////////////////////// |
697 | ///////////////////////////////////////////////////////////////////////////// |
467 | |
698 | |
468 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
699 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
469 | { |
700 | { |
470 | gethook = gethooksptr; |
|
|
471 | printf (PLUGIN_VERSION " init\n"); |
|
|
472 | |
|
|
473 | return 0; |
701 | return 0; |
474 | } |
702 | } |
475 | |
703 | |
476 | static CommArray_s rtn_cmd; |
704 | static CommArray_s rtn_cmd; |
477 | |
705 | |
… | |
… | |
557 | extern "C" int cfperl_postInitPlugin () |
785 | extern "C" int cfperl_postInitPlugin () |
558 | { |
786 | { |
559 | int hooktype = 1; |
787 | int hooktype = 1; |
560 | int rtype = 0; |
788 | int rtype = 0; |
561 | |
789 | |
562 | printf (PLUGIN_VERSION " post init\n"); |
|
|
563 | |
|
|
564 | systemDirectory = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_directory"); |
|
|
565 | object_set_property = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_set_property"); |
|
|
566 | map_get_map = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_map_get_map"); |
|
|
567 | object_insert = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_insert"); |
|
|
568 | |
|
|
569 | cf_init_plugin (gethook); |
790 | cf_init_plugin (gethook); |
570 | |
791 | |
571 | return 0; |
792 | return 0; |
572 | } |
793 | } |
573 | |
794 | |
… | |
… | |
577 | } |
798 | } |
578 | |
799 | |
579 | void |
800 | void |
580 | cfperl_init () |
801 | cfperl_init () |
581 | { |
802 | { |
|
|
803 | PERL_SYS_INIT3 (&settings.argc, &settings.argv, 0); |
|
|
804 | perl = perl_alloc (); |
|
|
805 | perl_construct (perl); |
|
|
806 | |
|
|
807 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
|
|
808 | |
582 | char *argv[] = { |
809 | char *argv[] = { |
583 | "", |
810 | "", |
584 | "-e" |
811 | "-e" |
585 | "BEGIN {" |
|
|
586 | " cf->bootstrap;" |
812 | "cf->bootstrap;" |
587 | " unshift @INC, cf::datadir ();" |
813 | "unshift @INC, cf::datadir ();" |
588 | "}" |
|
|
589 | "" |
|
|
590 | "use cf;" |
814 | "require cf;" |
591 | }; |
815 | }; |
592 | |
|
|
593 | perl = perl_alloc (); |
|
|
594 | perl_construct (perl); |
|
|
595 | |
|
|
596 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
|
|
597 | |
816 | |
598 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
817 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
599 | { |
818 | { |
600 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
819 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
601 | |
|
|
602 | exit (EXIT_FAILURE); |
820 | exit (EXIT_FAILURE); |
603 | //perl_destruct (perl); |
|
|
604 | //perl_free (perl); |
|
|
605 | //perl = 0; |
|
|
606 | //return; |
|
|
607 | } |
821 | } |
608 | |
822 | |
609 | obj_cache = newHV (); |
823 | obj_cache = newHV (); |
610 | } |
824 | } |
611 | |
825 | |
… | |
… | |
621 | static event_klass klass_of[NUM_EVENT_TYPES] = { |
835 | static event_klass klass_of[NUM_EVENT_TYPES] = { |
622 | # define def(type,name) KLASS_ ## type, |
836 | # define def(type,name) KLASS_ ## type, |
623 | # include "eventinc.h" |
837 | # include "eventinc.h" |
624 | # undef def |
838 | # undef def |
625 | }; |
839 | }; |
|
|
840 | |
|
|
841 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
626 | |
842 | |
627 | static void |
843 | static void |
628 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
844 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
629 | { |
845 | { |
630 | // event must be in array |
846 | // event must be in array |
… | |
… | |
673 | // 2a. per-type callback |
889 | // 2a. per-type callback |
674 | // 4. global callbacks |
890 | // 4. global callbacks |
675 | |
891 | |
676 | gather_callbacks (callbacks, cb_global, event); |
892 | gather_callbacks (callbacks, cb_global, event); |
677 | |
893 | |
678 | switch (klass_of [event]) |
894 | switch (KLASS_OF (event)) |
679 | { |
895 | { |
680 | case KLASS_GLOBAL: |
896 | case KLASS_GLOBAL: |
681 | break; |
897 | break; |
682 | |
898 | |
683 | case KLASS_OBJECT: |
899 | case KLASS_OBJECT: |
684 | dt = (data_type) va_arg (ap, int); |
900 | dt = (data_type) va_arg (ap, int); |
685 | assert (("first argument must be of type object", dt == DT_OBJECT)); |
901 | assert (("first argument must be of type object", dt == DT_OBJECT)); |
686 | op = va_arg (ap, object *); |
902 | op = va_arg (ap, object *); |
687 | |
903 | |
688 | if (op->cb) |
904 | if (op->cb) |
689 | gather_callbacks (callbacks, (AV *)op->cb, event); |
905 | gather_callbacks (callbacks, op->cb, event); |
|
|
906 | |
|
|
907 | if (op->type) |
|
|
908 | { |
|
|
909 | if (op->subtype && op->type + op->subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) |
|
|
910 | { |
|
|
911 | SV *registry = AvARRAY (cb_type)[op->type + op->subtype * NUM_SUBTYPES]; |
|
|
912 | |
|
|
913 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
914 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
915 | } |
|
|
916 | |
|
|
917 | if (op->type <= AvFILLp (cb_type)) |
|
|
918 | { |
|
|
919 | SV *registry = AvARRAY (cb_type)[op->type]; |
|
|
920 | |
|
|
921 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
922 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
923 | } |
|
|
924 | } |
690 | |
925 | |
691 | gather_callbacks (callbacks, cb_object, event); |
926 | gather_callbacks (callbacks, cb_object, event); |
692 | |
|
|
693 | if (op->type > 0 && op->type <= AvFILLp (cb_type)) |
|
|
694 | { |
|
|
695 | SV *registry = AvARRAY (cb_type)[op->type]; |
|
|
696 | |
|
|
697 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
698 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
699 | } |
|
|
700 | |
927 | |
701 | break; |
928 | break; |
702 | |
929 | |
703 | case KLASS_PLAYER: |
930 | case KLASS_PLAYER: |
704 | dt = (data_type) va_arg (ap, int); |
931 | dt = (data_type) va_arg (ap, int); |
705 | assert (("first argument must be of type player", dt == DT_PLAYER)); |
932 | assert (("first argument must be of type player", dt == DT_PLAYER)); |
706 | pl = va_arg (ap, player *); |
933 | pl = va_arg (ap, player *); |
707 | |
934 | |
708 | if (pl->cb) |
935 | if (pl->cb) |
709 | gather_callbacks (callbacks, (AV *)pl->cb, event); |
936 | gather_callbacks (callbacks, pl->cb, event); |
710 | |
937 | |
711 | gather_callbacks (callbacks, cb_player, event); |
938 | gather_callbacks (callbacks, cb_player, event); |
712 | break; |
939 | break; |
713 | |
940 | |
714 | case KLASS_MAP: |
941 | case KLASS_MAP: |
715 | dt = (data_type) va_arg (ap, int); |
942 | dt = (data_type) va_arg (ap, int); |
716 | assert (("first argument must be of type object", dt == DT_MAP)); |
943 | assert (("first argument must be of type object", dt == DT_MAP)); |
717 | map = va_arg (ap, mapstruct *); |
944 | map = va_arg (ap, mapstruct *); |
718 | |
945 | |
719 | if (map->cb) |
946 | if (map->cb) |
720 | gather_callbacks (callbacks, (AV *)map->cb, event); |
947 | gather_callbacks (callbacks, map->cb, event); |
721 | |
948 | |
722 | gather_callbacks (callbacks, cb_map, event); |
949 | gather_callbacks (callbacks, cb_map, event); |
723 | break; |
950 | break; |
724 | |
951 | |
725 | default: |
952 | default: |
… | |
… | |
738 | EXTEND (SP, 3); |
965 | EXTEND (SP, 3); |
739 | |
966 | |
740 | PUSHs (sv_2mortal (newSViv (event))); // only used for debugging nowadays |
967 | PUSHs (sv_2mortal (newSViv (event))); // only used for debugging nowadays |
741 | PUSHs (sv_2mortal (newRV_noinc ((SV *)callbacks))); |
968 | PUSHs (sv_2mortal (newRV_noinc ((SV *)callbacks))); |
742 | |
969 | |
743 | switch (klass_of [event]) |
970 | switch (KLASS_OF (event)) |
744 | { |
971 | { |
745 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
972 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
746 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
973 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
747 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
974 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
748 | } |
975 | } |
… | |
… | |
938 | const_iv (BUILDER) |
1165 | const_iv (BUILDER) |
939 | const_iv (MATERIAL) |
1166 | const_iv (MATERIAL) |
940 | const_iv (ITEM_TRANSFORMER) |
1167 | const_iv (ITEM_TRANSFORMER) |
941 | const_iv (QUEST) |
1168 | const_iv (QUEST) |
942 | |
1169 | |
|
|
1170 | const_iv (NUM_SUBTYPES) |
|
|
1171 | |
943 | const_iv (ST_BD_BUILD) |
1172 | const_iv (ST_BD_BUILD) |
944 | const_iv (ST_BD_REMOVE) |
1173 | const_iv (ST_BD_REMOVE) |
945 | |
1174 | |
946 | const_iv (ST_MAT_FLOOR) |
1175 | const_iv (ST_MAT_FLOOR) |
947 | const_iv (ST_MAT_WALL) |
1176 | const_iv (ST_MAT_WALL) |
… | |
… | |
1175 | |
1404 | |
1176 | const_iv (SK_EXP_ADD_SKILL) |
1405 | const_iv (SK_EXP_ADD_SKILL) |
1177 | const_iv (SK_EXP_TOTAL) |
1406 | const_iv (SK_EXP_TOTAL) |
1178 | const_iv (SK_EXP_NONE) |
1407 | const_iv (SK_EXP_NONE) |
1179 | const_iv (SK_SUBTRACT_SKILL_EXP) |
1408 | const_iv (SK_SUBTRACT_SKILL_EXP) |
|
|
1409 | const_iv (SK_EXP_SKILL_ONLY) |
1180 | |
1410 | |
1181 | const_iv (SK_LOCKPICKING) |
1411 | const_iv (SK_LOCKPICKING) |
1182 | const_iv (SK_HIDING) |
1412 | const_iv (SK_HIDING) |
1183 | const_iv (SK_SMITHERY) |
1413 | const_iv (SK_SMITHERY) |
1184 | const_iv (SK_BOWYER) |
1414 | const_iv (SK_BOWYER) |
… | |
… | |
1288 | |
1518 | |
1289 | const_iv (KLASS_GLOBAL) |
1519 | const_iv (KLASS_GLOBAL) |
1290 | const_iv (KLASS_OBJECT) |
1520 | const_iv (KLASS_OBJECT) |
1291 | const_iv (KLASS_PLAYER) |
1521 | const_iv (KLASS_PLAYER) |
1292 | const_iv (KLASS_MAP) |
1522 | const_iv (KLASS_MAP) |
1293 | |
|
|
1294 | const_iv (EVENT_OBJECT_INSTANTIATE) |
|
|
1295 | }; |
1523 | }; |
1296 | |
1524 | |
1297 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1525 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1298 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1526 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1299 | |
1527 | |
1300 | static const struct { |
1528 | static const struct { |
1301 | const char *name; |
1529 | const char *name; |
|
|
1530 | int skip; |
1302 | IV klass; |
1531 | IV klass; |
1303 | IV iv; |
1532 | IV iv; |
1304 | } *eiv, event_iv[] = { |
1533 | } *eiv, event_iv[] = { |
1305 | # define def(klass,name) { # name, (IV)KLASS_ ## klass, (IV)EVENT_ ## klass ## _ ## name }, |
1534 | # define def(klass,name) { "EVENT_" # klass "_" # name, sizeof ("EVENT_" # klass), (IV)KLASS_ ## klass, (IV)EVENT_ ## klass ## _ ## name }, |
1306 | # include "eventinc.h" |
1535 | # include "eventinc.h" |
1307 | # undef def |
1536 | # undef def |
1308 | }; |
1537 | }; |
1309 | |
1538 | |
1310 | AV *av = get_av ("cf::EVENT", 1); |
1539 | AV *av = get_av ("cf::EVENT", 1); |
1311 | |
1540 | |
1312 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1541 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1313 | { |
1542 | { |
1314 | AV *event = newAV (); |
1543 | AV *event = newAV (); |
1315 | av_push (event, newSVpv ((char *)eiv->name, 0)); |
1544 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1316 | av_push (event, newSViv (eiv->klass)); |
1545 | av_push (event, newSViv (eiv->klass)); |
1317 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1546 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
|
|
1547 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1318 | } |
1548 | } |
1319 | |
1549 | |
1320 | static const struct { |
1550 | static const struct { |
1321 | int dtype; |
1551 | int dtype; |
1322 | const char *name; |
1552 | const char *name; |
… | |
… | |
1343 | prop (CFAPI_INT, MAP_PROP_WINDDIR) |
1573 | prop (CFAPI_INT, MAP_PROP_WINDDIR) |
1344 | prop (CFAPI_INT, MAP_PROP_SKY) |
1574 | prop (CFAPI_INT, MAP_PROP_SKY) |
1345 | prop (CFAPI_INT, MAP_PROP_WPARTX) |
1575 | prop (CFAPI_INT, MAP_PROP_WPARTX) |
1346 | prop (CFAPI_INT, MAP_PROP_WPARTY) |
1576 | prop (CFAPI_INT, MAP_PROP_WPARTY) |
1347 | prop (CFAPI_STRING, MAP_PROP_MESSAGE) |
1577 | prop (CFAPI_STRING, MAP_PROP_MESSAGE) |
1348 | prop (CFAPI_PMAP, MAP_PROP_NEXT) |
|
|
1349 | prop (CFAPI_PREGION, MAP_PROP_REGION) |
1578 | prop (CFAPI_PREGION, MAP_PROP_REGION) |
1350 | prop (CFAPI_POBJECT, OBJECT_PROP_OB_ABOVE) |
|
|
1351 | prop (CFAPI_POBJECT, OBJECT_PROP_OB_BELOW) |
|
|
1352 | prop (CFAPI_POBJECT, OBJECT_PROP_NEXT_ACTIVE_OB) |
1579 | prop (CFAPI_POBJECT, OBJECT_PROP_NEXT_ACTIVE_OB) |
1353 | prop (CFAPI_POBJECT, OBJECT_PROP_PREV_ACTIVE_OB) |
1580 | prop (CFAPI_POBJECT, OBJECT_PROP_PREV_ACTIVE_OB) |
1354 | prop (CFAPI_POBJECT, OBJECT_PROP_INVENTORY) |
1581 | prop (CFAPI_POBJECT, OBJECT_PROP_INVENTORY) |
1355 | prop (CFAPI_POBJECT, OBJECT_PROP_ENVIRONMENT) |
1582 | prop (CFAPI_POBJECT, OBJECT_PROP_ENVIRONMENT) |
1356 | prop (CFAPI_POBJECT, OBJECT_PROP_HEAD) |
|
|
1357 | prop (CFAPI_POBJECT, OBJECT_PROP_CONTAINER) |
1583 | prop (CFAPI_POBJECT, OBJECT_PROP_CONTAINER) |
1358 | prop (CFAPI_PMAP, OBJECT_PROP_MAP) |
1584 | prop (CFAPI_PMAP, OBJECT_PROP_MAP) |
1359 | prop (CFAPI_INT, OBJECT_PROP_COUNT) |
1585 | prop (CFAPI_INT, OBJECT_PROP_COUNT) |
1360 | prop (CFAPI_INT, OBJECT_PROP_REFCOUNT) |
1586 | prop (CFAPI_INT, OBJECT_PROP_REFCOUNT) |
1361 | prop (CFAPI_STRING, OBJECT_PROP_NAME) |
1587 | prop (CFAPI_STRING, OBJECT_PROP_NAME) |
… | |
… | |
1451 | { |
1677 | { |
1452 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1678 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1453 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1679 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1454 | } |
1680 | } |
1455 | |
1681 | |
1456 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
|
|
1457 | cb_object = get_av ("cf::CB_OBJECT", 1); |
|
|
1458 | cb_player = get_av ("cf::CB_PLAYER", 1); |
|
|
1459 | cb_type = get_av ("cf::CB_TYPE" , 1); |
|
|
1460 | cb_map = get_av ("cf::CB_MAP" , 1); |
|
|
1461 | |
|
|
1462 | //I_EVENT_API (PACKAGE); |
1682 | //I_EVENT_API (PACKAGE); |
|
|
1683 | } |
|
|
1684 | |
|
|
1685 | void _reload_1 () |
|
|
1686 | CODE: |
|
|
1687 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
|
|
1688 | cb_object = get_av ("cf::CB_OBJECT", 1); |
|
|
1689 | cb_player = get_av ("cf::CB_PLAYER", 1); |
|
|
1690 | cb_type = get_av ("cf::CB_TYPE" , 1); |
|
|
1691 | cb_map = get_av ("cf::CB_MAP" , 1); |
|
|
1692 | |
|
|
1693 | void _reload_2 () |
|
|
1694 | CODE: |
|
|
1695 | { |
|
|
1696 | // reattach to all attachable objects in the game. |
|
|
1697 | for (player *pl = first_player; pl; pl = pl->next) |
|
|
1698 | reattach (pl); |
|
|
1699 | |
|
|
1700 | for (mapstruct *map = first_map; map; map = map->next) |
|
|
1701 | reattach (map); |
|
|
1702 | |
|
|
1703 | for (object *op = objects; op; op = op->next) |
|
|
1704 | reattach (op); |
1463 | } |
1705 | } |
1464 | |
1706 | |
1465 | NV floor (NV x) |
1707 | NV floor (NV x) |
1466 | |
1708 | |
1467 | NV ceil (NV x) |
1709 | NV ceil (NV x) |
… | |
… | |
1477 | PROTOTYPE: $$ |
1719 | PROTOTYPE: $$ |
1478 | |
1720 | |
1479 | char *path_combine_and_normalize (char *base, char *path) |
1721 | char *path_combine_and_normalize (char *base, char *path) |
1480 | PROTOTYPE: $$ |
1722 | PROTOTYPE: $$ |
1481 | |
1723 | |
1482 | char * |
1724 | const char * |
1483 | cf_get_maps_directory (char *path) |
1725 | get_maps_directory (char *path) |
1484 | PROTOTYPE: $ |
1726 | PROTOTYPE: $ |
1485 | ALIAS: maps_directory = 0 |
1727 | ALIAS: maps_directory = 0 |
|
|
1728 | CODE: |
|
|
1729 | RETVAL = create_pathname (path); |
|
|
1730 | OUTPUT: RETVAL |
1486 | |
1731 | |
1487 | void |
1732 | void |
1488 | sub_generation_inc () |
1733 | sub_generation_inc () |
1489 | CODE: |
1734 | CODE: |
1490 | PL_sub_generation++; |
1735 | PL_sub_generation++; |
… | |
… | |
1499 | confdir = 3 |
1744 | confdir = 3 |
1500 | localdir = 4 |
1745 | localdir = 4 |
1501 | playerdir = 5 |
1746 | playerdir = 5 |
1502 | datadir = 6 |
1747 | datadir = 6 |
1503 | CODE: |
1748 | CODE: |
1504 | { |
1749 | switch (ix) |
1505 | int unused_type; |
1750 | { |
1506 | RETVAL = (char *)systemDirectory (&unused_type, ix); |
1751 | case 0: RETVAL = settings.mapdir ; break; |
1507 | } |
1752 | case 1: RETVAL = settings.uniquedir; break; |
|
|
1753 | case 2: RETVAL = settings.tmpdir ; break; |
|
|
1754 | case 3: RETVAL = settings.confdir ; break; |
|
|
1755 | case 4: RETVAL = settings.localdir ; break; |
|
|
1756 | case 5: RETVAL = settings.playerdir; break; |
|
|
1757 | case 6: RETVAL = settings.datadir ; break; |
|
|
1758 | } |
1508 | OUTPUT: RETVAL |
1759 | OUTPUT: RETVAL |
1509 | |
1760 | |
1510 | int |
1761 | int |
1511 | cf_find_animation (char *text) |
1762 | cf_find_animation (char *text) |
1512 | PROTOTYPE: $ |
1763 | PROTOTYPE: $ |
1513 | |
1764 | |
1514 | int random_roll(int min, int max, object *op, int goodbad); |
1765 | int random_roll(int min, int max, object *op, int goodbad); |
1515 | |
1766 | |
1516 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1767 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1517 | |
1768 | |
1518 | int invoke (int event, SV *arg1, ...) |
1769 | int invoke (int event, ...) |
1519 | CODE: |
1770 | CODE: |
1520 | { |
1771 | if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL"); |
1521 | // parse first arg and call invoke_object etc as seen fit |
1772 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1522 | //TODO |
1773 | for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1523 | //cfperl_invoke (event, |
1774 | RETVAL = INVOKE_((event_type)event, ARG_AV (av)); |
1524 | } |
1775 | OUTPUT: RETVAL |
1525 | |
1776 | |
1526 | int |
1777 | int |
1527 | exp_to_level (val64 exp) |
1778 | exp_to_level (val64 exp) |
1528 | CODE: |
1779 | CODE: |
1529 | { |
1780 | { |
… | |
… | |
1560 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1811 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1561 | else |
1812 | else |
1562 | XSRETURN_UNDEF; |
1813 | XSRETURN_UNDEF; |
1563 | OUTPUT: RETVAL |
1814 | OUTPUT: RETVAL |
1564 | |
1815 | |
|
|
1816 | int |
|
|
1817 | _valid (SV *obj) |
|
|
1818 | CODE: |
|
|
1819 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
|
|
1820 | OUTPUT: |
|
|
1821 | RETVAL |
|
|
1822 | |
1565 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1823 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
|
|
1824 | |
|
|
1825 | int invoke (object *op, int event, ...) |
|
|
1826 | CODE: |
|
|
1827 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
|
|
1828 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1829 | 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)); |
|
|
1831 | OUTPUT: RETVAL |
|
|
1832 | |
|
|
1833 | SV *registry (object *op) |
|
|
1834 | CODE: |
|
|
1835 | RETVAL = registry_of (op); |
|
|
1836 | OUTPUT: |
|
|
1837 | RETVAL |
|
|
1838 | |
|
|
1839 | object *head (object *op) |
|
|
1840 | PROTOTYPE: $ |
|
|
1841 | ALIAS: |
|
|
1842 | more = 1 |
|
|
1843 | above = 2 |
|
|
1844 | below = 3 |
|
|
1845 | CODE: |
|
|
1846 | switch (ix) |
|
|
1847 | { |
|
|
1848 | case 0: RETVAL = op->head ? op->head : op; break; // DOH! |
|
|
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 |
1566 | |
1855 | |
1567 | SV * |
1856 | SV * |
1568 | get_property (object *obj, int type, int idx) |
1857 | get_property (object *obj, int type, int idx) |
1569 | CODE: |
1858 | CODE: |
1570 | RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); |
1859 | RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); |
… | |
… | |
1649 | |
1938 | |
1650 | int need_identify (const object *obj); |
1939 | int need_identify (const object *obj); |
1651 | |
1940 | |
1652 | int apply_shop_mat (object *shop_mat, object *op); |
1941 | int apply_shop_mat (object *shop_mat, object *op); |
1653 | |
1942 | |
1654 | void cf_object_move (object *op, int dir, object *originator = op) |
1943 | int move (object *op, int dir, object *originator = op) |
|
|
1944 | CODE: |
|
|
1945 | RETVAL = move_ob (op, dir, originator); |
|
|
1946 | OUTPUT: |
|
|
1947 | RETVAL |
1655 | |
1948 | |
1656 | void cf_object_apply (object *op, object *author, int flags = 0) |
1949 | void cf_object_apply (object *op, object *author, int flags = 0) |
1657 | |
1950 | |
1658 | void cf_object_apply_below (object *op) |
1951 | void cf_object_apply_below (object *op) |
1659 | |
1952 | |
… | |
… | |
1700 | int cf_object_out_of_map (object *op, int x, int y) |
1993 | int cf_object_out_of_map (object *op, int x, int y) |
1701 | |
1994 | |
1702 | void cf_object_drop (object *op, object *author) |
1995 | void cf_object_drop (object *op, object *author) |
1703 | |
1996 | |
1704 | void cf_object_take (object *op, object *author) |
1997 | void cf_object_take (object *op, object *author) |
1705 | |
|
|
1706 | void cf_object_say (object *op, char *msg) |
|
|
1707 | |
|
|
1708 | void cf_object_speak (object *op, char *msg) |
|
|
1709 | |
1998 | |
1710 | object *cf_object_insert_object (object *op, object *container) |
1999 | object *cf_object_insert_object (object *op, object *container) |
1711 | |
2000 | |
1712 | const char *cf_object_get_msg (object *ob) |
2001 | const char *cf_object_get_msg (object *ob) |
1713 | ALIAS: msg = 0 |
2002 | ALIAS: msg = 0 |
… | |
… | |
1767 | CODE: |
2056 | CODE: |
1768 | { |
2057 | { |
1769 | int unused_type; |
2058 | int unused_type; |
1770 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
2059 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
1771 | } |
2060 | } |
1772 | |
|
|
1773 | SV *registry (object *op) |
|
|
1774 | CODE: |
|
|
1775 | RETVAL = registry_of (op); |
|
|
1776 | OUTPUT: |
|
|
1777 | RETVAL |
|
|
1778 | |
2061 | |
1779 | # syntatic sugar for easier use in event callbacks. |
2062 | # syntatic sugar for easier use in event callbacks. |
1780 | const char *options (object *op) |
2063 | const char *options (object *op) |
1781 | CODE: |
2064 | CODE: |
1782 | RETVAL = op->name; |
2065 | RETVAL = op->name; |
… | |
… | |
1855 | |
2138 | |
1856 | void kill_player (object *op) |
2139 | void kill_player (object *op) |
1857 | |
2140 | |
1858 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2141 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
1859 | |
2142 | |
|
|
2143 | int invoke (player *pl, int event, ...) |
|
|
2144 | CODE: |
|
|
2145 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
|
|
2146 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
2147 | 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)); |
|
|
2149 | OUTPUT: RETVAL |
|
|
2150 | |
1860 | SV *registry (player *pl) |
2151 | SV *registry (player *pl) |
1861 | CODE: |
2152 | CODE: |
1862 | RETVAL = registry_of (pl); |
2153 | RETVAL = registry_of (pl); |
1863 | OUTPUT: |
2154 | OUTPUT: |
1864 | RETVAL |
2155 | RETVAL |
… | |
… | |
1988 | OUTPUT: RETVAL |
2279 | OUTPUT: RETVAL |
1989 | |
2280 | |
1990 | |
2281 | |
1991 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2282 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
1992 | |
2283 | |
|
|
2284 | mapstruct *first () |
|
|
2285 | PROTOTYPE: |
|
|
2286 | CODE: |
|
|
2287 | RETVAL = first_map; |
|
|
2288 | OUTPUT: RETVAL |
|
|
2289 | |
|
|
2290 | mapstruct *next (mapstruct *map) |
|
|
2291 | PROTOTYPE: |
|
|
2292 | CODE: |
|
|
2293 | RETVAL = map->next; |
|
|
2294 | OUTPUT: RETVAL |
|
|
2295 | |
|
|
2296 | int invoke (mapstruct *map, int event, ...) |
|
|
2297 | CODE: |
|
|
2298 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
|
|
2299 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
2300 | 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)); |
|
|
2302 | OUTPUT: RETVAL |
|
|
2303 | |
1993 | SV *registry (mapstruct *map) |
2304 | SV *registry (mapstruct *map) |
1994 | CODE: |
2305 | CODE: |
1995 | RETVAL = registry_of (map); |
2306 | RETVAL = registry_of (map); |
1996 | OUTPUT: |
2307 | OUTPUT: |
1997 | RETVAL |
2308 | RETVAL |
… | |
… | |
2016 | |
2327 | |
2017 | mapstruct *new (int width, int height) |
2328 | mapstruct *new (int width, int height) |
2018 | PROTOTYPE: |
2329 | PROTOTYPE: |
2019 | CODE: |
2330 | CODE: |
2020 | { |
2331 | { |
2021 | int unused_type; |
2332 | RETVAL = get_empty_map (width, height); |
2022 | RETVAL = (mapstruct*) map_get_map (&unused_type, 0, width, height); |
|
|
2023 | } |
2333 | } |
2024 | OUTPUT: |
2334 | OUTPUT: |
2025 | RETVAL |
2335 | RETVAL |
2026 | |
2336 | |
2027 | void delete_map (mapstruct *map) |
2337 | void delete_map (mapstruct *map) |
… | |
… | |
2042 | XSRETURN_UNDEF; |
2352 | XSRETURN_UNDEF; |
2043 | RETVAL = map->tile_path [dir]; |
2353 | RETVAL = map->tile_path [dir]; |
2044 | OUTPUT: |
2354 | OUTPUT: |
2045 | RETVAL |
2355 | RETVAL |
2046 | |
2356 | |
2047 | mapstruct *cf_map_get_map (char *name) |
2357 | mapstruct *ready_map_name (char *name, int flags = 0) |
2048 | PROTOTYPE: $ |
2358 | PROTOTYPE: $;$ |
2049 | ALIAS: map = 0 |
2359 | ALIAS: |
|
|
2360 | find = 0 |
|
|
2361 | get_map = 1 |
2050 | |
2362 | |
2051 | mapstruct *has_been_loaded (char *name) |
2363 | mapstruct *has_been_loaded (char *name) |
2052 | PROTOTYPE: $ |
2364 | PROTOTYPE: $ |
2053 | |
|
|
2054 | mapstruct *cf_map_get_first () |
|
|
2055 | PROTOTYPE: |
|
|
2056 | ALIAS: first = 0 |
|
|
2057 | |
2365 | |
2058 | # whoever "designed" the plug-in api should have wasted |
2366 | # whoever "designed" the plug-in api should have wasted |
2059 | # his/her time with staying away from the project - would have |
2367 | # his/her time with staying away from the project - would have |
2060 | # saved others a lot of time, without doubt. |
2368 | # saved others a lot of time, without doubt. |
2061 | void set_path (mapstruct *where, char *path) |
2369 | void set_path (mapstruct *where, char *path) |
… | |
… | |
2076 | |
2384 | |
2077 | void set_unique (mapstruct *map, bool unique) |
2385 | void set_unique (mapstruct *map, bool unique) |
2078 | CODE: |
2386 | CODE: |
2079 | map->unique = unique; |
2387 | map->unique = unique; |
2080 | |
2388 | |
|
|
2389 | void |
|
|
2390 | trigger (mapstruct *map, long connection, bool state = true) |
|
|
2391 | CODE: |
|
|
2392 | activate_connection (map, connection, state); |
|
|
2393 | |
|
|
2394 | void |
|
|
2395 | get_connection (mapstruct *map, long connection) |
|
|
2396 | PPCODE: |
|
|
2397 | oblinkpt *obp = get_connection_links (map, connection); |
|
|
2398 | if (obp) |
|
|
2399 | for (objectlink *ol = obp->link; ol; ol = ol->next) |
|
|
2400 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, ol->ob))); |
|
|
2401 | |
2081 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
2402 | object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
2082 | |
2403 | |
2083 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
2404 | object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
2084 | |
2405 | |
2085 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
2406 | object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
… | |
… | |
2089 | cf_map_normalise (mapstruct *map, int x, int y) |
2410 | cf_map_normalise (mapstruct *map, int x, int y) |
2090 | PPCODE: |
2411 | PPCODE: |
2091 | { |
2412 | { |
2092 | mapstruct *nmap = 0; |
2413 | mapstruct *nmap = 0; |
2093 | I16 nx = 0, ny = 0; |
2414 | I16 nx = 0, ny = 0; |
2094 | int flags = cf_map_get_flags (map, &nmap, x, y, &nx, &ny); |
2415 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2095 | |
2416 | |
2096 | EXTEND (SP, 4); |
2417 | EXTEND (SP, 4); |
2097 | PUSHs (sv_2mortal (newSViv (flags))); |
2418 | PUSHs (sv_2mortal (newSViv (flags))); |
2098 | |
2419 | |
2099 | if (GIMME_V == G_ARRAY) |
2420 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2111 | { |
2432 | { |
2112 | object *o; |
2433 | object *o; |
2113 | mapstruct *nmap = 0; |
2434 | mapstruct *nmap = 0; |
2114 | I16 nx, ny; |
2435 | I16 nx, ny; |
2115 | |
2436 | |
2116 | cf_map_get_flags (map, &nmap, x, y, &nx, &ny); |
2437 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2117 | |
2438 | |
2118 | if (nmap) |
2439 | if (nmap) |
2119 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2440 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2120 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2441 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
2121 | } |
2442 | } |
… | |
… | |
2146 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2467 | case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
2147 | } |
2468 | } |
2148 | OUTPUT: |
2469 | OUTPUT: |
2149 | RETVAL |
2470 | RETVAL |
2150 | |
2471 | |
2151 | # "deserialise" perl map data into the map # TODO# compatibility cruft, remove |
|
|
2152 | void |
|
|
2153 | _set_obs (mapstruct *map, SV *sv) |
|
|
2154 | CODE: |
|
|
2155 | { |
|
|
2156 | object *o; |
|
|
2157 | AV *av; |
|
|
2158 | int x, y; |
|
|
2159 | AV *obs = (AV *)SvRV (sv); |
|
|
2160 | |
2472 | |
2161 | for (y = 0; y < MAP_HEIGHT (map); y++) |
2473 | MODULE = cf PACKAGE = cf::arch |
2162 | for (x = 0; x < MAP_WIDTH (map); x++) |
|
|
2163 | { |
|
|
2164 | sv = *av_fetch (obs, x + y * MAP_HEIGHT (map), 1); |
|
|
2165 | |
2474 | |
2166 | if (!SvROK (sv)) |
2475 | archetype *find (const char *name) |
2167 | continue; |
2476 | CODE: |
|
|
2477 | RETVAL = find_archetype (name); |
|
|
2478 | OUTPUT: |
|
|
2479 | RETVAL |
2168 | |
2480 | |
2169 | av = (AV *)SvRV (sv); |
2481 | archetype *first() |
2170 | |
|
|
2171 | for (o = GET_MAP_OB (map, x, y); o; o = o->above) |
|
|
2172 | { |
|
|
2173 | sv = av_shift (av); |
|
|
2174 | |
|
|
2175 | if (SvROK (sv)) |
|
|
2176 | { |
|
|
2177 | sv_magic ((SV *)SvRV (sv), 0, PERL_MAGIC_ext, (char *)o, 0); |
|
|
2178 | SVptr_cache_set (o, sv); |
|
|
2179 | } |
|
|
2180 | } |
|
|
2181 | } |
|
|
2182 | } |
|
|
2183 | |
|
|
2184 | |
|
|
2185 | MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
|
|
2186 | |
|
|
2187 | archetype *cf_archetype_get_first() |
|
|
2188 | PROTOTYPE: |
2482 | PROTOTYPE: |
2189 | ALIAS: first = 0 |
2483 | CODE: |
|
|
2484 | RETVAL = first_archetype; |
|
|
2485 | OUTPUT: RETVAL |
2190 | |
2486 | |
2191 | archetype *cf_archetype_get_next (archetype *arch) |
2487 | archetype *next (archetype *arch) |
2192 | ALIAS: next = 0 |
2488 | CODE: |
|
|
2489 | RETVAL = arch->next; |
|
|
2490 | OUTPUT: RETVAL |
2193 | |
2491 | |
2194 | archetype *cf_archetype_get_head (archetype *arch) |
2492 | archetype *head (archetype *arch) |
2195 | ALIAS: head = 0 |
2493 | CODE: |
|
|
2494 | RETVAL = arch->head; |
|
|
2495 | OUTPUT: RETVAL |
2196 | |
2496 | |
2197 | archetype *cf_archetype_get_more (archetype *arch) |
2497 | archetype *more (archetype *arch) |
2198 | ALIAS: more = 0 |
2498 | CODE: |
|
|
2499 | RETVAL = arch->more; |
|
|
2500 | OUTPUT: RETVAL |
2199 | |
2501 | |
2200 | const char *cf_archetype_get_name (archetype *arch) |
2502 | const char *name (archetype *arch) |
2201 | ALIAS: name = 0 |
2503 | CODE: |
|
|
2504 | RETVAL = arch->name; |
|
|
2505 | OUTPUT: RETVAL |
2202 | |
2506 | |
2203 | object *cf_archetype_get_clone (archetype *arch) |
2507 | object *clone (archetype *arch) |
2204 | ALIAS: clone = 0 |
2508 | CODE: |
|
|
2509 | RETVAL = &arch->clone; |
|
|
2510 | OUTPUT: RETVAL |
2205 | |
2511 | |
2206 | MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ |
2512 | MODULE = cf PACKAGE = cf::party |
2207 | |
2513 | |
2208 | partylist *cf_party_get_first () |
2514 | partylist *first () |
2209 | PROTOTYPE: |
2515 | PROTOTYPE: |
2210 | ALIAS: first = 0 |
2516 | CODE: |
|
|
2517 | RETVAL = get_firstparty (); |
|
|
2518 | OUTPUT: RETVAL |
2211 | |
2519 | |
2212 | partylist *cf_party_get_next (partylist *party) |
2520 | partylist *next (partylist *party) |
2213 | ALIAS: next = 0 |
2521 | CODE: |
|
|
2522 | RETVAL = party->next; |
|
|
2523 | OUTPUT: RETVAL |
2214 | |
2524 | |
2215 | const char *cf_party_get_name (partylist *party) |
2525 | const char *name (partylist *party) |
|
|
2526 | CODE: |
|
|
2527 | RETVAL = party->partyname; |
|
|
2528 | OUTPUT: RETVAL |
2216 | |
2529 | |
2217 | const char *cf_party_get_password (partylist *party) |
2530 | const char *password (partylist *party) |
2218 | ALIAS: password = 0 |
2531 | CODE: |
|
|
2532 | RETVAL = party->passwd; |
|
|
2533 | OUTPUT: RETVAL |
2219 | |
2534 | |
2220 | player *cf_party_get_first_player (partylist *party) |
2535 | MODULE = cf PACKAGE = cf::region |
2221 | ALIAS: first_player = 0 |
|
|
2222 | |
2536 | |
2223 | player *cf_party_get_next_player (partylist *party, player *op) |
2537 | region *first () |
2224 | ALIAS: next_player = 0 |
|
|
2225 | |
|
|
2226 | |
|
|
2227 | MODULE = cf PACKAGE = cf::region PREFIX = cf_region_ |
|
|
2228 | |
|
|
2229 | region *cf_region_get_first () |
|
|
2230 | PROTOTYPE: |
2538 | PROTOTYPE: |
2231 | ALIAS: first = 0 |
2539 | CODE: |
|
|
2540 | RETVAL = first_region; |
|
|
2541 | OUTPUT: RETVAL |
2232 | |
2542 | |
|
|
2543 | region *next (region *reg) |
|
|
2544 | CODE: |
|
|
2545 | RETVAL = reg->next; |
|
|
2546 | OUTPUT: RETVAL |
|
|
2547 | |
|
|
2548 | const char *name (region *reg) |
|
|
2549 | CODE: |
|
|
2550 | RETVAL = reg->name; |
|
|
2551 | OUTPUT: RETVAL |
|
|
2552 | |
|
|
2553 | region *parent (region *reg) |
|
|
2554 | CODE: |
|
|
2555 | RETVAL = reg->parent; |
|
|
2556 | OUTPUT: RETVAL |
|
|
2557 | |
2233 | const char *cf_region_get_name (region *reg) |
2558 | const char *longname (region *reg) |
2234 | ALIAS: name = 0 |
2559 | CODE: |
|
|
2560 | RETVAL = reg->longname; |
|
|
2561 | OUTPUT: RETVAL |
2235 | |
2562 | |
2236 | region *cf_region_get_next (region *reg) |
2563 | const char *msg (region *reg) |
2237 | ALIAS: next = 0 |
2564 | CODE: |
|
|
2565 | RETVAL = reg->msg; |
|
|
2566 | OUTPUT: RETVAL |
2238 | |
2567 | |
2239 | region *cf_region_get_parent (region *reg) |
2568 | MODULE = cf PACKAGE = cf::living |
2240 | ALIAS: parent = 0 |
|
|
2241 | |
|
|
2242 | const char *cf_region_get_longname (region *reg) |
|
|
2243 | ALIAS: longname = 0 |
|
|
2244 | |
|
|
2245 | const char *cf_region_get_message (region *reg) |
|
|
2246 | ALIAS: message = 0 |
|
|
2247 | |
|
|
2248 | |
|
|
2249 | MODULE = cf PACKAGE = cf::living PREFIX = cf_living_ |
|
|
2250 | |
2569 | |
2251 | val64 |
2570 | val64 |
2252 | exp (living *liv, val64 new_val = 0) |
2571 | exp (living *liv, val64 new_val = 0) |
2253 | PROTOTYPE: $;$ |
2572 | PROTOTYPE: $;$ |
2254 | ALIAS: |
2573 | ALIAS: |