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 (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2006,2007,2008,2009,2010,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * 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 |
7 | * 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 |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
10 | * |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
14 | * GNU General Public License for more details. |
15 | * |
15 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
16 | * 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 |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
18 | * <http://www.gnu.org/licenses/>. |
19 | * |
19 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #include "autoconf.h" |
23 | #include "autoconf.h" |
24 | |
24 | |
… | |
… | |
28 | |
28 | |
29 | #include <cstdarg> |
29 | #include <cstdarg> |
30 | #include <typeinfo> |
30 | #include <typeinfo> |
31 | |
31 | |
32 | #include "global.h" |
32 | #include "global.h" |
33 | #include "../random_maps/random_map.h" |
33 | #include "rmg.h" |
|
|
34 | #include "noise.h" |
34 | #include "evthread.h" |
35 | #include "evthread.h" |
35 | #include "sproto.h" |
36 | #include "sproto.h" |
36 | |
37 | |
37 | #include <unistd.h> |
38 | #include <unistd.h> |
38 | #if _POSIX_MEMLOCK |
39 | #if _POSIX_MEMLOCK |
… | |
… | |
66 | static int tick_inhibit; |
67 | static int tick_inhibit; |
67 | static int tick_pending; |
68 | static int tick_pending; |
68 | |
69 | |
69 | global gbl_ev; |
70 | global gbl_ev; |
70 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
71 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
71 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
72 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick; |
72 | static AV *av_reflect; |
73 | static AV *av_reflect; |
73 | |
74 | |
74 | bitset<NUM_EVENT_TYPES> ev_want_event; |
75 | bitset<NUM_EVENT_TYPES> ev_want_event; |
75 | bitset<NUM_TYPES> ev_want_type; |
76 | bitset<NUM_TYPES> ev_want_type; |
76 | |
77 | |
… | |
… | |
84 | *stash_cf_client_wrap, |
85 | *stash_cf_client_wrap, |
85 | *stash_cf_arch_wrap, |
86 | *stash_cf_arch_wrap, |
86 | *stash_cf_party_wrap, |
87 | *stash_cf_party_wrap, |
87 | *stash_cf_region_wrap, |
88 | *stash_cf_region_wrap, |
88 | *stash_cf_living_wrap, |
89 | *stash_cf_living_wrap, |
|
|
90 | *stash_cf_layout_wrap, |
89 | *stash_ext_map_world; |
91 | *stash_ext_map_world; |
90 | |
92 | |
91 | static SV |
93 | static SV |
92 | *cv_cf_do_invoke, |
94 | *cv_cf_do_invoke, |
93 | *cv_cf__can_merge, |
95 | *cv_cf__can_merge, |
94 | *cv_cf_client_send_msg, |
96 | *cv_cf_client_send_msg, |
|
|
97 | *cv_cf_ix, |
95 | *cv_cf_tick, |
98 | *cv_cf_tick, |
96 | *cv_cf_match_match; |
99 | *cv_cf_match_match; |
97 | |
100 | |
98 | #ifndef newSVpv_utf8 |
101 | #ifndef newSVpv_utf8 |
99 | static SV * |
102 | static SV * |
… | |
… | |
122 | |
125 | |
123 | return sv; |
126 | return sv; |
124 | } |
127 | } |
125 | #endif |
128 | #endif |
126 | |
129 | |
127 | static noinline utf8_string |
130 | noinline utf8_string |
128 | cfSvPVutf8_nolen (SV *sv) |
131 | cfSvPVutf8_nolen (SV *sv) |
129 | { |
132 | { |
130 | SvGETMAGIC (sv); |
133 | SvGETMAGIC (sv); |
131 | |
134 | |
132 | if (SvPOK (sv)) |
135 | if (SvPOK (sv)) |
… | |
… | |
251 | { |
254 | { |
252 | static int last_mortalcount; |
255 | static int last_mortalcount; |
253 | if (mortals.size () != last_mortalcount) |
256 | if (mortals.size () != last_mortalcount) |
254 | { |
257 | { |
255 | last_mortalcount = mortals.size (); |
258 | last_mortalcount = mortals.size (); |
256 | LOG (llevInfo, "%d mortals.\n", (int)mortals.size ()); |
259 | object *specimen = is_a<object> (mortals [rndm (mortals.size ())]); |
|
|
260 | |
|
|
261 | LOG (llevInfo, "%d mortals (random specimen: %s).\n", |
|
|
262 | (int)mortals.size (), specimen ? specimen->debug_desc () : "(not an object)"); |
257 | |
263 | |
258 | if (0) |
264 | if (0) |
259 | { |
265 | { |
260 | for (int j = 0; j < mortals.size (); ++j)//D |
266 | for (int j = 0; j < mortals.size (); ++j)//D |
261 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
267 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
… | |
… | |
354 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
360 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
355 | |
361 | |
356 | static SV * |
362 | static SV * |
357 | newSVptr (void *ptr, HV *stash, HV *hv) |
363 | newSVptr (void *ptr, HV *stash, HV *hv) |
358 | { |
364 | { |
359 | SV *sv; |
|
|
360 | |
|
|
361 | if (!ptr) |
365 | if (!ptr) |
362 | return newSV (0); |
366 | return newSV (0); |
363 | |
367 | |
364 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
368 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
365 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
369 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
366 | } |
370 | } |
367 | |
371 | |
368 | static SV * |
372 | static SV * noinline |
369 | newSVptr (void *ptr, HV *stash) |
373 | newSVptr (void *ptr, HV *stash) |
370 | { |
374 | { |
371 | return newSVptr (ptr, stash, newHV ()); |
375 | return newSVptr (ptr, stash, newHV ()); |
372 | } |
376 | } |
373 | |
377 | |
… | |
… | |
388 | return 0; |
392 | return 0; |
389 | } |
393 | } |
390 | |
394 | |
391 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
395 | MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; |
392 | |
396 | |
393 | static SV * |
397 | static SV * noinline |
394 | newSVattachable (attachable *obj, HV *stash) |
398 | newSVattachable (attachable *obj, HV *stash) |
395 | { |
399 | { |
396 | if (!obj) |
400 | if (!obj) |
397 | return newSV (0); |
401 | return newSV (0); |
398 | |
402 | |
… | |
… | |
532 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
536 | static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
533 | static inline SV *to_sv (float v) { return newSVnv (v); } |
537 | static inline SV *to_sv (float v) { return newSVnv (v); } |
534 | static inline SV *to_sv (double v) { return newSVnv (v); } |
538 | 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); } |
539 | 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); } |
540 | static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
|
|
541 | // gcc dislikes noilnine on to_sv |
537 | static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
542 | static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
|
|
543 | static inline SV *to_sv (object * v) { return to_sv_ni (v); } |
538 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
544 | static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
539 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
545 | static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
540 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
546 | static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
541 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
547 | static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
542 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
548 | static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
543 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
549 | static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } |
|
|
550 | static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); } |
544 | |
551 | |
545 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
552 | static inline SV *to_sv (object & v) { return to_sv (&v); } |
546 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
553 | static inline SV *to_sv (living & v) { return to_sv (&v); } |
547 | |
554 | |
548 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
555 | static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
… | |
… | |
594 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
601 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
595 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
602 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
596 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
603 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
597 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
604 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
598 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
605 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
|
|
606 | static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); } |
599 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
607 | static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } |
600 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
608 | static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } |
601 | |
609 | |
602 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
610 | //static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
603 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
611 | static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
… | |
… | |
616 | static inline void sv_to (SV *sv, std::string &v) |
624 | static inline void sv_to (SV *sv, std::string &v) |
617 | { |
625 | { |
618 | STRLEN len; |
626 | STRLEN len; |
619 | char *data = SvPVbyte (sv, len); |
627 | char *data = SvPVbyte (sv, len); |
620 | v.assign (data, len); |
628 | v.assign (data, len); |
|
|
629 | } |
|
|
630 | |
|
|
631 | static inline void sv_to (SV *sv, refcnt_buf &v) |
|
|
632 | { |
|
|
633 | STRLEN len; |
|
|
634 | char *data = SvPVbyte (sv, len); |
|
|
635 | refcnt_buf buf (data, len); |
|
|
636 | v = buf; |
621 | } |
637 | } |
622 | |
638 | |
623 | static inline void sv_to (SV *sv, UUID &v) |
639 | static inline void sv_to (SV *sv, UUID &v) |
624 | { |
640 | { |
625 | if (!v.parse (SvPV_nolen (sv))) |
641 | if (!v.parse (SvPV_nolen (sv))) |
… | |
… | |
770 | exit (EXIT_FAILURE); |
786 | exit (EXIT_FAILURE); |
771 | } |
787 | } |
772 | |
788 | |
773 | eval_pv ( |
789 | eval_pv ( |
774 | "#line 1 'cfperl init'\n" |
790 | "#line 1 'cfperl init'\n" |
775 | "use EV ();\n" |
791 | "use EV ();\n" // required by bootstrap |
776 | "use Coro ();\n" |
792 | "use Coro ();\n" // required by bootstrap |
777 | "cf->bootstrap;\n" |
793 | "cf->bootstrap;\n" // required for cf::datadir |
778 | "unshift @INC, cf::datadir ();\n" |
794 | "unshift @INC, cf::datadir ();\n" // required for 'require' :) |
779 | "require cf;\n", |
795 | "require cf;\n", |
780 | 0 |
796 | 0 |
781 | ); |
797 | ); |
782 | |
798 | |
783 | if (SvTRUE (ERRSV)) |
799 | if (SvTRUE (ERRSV)) |
… | |
… | |
1142 | CALL_ARG (originator); |
1158 | CALL_ARG (originator); |
1143 | CALL_CALL ("cf::mapscript::activate", G_VOID); |
1159 | CALL_CALL ("cf::mapscript::activate", G_VOID); |
1144 | CALL_END; |
1160 | CALL_END; |
1145 | } |
1161 | } |
1146 | |
1162 | |
|
|
1163 | void cfperl_ix (client *ns, int set, faceidx idx, int pri) |
|
|
1164 | { |
|
|
1165 | CALL_BEGIN (3); |
|
|
1166 | CALL_ARG (ns); |
|
|
1167 | CALL_ARG (set); |
|
|
1168 | CALL_ARG (idx); |
|
|
1169 | CALL_ARG (pri); |
|
|
1170 | CALL_CALL (cv_cf_ix, G_VOID); |
|
|
1171 | CALL_END; |
|
|
1172 | } |
|
|
1173 | |
1147 | player * |
1174 | player * |
1148 | player::find (const_utf8_string name) |
1175 | player::find (const_utf8_string name) |
1149 | { |
1176 | { |
1150 | CALL_BEGIN (1); |
1177 | CALL_BEGIN (1); |
1151 | CALL_ARG (name); |
1178 | CALL_ARG (name); |
… | |
… | |
1397 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1424 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
1398 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1425 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
1399 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1426 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
1400 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1427 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1401 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1428 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1429 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1402 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1430 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1403 | |
1431 | |
1404 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1432 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1405 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1433 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
|
|
1434 | sv_server_tick = get_sv ("cf::SERVER_TICK", 1); SvUPGRADE (sv_server_tick, SVt_IV); |
1406 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1435 | sv_tick_start = get_sv ("cf::TICK_START" , 1); SvUPGRADE (sv_tick_start , SVt_NV); |
1407 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1436 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1408 | |
1437 | |
1409 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1438 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1410 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1439 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1411 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1440 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1412 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1441 | cb_player = get_av ("cf::CB_PLAYER", 1); |
… | |
… | |
1419 | _connect_to_perl_2 () |
1448 | _connect_to_perl_2 () |
1420 | { |
1449 | { |
1421 | cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke); |
1450 | cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke); |
1422 | cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge); |
1451 | cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge); |
1423 | cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg); |
1452 | cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg); |
|
|
1453 | cv_cf_ix = (SV *)get_cv ("cf::face::ix" , 0); assert (cv_cf_ix); |
1424 | cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick); |
1454 | cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick); |
1425 | cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match); |
1455 | cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match); |
1426 | } |
1456 | } |
1427 | |
1457 | |
1428 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1458 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
… | |
… | |
1433 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1463 | I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; |
1434 | |
1464 | |
1435 | _connect_to_perl_1 (); |
1465 | _connect_to_perl_1 (); |
1436 | |
1466 | |
1437 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1467 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1438 | |
|
|
1439 | //{ |
|
|
1440 | // require_pv ("Time::HiRes"); |
|
|
1441 | // |
|
|
1442 | // SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0); |
|
|
1443 | // if (!svp) croak ("Time::HiRes is required"); |
|
|
1444 | // if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer"); |
|
|
1445 | // coroapi::time = INT2PTR (double(*)(), SvIV(*svp)); |
|
|
1446 | //} |
|
|
1447 | |
1468 | |
1448 | static const struct { |
1469 | static const struct { |
1449 | const char *name; |
1470 | const char *name; |
1450 | IV iv; |
1471 | IV iv; |
1451 | } *civ, const_iv[] = { |
1472 | } *civ, const_iv[] = { |
… | |
… | |
1455 | # include "attackinc.h" |
1476 | # include "attackinc.h" |
1456 | # undef def |
1477 | # undef def |
1457 | # define def(uc, flags) const_iv (SK_ ## uc) |
1478 | # define def(uc, flags) const_iv (SK_ ## uc) |
1458 | # include "skillinc.h" |
1479 | # include "skillinc.h" |
1459 | # undef def |
1480 | # undef def |
1460 | |
1481 | # define def(name, use, nonuse) const_iv (body_ ## name) |
1461 | const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) |
1482 | # include "slotinc.h" |
|
|
1483 | # undef def |
1462 | |
1484 | |
1463 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1485 | const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) |
1464 | |
1486 | |
1465 | const_iv (MAX_TIME) |
1487 | const_iv (MAX_TIME) |
1466 | const_iv (MAXSOCKBUF) |
1488 | const_iv (MAXSOCKBUF) |
… | |
… | |
1480 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1502 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1481 | |
1503 | |
1482 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1504 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1483 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1505 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1484 | |
1506 | |
1485 | const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
|
|
1486 | const_iv (MAP_INACTIVE) |
|
|
1487 | |
|
|
1488 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1507 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1489 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1508 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1490 | |
1509 | |
1491 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1510 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1492 | |
1511 | |
1493 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1512 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1494 | }; |
1513 | }; |
1495 | |
1514 | |
1496 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1515 | for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) |
1497 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1516 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1498 | |
1517 | |
1499 | static const struct { |
1518 | static const struct { |
1500 | const char *name; |
1519 | const char *name; |
1501 | int skip; |
1520 | int skip; |
… | |
… | |
1507 | # undef def |
1526 | # undef def |
1508 | }; |
1527 | }; |
1509 | |
1528 | |
1510 | AV *av = get_av ("cf::EVENT", 1); |
1529 | AV *av = get_av ("cf::EVENT", 1); |
1511 | |
1530 | |
1512 | for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) |
1531 | for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) |
1513 | { |
1532 | { |
1514 | AV *event = newAV (); |
1533 | AV *event = newAV (); |
1515 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1534 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1516 | av_push (event, newSViv (eiv->klass)); |
1535 | av_push (event, newSViv (eiv->klass)); |
1517 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1536 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
… | |
… | |
1524 | |
1543 | |
1525 | void _gv_clear (SV *gv) |
1544 | void _gv_clear (SV *gv) |
1526 | CODE: |
1545 | CODE: |
1527 | assert (SvTYPE (gv) == SVt_PVGV); |
1546 | assert (SvTYPE (gv) == SVt_PVGV); |
1528 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
1547 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1548 | SvREFCNT_inc (gv); |
1529 | f (GvGP (gv)->gp_form); |
1549 | f (GvGP (gv)->gp_form); |
1530 | f (GvGP (gv)->gp_io); |
1550 | f (GvGP (gv)->gp_io); |
1531 | f (GvGP (gv)->gp_sv); |
1551 | f (GvGP (gv)->gp_sv); |
1532 | f (GvGP (gv)->gp_av); |
1552 | f (GvGP (gv)->gp_av); |
1533 | f (GvGP (gv)->gp_hv); |
1553 | f (GvGP (gv)->gp_hv); |
1534 | f (GvGP (gv)->gp_cv); |
1554 | f (GvGP (gv)->gp_cv); |
1535 | GvCVGEN (gv) = 0; |
1555 | GvCVGEN (gv) = 0; |
1536 | GvMULTI_off (gv); |
1556 | GvMULTI_off (gv); |
|
|
1557 | SvREFCNT_dec (gv); |
1537 | # undef f |
1558 | # undef f |
1538 | |
1559 | |
1539 | void _connect_to_perl_1 () |
1560 | void _connect_to_perl_1 () |
1540 | |
1561 | |
1541 | void _connect_to_perl_2 () |
1562 | void _connect_to_perl_2 () |
… | |
… | |
1552 | |
1573 | |
1553 | for_all_objects (op) |
1574 | for_all_objects (op) |
1554 | op->reattach (); |
1575 | op->reattach (); |
1555 | } |
1576 | } |
1556 | |
1577 | |
1557 | # support function for map-world.ext |
|
|
1558 | void _quantise (SV *data_sv, SV *plt_sv) |
|
|
1559 | CODE: |
|
|
1560 | { |
|
|
1561 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
|
|
1562 | croak ("_quantise called with invalid agruments"); |
|
|
1563 | |
|
|
1564 | plt_sv = SvRV (plt_sv); |
|
|
1565 | SV **plt = AvARRAY (plt_sv); |
|
|
1566 | int plt_count = AvFILL (plt_sv) + 1; |
|
|
1567 | |
|
|
1568 | STRLEN len; |
|
|
1569 | char *data = SvPVbyte (data_sv, len); |
|
|
1570 | char *dst = data; |
|
|
1571 | |
|
|
1572 | while (len >= 3) |
|
|
1573 | { |
|
|
1574 | for (SV **val_sv = plt + plt_count; val_sv-- > plt; ) |
|
|
1575 | { |
|
|
1576 | char *val = SvPVX (*val_sv); |
|
|
1577 | |
|
|
1578 | if (val [0] == data [0] |
|
|
1579 | && val [1] == data [1] |
|
|
1580 | && val [2] == data [2]) |
|
|
1581 | { |
|
|
1582 | *dst++ = val [3]; |
|
|
1583 | goto next; |
|
|
1584 | } |
|
|
1585 | } |
|
|
1586 | |
|
|
1587 | croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d", |
|
|
1588 | (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2], |
|
|
1589 | dst - SvPVX (data_sv), len); |
|
|
1590 | |
|
|
1591 | next: |
|
|
1592 | data += 3; |
|
|
1593 | len -= 3; |
|
|
1594 | } |
|
|
1595 | |
|
|
1596 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
|
|
1597 | } |
|
|
1598 | |
|
|
1599 | void init_anim () |
1578 | void init_anim () |
1600 | |
1579 | |
1601 | void init_globals () |
1580 | void init_globals () |
1602 | |
1581 | |
1603 | void init_experience () |
|
|
1604 | |
|
|
1605 | void init_attackmess () |
1582 | void init_attackmess () |
1606 | |
1583 | |
1607 | void init_dynamic () |
1584 | void init_dynamic () |
1608 | |
1585 | |
1609 | void load_settings () |
1586 | void load_settings () |
1610 | |
1587 | |
|
|
1588 | void _reload_exp_table () |
|
|
1589 | |
1611 | void load_materials () |
1590 | void _reload_materials () |
1612 | |
1591 | |
1613 | void init_uuid () |
1592 | void init_uuid () |
1614 | CODE: |
1593 | CODE: |
1615 | UUID::init (); |
1594 | UUID::init (); |
1616 | |
1595 | |
… | |
… | |
1649 | { |
1628 | { |
1650 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1629 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1651 | coroapi::cede (); |
1630 | coroapi::cede (); |
1652 | } |
1631 | } |
1653 | |
1632 | |
1654 | void server_tick () |
1633 | void one_tick () |
1655 | CODE: |
1634 | CODE: |
1656 | { |
1635 | { |
1657 | ev_now_update (EV_DEFAULT); |
1636 | ev_now_update (EV_DEFAULT); |
1658 | NOW = ev_now (EV_DEFAULT); |
1637 | NOW = ev_now (EV_DEFAULT); |
1659 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1638 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1660 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1639 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1661 | runtime = SvNVX (sv_runtime); |
1640 | runtime = SvNVX (sv_runtime); |
1662 | |
1641 | |
|
|
1642 | one_tick (); |
|
|
1643 | |
1663 | server_tick (); |
1644 | ++server_tick; |
|
|
1645 | SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick); |
1664 | |
1646 | |
1665 | ev_now_update (EV_DEFAULT); |
1647 | ev_now_update (EV_DEFAULT); |
1666 | NOW = ev_now (EV_DEFAULT); |
1648 | NOW = ev_now (EV_DEFAULT); |
1667 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1649 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
|
|
1650 | |
1668 | runtime += TICK; |
1651 | runtime += TICK; |
1669 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1652 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1670 | } |
1653 | } |
1671 | |
1654 | |
1672 | NV floor (NV x) |
1655 | NV floor (NV x) |
… | |
… | |
1676 | NV rndm (...) |
1659 | NV rndm (...) |
1677 | ALIAS: |
1660 | ALIAS: |
1678 | rmg_rndm = 1 |
1661 | rmg_rndm = 1 |
1679 | CODE: |
1662 | CODE: |
1680 | { |
1663 | { |
1681 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1664 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1682 | switch (items) |
1665 | switch (items) |
1683 | { |
1666 | { |
1684 | case 0: RETVAL = gen (); break; |
1667 | case 0: RETVAL = gen (); break; |
1685 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1668 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1686 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1669 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
… | |
… | |
1771 | |
1754 | |
1772 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1755 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1773 | INIT: |
1756 | INIT: |
1774 | #if __GLIBC__ |
1757 | #if __GLIBC__ |
1775 | mallopt (M_TOP_PAD, 1024 * 1024); |
1758 | mallopt (M_TOP_PAD, 1024 * 1024); |
1776 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); |
1759 | mallopt (M_MMAP_THRESHOLD, 1024 * 1024); |
1777 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
1760 | mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory |
|
|
1761 | if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10)) |
1778 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1762 | mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc |
1779 | #endif |
1763 | #endif |
1780 | |
1764 | |
1781 | int munlockall () |
1765 | int munlockall () |
1782 | |
1766 | |
1783 | #endif |
1767 | #endif |
… | |
… | |
1809 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
1793 | PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); |
1810 | PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); |
1794 | PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); |
1811 | PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount))); |
1795 | PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount))); |
1812 | } |
1796 | } |
1813 | |
1797 | |
1814 | int find_animation (utf8_string text) |
|
|
1815 | PROTOTYPE: $ |
|
|
1816 | |
|
|
1817 | int random_roll (int min, int max, object *op, int goodbad); |
1798 | int random_roll (int min, int max, object *op, int goodbad); |
1818 | |
1799 | |
1819 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1800 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1820 | |
1801 | |
1821 | int exp_to_level (val64 exp) |
1802 | int exp_to_level (val64 exp) |
1822 | |
1803 | |
1823 | val64 level_to_min_exp (int level) |
1804 | val64 level_to_min_exp (int level) |
1824 | |
1805 | |
|
|
1806 | const_utf8_string |
|
|
1807 | spellpathnames (int idx) |
|
|
1808 | CODE: |
|
|
1809 | RETVAL = spellpathnames [idx]; |
|
|
1810 | OUTPUT: RETVAL |
|
|
1811 | |
1825 | SV * |
1812 | SV * |
1826 | resistance_to_string (int atnr) |
1813 | attacktype_name (int atnr) |
1827 | CODE: |
1814 | CODE: |
1828 | if (atnr >= 0 && atnr < NROFATTACKS) |
1815 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1816 | ? newSVpv (attacktype_name [atnr], 0) |
|
|
1817 | : &PL_sv_undef; |
|
|
1818 | OUTPUT: RETVAL |
|
|
1819 | |
|
|
1820 | SV * |
|
|
1821 | attacktype_desc (int atnr) |
|
|
1822 | CODE: |
|
|
1823 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1824 | ? newSVpv (attacktype_desc [atnr], 0) |
|
|
1825 | : &PL_sv_undef; |
|
|
1826 | OUTPUT: RETVAL |
|
|
1827 | |
|
|
1828 | SV * |
|
|
1829 | resist_plus (int atnr) |
|
|
1830 | CODE: |
|
|
1831 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
1829 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1832 | ? newSVpv (resist_plus [atnr], 0) |
1830 | else |
1833 | : &PL_sv_undef; |
1831 | XSRETURN_UNDEF; |
1834 | OUTPUT: RETVAL |
|
|
1835 | |
|
|
1836 | SV * |
|
|
1837 | change_resist_msg (int atnr) |
|
|
1838 | CODE: |
|
|
1839 | RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) |
|
|
1840 | ? newSVpv (change_resist_msg [atnr], 0) |
|
|
1841 | : &PL_sv_undef; |
1832 | OUTPUT: RETVAL |
1842 | OUTPUT: RETVAL |
1833 | |
1843 | |
1834 | UUID |
1844 | UUID |
1835 | uuid_cur () |
1845 | uuid_cur () |
1836 | CODE: |
1846 | CODE: |
… | |
… | |
1877 | load_resource_file_ (octet_string filename) |
1887 | load_resource_file_ (octet_string filename) |
1878 | |
1888 | |
1879 | void |
1889 | void |
1880 | fix_weight () |
1890 | fix_weight () |
1881 | |
1891 | |
|
|
1892 | utf8_string |
|
|
1893 | expand_cfpod (int hintmode, int gender, const_utf8_string cfpod) |
|
|
1894 | PPCODE: |
|
|
1895 | XPUSHs (to_sv (player::expand_cfpod (hintmode, gender, cfpod))); |
|
|
1896 | |
1882 | MODULE = cf PACKAGE = cf::attachable |
1897 | MODULE = cf PACKAGE = cf::attachable |
1883 | |
1898 | |
1884 | int |
1899 | int |
1885 | valid (SV *obj) |
1900 | valid (SV *obj) |
1886 | CODE: |
1901 | CODE: |
… | |
… | |
1959 | int mortals_size () |
1974 | int mortals_size () |
1960 | CODE: |
1975 | CODE: |
1961 | RETVAL = attachable::mortals.size (); |
1976 | RETVAL = attachable::mortals.size (); |
1962 | OUTPUT: RETVAL |
1977 | OUTPUT: RETVAL |
1963 | |
1978 | |
1964 | const_utf8_string slot_use_name (U32 slot) |
1979 | const_utf8_string slot_name (U32 slot) |
1965 | ALIAS: |
1980 | ALIAS: |
|
|
1981 | slot_name = 0 |
|
|
1982 | slot_use_name = 1 |
1966 | slot_nonuse_name = 1 |
1983 | slot_nonuse_name = 2 |
1967 | CODE: |
1984 | CODE: |
1968 | { |
1985 | { |
1969 | if (slot >= NUM_BODY_LOCATIONS) |
1986 | if (slot >= NUM_BODY_LOCATIONS) |
1970 | croak ("body slot index out of range"); |
1987 | croak ("body slot index out of range"); |
1971 | |
1988 | |
1972 | switch (ix) |
1989 | switch (ix) |
1973 | { |
1990 | { |
|
|
1991 | case 0: RETVAL = body_locations[slot].name ; break; |
1974 | case 0: RETVAL = body_locations[slot].use_name; break; |
1992 | case 1: RETVAL = body_locations[slot].use_name ; break; |
1975 | case 1: RETVAL = body_locations[slot].nonuse_name; break; |
1993 | case 2: RETVAL = body_locations[slot].nonuse_name; break; |
1976 | } |
1994 | } |
1977 | } |
1995 | } |
1978 | OUTPUT: |
1996 | OUTPUT: |
1979 | RETVAL |
1997 | RETVAL |
1980 | |
1998 | |
… | |
… | |
2086 | |
2104 | |
2087 | void pick_up (object *who, object *op) |
2105 | void pick_up (object *who, object *op) |
2088 | |
2106 | |
2089 | void update_object (object *op, int action) |
2107 | void update_object (object *op, int action) |
2090 | |
2108 | |
2091 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
2109 | void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0) |
2092 | |
2110 | |
2093 | void player_lvl_adj (object *who, object *skill = 0) |
2111 | void player_lvl_adj (object *who, object *skill = 0) |
2094 | |
2112 | |
2095 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2113 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
2096 | |
2114 | |
… | |
… | |
2105 | int convert_item (object *item, object *converter) |
2123 | int convert_item (object *item, object *converter) |
2106 | |
2124 | |
2107 | void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); |
2125 | void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); |
2108 | |
2126 | |
2109 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2127 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2110 | |
|
|
2111 | # no clean way to get an object from an archetype - stupid idiotic |
|
|
2112 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
|
|
2113 | |
2128 | |
2114 | object *new (utf8_string archetype = 0) |
2129 | object *new (utf8_string archetype = 0) |
2115 | PROTOTYPE: ;$ |
2130 | PROTOTYPE: ;$ |
2116 | CODE: |
2131 | CODE: |
2117 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2132 | RETVAL = archetype |
|
|
2133 | ? archetype::get (archetype) |
|
|
2134 | : object::create (); |
2118 | OUTPUT: |
2135 | OUTPUT: |
2119 | RETVAL |
2136 | RETVAL |
2120 | |
2137 | |
2121 | object *generate (utf8_string arch, object *creator) |
2138 | object *generate (utf8_string arch, object *creator) |
2122 | CODE: |
2139 | CODE: |
2123 | object *obj = get_archetype (arch); |
2140 | object *obj = archetype::get (arch); |
2124 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2141 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2125 | RETVAL = obj; |
2142 | RETVAL = obj; |
2126 | OUTPUT: |
2143 | OUTPUT: |
2127 | RETVAL |
2144 | RETVAL |
2128 | |
2145 | |
… | |
… | |
2138 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2155 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2139 | |
2156 | |
2140 | if (RETVAL->destroyed ()) |
2157 | if (RETVAL->destroyed ()) |
2141 | RETVAL = 0; |
2158 | RETVAL = 0; |
2142 | } |
2159 | } |
|
|
2160 | OUTPUT: |
|
|
2161 | RETVAL |
2143 | |
2162 | |
2144 | shstr |
2163 | shstr |
2145 | object::kv_get (shstr key) |
2164 | object::kv_get (shstr key) |
|
|
2165 | CODE: |
|
|
2166 | RETVAL = THIS->kv.get (key); |
|
|
2167 | OUTPUT: |
|
|
2168 | RETVAL |
2146 | |
2169 | |
2147 | void |
2170 | void |
2148 | object::kv_del (shstr key) |
2171 | object::kv_del (shstr key) |
|
|
2172 | CODE: |
|
|
2173 | THIS->kv.del (key); |
2149 | |
2174 | |
2150 | void |
2175 | void |
2151 | object::kv_set (shstr key, shstr value) |
2176 | object::kv_set (shstr key, shstr value) |
|
|
2177 | CODE: |
|
|
2178 | THIS->kv.set (key, value); |
2152 | |
2179 | |
2153 | object *get_nearest_player (object *ob) |
2180 | object *get_nearest_player (object *ob) |
2154 | ALIAS: nearest_player = 0 |
2181 | ALIAS: nearest_player = 0 |
2155 | PREINIT: |
2182 | PREINIT: |
2156 | extern object *get_nearest_player (object *); |
2183 | extern object *get_nearest_player (object *); |
… | |
… | |
2359 | if (pl->ob && pl->ob->map == THIS) |
2386 | if (pl->ob && pl->ob->map == THIS) |
2360 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2387 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2361 | } |
2388 | } |
2362 | |
2389 | |
2363 | void |
2390 | void |
|
|
2391 | maptile::gen_quadmap (int x, int y, int z) |
|
|
2392 | CODE: |
|
|
2393 | gen_quadmap (THIS, x * 50, y * 50, z); |
|
|
2394 | |
|
|
2395 | void |
2364 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2396 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2365 | CODE: |
2397 | CODE: |
2366 | { |
2398 | { |
2367 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2399 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2368 | croak ("maptile::add_underlay: palette must be arrayref"); |
2400 | croak ("maptile::add_underlay: palette must be arrayref"); |
2369 | |
2401 | |
2370 | palette = SvRV (palette); |
2402 | palette = SvRV (palette); |
2371 | |
2403 | |
2372 | STRLEN idxlen; |
2404 | STRLEN idxlen; |
2373 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2405 | const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen); |
2374 | |
2406 | |
2375 | for (int x = 0; x < THIS->width; ++x) |
2407 | for (int x = 0; x < THIS->width; ++x) |
2376 | for (int y = 0; y < THIS->height; ++y) |
2408 | for (int y = 0; y < THIS->height; ++y) |
2377 | { |
2409 | { |
2378 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
2410 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
… | |
… | |
2384 | |
2416 | |
2385 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2417 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2386 | { |
2418 | { |
2387 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2419 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2388 | { |
2420 | { |
2389 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
2421 | object *ob = archetype::get (cfSvPVutf8_nolen (*elem)); |
2390 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2422 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2391 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2423 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2392 | |
2424 | |
2393 | if (ob->randomitems && !ob->above) |
2425 | if (ob->randomitems && !ob->above) |
2394 | { |
2426 | { |
… | |
… | |
2398 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2430 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2399 | // TODO: if this is a pickable object, then the item |
2431 | // TODO: if this is a pickable object, then the item |
2400 | // will at a bit weird - saving inside the player |
2432 | // will at a bit weird - saving inside the player |
2401 | // will clear the flag, but when the player drops |
2433 | // will clear the flag, but when the player drops |
2402 | // it without logging out, it keeps the flag. |
2434 | // it without logging out, it keeps the flag. |
2403 | // nobody ahs reported this, but this can be rather |
2435 | // nobody has reported this, but this can be rather |
2404 | // annoying on persistent maps. |
2436 | // annoying on persistent maps. |
2405 | } |
2437 | } |
2406 | } |
2438 | } |
2407 | } |
2439 | } |
2408 | } |
2440 | } |
2409 | |
|
|
2410 | skip: ; |
2441 | skip: ; |
2411 | } |
2442 | } |
2412 | } |
2443 | } |
2413 | |
2444 | |
2414 | void |
2445 | void |
… | |
… | |
2419 | croak ("maptile::set_regiondata: palette must be arrayref"); |
2450 | croak ("maptile::set_regiondata: palette must be arrayref"); |
2420 | |
2451 | |
2421 | palette = SvRV (palette); |
2452 | palette = SvRV (palette); |
2422 | |
2453 | |
2423 | STRLEN idxlen; |
2454 | STRLEN idxlen; |
2424 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2455 | const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen); |
2425 | |
2456 | |
2426 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2457 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2427 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2458 | uint8 *regions = salloc<uint8_t> (THIS->size ()); |
2428 | |
2459 | |
2429 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2460 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2430 | regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
2461 | regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
2431 | |
2462 | |
2432 | for (int y = 0; y < THIS->height; ++y) |
2463 | for (int y = 0; y < THIS->height; ++y) |
… | |
… | |
2445 | for (int x = 0; x < THIS->width; ++x) |
2476 | for (int x = 0; x < THIS->width; ++x) |
2446 | for (int y = 0; y < THIS->height; ++y) |
2477 | for (int y = 0; y < THIS->height; ++y) |
2447 | { |
2478 | { |
2448 | region *rgn = THIS->region (x, y); |
2479 | region *rgn = THIS->region (x, y); |
2449 | |
2480 | |
2450 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
|
|
2451 | if (object *op = THIS->at (x, y).top) |
2481 | if (object *op = THIS->at (x, y).top) |
2452 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2482 | if (rgn->treasure && rndm () < rgn->treasure_density) |
2453 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2483 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
2454 | } |
2484 | } |
2455 | |
2485 | |
… | |
… | |
2534 | } |
2564 | } |
2535 | OUTPUT: RETVAL |
2565 | OUTPUT: RETVAL |
2536 | |
2566 | |
2537 | # worst xs function of my life |
2567 | # worst xs function of my life |
2538 | bool |
2568 | bool |
2539 | _create_random_map (\ |
2569 | _create_random_map (maptile *self, SV *options) |
2540 | maptile *self,\ |
|
|
2541 | utf8_string wallstyle,\ |
|
|
2542 | utf8_string wall_name,\ |
|
|
2543 | utf8_string floorstyle,\ |
|
|
2544 | utf8_string monsterstyle,\ |
|
|
2545 | utf8_string treasurestyle,\ |
|
|
2546 | utf8_string layoutstyle,\ |
|
|
2547 | utf8_string doorstyle,\ |
|
|
2548 | utf8_string decorstyle,\ |
|
|
2549 | utf8_string miningstyle,\ |
|
|
2550 | utf8_string origin_map,\ |
|
|
2551 | utf8_string final_map,\ |
|
|
2552 | utf8_string exitstyle,\ |
|
|
2553 | utf8_string this_map,\ |
|
|
2554 | utf8_string exit_on_final_map,\ |
|
|
2555 | int xsize,\ |
|
|
2556 | int ysize,\ |
|
|
2557 | int expand2x,\ |
|
|
2558 | int layoutoptions1,\ |
|
|
2559 | int layoutoptions2,\ |
|
|
2560 | int layoutoptions3,\ |
|
|
2561 | int symmetry,\ |
|
|
2562 | int difficulty,\ |
|
|
2563 | int difficulty_given,\ |
|
|
2564 | float difficulty_increase,\ |
|
|
2565 | int dungeon_level,\ |
|
|
2566 | int dungeon_depth,\ |
|
|
2567 | int decoroptions,\ |
|
|
2568 | int orientation,\ |
|
|
2569 | int origin_y,\ |
|
|
2570 | int origin_x,\ |
|
|
2571 | U32 random_seed,\ |
|
|
2572 | val64 total_map_hp,\ |
|
|
2573 | int map_layout_style,\ |
|
|
2574 | int treasureoptions,\ |
|
|
2575 | int symmetry_used,\ |
|
|
2576 | region *region,\ |
|
|
2577 | utf8_string custom\ |
|
|
2578 | ) |
|
|
2579 | CODE: |
2570 | CODE: |
2580 | { |
2571 | { |
2581 | random_map_params rmp; |
2572 | random_map_params rmp ((HV *)SvRV (options)); |
2582 | |
|
|
2583 | assign (rmp.wallstyle , wallstyle); |
|
|
2584 | assign (rmp.wall_name , wall_name); |
|
|
2585 | assign (rmp.floorstyle , floorstyle); |
|
|
2586 | assign (rmp.monsterstyle , monsterstyle); |
|
|
2587 | assign (rmp.treasurestyle , treasurestyle); |
|
|
2588 | assign (rmp.layoutstyle , layoutstyle); |
|
|
2589 | assign (rmp.doorstyle , doorstyle); |
|
|
2590 | assign (rmp.decorstyle , decorstyle); |
|
|
2591 | assign (rmp.miningstyle , miningstyle); |
|
|
2592 | assign (rmp.exitstyle , exitstyle); |
|
|
2593 | assign (rmp.exit_on_final_map, exit_on_final_map); |
|
|
2594 | |
|
|
2595 | rmp.origin_map = origin_map; |
|
|
2596 | rmp.final_map = final_map; |
|
|
2597 | rmp.this_map = this_map; |
|
|
2598 | rmp.xsize = xsize; |
|
|
2599 | rmp.ysize = ysize; |
|
|
2600 | rmp.expand2x = expand2x; |
|
|
2601 | rmp.layoutoptions1 = layoutoptions1; |
|
|
2602 | rmp.layoutoptions2 = layoutoptions2; |
|
|
2603 | rmp.layoutoptions3 = layoutoptions3; |
|
|
2604 | rmp.symmetry = symmetry; |
|
|
2605 | rmp.difficulty = difficulty; |
|
|
2606 | rmp.difficulty_given = difficulty_given; |
|
|
2607 | rmp.difficulty_increase = difficulty_increase; |
|
|
2608 | rmp.dungeon_level = dungeon_level; |
|
|
2609 | rmp.dungeon_depth = dungeon_depth; |
|
|
2610 | rmp.decoroptions = decoroptions; |
|
|
2611 | rmp.orientation = orientation; |
|
|
2612 | rmp.origin_y = origin_y; |
|
|
2613 | rmp.origin_x = origin_x; |
|
|
2614 | rmp.random_seed = random_seed; |
|
|
2615 | rmp.total_map_hp = (uint64_t) total_map_hp; |
|
|
2616 | rmp.map_layout_style = map_layout_style; |
|
|
2617 | rmp.treasureoptions = treasureoptions; |
|
|
2618 | rmp.symmetry_used = symmetry_used; |
|
|
2619 | rmp.region = region; |
|
|
2620 | rmp.custom = custom; |
|
|
2621 | |
|
|
2622 | RETVAL = self->generate_random_map (&rmp); |
2573 | RETVAL = self->generate_random_map (&rmp); |
2623 | } |
2574 | } |
2624 | OUTPUT: |
2575 | OUTPUT: |
2625 | RETVAL |
2576 | RETVAL |
2626 | |
2577 | |
… | |
… | |
2637 | |
2588 | |
2638 | archetype *archetypes (U32 index) |
2589 | archetype *archetypes (U32 index) |
2639 | CODE: |
2590 | CODE: |
2640 | RETVAL = index < archetypes.size () ? archetypes [index] : 0; |
2591 | RETVAL = index < archetypes.size () ? archetypes [index] : 0; |
2641 | OUTPUT: RETVAL |
2592 | OUTPUT: RETVAL |
|
|
2593 | |
|
|
2594 | int skillvec_size () |
|
|
2595 | CODE: |
|
|
2596 | RETVAL = skillvec.size (); |
|
|
2597 | OUTPUT: RETVAL |
|
|
2598 | |
|
|
2599 | archetype *skillvec (U32 index) |
|
|
2600 | CODE: |
|
|
2601 | RETVAL = index < skillvec.size () ? (archetype *)(object *)skillvec [index] : 0; |
|
|
2602 | OUTPUT: RETVAL |
|
|
2603 | |
|
|
2604 | void |
|
|
2605 | find_by_type (int type) |
|
|
2606 | PPCODE: |
|
|
2607 | for_all_archetypes (arch) |
|
|
2608 | if (arch->type == type) |
|
|
2609 | XPUSHs (sv_2mortal (to_sv (arch))); |
2642 | |
2610 | |
2643 | INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | |
2611 | INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | |
2644 | |
2612 | |
2645 | MODULE = cf PACKAGE = cf::party |
2613 | MODULE = cf PACKAGE = cf::party |
2646 | |
2614 | |
… | |
… | |
2695 | list () |
2663 | list () |
2696 | PPCODE: |
2664 | PPCODE: |
2697 | EXTEND (SP, clients.size ()); |
2665 | EXTEND (SP, clients.size ()); |
2698 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2666 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
2699 | PUSHs (sv_2mortal (to_sv (*i))); |
2667 | PUSHs (sv_2mortal (to_sv (*i))); |
|
|
2668 | |
|
|
2669 | STRLEN |
|
|
2670 | client::inbuf_append (SV *data) |
|
|
2671 | CODE: |
|
|
2672 | { |
|
|
2673 | STRLEN len; |
|
|
2674 | char *ptr = SvPVbyte (data, len); |
|
|
2675 | |
|
|
2676 | min_it (len, sizeof (THIS->inbuf) - THIS->inbuf_len); |
|
|
2677 | memcpy (THIS->inbuf + THIS->inbuf_len, ptr, len); |
|
|
2678 | THIS->inbuf_len += len; |
|
|
2679 | |
|
|
2680 | THIS->inbuf_handle (); |
|
|
2681 | |
|
|
2682 | RETVAL = len; |
|
|
2683 | } |
|
|
2684 | OUTPUT: RETVAL |
2700 | |
2685 | |
2701 | void |
2686 | void |
2702 | client::send_packet (SV *packet) |
2687 | client::send_packet (SV *packet) |
2703 | CODE: |
2688 | CODE: |
2704 | { |
2689 | { |
… | |
… | |
2760 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2745 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2761 | |
2746 | |
2762 | faceidx alloc (utf8_string name) |
2747 | faceidx alloc (utf8_string name) |
2763 | CODE: |
2748 | CODE: |
2764 | { |
2749 | { |
2765 | do |
2750 | RETVAL = face_alloc (); |
2766 | { |
|
|
2767 | RETVAL = faces.size (); |
|
|
2768 | faces.resize (RETVAL + 1); |
|
|
2769 | } |
|
|
2770 | while (!RETVAL); // crude way to leave index 0 |
|
|
2771 | |
2751 | |
2772 | faces [RETVAL].name = name; |
2752 | faces [RETVAL].name = name; |
2773 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2753 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2774 | |
2754 | |
2775 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2755 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2776 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2756 | if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; |
2777 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2757 | if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; |
2778 | } |
2758 | } |
|
|
2759 | OUTPUT: RETVAL |
|
|
2760 | |
|
|
2761 | faceidx faces_size () |
|
|
2762 | CODE: |
|
|
2763 | RETVAL = faces.size (); |
2779 | OUTPUT: RETVAL |
2764 | OUTPUT: RETVAL |
2780 | |
2765 | |
2781 | void set_type (faceidx idx, int value) |
2766 | void set_type (faceidx idx, int value) |
2782 | ALIAS: |
2767 | ALIAS: |
2783 | set_type = 0 |
2768 | set_type = 0 |
… | |
… | |
2794 | case 2: f->magicmap = value; break; |
2779 | case 2: f->magicmap = value; break; |
2795 | case 3: f->smooth = value; break; |
2780 | case 3: f->smooth = value; break; |
2796 | case 4: f->smoothlevel = value; break; |
2781 | case 4: f->smoothlevel = value; break; |
2797 | } |
2782 | } |
2798 | |
2783 | |
2799 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2784 | void set_csum (faceidx idx, int faceset, SV *chksum) |
2800 | CODE: |
2785 | CODE: |
2801 | { |
2786 | { |
2802 | faceinfo *f = face_info (idx); assert (f); |
2787 | faceinfo *f = face_info (idx); assert (f); |
2803 | facedata *d = &(faceset ? f->data64 : f->data32); |
2788 | facedata *d = f->face + faceset; |
2804 | sv_to (data, d->data); |
|
|
2805 | STRLEN clen; |
2789 | STRLEN clen; |
2806 | char *cdata = SvPVbyte (chksum, clen); |
2790 | char *cdata = SvPVbyte (chksum, clen); |
2807 | clen = min (CHKSUM_MAXLEN, clen); |
|
|
2808 | |
2791 | |
|
|
2792 | assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN)); |
2809 | assert (("cf::face::set_data must be called with a non-empty checksum", clen)); |
2793 | assert (("cf::face::set_data must be called with a non-empty checksum", clen)); |
2810 | |
2794 | |
2811 | if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) |
2795 | if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) |
2812 | { |
2796 | { |
2813 | d->chksum_len = clen; |
2797 | d->chksum_len = clen; |
2814 | memcpy (d->chksum, cdata, clen); |
2798 | memcpy (d->chksum, cdata, clen); |
2815 | |
2799 | |
2816 | // invalidate existing client face info |
2800 | // invalidate existing client face info |
2817 | for_all_clients (ns) |
2801 | for_all_clients (ns) |
2818 | if (ns->faceset == faceset) |
2802 | ns->invalidate_face (idx); |
2819 | { |
|
|
2820 | ns->faces_sent [idx] = false; |
|
|
2821 | ns->force_newmap = true; |
|
|
2822 | } |
|
|
2823 | } |
2803 | } |
2824 | } |
2804 | } |
2825 | |
2805 | |
2826 | int get_data_size (faceidx idx, int faceset = 0) |
2806 | SV *mangle_csum (SV *chksum) |
2827 | CODE: |
2807 | CODE: |
2828 | facedata *d = face_data (idx, faceset); |
2808 | STRLEN len; |
2829 | if (!d) XSRETURN_UNDEF; |
2809 | char *data = SvPVbyte (chksum, len); |
2830 | RETVAL = d->data.size (); |
2810 | RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN)); |
2831 | OUTPUT: |
2811 | OUTPUT: |
2832 | RETVAL |
2812 | RETVAL |
2833 | |
2813 | |
2834 | SV *get_chksum (faceidx idx, int faceset = 0) |
2814 | SV *get_csum (faceidx idx, int faceset = 0) |
2835 | CODE: |
2815 | CODE: |
2836 | facedata *d = face_data (idx, faceset); |
2816 | facedata *d = face_data (idx, faceset); |
2837 | if (!d) XSRETURN_UNDEF; |
2817 | if (!d) XSRETURN_UNDEF; |
2838 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2818 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2839 | OUTPUT: |
2819 | OUTPUT: |
2840 | RETVAL |
2820 | RETVAL |
2841 | |
2821 | |
2842 | SV *get_data (faceidx idx, int faceset = 0) |
2822 | int get_type (faceidx idx) |
2843 | CODE: |
2823 | CODE: |
2844 | facedata *d = face_data (idx, faceset); |
2824 | faceinfo *f = face_info (idx); |
2845 | if (!d) XSRETURN_UNDEF; |
2825 | if (!f) XSRETURN_UNDEF; |
2846 | RETVAL = newSVpvn (d->data.data (), d->data.length ()); |
2826 | RETVAL = f->type; |
2847 | OUTPUT: |
2827 | OUTPUT: |
2848 | RETVAL |
2828 | RETVAL |
2849 | |
2829 | |
|
|
2830 | SV *get_name (faceidx idx) |
|
|
2831 | CODE: |
|
|
2832 | faceinfo *f = face_info (idx); |
|
|
2833 | if (!f) XSRETURN_UNDEF; |
|
|
2834 | RETVAL = to_sv (f->name); |
|
|
2835 | OUTPUT: |
|
|
2836 | RETVAL |
|
|
2837 | |
2850 | void invalidate (faceidx idx) |
2838 | void invalidate (faceidx idx) |
2851 | CODE: |
2839 | CODE: |
2852 | for_all_clients (ns) |
2840 | for_all_clients (ns) |
2853 | { |
2841 | ns->invalidate_face (idx); |
2854 | ns->faces_sent [idx] = false; |
|
|
2855 | ns->force_newmap = true; |
|
|
2856 | } |
|
|
2857 | |
2842 | |
2858 | void invalidate_all () |
2843 | void invalidate_all () |
2859 | CODE: |
2844 | CODE: |
2860 | for_all_clients (ns) |
2845 | for_all_clients (ns) |
2861 | { |
2846 | ns->invalidate_all_faces (); |
2862 | ns->faces_sent.reset (); |
|
|
2863 | ns->force_newmap = true; |
|
|
2864 | } |
|
|
2865 | |
2847 | |
2866 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2848 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2867 | |
2849 | |
2868 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2850 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2869 | |
2851 | |
… | |
… | |
2873 | OUTPUT: RETVAL |
2855 | OUTPUT: RETVAL |
2874 | |
2856 | |
2875 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2857 | animidx set (utf8_string name, SV *frames, int facings = 1) |
2876 | CODE: |
2858 | CODE: |
2877 | { |
2859 | { |
2878 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2860 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
2879 | croak ("frames must be an arrayref"); |
2861 | croak ("frames must be an arrayref"); |
2880 | |
2862 | |
2881 | AV *av = (AV *)SvRV (frames); |
2863 | AV *av = (AV *)SvRV (frames); |
2882 | |
2864 | |
2883 | animation *anim = &animation::find (name); |
2865 | animation *anim = &animation::find (name); |
2884 | if (anim->number) |
2866 | if (anim->number) |
2885 | { |
2867 | { |
2886 | anim->resize (av_len (av) + 1); |
2868 | anim->resize (av_len (av) + 1); |
2887 | anim->facings = facings; |
2869 | anim->facings = facings; |
2888 | } |
2870 | } |
… | |
… | |
2960 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2942 | XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); |
2961 | |
2943 | |
2962 | self->skip (); |
2944 | self->skip (); |
2963 | } |
2945 | } |
2964 | |
2946 | |
|
|
2947 | MODULE = cf PACKAGE = cf::treasurelist |
|
|
2948 | |
|
|
2949 | # quick hack, because I didn't want to implement accessors for treasurelist. |
|
|
2950 | # this asks for even more autogen, actually. |
|
|
2951 | |
|
|
2952 | void |
|
|
2953 | expand (treasurelist *list) |
|
|
2954 | PPCODE: |
|
|
2955 | EXTEND (SP, 3); |
|
|
2956 | PUSHs (sv_2mortal (to_sv (list->name))); |
|
|
2957 | PUSHs (sv_2mortal (to_sv (list->total_chance))); |
|
|
2958 | AV *av = newAV (); |
|
|
2959 | PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
2960 | for (treasure *item = list->items; item; item = item->next) |
|
|
2961 | { |
|
|
2962 | AV *iav = newAV (); |
|
|
2963 | av_push (av, newRV_noinc ((SV *)iav)); |
|
|
2964 | |
|
|
2965 | av_extend (iav, 7); |
|
|
2966 | av_push (iav, to_sv (item->item)); |
|
|
2967 | av_push (iav, to_sv (item->name)); |
|
|
2968 | av_push (iav, to_sv (item->change_arch.name)); |
|
|
2969 | av_push (iav, to_sv (item->change_arch.title)); |
|
|
2970 | av_push (iav, to_sv (item->change_arch.slaying)); |
|
|
2971 | av_push (iav, to_sv (item->chance)); |
|
|
2972 | av_push (iav, to_sv (item->nrof)); |
|
|
2973 | av_push (iav, to_sv (item->magic)); |
|
|
2974 | } |
|
|
2975 | |
|
|
2976 | MODULE = cf PACKAGE = cf::layout |
|
|
2977 | |
|
|
2978 | INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h | |
|
|
2979 | |