ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.388 by root, Wed Jun 30 01:57:54 2010 UTC vs.
Revision 1.429 by root, Sat Nov 17 23:33:18 2018 UTC

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
29#include <cstdarg> 32#include <cstdarg>
30#include <typeinfo> 33#include <typeinfo>
31 34
32#include "global.h" 35#include "global.h"
33#include "../random_maps/random_map.h" 36#include "rmg.h"
37#include "noise.h"
34#include "evthread.h" 38#include "evthread.h"
35#include "sproto.h" 39#include "sproto.h"
36 40
37#include <unistd.h> 41#include <unistd.h>
38#if _POSIX_MEMLOCK 42#if _POSIX_MEMLOCK
66static int tick_inhibit; 70static int tick_inhibit;
67static int tick_pending; 71static int tick_pending;
68 72
69global gbl_ev; 73global gbl_ev;
70static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; 74static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
71static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; 75static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick;
72static AV *av_reflect; 76static AV *av_reflect;
73 77
74bitset<NUM_EVENT_TYPES> ev_want_event; 78bitset<NUM_EVENT_TYPES> ev_want_event;
75bitset<NUM_TYPES> ev_want_type; 79bitset<NUM_TYPES> ev_want_type;
76 80
84 *stash_cf_client_wrap, 88 *stash_cf_client_wrap,
85 *stash_cf_arch_wrap, 89 *stash_cf_arch_wrap,
86 *stash_cf_party_wrap, 90 *stash_cf_party_wrap,
87 *stash_cf_region_wrap, 91 *stash_cf_region_wrap,
88 *stash_cf_living_wrap, 92 *stash_cf_living_wrap,
93 *stash_cf_layout_wrap,
89 *stash_ext_map_world; 94 *stash_ext_map_world;
90 95
91static SV 96static SV
92 *cv_cf_do_invoke, 97 *cv_cf_do_invoke,
93 *cv_cf__can_merge, 98 *cv_cf__can_merge,
94 *cv_cf_client_send_msg, 99 *cv_cf_client_send_msg,
100 *cv_cf_ix,
95 *cv_cf_tick, 101 *cv_cf_tick,
96 *cv_cf_match_match; 102 *cv_cf_match_match;
97 103
98#ifndef newSVpv_utf8 104#ifndef newSVpv_utf8
99static SV * 105static SV *
122 128
123 return sv; 129 return sv;
124} 130}
125#endif 131#endif
126 132
127noinline utf8_string 133ecb_noinline utf8_string
128cfSvPVutf8_nolen (SV *sv) 134cfSvPVutf8_nolen (SV *sv)
129{ 135{
130 SvGETMAGIC (sv); 136 SvGETMAGIC (sv);
131 137
132 if (SvPOK (sv)) 138 if (SvPOK (sv))
251 { 257 {
252 static int last_mortalcount; 258 static int last_mortalcount;
253 if (mortals.size () != last_mortalcount) 259 if (mortals.size () != last_mortalcount)
254 { 260 {
255 last_mortalcount = mortals.size (); 261 last_mortalcount = mortals.size ();
256 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)");
257 266
258 if (0) 267 if (0)
259 { 268 {
260 for (int j = 0; j < mortals.size (); ++j)//D 269 for (int j = 0; j < mortals.size (); ++j)//D
261 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
361 370
362 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);
363 return sv_bless (newRV_noinc ((SV *)hv), stash); 372 return sv_bless (newRV_noinc ((SV *)hv), stash);
364} 373}
365 374
366static SV * noinline 375ecb_noinline static SV *
367newSVptr (void *ptr, HV *stash) 376newSVptr (void *ptr, HV *stash)
368{ 377{
369 return newSVptr (ptr, stash, newHV ()); 378 return newSVptr (ptr, stash, newHV ());
370} 379}
371 380
386 return 0; 395 return 0;
387} 396}
388 397
389MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; 398MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free};
390 399
391static SV * noinline 400ecb_noinline static SV *
392newSVattachable (attachable *obj, HV *stash) 401newSVattachable (attachable *obj, HV *stash)
393{ 402{
394 if (!obj) 403 if (!obj)
395 return newSV (0); 404 return newSV (0);
396 405
450 croak ("object of type %s expected", klass); 459 croak ("object of type %s expected", klass);
451 460
452 return SvPTR_nc (sv); 461 return SvPTR_nc (sv);
453} 462}
454 463
455static long noinline 464ecb_noinline static long
456SvPTR_ornull (SV *sv, const char *klass) 465SvPTR_ornull (SV *sv, const char *klass)
457{ 466{
458 if (expect_false (!SvOK (sv))) return 0; 467 if (expect_false (!SvOK (sv))) return 0;
459 468
460 return SvPTR (sv, klass); 469 return SvPTR (sv, klass);
461} 470}
462 471
463static long noinline 472ecb_noinline static long
464SvPTR_ornull_client (SV *sv) 473SvPTR_ornull_client (SV *sv)
465{ 474{
466 if (expect_false (!SvOK (sv))) return 0; 475 if (expect_false (!SvOK (sv))) return 0;
467 476
468 if (!SvROK (sv) 477 if (!SvROK (sv)
471 croak ("object of type cf::client expected"); 480 croak ("object of type cf::client expected");
472 481
473 return SvPTR_nc (sv); 482 return SvPTR_nc (sv);
474} 483}
475 484
476static long noinline 485ecb_noinline static long
477SvPTR_ornull_object (SV *sv) 486SvPTR_ornull_object (SV *sv)
478{ 487{
479 if (expect_false (!SvOK (sv))) return 0; 488 if (expect_false (!SvOK (sv))) return 0;
480 489
481 if (!SvROK (sv) 490 if (!SvROK (sv)
486 croak ("object of type cf::object expected"); 495 croak ("object of type cf::object expected");
487 496
488 return SvPTR_nc (sv); 497 return SvPTR_nc (sv);
489} 498}
490 499
491static long noinline 500ecb_noinline static long
492SvPTR_ornull_maptile (SV *sv) 501SvPTR_ornull_maptile (SV *sv)
493{ 502{
494 if (expect_false (!SvOK (sv))) return 0; 503 if (expect_false (!SvOK (sv))) return 0;
495 504
496 if (!SvROK (sv) 505 if (!SvROK (sv)
500 croak ("object of type cf::map expected"); 509 croak ("object of type cf::map expected");
501 510
502 return SvPTR_nc (sv); 511 return SvPTR_nc (sv);
503} 512}
504 513
505static long noinline 514ecb_noinline static long
506SvPTR_ornull_player (SV *sv) 515SvPTR_ornull_player (SV *sv)
507{ 516{
508 if (expect_false (!SvOK (sv))) return 0; 517 if (expect_false (!SvOK (sv))) return 0;
509 518
510 if (!SvROK (sv) 519 if (!SvROK (sv)
530static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 539static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
531static inline SV *to_sv (float v) { return newSVnv (v); } 540static inline SV *to_sv (float v) { return newSVnv (v); }
532static inline SV *to_sv (double v) { return newSVnv (v); } 541static inline SV *to_sv (double v) { return newSVnv (v); }
533static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 542static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); }
534static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } 543static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
535// gcc dislikes noilnine on to_sv 544// gcc dislikes noinline on to_sv
536static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } 545ecb_noinline static SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); }
537static inline SV *to_sv (object * v) { return to_sv_ni (v); } 546static inline SV *to_sv (object * v) { return to_sv_ni (v); }
538static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 547static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
539static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 548static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
540static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 549static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
541static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 550static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
542static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 551static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
543static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } 552static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); }
553static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); }
544 554
545static inline SV *to_sv (object & v) { return to_sv (&v); } 555static inline SV *to_sv (object & v) { return to_sv (&v); }
546static inline SV *to_sv (living & v) { return to_sv (&v); } 556static inline SV *to_sv (living & v) { return to_sv (&v); }
547 557
548static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 558static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
594static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } 604static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); }
595static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 605static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
596static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } 606static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); }
597static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } 607static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); }
598static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } 608static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); }
609static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); }
599static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } 610static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); }
600static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } 611static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); }
601 612
602//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 613//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
603static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 614static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
616static inline void sv_to (SV *sv, std::string &v) 627static inline void sv_to (SV *sv, std::string &v)
617{ 628{
618 STRLEN len; 629 STRLEN len;
619 char *data = SvPVbyte (sv, len); 630 char *data = SvPVbyte (sv, len);
620 v.assign (data, len); 631 v.assign (data, len);
632}
633
634static 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;
621} 640}
622 641
623static inline void sv_to (SV *sv, UUID &v) 642static inline void sv_to (SV *sv, UUID &v)
624{ 643{
625 if (!v.parse (SvPV_nolen (sv))) 644 if (!v.parse (SvPV_nolen (sv)))
710 return sv; 729 return sv;
711} 730}
712 731
713// typemap support, mostly to avoid excessive inlining 732// typemap support, mostly to avoid excessive inlining
714template<class type> 733template<class type>
715static void noinline 734ecb_noinline static void
716cf_obj_to (SV *arg, type &var) 735cf_obj_to (SV *arg, type &var)
717{ 736{
718 sv_to (arg, var); 737 sv_to (arg, var);
719 if (expect_false (!var)) 738 if (expect_false (!var))
720 croak ("must not pass invalid/null cf_obj here"); 739 croak ("must not pass invalid/null cf_obj here");
721} 740}
722 741
723template<class object> 742template<class object>
724static void noinline 743ecb_noinline static void
725cf_obj_ornull_to (SV *arg, object *&var) 744cf_obj_ornull_to (SV *arg, object *&var)
726{ 745{
727 if (SvOK (arg)) 746 if (SvOK (arg))
728 { 747 {
729 sv_to (arg, var); 748 sv_to (arg, var);
821# undef def 840# undef def
822}; 841};
823 842
824#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)
825 844
826static void noinline 845ecb_noinline static void
827gather_callbacks (AV *&callbacks, AV *registry, event_type event) 846gather_callbacks (AV *&callbacks, AV *registry, event_type event)
828{ 847{
829 // event must be in array 848 // event must be in array
830 if (event >= 0 && event <= AvFILLp (registry)) 849 if (event >= 0 && event <= AvFILLp (registry))
831 { 850 {
917{ 936{
918 attachable::gather_callbacks (callbacks, event); 937 attachable::gather_callbacks (callbacks, event);
919 ::gather_callbacks (callbacks, cb_map, event); 938 ::gather_callbacks (callbacks, cb_map, event);
920} 939}
921 940
922static void noinline 941ecb_noinline static void
923_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) 942_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
924{ 943{
925 for (int event = 0; event <= AvFILLp (registry); ++event) 944 for (int event = 0; event <= AvFILLp (registry); ++event)
926 { 945 {
927 SV *cbs_ = AvARRAY (registry)[event]; 946 SV *cbs_ = AvARRAY (registry)[event];
1142 CALL_ARG (originator); 1161 CALL_ARG (originator);
1143 CALL_CALL ("cf::mapscript::activate", G_VOID); 1162 CALL_CALL ("cf::mapscript::activate", G_VOID);
1144 CALL_END; 1163 CALL_END;
1145} 1164}
1146 1165
1166void 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
1147player * 1177player *
1148player::find (const_utf8_string name) 1178player::find (const_utf8_string name)
1149{ 1179{
1150 CALL_BEGIN (1); 1180 CALL_BEGIN (1);
1151 CALL_ARG (name); 1181 CALL_ARG (name);
1245 CALL_ARG (y); 1275 CALL_ARG (y);
1246 CALL_CALL ("cf::object::player::goto", G_VOID); 1276 CALL_CALL ("cf::object::player::goto", G_VOID);
1247 CALL_END; 1277 CALL_END;
1248} 1278}
1249 1279
1250const_utf8_string 1280const_utf8_string
1251object::ref () const 1281object::ref () const
1252{ 1282{
1253 if (type == PLAYER) 1283 if (type == PLAYER)
1254 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);
1255 else 1285 else
1397 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); 1427 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1);
1398 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); 1428 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1);
1399 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); 1429 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1);
1400 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1430 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1401 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); 1431 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1);
1432 stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1);
1402 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); 1433 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1);
1403 1434
1404 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);
1405 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);
1406 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);
1407 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);
1408 1440
1409 cb_global = get_av ("cf::CB_GLOBAL", 1); 1441 cb_global = get_av ("cf::CB_GLOBAL", 1);
1410 cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); 1442 cb_attachable = get_av ("cf::CB_ATTACHABLE", 1);
1411 cb_object = get_av ("cf::CB_OBJECT", 1); 1443 cb_object = get_av ("cf::CB_OBJECT", 1);
1412 cb_player = get_av ("cf::CB_PLAYER", 1); 1444 cb_player = get_av ("cf::CB_PLAYER", 1);
1419_connect_to_perl_2 () 1451_connect_to_perl_2 ()
1420{ 1452{
1421 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);
1422 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);
1423 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);
1424 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);
1425 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);
1426} 1459}
1427 1460
1428MODULE = cf PACKAGE = cf PREFIX = cf_ 1461MODULE = cf PACKAGE = cf PREFIX = cf_
1433 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1466 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1434 1467
1435 _connect_to_perl_1 (); 1468 _connect_to_perl_1 ();
1436 1469
1437 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1470 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 1471
1448 static const struct { 1472 static const struct {
1449 const char *name; 1473 const char *name;
1450 IV iv; 1474 IV iv;
1451 } *civ, const_iv[] = { 1475 } *civ, const_iv[] = {
1455# include "attackinc.h" 1479# include "attackinc.h"
1456# undef def 1480# undef def
1457# define def(uc, flags) const_iv (SK_ ## uc) 1481# define def(uc, flags) const_iv (SK_ ## uc)
1458# include "skillinc.h" 1482# include "skillinc.h"
1459# undef def 1483# undef def
1460 1484# define def(name, use, nonuse) const_iv (body_ ## name)
1461 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1485# include "slotinc.h"
1486# undef def
1462 1487
1463 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1488 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1464 1489
1465 const_iv (MAX_TIME) 1490 const_iv (MAX_TIME)
1466 const_iv (MAXSOCKBUF) 1491 const_iv (MAXSOCKBUF)
1479 1504
1480 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) 1505 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE)
1481 1506
1482 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)
1483 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)
1484
1485 const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING)
1486 const_iv (MAP_INACTIVE)
1487 1509
1488 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)
1489 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)
1490 1512
1491 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)
1524 1546
1525void _gv_clear (SV *gv) 1547void _gv_clear (SV *gv)
1526 CODE: 1548 CODE:
1527 assert (SvTYPE (gv) == SVt_PVGV); 1549 assert (SvTYPE (gv) == SVt_PVGV);
1528# 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);
1529 f (GvGP (gv)->gp_form); 1552 f (GvGP (gv)->gp_form);
1530 f (GvGP (gv)->gp_io); 1553 f (GvGP (gv)->gp_io);
1531 f (GvGP (gv)->gp_sv); 1554 f (GvGP (gv)->gp_sv);
1532 f (GvGP (gv)->gp_av); 1555 f (GvGP (gv)->gp_av);
1533 f (GvGP (gv)->gp_hv); 1556 f (GvGP (gv)->gp_hv);
1534 f (GvGP (gv)->gp_cv); 1557 f (GvGP (gv)->gp_cv);
1535 GvCVGEN (gv) = 0; 1558 GvCVGEN (gv) = 0;
1536 GvMULTI_off (gv); 1559 GvMULTI_off (gv);
1560 SvREFCNT_dec (gv);
1537# undef f 1561# undef f
1538 1562
1539void _connect_to_perl_1 () 1563void _connect_to_perl_1 ()
1540 1564
1541void _connect_to_perl_2 () 1565void _connect_to_perl_2 ()
1552 1576
1553 for_all_objects (op) 1577 for_all_objects (op)
1554 op->reattach (); 1578 op->reattach ();
1555} 1579}
1556 1580
1557# support function for map-world.ext
1558void _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
1599void init_anim () 1581void init_anim ()
1600 1582
1601void init_globals () 1583void init_globals ()
1602 1584
1603void init_attackmess () 1585void init_attackmess ()
1604 1586
1605void init_dynamic () 1587void init_dynamic ()
1606 1588
1607void load_settings () 1589void load_settings ()
1608 1590
1609void reload_exp_table () 1591void _reload_exp_table ()
1610 1592
1611void reload_materials () 1593void _reload_materials ()
1612 1594
1613void init_uuid () 1595void init_uuid ()
1614 CODE: 1596 CODE:
1615 UUID::init (); 1597 UUID::init ();
1616 1598
1627 coroapi::cede_to_tick (); 1609 coroapi::cede_to_tick ();
1628 1610
1629NV till_tick () 1611NV till_tick ()
1630 CODE: 1612 CODE:
1631 RETVAL = SvNVX (sv_next_tick) - now (); 1613 RETVAL = SvNVX (sv_next_tick) - now ();
1632 OUTPUT: 1614 OUTPUT: RETVAL
1633 RETVAL
1634 1615
1635int tick_inhibit () 1616int tick_inhibit ()
1636 CODE: 1617 CODE:
1637 RETVAL = tick_inhibit; 1618 RETVAL = tick_inhibit;
1638 OUTPUT: 1619 OUTPUT: RETVAL
1639 RETVAL
1640 1620
1641void tick_inhibit_inc () 1621void tick_inhibit_inc ()
1642 CODE: 1622 CODE:
1643 ++tick_inhibit; 1623 ++tick_inhibit;
1644 1624
1649 { 1629 {
1650 ev_async_send (EV_DEFAULT, &tick_watcher); 1630 ev_async_send (EV_DEFAULT, &tick_watcher);
1651 coroapi::cede (); 1631 coroapi::cede ();
1652 } 1632 }
1653 1633
1654void server_tick () 1634void one_tick ()
1655 CODE: 1635 CODE:
1656{ 1636{
1657 ev_now_update (EV_DEFAULT); 1637 ev_now_update (EV_DEFAULT);
1658 NOW = ev_now (EV_DEFAULT); 1638 NOW = ev_now (EV_DEFAULT);
1659 SvNV_set (sv_now, NOW); SvNOK_only (sv_now); 1639 SvNV_set (sv_now, NOW); SvNOK_only (sv_now);
1660 SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); 1640 SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start);
1661 runtime = SvNVX (sv_runtime); 1641 runtime = SvNVX (sv_runtime);
1662 1642
1643 one_tick ();
1644
1663 server_tick (); 1645 ++server_tick;
1646 SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick);
1664 1647
1665 ev_now_update (EV_DEFAULT); 1648 ev_now_update (EV_DEFAULT);
1666 NOW = ev_now (EV_DEFAULT); 1649 NOW = ev_now (EV_DEFAULT);
1667 SvNV_set (sv_now, NOW); SvNOK_only (sv_now); 1650 SvNV_set (sv_now, NOW); SvNOK_only (sv_now);
1651
1668 runtime += TICK; 1652 runtime += TICK;
1669 SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); 1653 SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime);
1670} 1654}
1671 1655
1672NV floor (NV x) 1656NV floor (NV x)
1676NV rndm (...) 1660NV rndm (...)
1677 ALIAS: 1661 ALIAS:
1678 rmg_rndm = 1 1662 rmg_rndm = 1
1679 CODE: 1663 CODE:
1680{ 1664{
1681 rand_gen &gen = ix ? rmg_rndm : rndm; 1665 rand_gen &gen = ix ? rmg_rndm : rndm;
1682 switch (items) 1666 switch (items)
1683 { 1667 {
1684 case 0: RETVAL = gen (); break; 1668 case 0: RETVAL = gen (); break;
1685 case 1: RETVAL = gen (SvUV (ST (0))); break; 1669 case 1: RETVAL = gen (SvUV (ST (0))); break;
1686 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1670 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1687 default: croak ("cf::rndm requires zero, one or two parameters."); break; 1671 default: croak ("cf::rndm requires zero, one or two parameters."); break;
1688 } 1672 }
1689} 1673}
1690 OUTPUT: 1674 OUTPUT: RETVAL
1691 RETVAL
1692 1675
1693NV clamp (NV value, NV min_value, NV max_value) 1676NV clamp (NV value, NV min_value, NV max_value)
1694 CODE: 1677 CODE:
1695 RETVAL = clamp (value, min_value, max_value); 1678 RETVAL = clamp (value, min_value, max_value);
1696 OUTPUT: 1679 OUTPUT: RETVAL
1697 RETVAL
1698 1680
1699NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out) 1681NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out)
1700 CODE: 1682 CODE:
1701 RETVAL = lerp (value, min_in, max_in, min_out, max_out); 1683 RETVAL = lerp (value, min_in, max_in, min_out, max_out);
1702 OUTPUT: 1684 OUTPUT: RETVAL
1703 RETVAL
1704 1685
1705const char *ordinal (int i) 1686const char *ordinal (int i)
1706 1687
1707void weaken (...) 1688void weaken (...)
1708 PROTOTYPE: @ 1689 PROTOTYPE: @
1771 1752
1772int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1753int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1773 INIT: 1754 INIT:
1774#if __GLIBC__ 1755#if __GLIBC__
1775 mallopt (M_TOP_PAD, 1024 * 1024); 1756 mallopt (M_TOP_PAD, 1024 * 1024);
1776 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); 1757 mallopt (M_MMAP_THRESHOLD, 1024 * 1024);
1777 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory 1758 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1759 if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10))
1778 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1760 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1779#endif 1761#endif
1780 1762
1781int munlockall () 1763int munlockall ()
1782 1764
1783#endif 1765#endif
1806 EXTEND (SP, 5*2); 1788 EXTEND (SP, 5*2);
1807 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)));
1808 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)));
1809 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))));
1810 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)));
1811 PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount)));
1812} 1793}
1813
1814int find_animation (utf8_string text)
1815 PROTOTYPE: $
1816 1794
1817int random_roll (int min, int max, object *op, int goodbad); 1795int random_roll (int min, int max, object *op, int goodbad);
1818 1796
1819const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1797const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1820 1798
1821int exp_to_level (val64 exp) 1799int exp_to_level (val64 exp)
1822 1800
1823val64 level_to_min_exp (int level) 1801val64 level_to_min_exp (int level)
1824 1802
1803const_utf8_string
1804spellpathnames (int idx)
1805 CODE:
1806 RETVAL = spellpathnames [idx];
1807 OUTPUT: RETVAL
1808
1825SV * 1809SV *
1826resistance_to_string (int atnr) 1810attacktype_name (int atnr)
1827 CODE: 1811 CODE:
1828 if (atnr >= 0 && atnr < NROFATTACKS) 1812 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1829 RETVAL = newSVpv (resist_plus[atnr], 0); 1813 ? newSVpv (attacktype_name [atnr], 0)
1830 else 1814 : &PL_sv_undef;
1831 XSRETURN_UNDEF;
1832 OUTPUT: RETVAL 1815 OUTPUT: RETVAL
1816
1817SV *
1818attacktype_desc (int atnr)
1819 CODE:
1820 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1821 ? newSVpv (attacktype_desc [atnr], 0)
1822 : &PL_sv_undef;
1823 OUTPUT: RETVAL
1824
1825SV *
1826resist_plus (int atnr)
1827 CODE:
1828 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1829 ? newSVpv (resist_plus [atnr], 0)
1830 : &PL_sv_undef;
1831 OUTPUT: RETVAL
1832
1833SV *
1834change_resist_msg (int atnr)
1835 CODE:
1836 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1837 ? newSVpv (change_resist_msg [atnr], 0)
1838 : &PL_sv_undef;
1839 OUTPUT: RETVAL
1840
1841int
1842skill_flags (int idx)
1843 CODE:
1844 if (idx < 0 || idx >= array_length (skill_flags))
1845 croak ("skill_flags: index out of bounds");
1846 RETVAL = skill_flags [idx];
1847 OUTPUT: RETVAL
1833 1848
1834UUID 1849UUID
1835uuid_cur () 1850uuid_cur ()
1836 CODE: 1851 CODE:
1837 RETVAL = UUID::cur; 1852 RETVAL = UUID::cur;
1838 OUTPUT: 1853 OUTPUT: RETVAL
1839 RETVAL
1840 1854
1841UUID 1855UUID
1842uuid_gen () 1856uuid_gen ()
1843 CODE: 1857 CODE:
1844 RETVAL = UUID::gen (); 1858 RETVAL = UUID::gen ();
1845 OUTPUT: 1859 OUTPUT: RETVAL
1846 RETVAL
1847 1860
1848val64 1861val64
1849uuid_seq (UUID uuid) 1862uuid_seq (UUID uuid)
1850 CODE: 1863 CODE:
1851 RETVAL = uuid.seq; 1864 RETVAL = uuid.seq;
1852 OUTPUT: 1865 OUTPUT: RETVAL
1853 RETVAL
1854 1866
1855UUID 1867UUID
1856uuid_str (val64 seq) 1868uuid_str (val64 seq)
1857 CODE: 1869 CODE:
1858 RETVAL.seq = seq; 1870 RETVAL.seq = seq;
1859 OUTPUT: 1871 OUTPUT: RETVAL
1860 RETVAL
1861 1872
1862void 1873void
1863coin_names () 1874coin_names ()
1864 PPCODE: 1875 PPCODE:
1865 EXTEND (SP, NUM_COINS); 1876 EXTEND (SP, NUM_COINS);
1877load_resource_file_ (octet_string filename) 1888load_resource_file_ (octet_string filename)
1878 1889
1879void 1890void
1880fix_weight () 1891fix_weight ()
1881 1892
1893utf8_string
1894expand_cfpod (int hintmode, int gender, const_utf8_string cfpod)
1895 PPCODE:
1896 XPUSHs (to_sv (player::expand_cfpod (hintmode, gender, cfpod)));
1897
1882MODULE = cf PACKAGE = cf::attachable 1898MODULE = cf PACKAGE = cf::attachable
1883 1899
1884int 1900int
1885valid (SV *obj) 1901valid (SV *obj)
1886 CODE: 1902 CODE:
1887 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1903 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1888 OUTPUT: 1904 OUTPUT: RETVAL
1889 RETVAL
1890 1905
1891bool should_invoke (attachable *obj, int event) 1906bool should_invoke (attachable *obj, int event)
1892 CODE: 1907 CODE:
1893 RETVAL = obj->should_invoke ((event_type)event); 1908 RETVAL = obj->should_invoke ((event_type)event);
1894 OUTPUT: RETVAL 1909 OUTPUT: RETVAL
1959int mortals_size () 1974int mortals_size ()
1960 CODE: 1975 CODE:
1961 RETVAL = attachable::mortals.size (); 1976 RETVAL = attachable::mortals.size ();
1962 OUTPUT: RETVAL 1977 OUTPUT: RETVAL
1963 1978
1964const_utf8_string slot_use_name (U32 slot) 1979const_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: RETVAL
1979 RETVAL
1980 1997
1981# missing properties 1998# missing properties
1982 1999
1983object *head (object *op) 2000object *head (object *op)
1984 PROTOTYPE: $ 2001 PROTOTYPE: $
2020 if (ix) 2037 if (ix)
2021 op->slot[slot].used = value; 2038 op->slot[slot].used = value;
2022 else 2039 else
2023 op->slot[slot].info = value; 2040 op->slot[slot].info = value;
2024} 2041}
2025 OUTPUT: 2042 OUTPUT: RETVAL
2026 RETVAL
2027 2043
2028object *find_best_object_match (object *op, utf8_string match) 2044object *find_best_object_match (object *op, utf8_string match)
2029 2045
2030int apply_shop_mat (object *shop_mat, object *op); 2046int apply_shop_mat (object *shop_mat, object *op);
2031 2047
2032int move (object *op, int dir, object *originator = op) 2048int move (object *op, int dir, object *originator = op)
2033 CODE: 2049 CODE:
2034 RETVAL = op->move (dir, originator); 2050 RETVAL = op->move (dir, originator);
2035 OUTPUT: 2051 OUTPUT: RETVAL
2036 RETVAL
2037 2052
2038void apply_below (object *op) 2053void apply_below (object *op)
2039 CODE: 2054 CODE:
2040 player_apply_below (op); 2055 player_apply_below (op);
2041 2056
2105int convert_item (object *item, object *converter) 2120int convert_item (object *item, object *converter)
2106 2121
2107void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags); 2122void fix_generated_item (object *op, object *creator, int difficulty, int max_magic, int flags);
2108 2123
2109MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2124MODULE = 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 2125
2114object *new (utf8_string archetype = 0) 2126object *new (utf8_string archetype = 0)
2115 PROTOTYPE: ;$ 2127 PROTOTYPE: ;$
2116 CODE: 2128 CODE:
2117 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2129 RETVAL = archetype
2130 ? archetype::get (archetype)
2131 : object::create ();
2118 OUTPUT: 2132 OUTPUT: RETVAL
2119 RETVAL
2120 2133
2121object *generate (utf8_string arch, object *creator) 2134object *generate (utf8_string arch, object *creator)
2122 CODE: 2135 CODE:
2123 object *obj = get_archetype (arch); 2136 object *obj = archetype::get (arch);
2124 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2137 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2125 RETVAL = obj; 2138 RETVAL = obj;
2126 OUTPUT: 2139 OUTPUT: RETVAL
2127 RETVAL
2128 2140
2129object *find_object (U32 tag) 2141object *find_object (U32 tag)
2130 2142
2131object *find_object_uuid (UUID i) 2143object *find_object_uuid (UUID i)
2132 2144
2138 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2150 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2139 2151
2140 if (RETVAL->destroyed ()) 2152 if (RETVAL->destroyed ())
2141 RETVAL = 0; 2153 RETVAL = 0;
2142} 2154}
2155 OUTPUT: RETVAL
2143 2156
2144shstr 2157shstr
2145object::kv_get (shstr key) 2158object::kv_get (shstr key)
2159 CODE:
2160 RETVAL = THIS->kv.get (key);
2161 OUTPUT: RETVAL
2146 2162
2147void 2163void
2148object::kv_del (shstr key) 2164object::kv_del (shstr key)
2165 CODE:
2166 THIS->kv.del (key);
2149 2167
2150void 2168void
2151object::kv_set (shstr key, shstr value) 2169object::kv_set (shstr key, shstr value)
2170 CODE:
2171 THIS->kv.set (key, value);
2152 2172
2153object *get_nearest_player (object *ob) 2173object *get_nearest_player (object *ob)
2154 ALIAS: nearest_player = 0 2174 ALIAS: nearest_player = 0
2155 PREINIT: 2175 PREINIT:
2156 extern object *get_nearest_player (object *); 2176 extern object *get_nearest_player (object *);
2245#d# TODO: replace by blocked_los accessor, fix code using this 2265#d# TODO: replace by blocked_los accessor, fix code using this
2246bool 2266bool
2247cell_visible (player *pl, int dx, int dy) 2267cell_visible (player *pl, int dx, int dy)
2248 CODE: 2268 CODE:
2249 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; 2269 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED;
2250 OUTPUT: 2270 OUTPUT: RETVAL
2251 RETVAL
2252 2271
2253void 2272void
2254send (player *pl, SV *packet) 2273send (player *pl, SV *packet)
2255 CODE: 2274 CODE:
2256{ 2275{
2332outdoor_darkness (int darkness = 0) 2351outdoor_darkness (int darkness = 0)
2333 CODE: 2352 CODE:
2334 RETVAL = maptile::outdoor_darkness; 2353 RETVAL = maptile::outdoor_darkness;
2335 if (items) 2354 if (items)
2336 maptile::outdoor_darkness = darkness; 2355 maptile::outdoor_darkness = darkness;
2337 OUTPUT: 2356 OUTPUT: RETVAL
2338 RETVAL
2339 2357
2340void 2358void
2341maptile::instantiate () 2359maptile::instantiate ()
2342 2360
2343maptile *new () 2361maptile *new ()
2344 PROTOTYPE: 2362 PROTOTYPE:
2345 CODE: 2363 CODE:
2346 RETVAL = new maptile; 2364 RETVAL = new maptile;
2347 OUTPUT: 2365 OUTPUT: RETVAL
2348 RETVAL
2349 2366
2350void 2367void
2351maptile::players () 2368maptile::players ()
2352 PPCODE: 2369 PPCODE:
2353 if (GIMME_V == G_SCALAR) 2370 if (GIMME_V == G_SCALAR)
2359 if (pl->ob && pl->ob->map == THIS) 2376 if (pl->ob && pl->ob->map == THIS)
2360 PUSHs (sv_2mortal (to_sv (pl->ob))); 2377 PUSHs (sv_2mortal (to_sv (pl->ob)));
2361 } 2378 }
2362 2379
2363void 2380void
2381maptile::gen_quadmap (int x, int y, int z)
2382 CODE:
2383 gen_quadmap (THIS, x * 50, y * 50, z);
2384
2385void
2364maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2386maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2365 CODE: 2387 CODE:
2366{ 2388{
2367 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2389 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2368 croak ("maptile::add_underlay: palette must be arrayref"); 2390 croak ("maptile::add_underlay: palette must be arrayref");
2369 2391
2370 palette = SvRV (palette); 2392 palette = SvRV (palette);
2371 2393
2372 STRLEN idxlen; 2394 STRLEN idxlen;
2373 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2395 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2374 2396
2375 for (int x = 0; x < THIS->width; ++x) 2397 for (int x = 0; x < THIS->width; ++x)
2376 for (int y = 0; y < THIS->height; ++y) 2398 for (int y = 0; y < THIS->height; ++y)
2377 { 2399 {
2378 for (object *op = THIS->at (x, y).bot; op; op = op->above) 2400 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2384 2406
2385 if (IN_RANGE_EXC (offs, 0, idxlen)) 2407 if (IN_RANGE_EXC (offs, 0, idxlen))
2386 { 2408 {
2387 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2409 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2388 { 2410 {
2389 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2411 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2390 ob->flag [FLAG_NO_MAP_SAVE] = true; 2412 ob->flag [FLAG_NO_MAP_SAVE] = true;
2391 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2413 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2392 2414
2393 if (ob->randomitems && !ob->above) 2415 if (ob->randomitems && !ob->above)
2394 { 2416 {
2398 op->flag [FLAG_NO_MAP_SAVE] = true; 2420 op->flag [FLAG_NO_MAP_SAVE] = true;
2399 // TODO: if this is a pickable object, then the item 2421 // TODO: if this is a pickable object, then the item
2400 // will at a bit weird - saving inside the player 2422 // will at a bit weird - saving inside the player
2401 // will clear the flag, but when the player drops 2423 // will clear the flag, but when the player drops
2402 // it without logging out, it keeps the flag. 2424 // it without logging out, it keeps the flag.
2403 // nobody ahs reported this, but this can be rather 2425 // nobody has reported this, but this can be rather
2404 // annoying on persistent maps. 2426 // annoying on persistent maps.
2405 } 2427 }
2406 } 2428 }
2407 } 2429 }
2408 } 2430 }
2409
2410 skip: ; 2431 skip: ;
2411 } 2432 }
2412} 2433}
2413 2434
2414void 2435void
2419 croak ("maptile::set_regiondata: palette must be arrayref"); 2440 croak ("maptile::set_regiondata: palette must be arrayref");
2420 2441
2421 palette = SvRV (palette); 2442 palette = SvRV (palette);
2422 2443
2423 STRLEN idxlen; 2444 STRLEN idxlen;
2424 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); 2445 const uint8 *idx = (const uint8 *)SvPVbyte (data, idxlen);
2425 2446
2426 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; 2447 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1];
2427 uint8_t *regions = salloc<uint8_t> (THIS->size ()); 2448 uint8 *regions = salloc<uint8_t> (THIS->size ());
2428 2449
2429 for (int i = av_len ((AV *)palette) + 1; i--; ) 2450 for (int i = av_len ((AV *)palette) + 1; i--; )
2430 regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); 2451 regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1)));
2431 2452
2432 for (int y = 0; y < THIS->height; ++y) 2453 for (int y = 0; y < THIS->height; ++y)
2445 for (int x = 0; x < THIS->width; ++x) 2466 for (int x = 0; x < THIS->width; ++x)
2446 for (int y = 0; y < THIS->height; ++y) 2467 for (int y = 0; y < THIS->height; ++y)
2447 { 2468 {
2448 region *rgn = THIS->region (x, y); 2469 region *rgn = THIS->region (x, y);
2449 2470
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) 2471 if (object *op = THIS->at (x, y).top)
2452 if (rgn->treasure && rndm () < rgn->treasure_density) 2472 if (rgn->treasure && rndm () < rgn->treasure_density)
2453 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2473 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2454 } 2474 }
2455 2475
2485 if (!pos.move (dir).normalise ()) 2505 if (!pos.move (dir).normalise ())
2486 XSRETURN_UNDEF; 2506 XSRETURN_UNDEF;
2487 2507
2488 RETVAL = &*pos; 2508 RETVAL = &*pos;
2489} 2509}
2490 OUTPUT: 2510 OUTPUT: RETVAL
2491 RETVAL
2492 2511
2493void 2512void
2494at (maptile *map, unsigned int x, unsigned int y, int dir = 0) 2513at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2495 PROTOTYPE: $$$;$ 2514 PROTOTYPE: $$$;$
2496 PPCODE: 2515 PPCODE:
2534} 2553}
2535 OUTPUT: RETVAL 2554 OUTPUT: RETVAL
2536 2555
2537# worst xs function of my life 2556# worst xs function of my life
2538bool 2557bool
2539_create_random_map (\ 2558_create_random_map (maptile *self, SV *options)
2540 maptile *self,\
2541 SV *options,\
2542 val64 total_map_hp,\
2543 region *region\
2544)
2545 CODE: 2559 CODE:
2546{ 2560{
2547 random_map_params rmp; 2561 random_map_params rmp ((HV *)SvRV (options));
2548
2549 rmp.hv = (HV *)SvREFCNT_inc_NN (SvRV (options));
2550
2551 assign (rmp.wall_name , rmp.get_str ("wall_name"));
2552 assign (rmp.monsterstyle , rmp.get_str ("monsterstyle"));
2553 assign (rmp.layoutstyle , rmp.get_str ("layoutstyle"));
2554 assign (rmp.doorstyle , rmp.get_str ("doorstyle"));
2555 assign (rmp.exit_on_final_map, rmp.get_str ("exit_on_final_map"));
2556
2557 rmp.origin_map = rmp.get_str ("origin_map");
2558 rmp.origin_x = rmp.get_iv ("origin_x");
2559 rmp.origin_y = rmp.get_iv ("origin_y");
2560 rmp.final_map = rmp.get_str ("final_map");
2561 rmp.this_map = rmp.get_str ("this_map");
2562 rmp.xsize = rmp.get_iv ("xsize");
2563 rmp.ysize = rmp.get_iv ("ysize");
2564 rmp.expand2x = rmp.get_iv ("expand2x");
2565 rmp.layoutoptions1 = rmp.get_iv ("layoutoptions1");
2566 rmp.layoutoptions2 = rmp.get_iv ("layoutoptions2");
2567 rmp.layoutoptions3 = rmp.get_iv ("layoutoptions3");
2568 rmp.symmetry = rmp.get_iv ("symmetry");
2569 rmp.difficulty = rmp.get_iv ("difficulty");
2570 rmp.difficulty_given = rmp.get_iv ("difficulty_given");
2571 rmp.difficulty_increase = rmp.get_nv ("difficulty_increase");
2572 rmp.dungeon_level = rmp.get_iv ("dungeon_level");
2573 rmp.dungeon_depth = rmp.get_iv ("dungeon_depth");
2574 rmp.orientation = rmp.get_iv ("orientation");
2575 rmp.random_seed = rmp.get_uv ("random_seed");
2576 rmp.total_map_hp = (uint64_t)total_map_hp;
2577 rmp.map_layout_style = rmp.get_iv ("map_layout_style");
2578 rmp.symmetry_used = rmp.get_iv ("symmetry_used");
2579 rmp.region = region;
2580
2581 RETVAL = self->generate_random_map (&rmp); 2562 RETVAL = self->generate_random_map (&rmp);
2582} 2563}
2583 OUTPUT: 2564 OUTPUT: RETVAL
2584 RETVAL
2585 2565
2586MODULE = cf PACKAGE = cf::mapspace 2566MODULE = cf PACKAGE = cf::mapspace
2587 2567
2588INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h | 2568INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h |
2589 2569
2596 2576
2597archetype *archetypes (U32 index) 2577archetype *archetypes (U32 index)
2598 CODE: 2578 CODE:
2599 RETVAL = index < archetypes.size () ? archetypes [index] : 0; 2579 RETVAL = index < archetypes.size () ? archetypes [index] : 0;
2600 OUTPUT: RETVAL 2580 OUTPUT: RETVAL
2581
2582int skillvec_size ()
2583 CODE:
2584 RETVAL = skillvec.size ();
2585 OUTPUT: RETVAL
2586
2587archetype *skillvec (U32 index)
2588 CODE:
2589 RETVAL = index < skillvec.size () ? (archetype *)(object *)skillvec [index] : 0;
2590 OUTPUT: RETVAL
2591
2592void
2593find_by_type (int type)
2594 PPCODE:
2595 for_all_archetypes (arch)
2596 if (arch->type == type)
2597 XPUSHs (sv_2mortal (to_sv (arch)));
2601 2598
2602INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h | 2599INCLUDE: $PERL $srcdir/genacc archetype $srcdir/../include/object.h |
2603 2600
2604MODULE = cf PACKAGE = cf::party 2601MODULE = cf PACKAGE = cf::party
2605 2602
2654list () 2651list ()
2655 PPCODE: 2652 PPCODE:
2656 EXTEND (SP, clients.size ()); 2653 EXTEND (SP, clients.size ());
2657 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 2654 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
2658 PUSHs (sv_2mortal (to_sv (*i))); 2655 PUSHs (sv_2mortal (to_sv (*i)));
2656
2657STRLEN
2658client::inbuf_append (SV *data)
2659 CODE:
2660{
2661 STRLEN len;
2662 char *ptr = SvPVbyte (data, len);
2663
2664 min_it (len, sizeof (THIS->inbuf) - THIS->inbuf_len);
2665 memcpy (THIS->inbuf + THIS->inbuf_len, ptr, len);
2666 THIS->inbuf_len += len;
2667
2668 THIS->inbuf_handle ();
2669
2670 RETVAL = len;
2671}
2672 OUTPUT: RETVAL
2659 2673
2660void 2674void
2661client::send_packet (SV *packet) 2675client::send_packet (SV *packet)
2662 CODE: 2676 CODE:
2663{ 2677{
2681 if (RETVAL) 2695 if (RETVAL)
2682 { 2696 {
2683 THIS->send_face (RETVAL, pri); 2697 THIS->send_face (RETVAL, pri);
2684 THIS->flush_fx (); 2698 THIS->flush_fx ();
2685 } 2699 }
2686 OUTPUT: 2700 OUTPUT: RETVAL
2687 RETVAL
2688 2701
2689int 2702int
2690client::fx_want (int idx, int value = -1) 2703client::fx_want (int idx, int value = -1)
2691 CODE: 2704 CODE:
2692 if (0 < idx && idx < FT_NUM) 2705 if (0 < idx && idx < FT_NUM)
2695 if (items > 2) 2708 if (items > 2)
2696 THIS->fx_want [idx] = value; 2709 THIS->fx_want [idx] = value;
2697 } 2710 }
2698 else 2711 else
2699 RETVAL = 0; 2712 RETVAL = 0;
2700 OUTPUT: 2713 OUTPUT: RETVAL
2701 RETVAL
2702 2714
2703MODULE = cf PACKAGE = cf::sound PREFIX = sound_ 2715MODULE = cf PACKAGE = cf::sound PREFIX = sound_
2704 2716
2705faceidx sound_find (utf8_string name) 2717faceidx sound_find (utf8_string name)
2706 2718
2719faceidx face_find (utf8_string name, faceidx defidx = 0) 2731faceidx face_find (utf8_string name, faceidx defidx = 0)
2720 2732
2721faceidx alloc (utf8_string name) 2733faceidx alloc (utf8_string name)
2722 CODE: 2734 CODE:
2723{ 2735{
2724 do 2736 RETVAL = face_alloc ();
2725 {
2726 RETVAL = faces.size ();
2727 faces.resize (RETVAL + 1);
2728 }
2729 while (!RETVAL); // crude way to leave index 0
2730 2737
2731 faces [RETVAL].name = name; 2738 faces [RETVAL].name = name;
2732 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); 2739 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL));
2733 2740
2734 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; 2741 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL;
2735 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL; 2742 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL;
2736 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL; 2743 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL;
2737} 2744}
2745 OUTPUT: RETVAL
2746
2747faceidx faces_size ()
2748 CODE:
2749 RETVAL = faces.size ();
2738 OUTPUT: RETVAL 2750 OUTPUT: RETVAL
2739 2751
2740void set_type (faceidx idx, int value) 2752void set_type (faceidx idx, int value)
2741 ALIAS: 2753 ALIAS:
2742 set_type = 0 2754 set_type = 0
2753 case 2: f->magicmap = value; break; 2765 case 2: f->magicmap = value; break;
2754 case 3: f->smooth = value; break; 2766 case 3: f->smooth = value; break;
2755 case 4: f->smoothlevel = value; break; 2767 case 4: f->smoothlevel = value; break;
2756 } 2768 }
2757 2769
2758void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2770void set_csum (faceidx idx, int faceset, SV *chksum)
2759 CODE: 2771 CODE:
2760{ 2772{
2761 faceinfo *f = face_info (idx); assert (f); 2773 faceinfo *f = face_info (idx); assert (f);
2762 facedata *d = &(faceset ? f->data64 : f->data32); 2774 facedata *d = f->face + faceset;
2763 sv_to (data, d->data);
2764 STRLEN clen; 2775 STRLEN clen;
2765 char *cdata = SvPVbyte (chksum, clen); 2776 char *cdata = SvPVbyte (chksum, clen);
2766 clen = min (CHKSUM_MAXLEN, clen);
2767 2777
2778 assert (("cf::face::set_data called with too long checksum", clen <= CHKSUM_MAXLEN));
2768 assert (("cf::face::set_data must be called with a non-empty checksum", clen)); 2779 assert (("cf::face::set_data must be called with a non-empty checksum", clen));
2769 2780
2770 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen)) 2781 if (clen != d->chksum_len || memcmp (d->chksum, cdata, clen))
2771 { 2782 {
2772 d->chksum_len = clen; 2783 d->chksum_len = clen;
2773 memcpy (d->chksum, cdata, clen); 2784 memcpy (d->chksum, cdata, clen);
2774 2785
2775 // invalidate existing client face info 2786 // invalidate existing client face info
2776 for_all_clients (ns) 2787 for_all_clients (ns)
2777 if (ns->faceset == faceset) 2788 ns->invalidate_face (idx);
2778 {
2779 ns->faces_sent [idx] = false;
2780 ns->force_newmap = true;
2781 }
2782 } 2789 }
2783} 2790}
2784 2791
2785int get_data_size (faceidx idx, int faceset = 0) 2792SV *mangle_csum (SV *chksum)
2786 CODE: 2793 CODE:
2787 facedata *d = face_data (idx, faceset); 2794 STRLEN len;
2788 if (!d) XSRETURN_UNDEF; 2795 char *data = SvPVbyte (chksum, len);
2789 RETVAL = d->data.size (); 2796 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN));
2790 OUTPUT: 2797 OUTPUT: RETVAL
2791 RETVAL
2792 2798
2793SV *get_chksum (faceidx idx, int faceset = 0) 2799SV *get_csum (faceidx idx, int faceset = 0)
2794 CODE: 2800 CODE:
2795 facedata *d = face_data (idx, faceset); 2801 facedata *d = face_data (idx, faceset);
2796 if (!d) XSRETURN_UNDEF; 2802 if (!d) XSRETURN_UNDEF;
2797 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2803 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2798 OUTPUT: 2804 OUTPUT: RETVAL
2799 RETVAL
2800 2805
2801SV *get_data (faceidx idx, int faceset = 0) 2806int get_type (faceidx idx)
2802 CODE: 2807 CODE:
2803 facedata *d = face_data (idx, faceset); 2808 faceinfo *f = face_info (idx);
2804 if (!d) XSRETURN_UNDEF; 2809 if (!f) XSRETURN_UNDEF;
2805 RETVAL = newSVpvn (d->data.data (), d->data.length ()); 2810 RETVAL = f->type;
2806 OUTPUT: 2811 OUTPUT: RETVAL
2807 RETVAL 2812
2813SV *get_name (faceidx idx)
2814 CODE:
2815 faceinfo *f = face_info (idx);
2816 if (!f) XSRETURN_UNDEF;
2817 RETVAL = to_sv (f->name);
2818 OUTPUT: RETVAL
2808 2819
2809void invalidate (faceidx idx) 2820void invalidate (faceidx idx)
2810 CODE: 2821 CODE:
2811 for_all_clients (ns) 2822 for_all_clients (ns)
2812 { 2823 ns->invalidate_face (idx);
2813 ns->faces_sent [idx] = false;
2814 ns->force_newmap = true;
2815 }
2816 2824
2817void invalidate_all () 2825void invalidate_all ()
2818 CODE: 2826 CODE:
2819 for_all_clients (ns) 2827 for_all_clients (ns)
2820 { 2828 ns->invalidate_all_faces ();
2821 ns->faces_sent.reset ();
2822 ns->force_newmap = true;
2823 }
2824 2829
2825MODULE = cf PACKAGE = cf::anim PREFIX = anim_ 2830MODULE = cf PACKAGE = cf::anim PREFIX = anim_
2826 2831
2827#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | 2832#INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h |
2828 2833
2832 OUTPUT: RETVAL 2837 OUTPUT: RETVAL
2833 2838
2834animidx set (utf8_string name, SV *frames, int facings = 1) 2839animidx set (utf8_string name, SV *frames, int facings = 1)
2835 CODE: 2840 CODE:
2836{ 2841{
2837 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) 2842 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV)
2838 croak ("frames must be an arrayref"); 2843 croak ("frames must be an arrayref");
2839 2844
2840 AV *av = (AV *)SvRV (frames); 2845 AV *av = (AV *)SvRV (frames);
2841 2846
2842 animation *anim = &animation::find (name); 2847 animation *anim = &animation::find (name);
2843 if (anim->number) 2848 if (anim->number)
2844 { 2849 {
2845 anim->resize (av_len (av) + 1); 2850 anim->resize (av_len (av) + 1);
2846 anim->facings = facings; 2851 anim->facings = facings;
2847 } 2852 }
2882bool 2887bool
2883errors_are_fatal (bool fatal) 2888errors_are_fatal (bool fatal)
2884 CODE: 2889 CODE:
2885 RETVAL = object_thawer::errors_are_fatal; 2890 RETVAL = object_thawer::errors_are_fatal;
2886 object_thawer::errors_are_fatal = fatal; 2891 object_thawer::errors_are_fatal = fatal;
2887 OUTPUT: 2892 OUTPUT: RETVAL
2888 RETVAL
2889 2893
2890SV * 2894SV *
2891new_from_file (char *klass, octet_string path) 2895new_from_file (char *klass, octet_string path)
2892 CODE: 2896 CODE:
2893 object_thawer *f = new object_thawer (path); 2897 object_thawer *f = new object_thawer (path);
2919 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2923 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2920 2924
2921 self->skip (); 2925 self->skip ();
2922 } 2926 }
2923 2927
2928MODULE = cf PACKAGE = cf::treasurelist
2929
2930# quick hack, because I didn't want to implement accessors for treasurelist.
2931# this asks for even more autogen, actually.
2932
2933void
2934expand (treasurelist *list)
2935 PPCODE:
2936 EXTEND (SP, 3);
2937 PUSHs (sv_2mortal (to_sv (list->name)));
2938 PUSHs (sv_2mortal (to_sv (list->total_chance)));
2939 AV *av = newAV ();
2940 PUSHs (sv_2mortal (newRV_noinc ((SV *)av)));
2941 for (treasure *item = list->items; item; item = item->next)
2942 {
2943 AV *iav = newAV ();
2944 av_push (av, newRV_noinc ((SV *)iav));
2945
2946 av_extend (iav, 7);
2947 av_push (iav, to_sv (item->item));
2948 av_push (iav, to_sv (item->name));
2949 av_push (iav, to_sv (item->change_arch.name));
2950 av_push (iav, to_sv (item->change_arch.title));
2951 av_push (iav, to_sv (item->change_arch.slaying));
2952 av_push (iav, to_sv (item->chance));
2953 av_push (iav, to_sv (item->nrof));
2954 av_push (iav, to_sv (item->magic));
2955 }
2956
2957MODULE = cf PACKAGE = cf::layout
2958
2959INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2960

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines