1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
|
|
4 | * Copyright (©) 2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2006,2007,2008,2009,2010,2012,2015 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
6 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
10 | * option) any later version. |
10 | * |
11 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * GNU General Public License for more details. |
15 | * |
16 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
17 | * You should have received a copy of the Affero GNU General Public License |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
19 | * <http://www.gnu.org/licenses/>. |
19 | * |
20 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
22 | */ |
22 | |
23 | |
23 | #include "autoconf.h" |
24 | #include "autoconf.h" |
|
|
25 | |
|
|
26 | #define CFPERL 1 |
24 | |
27 | |
25 | #if HAVE_EXECINFO_H |
28 | #if HAVE_EXECINFO_H |
26 | # include <execinfo.h> |
29 | # include <execinfo.h> |
27 | #endif |
30 | #endif |
28 | |
31 | |
… | |
… | |
67 | static int tick_inhibit; |
70 | static int tick_inhibit; |
68 | static int tick_pending; |
71 | static int tick_pending; |
69 | |
72 | |
70 | global gbl_ev; |
73 | global gbl_ev; |
71 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
74 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
72 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
75 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick; |
73 | static AV *av_reflect; |
76 | static AV *av_reflect; |
74 | |
77 | |
75 | bitset<NUM_EVENT_TYPES> ev_want_event; |
78 | bitset<NUM_EVENT_TYPES> ev_want_event; |
76 | bitset<NUM_TYPES> ev_want_type; |
79 | bitset<NUM_TYPES> ev_want_type; |
77 | |
80 | |
… | |
… | |
92 | |
95 | |
93 | static SV |
96 | static SV |
94 | *cv_cf_do_invoke, |
97 | *cv_cf_do_invoke, |
95 | *cv_cf__can_merge, |
98 | *cv_cf__can_merge, |
96 | *cv_cf_client_send_msg, |
99 | *cv_cf_client_send_msg, |
|
|
100 | *cv_cf_ix, |
97 | *cv_cf_tick, |
101 | *cv_cf_tick, |
98 | *cv_cf_match_match; |
102 | *cv_cf_match_match; |
99 | |
103 | |
100 | #ifndef newSVpv_utf8 |
104 | #ifndef newSVpv_utf8 |
101 | static SV * |
105 | static SV * |
… | |
… | |
124 | |
128 | |
125 | return sv; |
129 | return sv; |
126 | } |
130 | } |
127 | #endif |
131 | #endif |
128 | |
132 | |
129 | noinline utf8_string |
133 | ecb_noinline utf8_string |
130 | cfSvPVutf8_nolen (SV *sv) |
134 | cfSvPVutf8_nolen (SV *sv) |
131 | { |
135 | { |
132 | SvGETMAGIC (sv); |
136 | SvGETMAGIC (sv); |
133 | |
137 | |
134 | if (SvPOK (sv)) |
138 | if (SvPOK (sv)) |
… | |
… | |
253 | { |
257 | { |
254 | static int last_mortalcount; |
258 | static int last_mortalcount; |
255 | if (mortals.size () != last_mortalcount) |
259 | if (mortals.size () != last_mortalcount) |
256 | { |
260 | { |
257 | last_mortalcount = mortals.size (); |
261 | last_mortalcount = mortals.size (); |
258 | LOG (llevInfo, "%d mortals.\n", (int)mortals.size ()); |
262 | object *specimen = is_a<object> (mortals [rndm (mortals.size ())]); |
|
|
263 | |
|
|
264 | LOG (llevInfo, "%d mortals (random specimen: %s).\n", |
|
|
265 | (int)mortals.size (), specimen ? specimen->debug_desc () : "(not an object)"); |
259 | |
266 | |
260 | if (0) |
267 | if (0) |
261 | { |
268 | { |
262 | for (int j = 0; j < mortals.size (); ++j)//D |
269 | for (int j = 0; j < mortals.size (); ++j)//D |
263 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
270 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
… | |
… | |
363 | |
370 | |
364 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
371 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
365 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
372 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
366 | } |
373 | } |
367 | |
374 | |
368 | static SV * noinline |
375 | ecb_noinline static SV * |
369 | newSVptr (void *ptr, HV *stash) |
376 | newSVptr (void *ptr, HV *stash) |
370 | { |
377 | { |
371 | return newSVptr (ptr, stash, newHV ()); |
378 | return newSVptr (ptr, stash, newHV ()); |
372 | } |
379 | } |
373 | |
380 | |
… | |
… | |
388 | return 0; |
395 | return 0; |
389 | } |
396 | } |
390 | |
397 | |
391 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
398 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
392 | |
399 | |
393 | static SV * noinline |
400 | ecb_noinline static SV * |
394 | newSVattachable (attachable *obj, HV *stash) |
401 | newSVattachable (attachable *obj, HV *stash) |
395 | { |
402 | { |
396 | if (!obj) |
403 | if (!obj) |
397 | return newSV (0); |
404 | return newSV (0); |
398 | |
405 | |
… | |
… | |
452 | croak ("object of type %s expected", klass); |
459 | croak ("object of type %s expected", klass); |
453 | |
460 | |
454 | return SvPTR_nc (sv); |
461 | return SvPTR_nc (sv); |
455 | } |
462 | } |
456 | |
463 | |
457 | static long noinline |
464 | ecb_noinline static long |
458 | SvPTR_ornull (SV *sv, const char *klass) |
465 | SvPTR_ornull (SV *sv, const char *klass) |
459 | { |
466 | { |
460 | if (expect_false (!SvOK (sv))) return 0; |
467 | if (expect_false (!SvOK (sv))) return 0; |
461 | |
468 | |
462 | return SvPTR (sv, klass); |
469 | return SvPTR (sv, klass); |
463 | } |
470 | } |
464 | |
471 | |
465 | static long noinline |
472 | ecb_noinline static long |
466 | SvPTR_ornull_client (SV *sv) |
473 | SvPTR_ornull_client (SV *sv) |
467 | { |
474 | { |
468 | if (expect_false (!SvOK (sv))) return 0; |
475 | if (expect_false (!SvOK (sv))) return 0; |
469 | |
476 | |
470 | if (!SvROK (sv) |
477 | if (!SvROK (sv) |
… | |
… | |
473 | croak ("object of type cf::client expected"); |
480 | croak ("object of type cf::client expected"); |
474 | |
481 | |
475 | return SvPTR_nc (sv); |
482 | return SvPTR_nc (sv); |
476 | } |
483 | } |
477 | |
484 | |
478 | static long noinline |
485 | ecb_noinline static long |
479 | SvPTR_ornull_object (SV *sv) |
486 | SvPTR_ornull_object (SV *sv) |
480 | { |
487 | { |
481 | if (expect_false (!SvOK (sv))) return 0; |
488 | if (expect_false (!SvOK (sv))) return 0; |
482 | |
489 | |
483 | if (!SvROK (sv) |
490 | if (!SvROK (sv) |
… | |
… | |
488 | croak ("object of type cf::object expected"); |
495 | croak ("object of type cf::object expected"); |
489 | |
496 | |
490 | return SvPTR_nc (sv); |
497 | return SvPTR_nc (sv); |
491 | } |
498 | } |
492 | |
499 | |
493 | static long noinline |
500 | ecb_noinline static long |
494 | SvPTR_ornull_maptile (SV *sv) |
501 | SvPTR_ornull_maptile (SV *sv) |
495 | { |
502 | { |
496 | if (expect_false (!SvOK (sv))) return 0; |
503 | if (expect_false (!SvOK (sv))) return 0; |
497 | |
504 | |
498 | if (!SvROK (sv) |
505 | if (!SvROK (sv) |
… | |
… | |
502 | croak ("object of type cf::map expected"); |
509 | croak ("object of type cf::map expected"); |
503 | |
510 | |
504 | return SvPTR_nc (sv); |
511 | return SvPTR_nc (sv); |
505 | } |
512 | } |
506 | |
513 | |
507 | static long noinline |
514 | ecb_noinline static long |
508 | SvPTR_ornull_player (SV *sv) |
515 | SvPTR_ornull_player (SV *sv) |
509 | { |
516 | { |
510 | if (expect_false (!SvOK (sv))) return 0; |
517 | if (expect_false (!SvOK (sv))) return 0; |
511 | |
518 | |
512 | if (!SvROK (sv) |
519 | if (!SvROK (sv) |
… | |
… | |
532 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
539 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
533 | static inline SV *to_sv (float v) { return newSVnv (v); } |
540 | static inline SV *to_sv (float v) { return newSVnv (v); } |
534 | static inline SV *to_sv (double v) { return newSVnv (v); } |
541 | static inline SV *to_sv (double v) { return newSVnv (v); } |
535 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
542 | static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
536 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
543 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
537 | // gcc dislikes noilnine on to_sv |
544 | // gcc dislikes noinline on to_sv |
538 | static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
545 | ecb_noinline static SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
539 | static inline SV *to_sv (object * v) { return to_sv_ni (v); } |
546 | static inline SV *to_sv (object * v) { return to_sv_ni (v); } |
540 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
547 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
541 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
548 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
542 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
549 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
543 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
550 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
… | |
… | |
622 | STRLEN len; |
629 | STRLEN len; |
623 | char *data = SvPVbyte (sv, len); |
630 | char *data = SvPVbyte (sv, len); |
624 | v.assign (data, len); |
631 | v.assign (data, len); |
625 | } |
632 | } |
626 | |
633 | |
|
|
634 | static inline void sv_to (SV *sv, refcnt_buf &v) |
|
|
635 | { |
|
|
636 | STRLEN len; |
|
|
637 | char *data = SvPVbyte (sv, len); |
|
|
638 | refcnt_buf buf (data, len); |
|
|
639 | v = buf; |
|
|
640 | } |
|
|
641 | |
627 | static inline void sv_to (SV *sv, UUID &v) |
642 | static inline void sv_to (SV *sv, UUID &v) |
628 | { |
643 | { |
629 | if (!v.parse (SvPV_nolen (sv))) |
644 | if (!v.parse (SvPV_nolen (sv))) |
630 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
645 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
631 | } |
646 | } |
… | |
… | |
714 | return sv; |
729 | return sv; |
715 | } |
730 | } |
716 | |
731 | |
717 | // typemap support, mostly to avoid excessive inlining |
732 | // typemap support, mostly to avoid excessive inlining |
718 | template<class type> |
733 | template<class type> |
719 | static void noinline |
734 | ecb_noinline static void |
720 | cf_obj_to (SV *arg, type &var) |
735 | cf_obj_to (SV *arg, type &var) |
721 | { |
736 | { |
722 | sv_to (arg, var); |
737 | sv_to (arg, var); |
723 | if (expect_false (!var)) |
738 | if (expect_false (!var)) |
724 | croak ("must not pass invalid/null cf_obj here"); |
739 | croak ("must not pass invalid/null cf_obj here"); |
725 | } |
740 | } |
726 | |
741 | |
727 | template<class object> |
742 | template<class object> |
728 | static void noinline |
743 | ecb_noinline static void |
729 | cf_obj_ornull_to (SV *arg, object *&var) |
744 | cf_obj_ornull_to (SV *arg, object *&var) |
730 | { |
745 | { |
731 | if (SvOK (arg)) |
746 | if (SvOK (arg)) |
732 | { |
747 | { |
733 | sv_to (arg, var); |
748 | sv_to (arg, var); |
… | |
… | |
825 | # undef def |
840 | # undef def |
826 | }; |
841 | }; |
827 | |
842 | |
828 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
843 | #define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) |
829 | |
844 | |
830 | static void noinline |
845 | ecb_noinline static void |
831 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
846 | gather_callbacks (AV *&callbacks, AV *registry, event_type event) |
832 | { |
847 | { |
833 | // event must be in array |
848 | // event must be in array |
834 | if (event >= 0 && event <= AvFILLp (registry)) |
849 | if (event >= 0 && event <= AvFILLp (registry)) |
835 | { |
850 | { |
… | |
… | |
921 | { |
936 | { |
922 | attachable::gather_callbacks (callbacks, event); |
937 | attachable::gather_callbacks (callbacks, event); |
923 | ::gather_callbacks (callbacks, cb_map, event); |
938 | ::gather_callbacks (callbacks, cb_map, event); |
924 | } |
939 | } |
925 | |
940 | |
926 | static void noinline |
941 | ecb_noinline static void |
927 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
942 | _recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) |
928 | { |
943 | { |
929 | for (int event = 0; event <= AvFILLp (registry); ++event) |
944 | for (int event = 0; event <= AvFILLp (registry); ++event) |
930 | { |
945 | { |
931 | SV *cbs_ = AvARRAY (registry)[event]; |
946 | SV *cbs_ = AvARRAY (registry)[event]; |
… | |
… | |
1146 | CALL_ARG (originator); |
1161 | CALL_ARG (originator); |
1147 | CALL_CALL ("cf::mapscript::activate", G_VOID); |
1162 | CALL_CALL ("cf::mapscript::activate", G_VOID); |
1148 | CALL_END; |
1163 | CALL_END; |
1149 | } |
1164 | } |
1150 | |
1165 | |
|
|
1166 | void cfperl_ix (client *ns, int set, faceidx idx, int pri) |
|
|
1167 | { |
|
|
1168 | CALL_BEGIN (3); |
|
|
1169 | CALL_ARG (ns); |
|
|
1170 | CALL_ARG (set); |
|
|
1171 | CALL_ARG (idx); |
|
|
1172 | CALL_ARG (pri); |
|
|
1173 | CALL_CALL (cv_cf_ix, G_VOID); |
|
|
1174 | CALL_END; |
|
|
1175 | } |
|
|
1176 | |
1151 | player * |
1177 | player * |
1152 | player::find (const_utf8_string name) |
1178 | player::find (const_utf8_string name) |
1153 | { |
1179 | { |
1154 | CALL_BEGIN (1); |
1180 | CALL_BEGIN (1); |
1155 | CALL_ARG (name); |
1181 | CALL_ARG (name); |
… | |
… | |
1249 | CALL_ARG (y); |
1275 | CALL_ARG (y); |
1250 | CALL_CALL ("cf::object::player::goto", G_VOID); |
1276 | CALL_CALL ("cf::object::player::goto", G_VOID); |
1251 | CALL_END; |
1277 | CALL_END; |
1252 | } |
1278 | } |
1253 | |
1279 | |
1254 | const_utf8_string |
1280 | const_utf8_string |
1255 | object::ref () const |
1281 | object::ref () const |
1256 | { |
1282 | { |
1257 | if (type == PLAYER) |
1283 | if (type == PLAYER) |
1258 | return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name); |
1284 | return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name); |
1259 | else |
1285 | else |
… | |
… | |
1404 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1430 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1405 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1431 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1406 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1432 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1407 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1433 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1408 | |
1434 | |
1409 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1435 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1410 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1436 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
|
|
1437 | sv_server_tick = get_sv ("cf::SERVER_TICK", 1); SvUPGRADE (sv_server_tick, SVt_IV); |
1411 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1438 | sv_tick_start = get_sv ("cf::TICK_START" , 1); SvUPGRADE (sv_tick_start , SVt_NV); |
1412 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1439 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1413 | |
1440 | |
1414 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1441 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1415 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1442 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1416 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1443 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1417 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1444 | cb_player = get_av ("cf::CB_PLAYER", 1); |
… | |
… | |
1424 | _connect_to_perl_2 () |
1451 | _connect_to_perl_2 () |
1425 | { |
1452 | { |
1426 | cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke); |
1453 | cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke); |
1427 | cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge); |
1454 | cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge); |
1428 | cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg); |
1455 | cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg); |
|
|
1456 | cv_cf_ix = (SV *)get_cv ("cf::face::ix" , 0); assert (cv_cf_ix); |
1429 | cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick); |
1457 | cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick); |
1430 | cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match); |
1458 | cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match); |
1431 | } |
1459 | } |
1432 | |
1460 | |
1433 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1461 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
… | |
… | |
1438 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1466 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1439 | |
1467 | |
1440 | _connect_to_perl_1 (); |
1468 | _connect_to_perl_1 (); |
1441 | |
1469 | |
1442 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1470 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1443 | |
|
|
1444 | //{ |
|
|
1445 | // require_pv ("Time::HiRes"); |
|
|
1446 | // |
|
|
1447 | // SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0); |
|
|
1448 | // if (!svp) croak ("Time::HiRes is required"); |
|
|
1449 | // if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer"); |
|
|
1450 | // coroapi::time = INT2PTR (double(*)(), SvIV(*svp)); |
|
|
1451 | //} |
|
|
1452 | |
1471 | |
1453 | static const struct { |
1472 | static const struct { |
1454 | const char *name; |
1473 | const char *name; |
1455 | IV iv; |
1474 | IV iv; |
1456 | } *civ, const_iv[] = { |
1475 | } *civ, const_iv[] = { |
… | |
… | |
1486 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1505 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1487 | |
1506 | |
1488 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1507 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1489 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1508 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1490 | |
1509 | |
1491 | const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
|
|
1492 | const_iv (MAP_INACTIVE) |
|
|
1493 | |
|
|
1494 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1510 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1495 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1511 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1496 | |
1512 | |
1497 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1513 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1498 | |
1514 | |
1499 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1515 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1500 | }; |
1516 | }; |
1501 | |
1517 | |
1502 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1518 | for (civ = const_iv + ecb_array_length (const_iv); civ-- > const_iv; ) |
1503 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1519 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1504 | |
1520 | |
1505 | static const struct { |
1521 | static const struct { |
1506 | const char *name; |
1522 | const char *name; |
1507 | int skip; |
1523 | int skip; |
… | |
… | |
1513 | # undef def |
1529 | # undef def |
1514 | }; |
1530 | }; |
1515 | |
1531 | |
1516 | AV *av = get_av ("cf::EVENT", 1); |
1532 | AV *av = get_av ("cf::EVENT", 1); |
1517 | |
1533 | |
1518 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1534 | for (eiv = event_iv + ecb_array_length (event_iv); eiv-- > event_iv; ) |
1519 | { |
1535 | { |
1520 | AV *event = newAV (); |
1536 | AV *event = newAV (); |
1521 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1537 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1522 | av_push (event, newSViv (eiv->klass)); |
1538 | av_push (event, newSViv (eiv->klass)); |
1523 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1539 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1530 | |
1546 | |
1531 | void _gv_clear (SV *gv) |
1547 | void _gv_clear (SV *gv) |
1532 | CODE: |
1548 | CODE: |
1533 | assert (SvTYPE (gv) == SVt_PVGV); |
1549 | assert (SvTYPE (gv) == SVt_PVGV); |
1534 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
1550 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1551 | SvREFCNT_inc (gv); |
1535 | f (GvGP (gv)->gp_form); |
1552 | f (GvGP (gv)->gp_form); |
1536 | f (GvGP (gv)->gp_io); |
1553 | f (GvGP (gv)->gp_io); |
1537 | f (GvGP (gv)->gp_sv); |
1554 | f (GvGP (gv)->gp_sv); |
1538 | f (GvGP (gv)->gp_av); |
1555 | f (GvGP (gv)->gp_av); |
1539 | f (GvGP (gv)->gp_hv); |
1556 | f (GvGP (gv)->gp_hv); |
1540 | f (GvGP (gv)->gp_cv); |
1557 | f (GvGP (gv)->gp_cv); |
1541 | GvCVGEN (gv) = 0; |
1558 | GvCVGEN (gv) = 0; |
1542 | GvMULTI_off (gv); |
1559 | GvMULTI_off (gv); |
|
|
1560 | SvREFCNT_dec (gv); |
1543 | # undef f |
1561 | # undef f |
1544 | |
1562 | |
1545 | void _connect_to_perl_1 () |
1563 | void _connect_to_perl_1 () |
1546 | |
1564 | |
1547 | void _connect_to_perl_2 () |
1565 | void _connect_to_perl_2 () |
… | |
… | |
1568 | |
1586 | |
1569 | void init_dynamic () |
1587 | void init_dynamic () |
1570 | |
1588 | |
1571 | void load_settings () |
1589 | void load_settings () |
1572 | |
1590 | |
1573 | void reload_exp_table () |
1591 | void _reload_exp_table () |
1574 | |
1592 | |
1575 | void reload_materials () |
1593 | void _reload_materials () |
1576 | |
1594 | |
1577 | void init_uuid () |
1595 | void init_uuid () |
1578 | CODE: |
1596 | CODE: |
1579 | UUID::init (); |
1597 | UUID::init (); |
1580 | |
1598 | |
… | |
… | |
1591 | coroapi::cede_to_tick (); |
1609 | coroapi::cede_to_tick (); |
1592 | |
1610 | |
1593 | NV till_tick () |
1611 | NV till_tick () |
1594 | CODE: |
1612 | CODE: |
1595 | RETVAL = SvNVX (sv_next_tick) - now (); |
1613 | RETVAL = SvNVX (sv_next_tick) - now (); |
1596 | OUTPUT: |
1614 | OUTPUT: RETVAL |
1597 | RETVAL |
|
|
1598 | |
1615 | |
1599 | int tick_inhibit () |
1616 | int tick_inhibit () |
1600 | CODE: |
1617 | CODE: |
1601 | RETVAL = tick_inhibit; |
1618 | RETVAL = tick_inhibit; |
1602 | OUTPUT: |
1619 | OUTPUT: RETVAL |
1603 | RETVAL |
|
|
1604 | |
1620 | |
1605 | void tick_inhibit_inc () |
1621 | void tick_inhibit_inc () |
1606 | CODE: |
1622 | CODE: |
1607 | ++tick_inhibit; |
1623 | ++tick_inhibit; |
1608 | |
1624 | |
… | |
… | |
1613 | { |
1629 | { |
1614 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1630 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1615 | coroapi::cede (); |
1631 | coroapi::cede (); |
1616 | } |
1632 | } |
1617 | |
1633 | |
1618 | void server_tick () |
1634 | void one_tick () |
1619 | CODE: |
1635 | CODE: |
1620 | { |
1636 | { |
1621 | ev_now_update (EV_DEFAULT); |
1637 | ev_now_update (EV_DEFAULT); |
1622 | NOW = ev_now (EV_DEFAULT); |
1638 | NOW = ev_now (EV_DEFAULT); |
1623 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1639 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1624 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1640 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1625 | runtime = SvNVX (sv_runtime); |
1641 | runtime = SvNVX (sv_runtime); |
1626 | |
1642 | |
|
|
1643 | one_tick (); |
|
|
1644 | |
1627 | server_tick (); |
1645 | ++server_tick; |
|
|
1646 | SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick); |
1628 | |
1647 | |
1629 | ev_now_update (EV_DEFAULT); |
1648 | ev_now_update (EV_DEFAULT); |
1630 | NOW = ev_now (EV_DEFAULT); |
1649 | NOW = ev_now (EV_DEFAULT); |
1631 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1650 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
|
|
1651 | |
1632 | runtime += TICK; |
1652 | runtime += TICK; |
1633 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1653 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1634 | } |
1654 | } |
1635 | |
1655 | |
1636 | NV floor (NV x) |
1656 | NV floor (NV x) |
… | |
… | |
1640 | NV rndm (...) |
1660 | NV rndm (...) |
1641 | ALIAS: |
1661 | ALIAS: |
1642 | rmg_rndm = 1 |
1662 | rmg_rndm = 1 |
1643 | CODE: |
1663 | CODE: |
1644 | { |
1664 | { |
1645 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1665 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1646 | switch (items) |
1666 | switch (items) |
1647 | { |
1667 | { |
1648 | case 0: RETVAL = gen (); break; |
1668 | case 0: RETVAL = gen (); break; |
1649 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1669 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1650 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1670 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1651 | default: croak ("cf::rndm requires zero, one or two parameters."); break; |
1671 | default: croak ("cf::rndm requires zero, one or two parameters."); break; |
1652 | } |
1672 | } |
1653 | } |
1673 | } |
1654 | OUTPUT: |
1674 | OUTPUT: RETVAL |
1655 | RETVAL |
|
|
1656 | |
1675 | |
1657 | NV clamp (NV value, NV min_value, NV max_value) |
1676 | NV clamp (NV value, NV min_value, NV max_value) |
1658 | CODE: |
1677 | CODE: |
1659 | RETVAL = clamp (value, min_value, max_value); |
1678 | RETVAL = clamp (value, min_value, max_value); |
1660 | OUTPUT: |
1679 | OUTPUT: RETVAL |
1661 | RETVAL |
|
|
1662 | |
1680 | |
1663 | NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out) |
1681 | NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out) |
1664 | CODE: |
1682 | CODE: |
1665 | RETVAL = lerp (value, min_in, max_in, min_out, max_out); |
1683 | RETVAL = lerp (value, min_in, max_in, min_out, max_out); |
1666 | OUTPUT: |
1684 | OUTPUT: RETVAL |
1667 | RETVAL |
|
|
1668 | |
1685 | |
1669 | const char *ordinal (int i) |
1686 | const char *ordinal (int i) |
1670 | |
1687 | |
1671 | void weaken (...) |
1688 | void weaken (...) |
1672 | PROTOTYPE: @ |
1689 | PROTOTYPE: @ |
… | |
… | |
1771 | EXTEND (SP, 5*2); |
1788 | EXTEND (SP, 5*2); |
1772 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
1789 | PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); |
1773 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
1790 | PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); |
1774 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
1791 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
1775 | PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); |
1792 | PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); |
1776 | PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount))); |
|
|
1777 | } |
1793 | } |
1778 | |
|
|
1779 | int find_animation (utf8_string text) |
|
|
1780 | PROTOTYPE: $ |
|
|
1781 | |
1794 | |
1782 | int random_roll (int min, int max, object *op, int goodbad); |
1795 | int random_roll (int min, int max, object *op, int goodbad); |
1783 | |
1796 | |
1784 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1797 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1785 | |
1798 | |
1786 | int exp_to_level (val64 exp) |
1799 | int exp_to_level (val64 exp) |
1787 | |
1800 | |
1788 | val64 level_to_min_exp (int level) |
1801 | val64 level_to_min_exp (int level) |
|
|
1802 | |
|
|
1803 | const_utf8_string |
|
|
1804 | spellpathnames (int idx) |
|
|
1805 | CODE: |
|
|
1806 | RETVAL = spellpathnames [idx]; |
|
|
1807 | OUTPUT: RETVAL |
1789 | |
1808 | |
1790 | SV * |
1809 | SV * |
1791 | attacktype_name (int atnr) |
1810 | attacktype_name (int atnr) |
1792 | CODE: |
1811 | CODE: |
1793 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1812 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
… | |
… | |
1817 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1836 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1818 | ? newSVpv (change_resist_msg [atnr], 0) |
1837 | ? newSVpv (change_resist_msg [atnr], 0) |
1819 | : &PL_sv_undef; |
1838 | : &PL_sv_undef; |
1820 | OUTPUT: RETVAL |
1839 | OUTPUT: RETVAL |
1821 | |
1840 | |
|
|
1841 | int |
|
|
1842 | skill_flags (int idx) |
|
|
1843 | CODE: |
|
|
1844 | if (idx < 0 || idx >= ecb_array_length (skill_flags)) |
|
|
1845 | croak ("skill_flags: index out of bounds"); |
|
|
1846 | RETVAL = skill_flags [idx]; |
|
|
1847 | OUTPUT: RETVAL |
|
|
1848 | |
1822 | UUID |
1849 | UUID |
1823 | uuid_cur () |
1850 | uuid_cur () |
1824 | CODE: |
1851 | CODE: |
1825 | RETVAL = UUID::cur; |
1852 | RETVAL = UUID::cur; |
1826 | OUTPUT: |
1853 | OUTPUT: RETVAL |
1827 | RETVAL |
|
|
1828 | |
1854 | |
1829 | UUID |
1855 | UUID |
1830 | uuid_gen () |
1856 | uuid_gen () |
1831 | CODE: |
1857 | CODE: |
1832 | RETVAL = UUID::gen (); |
1858 | RETVAL = UUID::gen (); |
1833 | OUTPUT: |
1859 | OUTPUT: RETVAL |
1834 | RETVAL |
|
|
1835 | |
1860 | |
1836 | val64 |
1861 | val64 |
1837 | uuid_seq (UUID uuid) |
1862 | uuid_seq (UUID uuid) |
1838 | CODE: |
1863 | CODE: |
1839 | RETVAL = uuid.seq; |
1864 | RETVAL = uuid.seq; |
1840 | OUTPUT: |
1865 | OUTPUT: RETVAL |
1841 | RETVAL |
|
|
1842 | |
1866 | |
1843 | UUID |
1867 | UUID |
1844 | uuid_str (val64 seq) |
1868 | uuid_str (val64 seq) |
1845 | CODE: |
1869 | CODE: |
1846 | RETVAL.seq = seq; |
1870 | RETVAL.seq = seq; |
1847 | OUTPUT: |
1871 | OUTPUT: RETVAL |
1848 | RETVAL |
|
|
1849 | |
1872 | |
1850 | void |
1873 | void |
1851 | coin_names () |
1874 | coin_names () |
1852 | PPCODE: |
1875 | PPCODE: |
1853 | EXTEND (SP, NUM_COINS); |
1876 | EXTEND (SP, NUM_COINS); |
… | |
… | |
1865 | load_resource_file_ (octet_string filename) |
1888 | load_resource_file_ (octet_string filename) |
1866 | |
1889 | |
1867 | void |
1890 | void |
1868 | fix_weight () |
1891 | fix_weight () |
1869 | |
1892 | |
|
|
1893 | utf8_string |
|
|
1894 | expand_cfpod (int hintmode, int gender, const_utf8_string cfpod) |
|
|
1895 | PPCODE: |
|
|
1896 | XPUSHs (to_sv (player::expand_cfpod (hintmode, gender, cfpod))); |
|
|
1897 | |
1870 | MODULE = cf PACKAGE = cf::attachable |
1898 | MODULE = cf PACKAGE = cf::attachable |
1871 | |
1899 | |
1872 | int |
1900 | int |
1873 | valid (SV *obj) |
1901 | valid (SV *obj) |
1874 | CODE: |
1902 | CODE: |
1875 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1903 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1876 | OUTPUT: |
1904 | OUTPUT: RETVAL |
1877 | RETVAL |
|
|
1878 | |
1905 | |
1879 | bool should_invoke (attachable *obj, int event) |
1906 | bool should_invoke (attachable *obj, int event) |
1880 | CODE: |
1907 | CODE: |
1881 | RETVAL = obj->should_invoke ((event_type)event); |
1908 | RETVAL = obj->should_invoke ((event_type)event); |
1882 | OUTPUT: RETVAL |
1909 | OUTPUT: RETVAL |
… | |
… | |
1964 | case 0: RETVAL = body_locations[slot].name ; break; |
1991 | case 0: RETVAL = body_locations[slot].name ; break; |
1965 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1992 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1966 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1993 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1967 | } |
1994 | } |
1968 | } |
1995 | } |
1969 | OUTPUT: |
1996 | OUTPUT: RETVAL |
1970 | RETVAL |
|
|
1971 | |
1997 | |
1972 | # missing properties |
1998 | # missing properties |
1973 | |
1999 | |
1974 | object *head (object *op) |
2000 | object *head (object *op) |
1975 | PROTOTYPE: $ |
2001 | PROTOTYPE: $ |
… | |
… | |
1983 | PPCODE: |
2009 | PPCODE: |
1984 | { |
2010 | { |
1985 | for (object *o = obj->inv; o; o = o->below) |
2011 | for (object *o = obj->inv; o; o = o->below) |
1986 | XPUSHs (sv_2mortal (to_sv (o))); |
2012 | XPUSHs (sv_2mortal (to_sv (o))); |
1987 | } |
2013 | } |
1988 | |
|
|
1989 | void |
|
|
1990 | set_animation (object *op, int idx) |
|
|
1991 | CODE: |
|
|
1992 | SET_ANIMATION (op, idx); |
|
|
1993 | |
|
|
1994 | int |
|
|
1995 | num_animations (object *op) |
|
|
1996 | CODE: |
|
|
1997 | RETVAL = NUM_ANIMATIONS (op); |
|
|
1998 | OUTPUT: RETVAL |
|
|
1999 | |
2014 | |
2000 | int slot_info (object *op, UV slot, int value = 0) |
2015 | int slot_info (object *op, UV slot, int value = 0) |
2001 | ALIAS: |
2016 | ALIAS: |
2002 | slot_used = 1 |
2017 | slot_used = 1 |
2003 | CODE: |
2018 | CODE: |
… | |
… | |
2011 | if (ix) |
2026 | if (ix) |
2012 | op->slot[slot].used = value; |
2027 | op->slot[slot].used = value; |
2013 | else |
2028 | else |
2014 | op->slot[slot].info = value; |
2029 | op->slot[slot].info = value; |
2015 | } |
2030 | } |
2016 | OUTPUT: |
2031 | OUTPUT: RETVAL |
2017 | RETVAL |
|
|
2018 | |
2032 | |
2019 | object *find_best_object_match (object *op, utf8_string match) |
2033 | object *find_best_object_match (object *op, utf8_string match) |
2020 | |
2034 | |
2021 | int apply_shop_mat (object *shop_mat, object *op); |
2035 | int apply_shop_mat (object *shop_mat, object *op); |
2022 | |
2036 | |
2023 | int move (object *op, int dir, object *originator = op) |
2037 | int move (object *op, int dir, object *originator = op) |
2024 | CODE: |
2038 | CODE: |
2025 | RETVAL = op->move (dir, originator); |
2039 | RETVAL = op->move (dir, originator); |
2026 | OUTPUT: |
2040 | OUTPUT: RETVAL |
2027 | RETVAL |
|
|
2028 | |
2041 | |
2029 | void apply_below (object *op) |
2042 | void apply_below (object *op) |
2030 | CODE: |
2043 | CODE: |
2031 | player_apply_below (op); |
2044 | player_apply_below (op); |
2032 | |
2045 | |
… | |
… | |
2096 | int convert_item (object *item, object *converter) |
2109 | int convert_item (object *item, object *converter) |
2097 | |
2110 | |
2098 | void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); |
2111 | void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); |
2099 | |
2112 | |
2100 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2113 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2101 | |
|
|
2102 | # no clean way to get an object from an archetype - stupid idiotic |
|
|
2103 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
|
|
2104 | |
2114 | |
2105 | object *new (utf8_string archetype = 0) |
2115 | object *new (utf8_string archetype = 0) |
2106 | PROTOTYPE: ;$ |
2116 | PROTOTYPE: ;$ |
2107 | CODE: |
2117 | CODE: |
2108 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2118 | RETVAL = archetype |
|
|
2119 | ? archetype::get (archetype) |
|
|
2120 | : object::create (); |
2109 | OUTPUT: |
2121 | OUTPUT: RETVAL |
2110 | RETVAL |
|
|
2111 | |
2122 | |
2112 | object *generate (utf8_string arch, object *creator) |
2123 | object *generate (utf8_string arch, object *creator) |
2113 | CODE: |
2124 | CODE: |
2114 | object *obj = get_archetype (arch); |
2125 | object *obj = archetype::get (arch); |
2115 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2126 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2116 | RETVAL = obj; |
2127 | RETVAL = obj; |
2117 | OUTPUT: |
2128 | OUTPUT: RETVAL |
2118 | RETVAL |
|
|
2119 | |
2129 | |
2120 | object *find_object (U32 tag) |
2130 | object *find_object (U32 tag) |
2121 | |
2131 | |
2122 | object *find_object_uuid (UUID i) |
2132 | object *find_object_uuid (UUID i) |
2123 | |
2133 | |
… | |
… | |
2129 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2139 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2130 | |
2140 | |
2131 | if (RETVAL->destroyed ()) |
2141 | if (RETVAL->destroyed ()) |
2132 | RETVAL = 0; |
2142 | RETVAL = 0; |
2133 | } |
2143 | } |
|
|
2144 | OUTPUT: RETVAL |
2134 | |
2145 | |
2135 | shstr |
2146 | shstr |
2136 | object::kv_get (shstr key) |
2147 | object::kv_get (shstr key) |
2137 | CODE: |
2148 | CODE: |
2138 | RETVAL = THIS->kv.get (key); |
2149 | RETVAL = THIS->kv.get (key); |
2139 | OUTPUT: |
2150 | OUTPUT: RETVAL |
2140 | RETVAL |
|
|
2141 | |
2151 | |
2142 | void |
2152 | void |
2143 | object::kv_del (shstr key) |
2153 | object::kv_del (shstr key) |
2144 | CODE: |
2154 | CODE: |
2145 | THIS->kv.del (key); |
2155 | THIS->kv.del (key); |
… | |
… | |
2244 | #d# TODO: replace by blocked_los accessor, fix code using this |
2254 | #d# TODO: replace by blocked_los accessor, fix code using this |
2245 | bool |
2255 | bool |
2246 | cell_visible (player *pl, int dx, int dy) |
2256 | cell_visible (player *pl, int dx, int dy) |
2247 | CODE: |
2257 | CODE: |
2248 | RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; |
2258 | RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; |
2249 | OUTPUT: |
2259 | OUTPUT: RETVAL |
2250 | RETVAL |
|
|
2251 | |
2260 | |
2252 | void |
2261 | void |
2253 | send (player *pl, SV *packet) |
2262 | send (player *pl, SV *packet) |
2254 | CODE: |
2263 | CODE: |
2255 | { |
2264 | { |
… | |
… | |
2331 | outdoor_darkness (int darkness = 0) |
2340 | outdoor_darkness (int darkness = 0) |
2332 | CODE: |
2341 | CODE: |
2333 | RETVAL = maptile::outdoor_darkness; |
2342 | RETVAL = maptile::outdoor_darkness; |
2334 | if (items) |
2343 | if (items) |
2335 | maptile::outdoor_darkness = darkness; |
2344 | maptile::outdoor_darkness = darkness; |
2336 | OUTPUT: |
2345 | OUTPUT: RETVAL |
2337 | RETVAL |
|
|
2338 | |
2346 | |
2339 | void |
2347 | void |
2340 | maptile::instantiate () |
2348 | maptile::instantiate () |
2341 | |
2349 | |
2342 | maptile *new () |
2350 | maptile *new () |
2343 | PROTOTYPE: |
2351 | PROTOTYPE: |
2344 | CODE: |
2352 | CODE: |
2345 | RETVAL = new maptile; |
2353 | RETVAL = new maptile; |
2346 | OUTPUT: |
2354 | OUTPUT: RETVAL |
2347 | RETVAL |
|
|
2348 | |
2355 | |
2349 | void |
2356 | void |
2350 | maptile::players () |
2357 | maptile::players () |
2351 | PPCODE: |
2358 | PPCODE: |
2352 | if (GIMME_V == G_SCALAR) |
2359 | if (GIMME_V == G_SCALAR) |
… | |
… | |
2357 | for_all_players (pl) |
2364 | for_all_players (pl) |
2358 | if (pl->ob && pl->ob->map == THIS) |
2365 | if (pl->ob && pl->ob->map == THIS) |
2359 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2366 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2360 | } |
2367 | } |
2361 | |
2368 | |
2362 | #if 0 |
|
|
2363 | |
|
|
2364 | void |
2369 | void |
2365 | maptile::add_quadland (int mx, int my, int mz, SV *biome_map, SV *biome_plt) |
2370 | maptile::gen_quadmap (int x, int y, int z) |
2366 | CODE: |
2371 | CODE: |
2367 | { |
2372 | gen_quadmap (THIS, x * 50, y * 50, z); |
2368 | static frac_gen<vec2d> frac; |
|
|
2369 | |
2373 | |
|
|
2374 | void |
|
|
2375 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
|
|
2376 | CODE: |
|
|
2377 | { |
2370 | if (!SvROK (biome_plt) || SvTYPE (SvRV (biome_plt)) != SVt_PVAV) |
2378 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2371 | croak ("maptile::add_quadland: biome_plt must be arrayref"); |
2379 | croak ("maptile::add_underlay: palette must be arrayref"); |
2372 | |
2380 | |
2373 | biome_plt = SvRV (biome_plt); |
2381 | palette = SvRV (palette); |
2374 | |
2382 | |
2375 | const uint8_t *bmap = (const uint8_t *)SvPVbyte_nolen (biome_map); |
2383 | STRLEN idxlen; |
|
|
2384 | const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen); |
2376 | |
2385 | |
2377 | for (int x = 0; x < THIS->width; ++x) |
2386 | for (int x = 0; x < THIS->width; ++x) |
2378 | for (int y = 0; y < THIS->height; ++y) |
2387 | for (int y = 0; y < THIS->height; ++y) |
2379 | { |
2388 | { |
2380 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
2389 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
2381 | if (op->flag [FLAG_IS_FLOOR]) |
2390 | if (op->flag [FLAG_IS_FLOOR]) |
2382 | goto skip; |
2391 | goto skip; |
2383 | |
2392 | |
2384 | { |
2393 | { |
2385 | float fx = mx * THIS->width + x; |
|
|
2386 | float fy = my * THIS->height + y; |
|
|
2387 | |
|
|
2388 | int temp = clamp (int (32 * frac.fBm (vec2d (fx * 0.001, fy * 0.001), 2) ) - 8, 0, 15); |
|
|
2389 | int rain = clamp (int (16 * frac.ridgedmultifractal (vec2d (fx * 0.01, fy * 0.01), 3, 1.03, 2)) - 8, 0, 15); |
|
|
2390 | |
|
|
2391 | rain = lerp (rain, 0, 15, 0, temp); |
|
|
2392 | printf ("rain %d\n", temp);//D |
|
|
2393 | |
|
|
2394 | int biome = bmap [rain * 16 + temp]; |
|
|
2395 | |
|
|
2396 | //printf ("%2d %2d => %s\n", temp, rain, SvPV_nolen (AvARRAY ((AV *)biome_plt)[biome]));//D |
|
|
2397 | #if 1 |
|
|
2398 | if (SV **elem = av_fetch ((AV *)biome_plt, bmap [rain * 16 + temp], 0)) |
|
|
2399 | { |
|
|
2400 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
|
|
2401 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
|
|
2402 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
|
|
2403 | |
|
|
2404 | if (ob->randomitems && !ob->above) |
|
|
2405 | { |
|
|
2406 | ob->create_treasure (ob->randomitems); |
|
|
2407 | |
|
|
2408 | for (object *op = ob->above; op; op = op->above) |
|
|
2409 | op->flag [FLAG_NO_MAP_SAVE] = true; |
|
|
2410 | } |
|
|
2411 | } |
|
|
2412 | #endif |
|
|
2413 | } |
|
|
2414 | skip: ; |
|
|
2415 | } |
|
|
2416 | } |
|
|
2417 | |
|
|
2418 | #endif |
|
|
2419 | |
|
|
2420 | void |
|
|
2421 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
|
|
2422 | CODE: |
|
|
2423 | { |
|
|
2424 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
|
|
2425 | croak ("maptile::add_underlay: palette must be arrayref"); |
|
|
2426 | |
|
|
2427 | palette = SvRV (palette); |
|
|
2428 | |
|
|
2429 | STRLEN idxlen; |
|
|
2430 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
|
|
2431 | |
|
|
2432 | for (int x = 0; x < THIS->width; ++x) |
|
|
2433 | for (int y = 0; y < THIS->height; ++y) |
|
|
2434 | { |
|
|
2435 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
|
|
2436 | if (op->flag [FLAG_IS_FLOOR]) |
|
|
2437 | goto skip; |
|
|
2438 | |
|
|
2439 | { |
|
|
2440 | int offs = offset + y * stride + x; |
2394 | int offs = offset + y * stride + x; |
2441 | |
2395 | |
2442 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2396 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2443 | { |
2397 | { |
2444 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2398 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2445 | { |
2399 | { |
2446 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
2400 | object *ob = archetype::get (cfSvPVutf8_nolen (*elem)); |
2447 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2401 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2448 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2402 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2449 | |
2403 | |
2450 | if (ob->randomitems && !ob->above) |
2404 | if (ob->randomitems && !ob->above) |
2451 | { |
2405 | { |
… | |
… | |
2475 | croak ("maptile::set_regiondata: palette must be arrayref"); |
2429 | croak ("maptile::set_regiondata: palette must be arrayref"); |
2476 | |
2430 | |
2477 | palette = SvRV (palette); |
2431 | palette = SvRV (palette); |
2478 | |
2432 | |
2479 | STRLEN idxlen; |
2433 | STRLEN idxlen; |
2480 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2434 | const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen); |
2481 | |
2435 | |
2482 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2436 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2483 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2437 | uint8 *regions = salloc<uint8_t> (THIS->size ()); |
2484 | |
2438 | |
2485 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2439 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2486 | regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
2440 | regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
2487 | |
2441 | |
2488 | for (int y = 0; y < THIS->height; ++y) |
2442 | for (int y = 0; y < THIS->height; ++y) |
… | |
… | |
2540 | if (!pos.move (dir).normalise ()) |
2494 | if (!pos.move (dir).normalise ()) |
2541 | XSRETURN_UNDEF; |
2495 | XSRETURN_UNDEF; |
2542 | |
2496 | |
2543 | RETVAL = &*pos; |
2497 | RETVAL = &*pos; |
2544 | } |
2498 | } |
2545 | OUTPUT: |
2499 | OUTPUT: RETVAL |
2546 | RETVAL |
|
|
2547 | |
2500 | |
2548 | void |
2501 | void |
2549 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2502 | at (maptile *map, unsigned int x, unsigned int y, int dir = 0) |
2550 | PROTOTYPE: $$$;$ |
2503 | PROTOTYPE: $$$;$ |
2551 | PPCODE: |
2504 | PPCODE: |
… | |
… | |
2592 | # worst xs function of my life |
2545 | # worst xs function of my life |
2593 | bool |
2546 | bool |
2594 | _create_random_map (maptile *self, SV *options) |
2547 | _create_random_map (maptile *self, SV *options) |
2595 | CODE: |
2548 | CODE: |
2596 | { |
2549 | { |
2597 | random_map_params rmp ((HV *)SvRV (options)); |
2550 | random_map_params rmp ((HV *)SvRV (options)); |
2598 | RETVAL = self->generate_random_map (&rmp); |
2551 | RETVAL = self->generate_random_map (&rmp); |
2599 | } |
2552 | } |
2600 | OUTPUT: |
2553 | OUTPUT: RETVAL |
2601 | RETVAL |
|
|
2602 | |
2554 | |
2603 | MODULE = cf PACKAGE = cf::mapspace |
2555 | MODULE = cf PACKAGE = cf::mapspace |
2604 | |
2556 | |
2605 | INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h | |
2557 | INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h | |
2606 | |
2558 | |
… | |
… | |
2613 | |
2565 | |
2614 | archetype *archetypes (U32 index) |
2566 | archetype *archetypes (U32 index) |
2615 | CODE: |
2567 | CODE: |
2616 | RETVAL = index < archetypes.size () ? archetypes [index] : 0; |
2568 | RETVAL = index < archetypes.size () ? archetypes [index] : 0; |
2617 | OUTPUT: RETVAL |
2569 | OUTPUT: RETVAL |
|
|
2570 | |
|
|
2571 | int skillvec_size () |
|
|
2572 | CODE: |
|
|
2573 | RETVAL = skillvec.size (); |
|
|
2574 | OUTPUT: RETVAL |
|
|
2575 | |
|
|
2576 | archetype *skillvec (U32 index) |
|
|
2577 | CODE: |
|
|
2578 | RETVAL = index < skillvec.size () ? (archetype *)(object *)skillvec [index] : 0; |
|
|
2579 | OUTPUT: RETVAL |
|
|
2580 | |
|
|
2581 | void |
|
|
2582 | find_by_type (int type) |
|
|
2583 | PPCODE: |
|
|
2584 | for_all_archetypes (arch) |
|
|
2585 | if (arch->type == type) |
|
|
2586 | XPUSHs (sv_2mortal (to_sv (arch))); |
2618 | |
2587 | |
2619 | INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | |
2588 | INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | |
2620 | |
2589 | |
2621 | MODULE = cf PACKAGE = cf::party |
2590 | MODULE = cf PACKAGE = cf::party |
2622 | |
2591 | |
… | |
… | |
2671 | list () |
2640 | list () |
2672 | PPCODE: |
2641 | PPCODE: |
2673 | EXTEND (SP, clients.size ()); |
2642 | EXTEND (SP, clients.size ()); |
2674 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2643 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2675 | PUSHs (sv_2mortal (to_sv (*i))); |
2644 | PUSHs (sv_2mortal (to_sv (*i))); |
|
|
2645 | |
|
|
2646 | STRLEN |
|
|
2647 | client::inbuf_append (SV *data) |
|
|
2648 | CODE: |
|
|
2649 | { |
|
|
2650 | STRLEN len; |
|
|
2651 | char *ptr = SvPVbyte (data, len); |
|
|
2652 | |
|
|
2653 | min_it (len, sizeof (THIS->inbuf) - THIS->inbuf_len); |
|
|
2654 | memcpy (THIS->inbuf + THIS->inbuf_len, ptr, len); |
|
|
2655 | THIS->inbuf_len += len; |
|
|
2656 | |
|
|
2657 | THIS->inbuf_handle (); |
|
|
2658 | |
|
|
2659 | RETVAL = len; |
|
|
2660 | } |
|
|
2661 | OUTPUT: RETVAL |
2676 | |
2662 | |
2677 | void |
2663 | void |
2678 | client::send_packet (SV *packet) |
2664 | client::send_packet (SV *packet) |
2679 | CODE: |
2665 | CODE: |
2680 | { |
2666 | { |
… | |
… | |
2698 | if (RETVAL) |
2684 | if (RETVAL) |
2699 | { |
2685 | { |
2700 | THIS->send_face (RETVAL, pri); |
2686 | THIS->send_face (RETVAL, pri); |
2701 | THIS->flush_fx (); |
2687 | THIS->flush_fx (); |
2702 | } |
2688 | } |
2703 | OUTPUT: |
2689 | OUTPUT: RETVAL |
2704 | RETVAL |
|
|
2705 | |
2690 | |
2706 | int |
2691 | int |
2707 | client::fx_want (int idx, int value = -1) |
2692 | client::fx_want (int idx, int value = -1) |
2708 | CODE: |
2693 | CODE: |
2709 | if (0 < idx && idx < FT_NUM) |
2694 | if (0 < idx && idx < FT_NUM) |
… | |
… | |
2712 | if (items > 2) |
2697 | if (items > 2) |
2713 | THIS->fx_want [idx] = value; |
2698 | THIS->fx_want [idx] = value; |
2714 | } |
2699 | } |
2715 | else |
2700 | else |
2716 | RETVAL = 0; |
2701 | RETVAL = 0; |
2717 | OUTPUT: |
2702 | OUTPUT: RETVAL |
2718 | RETVAL |
|
|
2719 | |
2703 | |
2720 | MODULE = cf PACKAGE = cf::sound PREFIX = sound_ |
2704 | MODULE = cf PACKAGE = cf::sound PREFIX = sound_ |
2721 | |
2705 | |
2722 | faceidx sound_find (utf8_string name) |
2706 | faceidx sound_find (utf8_string name) |
2723 | |
2707 | |
… | |
… | |
2736 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2720 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2737 | |
2721 | |
2738 | faceidx alloc (utf8_string name) |
2722 | faceidx alloc (utf8_string name) |
2739 | CODE: |
2723 | CODE: |
2740 | { |
2724 | { |
2741 | do |
2725 | RETVAL = face_alloc (); |
2742 | { |
|
|
2743 | RETVAL = faces.size (); |
|
|
2744 | faces.resize (RETVAL + 1); |
|
|
2745 | } |
|
|
2746 | while (!RETVAL); // crude way to leave index 0 |
|
|
2747 | |
2726 | |
2748 | faces [RETVAL].name = name; |
2727 | faces [RETVAL].name = name; |
2749 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2728 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2750 | |
2729 | |
2751 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2730 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2752 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2731 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2753 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2732 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2754 | } |
2733 | } |
|
|
2734 | OUTPUT: RETVAL |
|
|
2735 | |
|
|
2736 | faceidx faces_size () |
|
|
2737 | CODE: |
|
|
2738 | RETVAL = faces.size (); |
2755 | OUTPUT: RETVAL |
2739 | OUTPUT: RETVAL |
2756 | |
2740 | |
2757 | void set_type (faceidx idx, int value) |
2741 | void set_type (faceidx idx, int value) |
2758 | ALIAS: |
2742 | ALIAS: |
2759 | set_type = 0 |
2743 | set_type = 0 |
… | |
… | |
2770 | case 2: f->magicmap = value; break; |
2754 | case 2: f->magicmap = value; break; |
2771 | case 3: f->smooth = value; break; |
2755 | case 3: f->smooth = value; break; |
2772 | case 4: f->smoothlevel = value; break; |
2756 | case 4: f->smoothlevel = value; break; |
2773 | } |
2757 | } |
2774 | |
2758 | |
2775 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2759 | void set_csum (faceidx idx, int faceset, SV *chksum) |
2776 | CODE: |
2760 | CODE: |
2777 | { |
2761 | { |
2778 | faceinfo *f = face_info (idx); assert (f); |
2762 | faceinfo *f = face_info (idx); assert (f); |
2779 | facedata *d = f->face + faceset; |
2763 | facedata *d = f->face + faceset; |
2780 | sv_to (data, d->data); |
|
|
2781 | STRLEN clen; |
2764 | STRLEN clen; |
2782 | char *cdata = SvPVbyte (chksum, clen); |
2765 | char *cdata = SvPVbyte (chksum, clen); |
2783 | clen = min (CHKSUM_MAXLEN, clen); |
|
|
2784 | |
2766 | |
|
|
2767 | assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN)); |
2785 | assert (("cf::face::set_data must be called with a non-empty checksum", clen)); |
2768 | assert (("cf::face::set_data must be called with a non-empty checksum", clen)); |
2786 | |
2769 | |
2787 | if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) |
2770 | if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) |
2788 | { |
2771 | { |
2789 | d->chksum_len = clen; |
2772 | d->chksum_len = clen; |
2790 | memcpy (d->chksum, cdata, clen); |
2773 | memcpy (d->chksum, cdata, clen); |
2791 | |
2774 | |
2792 | // invalidate existing client face info |
2775 | // invalidate existing client face info |
2793 | for_all_clients (ns) |
2776 | for_all_clients (ns) |
2794 | if (ns->faceset == faceset) |
2777 | ns->invalidate_face (idx); |
2795 | { |
|
|
2796 | ns->faces_sent [idx] = false; |
|
|
2797 | ns->force_newmap = true; |
|
|
2798 | } |
|
|
2799 | } |
2778 | } |
2800 | } |
2779 | } |
2801 | |
2780 | |
2802 | int get_data_size (faceidx idx, int faceset = 0) |
2781 | SV *mangle_csum (SV *chksum) |
2803 | CODE: |
2782 | CODE: |
2804 | facedata *d = face_data (idx, faceset); |
2783 | STRLEN len; |
2805 | if (!d) XSRETURN_UNDEF; |
2784 | char *data = SvPVbyte (chksum, len); |
2806 | RETVAL = d->data.size (); |
2785 | RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN)); |
2807 | OUTPUT: |
2786 | OUTPUT: RETVAL |
2808 | RETVAL |
|
|
2809 | |
2787 | |
2810 | SV *get_chksum (faceidx idx, int faceset = 0) |
2788 | SV *get_csum (faceidx idx, int faceset = 0) |
2811 | CODE: |
2789 | CODE: |
2812 | facedata *d = face_data (idx, faceset); |
2790 | facedata *d = face_data (idx, faceset); |
2813 | if (!d) XSRETURN_UNDEF; |
2791 | if (!d) XSRETURN_UNDEF; |
2814 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2792 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2815 | OUTPUT: |
2793 | OUTPUT: RETVAL |
2816 | RETVAL |
|
|
2817 | |
2794 | |
2818 | SV *get_data (faceidx idx, int faceset = 0) |
2795 | int get_type (faceidx idx) |
2819 | CODE: |
2796 | CODE: |
2820 | facedata *d = face_data (idx, faceset); |
2797 | faceinfo *f = face_info (idx); |
2821 | if (!d) XSRETURN_UNDEF; |
2798 | if (!f) XSRETURN_UNDEF; |
2822 | RETVAL = newSVpvn (d->data.data (), d->data.length ()); |
2799 | RETVAL = f->type; |
2823 | OUTPUT: |
2800 | OUTPUT: RETVAL |
2824 | RETVAL |
2801 | |
|
|
2802 | SV *get_name (faceidx idx) |
|
|
2803 | CODE: |
|
|
2804 | faceinfo *f = face_info (idx); |
|
|
2805 | if (!f) XSRETURN_UNDEF; |
|
|
2806 | RETVAL = to_sv (f->name); |
|
|
2807 | OUTPUT: RETVAL |
2825 | |
2808 | |
2826 | void invalidate (faceidx idx) |
2809 | void invalidate (faceidx idx) |
2827 | CODE: |
2810 | CODE: |
2828 | for_all_clients (ns) |
2811 | for_all_clients (ns) |
2829 | { |
2812 | ns->invalidate_face (idx); |
2830 | ns->faces_sent [idx] = false; |
|
|
2831 | ns->force_newmap = true; |
|
|
2832 | } |
|
|
2833 | |
2813 | |
2834 | void invalidate_all () |
2814 | void invalidate_all () |
2835 | CODE: |
2815 | CODE: |
2836 | for_all_clients (ns) |
2816 | for_all_clients (ns) |
2837 | { |
2817 | ns->invalidate_all_faces (); |
2838 | ns->faces_sent.reset (); |
|
|
2839 | ns->force_newmap = true; |
|
|
2840 | } |
|
|
2841 | |
2818 | |
2842 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2819 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2843 | |
2820 | |
2844 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2821 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2845 | |
2822 | |
… | |
… | |
2849 | OUTPUT: RETVAL |
2826 | OUTPUT: RETVAL |
2850 | |
2827 | |
2851 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2828 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2852 | CODE: |
2829 | CODE: |
2853 | { |
2830 | { |
2854 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2831 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2855 | croak ("frames must be an arrayref"); |
2832 | croak ("frames must be an arrayref"); |
2856 | |
2833 | |
2857 | AV *av = (AV *)SvRV (frames); |
2834 | AV *av = (AV *)SvRV (frames); |
2858 | |
2835 | |
2859 | animation *anim = &animation::find (name); |
2836 | animation *anim = &animation::find (name); |
2860 | if (anim->number) |
2837 | if (anim->number) |
2861 | { |
2838 | { |
2862 | anim->resize (av_len (av) + 1); |
2839 | anim->resize (av_len (av) + 1); |
2863 | anim->facings = facings; |
2840 | anim->facings = facings; |
2864 | } |
2841 | } |
… | |
… | |
2899 | bool |
2876 | bool |
2900 | errors_are_fatal (bool fatal) |
2877 | errors_are_fatal (bool fatal) |
2901 | CODE: |
2878 | CODE: |
2902 | RETVAL = object_thawer::errors_are_fatal; |
2879 | RETVAL = object_thawer::errors_are_fatal; |
2903 | object_thawer::errors_are_fatal = fatal; |
2880 | object_thawer::errors_are_fatal = fatal; |
2904 | OUTPUT: |
2881 | OUTPUT: RETVAL |
2905 | RETVAL |
|
|
2906 | |
2882 | |
2907 | SV * |
2883 | SV * |
2908 | new_from_file (char *klass, octet_string path) |
2884 | new_from_file (char *klass, octet_string path) |
2909 | CODE: |
2885 | CODE: |
2910 | object_thawer *f = new object_thawer (path); |
2886 | object_thawer *f = new object_thawer (path); |
… | |
… | |
2936 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2912 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2937 | |
2913 | |
2938 | self->skip (); |
2914 | self->skip (); |
2939 | } |
2915 | } |
2940 | |
2916 | |
|
|
2917 | MODULE = cf PACKAGE = cf::treasurelist |
|
|
2918 | |
|
|
2919 | # quick hack, because I didn't want to implement accessors for treasurelist. |
|
|
2920 | # this asks for even more autogen, actually. |
|
|
2921 | |
|
|
2922 | void |
|
|
2923 | expand (treasurelist *list) |
|
|
2924 | PPCODE: |
|
|
2925 | EXTEND (SP, 3); |
|
|
2926 | PUSHs (sv_2mortal (to_sv (list->name))); |
|
|
2927 | PUSHs (sv_2mortal (to_sv (list->total_chance))); |
|
|
2928 | AV *av = newAV (); |
|
|
2929 | PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
2930 | for (treasure *item = list->items; item; item = item->next) |
|
|
2931 | { |
|
|
2932 | AV *iav = newAV (); |
|
|
2933 | av_push (av, newRV_noinc ((SV *)iav)); |
|
|
2934 | |
|
|
2935 | av_extend (iav, 7); |
|
|
2936 | av_push (iav, to_sv (item->item)); |
|
|
2937 | av_push (iav, to_sv (item->name)); |
|
|
2938 | av_push (iav, to_sv (item->change_arch.name)); |
|
|
2939 | av_push (iav, to_sv (item->change_arch.title)); |
|
|
2940 | av_push (iav, to_sv (item->change_arch.slaying)); |
|
|
2941 | av_push (iav, to_sv (item->chance)); |
|
|
2942 | av_push (iav, to_sv (item->nrof)); |
|
|
2943 | av_push (iav, to_sv (item->magic)); |
|
|
2944 | } |
|
|
2945 | |
2941 | MODULE = cf PACKAGE = cf::layout |
2946 | MODULE = cf PACKAGE = cf::layout |
2942 | |
2947 | |
2943 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
2948 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
2944 | |
2949 | |