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.367 by root, Mon Apr 12 05:22:38 2010 UTC vs.
Revision 1.404 by root, Wed May 4 07:36:41 2011 UTC

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
51#include <perl.h> 52#include <perl.h>
52#include <XSUB.h> 53#include <XSUB.h>
53 54
54#include "CoroAPI.h" 55#include "CoroAPI.h"
55#include "perlxsi.c" 56#include "perlxsi.c"
56
57extern sint64 *levels; // the experience table
58 57
59typedef object_thawer &object_thawer_ref; 58typedef object_thawer &object_thawer_ref;
60typedef object_freezer &object_freezer_ref; 59typedef object_freezer &object_freezer_ref;
61 60
62typedef std::string std__string; 61typedef std::string std__string;
85 *stash_cf_mapspace_wrap, 84 *stash_cf_mapspace_wrap,
86 *stash_cf_client_wrap, 85 *stash_cf_client_wrap,
87 *stash_cf_arch_wrap, 86 *stash_cf_arch_wrap,
88 *stash_cf_party_wrap, 87 *stash_cf_party_wrap,
89 *stash_cf_region_wrap, 88 *stash_cf_region_wrap,
90 *stash_cf_living_wrap; 89 *stash_cf_living_wrap,
90 *stash_cf_layout_wrap,
91 *stash_ext_map_world;
91 92
92static SV 93static SV
93 *cv_cf_do_invoke, 94 *cv_cf_do_invoke,
94 *cv_cf__can_merge, 95 *cv_cf__can_merge,
95 *cv_cf_client_send_msg, 96 *cv_cf_client_send_msg,
123 124
124 return sv; 125 return sv;
125} 126}
126#endif 127#endif
127 128
128static noinline utf8_string 129noinline utf8_string
129cfSvPVutf8_nolen (SV *sv) 130cfSvPVutf8_nolen (SV *sv)
130{ 131{
131 SvGETMAGIC (sv); 132 SvGETMAGIC (sv);
132 133
133 if (SvPOK (sv)) 134 if (SvPOK (sv))
353#endif 354#endif
354 355
355////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 356//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
356 357
357static SV * 358static SV *
358newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) 359newSVptr (void *ptr, HV *stash, HV *hv)
359{ 360{
360 SV *sv;
361
362 if (!ptr) 361 if (!ptr)
363 return newSV (0); 362 return newSV (0);
364 363
365 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); 364 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0);
366 return sv_bless (newRV_noinc ((SV *)hv), stash); 365 return sv_bless (newRV_noinc ((SV *)hv), stash);
366}
367
368static SV * noinline
369newSVptr (void *ptr, HV *stash)
370{
371 return newSVptr (ptr, stash, newHV ());
367} 372}
368 373
369static int 374static int
370attachable_free (pTHX_ SV *sv, MAGIC *mg) 375attachable_free (pTHX_ SV *sv, MAGIC *mg)
371{ 376{
383 return 0; 388 return 0;
384} 389}
385 390
386MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; 391MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free};
387 392
388static SV * 393static SV * noinline
389newSVattachable (attachable *obj, HV *stash) 394newSVattachable (attachable *obj, HV *stash)
390{ 395{
391 if (!obj) 396 if (!obj)
392 return newSV (0); 397 return newSV (0);
393 398
479 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap 484 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap
480 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap 485 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap
481 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap 486 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap
482 && !sv_derived_from (sv, "cf::object"))) 487 && !sv_derived_from (sv, "cf::object")))
483 croak ("object of type cf::object expected"); 488 croak ("object of type cf::object expected");
489
490 return SvPTR_nc (sv);
491}
492
493static long noinline
494SvPTR_ornull_maptile (SV *sv)
495{
496 if (expect_false (!SvOK (sv))) return 0;
497
498 if (!SvROK (sv)
499 || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap
500 && SvSTASH (SvRV (sv)) != stash_ext_map_world
501 && !sv_derived_from (sv, "cf::map")))
502 croak ("object of type cf::map expected");
484 503
485 return SvPTR_nc (sv); 504 return SvPTR_nc (sv);
486} 505}
487 506
488static long noinline 507static long noinline
513static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 532static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
514static inline SV *to_sv (float v) { return newSVnv (v); } 533static inline SV *to_sv (float v) { return newSVnv (v); }
515static inline SV *to_sv (double v) { return newSVnv (v); } 534static inline SV *to_sv (double v) { return newSVnv (v); }
516static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 535static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); }
517static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } 536static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
537// gcc dislikes noilnine on to_sv
518static inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } 538static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); }
539static inline SV *to_sv (object * v) { return to_sv_ni (v); }
519static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 540static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
520static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 541static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
521static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 542static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
522static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 543static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
523static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 544static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
524static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); } 545static inline SV *to_sv (mapspace * v) { return newSVptr (v, stash_cf_mapspace_wrap); }
546static inline SV *to_sv (layout * v) { return newSVptr (v, stash_cf_layout_wrap); }
525 547
526static inline SV *to_sv (object & v) { return to_sv (&v); } 548static inline SV *to_sv (object & v) { return to_sv (&v); }
527static inline SV *to_sv (living & v) { return to_sv (&v); } 549static inline SV *to_sv (living & v) { return to_sv (&v); }
528 550
529static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 551static inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
565static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 587static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); }
566static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } 588static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); }
567static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } 589static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); }
568static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 590static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
569static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 591static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
570static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } 592static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); }
571static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } 593static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); }
572static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } 594static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); }
595static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull_maptile (sv); }
573static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 596static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
574static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); }
575static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } 597static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); }
576static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 598static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
577static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } 599static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); }
578static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } 600static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); }
579static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } 601static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); }
602static inline void sv_to (SV *sv, layout * &v) { v = (layout *) SvPTR_ornull (sv, "cf::layout"); }
580static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); } 603static inline void sv_to (SV *sv, object_freezer * &v) { v = (object_freezer *) SvPTR_ornull (sv, "cf::object::freezer"); }
581static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); } 604static inline void sv_to (SV *sv, object_thawer * &v) { v = (object_thawer *) SvPTR_ornull (sv, "cf::object::thawer" ); }
582 605
583//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 606//static inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
584static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 607static inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
695template<class type> 718template<class type>
696static void noinline 719static void noinline
697cf_obj_to (SV *arg, type &var) 720cf_obj_to (SV *arg, type &var)
698{ 721{
699 sv_to (arg, var); 722 sv_to (arg, var);
700 if (!var) 723 if (expect_false (!var))
701 croak ("must not pass invalid/null cf_obj here"); 724 croak ("must not pass invalid/null cf_obj here");
702} 725}
703 726
704template<class object> 727template<class object>
705static void noinline 728static void noinline
706cf_obj_ornull_to (SV *arg, object *&var) 729cf_obj_ornull_to (SV *arg, object *&var)
707{ 730{
708 if (SvOK (arg)) 731 if (SvOK (arg))
709 { 732 {
710 sv_to (arg, var); 733 sv_to (arg, var);
711 if (!var) 734 if (expect_false (!var))
712 croak ("unable to convert perl object to C++ object"); 735 croak ("unable to convert perl object to C++ object");
713 } 736 }
714 else 737 else
715 var = 0; 738 var = 0;
716} 739}
751 exit (EXIT_FAILURE); 774 exit (EXIT_FAILURE);
752 } 775 }
753 776
754 eval_pv ( 777 eval_pv (
755 "#line 1 'cfperl init'\n" 778 "#line 1 'cfperl init'\n"
756 "use EV ();\n" 779 "use EV ();\n" // required by bootstrap
757 "use Coro ();\n" 780 "use Coro ();\n" // required by bootstrap
758 "cf->bootstrap;\n" 781 "cf->bootstrap;\n" // required for cf::datadir
759 "unshift @INC, cf::datadir ();\n" 782 "unshift @INC, cf::datadir ();\n" // required for 'require' :)
760 "require cf;\n", 783 "require cf;\n",
761 0 784 0
762 ); 785 );
763 786
764 if (SvTRUE (ERRSV)) 787 if (SvTRUE (ERRSV))
1139 1162
1140 return retval; 1163 return retval;
1141} 1164}
1142 1165
1143maptile * 1166maptile *
1144find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty) 1167find_style (const_utf8_string dirname, const_utf8_string stylename, int difficulty, bool recurse)
1145{ 1168{
1146 CALL_BEGIN (3); 1169 CALL_BEGIN (4);
1147 CALL_ARG (dirname); 1170 CALL_ARG (dirname);
1148 CALL_ARG (stylename); 1171 CALL_ARG (stylename);
1149 CALL_ARG (difficulty); 1172 CALL_ARG (difficulty);
1173 CALL_ARG (recurse);
1150 CALL_CALL ("ext::map_random::find_style", G_SCALAR); 1174 CALL_CALL ("ext::map_random::find_style", G_SCALAR);
1151 1175
1152 maptile *retval = 0; 1176 maptile *retval = 0;
1153 if (count) sv_to (POPs, retval); 1177 if (count) sv_to (POPs, retval);
1154 1178
1377 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); 1401 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1);
1378 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); 1402 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1);
1379 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); 1403 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1);
1380 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1404 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1381 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); 1405 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1);
1406 stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1);
1407 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1);
1382 1408
1383 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); 1409 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV);
1384 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); 1410 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV);
1385 sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); 1411 sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV);
1386 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); 1412 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV);
1434# include "attackinc.h" 1460# include "attackinc.h"
1435# undef def 1461# undef def
1436# define def(uc, flags) const_iv (SK_ ## uc) 1462# define def(uc, flags) const_iv (SK_ ## uc)
1437# include "skillinc.h" 1463# include "skillinc.h"
1438# undef def 1464# undef def
1439 1465# define def(name, use, nonuse) const_iv (body_ ## name)
1440 const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster) 1466# include "slotinc.h"
1441 const_iv (logBacktrace) 1467# undef def
1442
1443 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1444 1468
1445 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1469 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1446 1470
1447 const_iv (MAX_TIME) 1471 const_iv (MAX_TIME)
1448 const_iv (MAXSOCKBUF) 1472 const_iv (MAXSOCKBUF)
1462 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) 1486 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE)
1463 1487
1464 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) 1488 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE)
1465 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) 1489 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY)
1466 1490
1467 const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING)
1468 const_iv (MAP_INACTIVE)
1469
1470 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) 1491 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT)
1471 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) 1492 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP)
1472 1493
1473 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1494 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1474 1495
1475 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) 1496 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES)
1476 }; 1497 };
1477 1498
1478 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1499 for (civ = const_iv + array_length (const_iv); civ-- > const_iv; )
1479 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); 1500 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv));
1480 1501
1481 static const struct { 1502 static const struct {
1482 const char *name; 1503 const char *name;
1483 int skip; 1504 int skip;
1489# undef def 1510# undef def
1490 }; 1511 };
1491 1512
1492 AV *av = get_av ("cf::EVENT", 1); 1513 AV *av = get_av ("cf::EVENT", 1);
1493 1514
1494 for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) 1515 for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; )
1495 { 1516 {
1496 AV *event = newAV (); 1517 AV *event = newAV ();
1497 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1518 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1498 av_push (event, newSViv (eiv->klass)); 1519 av_push (event, newSViv (eiv->klass));
1499 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1520 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1534 1555
1535 for_all_objects (op) 1556 for_all_objects (op)
1536 op->reattach (); 1557 op->reattach ();
1537} 1558}
1538 1559
1539# support function for map-world.ext
1540void _quantise (SV *data_sv, SV *plt_sv)
1541 CODE:
1542{
1543 if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV)
1544 croak ("_quantise called with invalid agruments");
1545
1546 plt_sv = SvRV (plt_sv);
1547 SV **plt = AvARRAY (plt_sv);
1548 int plt_count = AvFILL (plt_sv) + 1;
1549
1550 STRLEN len;
1551 char *data = SvPVbyte (data_sv, len);
1552 char *dst = data;
1553
1554 while (len >= 3)
1555 {
1556 for (SV **val_sv = plt + plt_count; val_sv-- > plt; )
1557 {
1558 char *val = SvPVX (*val_sv);
1559
1560 if (val [0] == data [0]
1561 && val [1] == data [1]
1562 && val [2] == data [2])
1563 {
1564 *dst++ = val [3];
1565 goto next;
1566 }
1567 }
1568
1569 croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d",
1570 (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2],
1571 dst - SvPVX (data_sv), len);
1572
1573 next:
1574 data += 3;
1575 len -= 3;
1576 }
1577
1578 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1579}
1580
1581void init_anim () 1560void init_anim ()
1582 1561
1583void init_globals () 1562void init_globals ()
1584 1563
1585void init_experience ()
1586
1587void init_attackmess () 1564void init_attackmess ()
1588 1565
1589void init_dynamic () 1566void init_dynamic ()
1590 1567
1591void load_settings () 1568void load_settings ()
1592 1569
1570void reload_exp_table ()
1571
1593void load_materials () 1572void reload_materials ()
1594 1573
1595void init_uuid () 1574void init_uuid ()
1596 CODE: 1575 CODE:
1597 UUID::init (); 1576 UUID::init ();
1598 1577
1664 switch (items) 1643 switch (items)
1665 { 1644 {
1666 case 0: RETVAL = gen (); break; 1645 case 0: RETVAL = gen (); break;
1667 case 1: RETVAL = gen (SvUV (ST (0))); break; 1646 case 1: RETVAL = gen (SvUV (ST (0))); break;
1668 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1647 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1669 default: croak ("cf::rndm requires none, one or two parameters."); break; 1648 default: croak ("cf::rndm requires zero, one or two parameters."); break;
1670 } 1649 }
1671} 1650}
1672 OUTPUT: 1651 OUTPUT:
1673 RETVAL 1652 RETVAL
1674 1653
1753 1732
1754int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1733int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1755 INIT: 1734 INIT:
1756#if __GLIBC__ 1735#if __GLIBC__
1757 mallopt (M_TOP_PAD, 1024 * 1024); 1736 mallopt (M_TOP_PAD, 1024 * 1024);
1758 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); 1737 mallopt (M_MMAP_THRESHOLD, 1024 * 1024);
1759 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory 1738 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1739 if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10))
1760 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1740 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1761#endif 1741#endif
1762 1742
1763int munlockall () 1743int munlockall ()
1764 1744
1765#endif 1745#endif
1798 1778
1799int random_roll (int min, int max, object *op, int goodbad); 1779int random_roll (int min, int max, object *op, int goodbad);
1800 1780
1801const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1781const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1802 1782
1803int
1804exp_to_level (val64 exp) 1783int exp_to_level (val64 exp)
1784
1785val64 level_to_min_exp (int level)
1786
1787SV *
1788attacktype_name (int atnr)
1805 CODE: 1789 CODE:
1806{ 1790 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1807 int i = 0; 1791 ? newSVpv (attacktype_name [atnr], 0)
1808 1792 : &PL_sv_undef;
1809 RETVAL = settings.max_level;
1810
1811 for (i = 1; i <= settings.max_level; i++)
1812 {
1813 if (levels[i] > exp)
1814 {
1815 RETVAL = i - 1;
1816 break;
1817 }
1818 }
1819}
1820 OUTPUT: RETVAL 1793 OUTPUT: RETVAL
1821 1794
1822val64
1823level_to_min_exp (int level)
1824 CODE:
1825 if (level > settings.max_level)
1826 RETVAL = levels[settings.max_level];
1827 else if (level < 1)
1828 RETVAL = 0;
1829 else
1830 RETVAL = levels[level];
1831 OUTPUT: RETVAL
1832
1833SV * 1795SV *
1834resistance_to_string (int atnr) 1796attacktype_desc (int atnr)
1835 CODE: 1797 CODE:
1836 if (atnr >= 0 && atnr < NROFATTACKS) 1798 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1799 ? newSVpv (attacktype_desc [atnr], 0)
1800 : &PL_sv_undef;
1801 OUTPUT: RETVAL
1802
1803SV *
1804resist_plus (int atnr)
1805 CODE:
1806 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1837 RETVAL = newSVpv (resist_plus[atnr], 0); 1807 ? newSVpv (resist_plus [atnr], 0)
1838 else 1808 : &PL_sv_undef;
1839 XSRETURN_UNDEF; 1809 OUTPUT: RETVAL
1810
1811SV *
1812change_resist_msg (int atnr)
1813 CODE:
1814 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1815 ? newSVpv (change_resist_msg [atnr], 0)
1816 : &PL_sv_undef;
1840 OUTPUT: RETVAL 1817 OUTPUT: RETVAL
1841 1818
1842UUID 1819UUID
1843uuid_cur () 1820uuid_cur ()
1844 CODE: 1821 CODE:
1894 CODE: 1871 CODE:
1895 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1872 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1896 OUTPUT: 1873 OUTPUT:
1897 RETVAL 1874 RETVAL
1898 1875
1876bool should_invoke (attachable *obj, int event)
1877 CODE:
1878 RETVAL = obj->should_invoke ((event_type)event);
1879 OUTPUT: RETVAL
1880
1899void 1881void
1900debug_trace (attachable *obj, bool on = true) 1882debug_trace (attachable *obj, bool on = true)
1901 CODE: 1883 CODE:
1902 obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; 1884 obj->attachable_flags &= ~attachable::F_DEBUG_TRACE;
1903 if (on) 1885 if (on)
1962int mortals_size () 1944int mortals_size ()
1963 CODE: 1945 CODE:
1964 RETVAL = attachable::mortals.size (); 1946 RETVAL = attachable::mortals.size ();
1965 OUTPUT: RETVAL 1947 OUTPUT: RETVAL
1966 1948
1967const_utf8_string slot_use_name (U32 slot) 1949const_utf8_string slot_name (U32 slot)
1968 ALIAS: 1950 ALIAS:
1951 slot_name = 0
1952 slot_use_name = 1
1969 slot_nonuse_name = 1 1953 slot_nonuse_name = 2
1970 CODE: 1954 CODE:
1971{ 1955{
1972 if (slot >= NUM_BODY_LOCATIONS) 1956 if (slot >= NUM_BODY_LOCATIONS)
1973 croak ("body slot index out of range"); 1957 croak ("body slot index out of range");
1974 1958
1975 switch (ix) 1959 switch (ix)
1976 { 1960 {
1961 case 0: RETVAL = body_locations[slot].name ; break;
1977 case 0: RETVAL = body_locations[slot].use_name; break; 1962 case 1: RETVAL = body_locations[slot].use_name ; break;
1978 case 1: RETVAL = body_locations[slot].nonuse_name; break; 1963 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1979 } 1964 }
1980} 1965}
1981 OUTPUT: 1966 OUTPUT:
1982 RETVAL 1967 RETVAL
1983 1968
2028 OUTPUT: 2013 OUTPUT:
2029 RETVAL 2014 RETVAL
2030 2015
2031object *find_best_object_match (object *op, utf8_string match) 2016object *find_best_object_match (object *op, utf8_string match)
2032 2017
2033object *find_marked_object (object *op)
2034
2035int need_identify (object *obj);
2036
2037int apply_shop_mat (object *shop_mat, object *op); 2018int apply_shop_mat (object *shop_mat, object *op);
2038 2019
2039int move (object *op, int dir, object *originator = op) 2020int move (object *op, int dir, object *originator = op)
2040 CODE: 2021 CODE:
2041 RETVAL = op->move (dir, originator); 2022 RETVAL = op->move (dir, originator);
2093 2074
2094void pick_up (object *who, object *op) 2075void pick_up (object *who, object *op)
2095 2076
2096void update_object (object *op, int action) 2077void update_object (object *op, int action)
2097 2078
2098void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) 2079void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0)
2099 2080
2100void player_lvl_adj (object *who, object *skill = 0) 2081void player_lvl_adj (object *who, object *skill = 0)
2101 2082
2102int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 2083int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
2103 2084
2119# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2100# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2120 2101
2121object *new (utf8_string archetype = 0) 2102object *new (utf8_string archetype = 0)
2122 PROTOTYPE: ;$ 2103 PROTOTYPE: ;$
2123 CODE: 2104 CODE:
2124 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2105 RETVAL = archetype
2106 ? archetype::get (archetype)
2107 : object::create ();
2125 OUTPUT: 2108 OUTPUT:
2126 RETVAL 2109 RETVAL
2127 2110
2128object *generate (utf8_string arch, object *creator) 2111object *generate (utf8_string arch, object *creator)
2129 CODE: 2112 CODE:
2130 object *obj = get_archetype (arch); 2113 object *obj = archetype::get (arch);
2131 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2114 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2132 RETVAL = obj; 2115 RETVAL = obj;
2133 OUTPUT: 2116 OUTPUT:
2134 RETVAL 2117 RETVAL
2135 2118
2148 RETVAL = 0; 2131 RETVAL = 0;
2149} 2132}
2150 2133
2151shstr 2134shstr
2152object::kv_get (shstr key) 2135object::kv_get (shstr key)
2136 CODE:
2137 RETVAL = THIS->kv.get (key);
2138 OUTPUT:
2139 RETVAL
2153 2140
2154void 2141void
2155object::kv_del (shstr key) 2142object::kv_del (shstr key)
2143 CODE:
2144 THIS->kv.del (key);
2156 2145
2157void 2146void
2158object::kv_set (shstr key, shstr value) 2147object::kv_set (shstr key, shstr value)
2148 CODE:
2149 THIS->kv.set (key, value);
2159 2150
2160object *get_nearest_player (object *ob) 2151object *get_nearest_player (object *ob)
2161 ALIAS: nearest_player = 0 2152 ALIAS: nearest_player = 0
2162 PREINIT: 2153 PREINIT:
2163 extern object *get_nearest_player (object *); 2154 extern object *get_nearest_player (object *);
2366 if (pl->ob && pl->ob->map == THIS) 2357 if (pl->ob && pl->ob->map == THIS)
2367 PUSHs (sv_2mortal (to_sv (pl->ob))); 2358 PUSHs (sv_2mortal (to_sv (pl->ob)));
2368 } 2359 }
2369 2360
2370void 2361void
2362maptile::gen_quadmap (int x, int y, int z)
2363 CODE:
2364 gen_quadmap (THIS, x * 50, y * 50, z);
2365
2366void
2371maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2367maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2372 CODE: 2368 CODE:
2373{ 2369{
2374 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2370 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2375 croak ("maptile::add_underlay: palette must be arrayref"); 2371 croak ("maptile::add_underlay: palette must be arrayref");
2391 2387
2392 if (IN_RANGE_EXC (offs, 0, idxlen)) 2388 if (IN_RANGE_EXC (offs, 0, idxlen))
2393 { 2389 {
2394 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2390 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2395 { 2391 {
2396 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2392 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2397 ob->flag [FLAG_NO_MAP_SAVE] = true; 2393 ob->flag [FLAG_NO_MAP_SAVE] = true;
2398 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2394 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2399 2395
2400 if (ob->randomitems && !ob->above) 2396 if (ob->randomitems && !ob->above)
2401 { 2397 {
2405 op->flag [FLAG_NO_MAP_SAVE] = true; 2401 op->flag [FLAG_NO_MAP_SAVE] = true;
2406 // TODO: if this is a pickable object, then the item 2402 // TODO: if this is a pickable object, then the item
2407 // will at a bit weird - saving inside the player 2403 // will at a bit weird - saving inside the player
2408 // will clear the flag, but when the player drops 2404 // will clear the flag, but when the player drops
2409 // it without logging out, it keeps the flag. 2405 // it without logging out, it keeps the flag.
2410 // nobody ahs reported this, but this can be rather 2406 // nobody has reported this, but this can be rather
2411 // annoying on persistent maps. 2407 // annoying on persistent maps.
2412 } 2408 }
2413 } 2409 }
2414 } 2410 }
2415 } 2411 }
2416
2417 skip: ; 2412 skip: ;
2418 } 2413 }
2419} 2414}
2420 2415
2421void 2416void
2452 for (int x = 0; x < THIS->width; ++x) 2447 for (int x = 0; x < THIS->width; ++x)
2453 for (int y = 0; y < THIS->height; ++y) 2448 for (int y = 0; y < THIS->height; ++y)
2454 { 2449 {
2455 region *rgn = THIS->region (x, y); 2450 region *rgn = THIS->region (x, y);
2456 2451
2457 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2458 if (object *op = THIS->at (x, y).top) 2452 if (object *op = THIS->at (x, y).top)
2459 if (rgn->treasure && rndm () < rgn->treasure_density) 2453 if (rgn->treasure && rndm () < rgn->treasure_density)
2460 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2454 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2461 } 2455 }
2462 2456
2468 if (oblinkpt *obp = map->find_link (connection)) 2462 if (oblinkpt *obp = map->find_link (connection))
2469 for (objectlink *ol = obp->link; ol; ol = ol->next) 2463 for (objectlink *ol = obp->link; ol; ol = ol->next)
2470 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); 2464 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob)));
2471 2465
2472void 2466void
2473get_map_flags (maptile *map, int x, int y) 2467xy_normalise (maptile *map, int x, int y, int dir = 0)
2474 PPCODE: 2468 PPCODE:
2475{ 2469{
2476 maptile *nmap = 0; 2470 mapxy pos (map, x, y);
2477 I16 nx = 0, ny = 0; 2471 if (!pos.move (dir).normalise ())
2472 XSRETURN_EMPTY;
2478 2473
2479 PUTBACK;
2480 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2481 SPAGAIN;
2482
2483 EXTEND (SP, 4); 2474 EXTEND (SP, 3);
2484 PUSHs (sv_2mortal (newSViv (flags)));
2485
2486 if (GIMME_V == G_ARRAY)
2487 {
2488 PUSHs (sv_2mortal (to_sv (nmap))); 2475 PUSHs (sv_2mortal (to_sv (pos.m)));
2489 PUSHs (sv_2mortal (newSViv (nx))); 2476 PUSHs (sv_2mortal (to_sv (pos.x)));
2490 PUSHs (sv_2mortal (newSViv (ny))); 2477 PUSHs (sv_2mortal (to_sv (pos.y)));
2491 }
2492} 2478}
2493 2479
2494mapspace * 2480mapspace *
2495ms (maptile *map, unsigned int x, unsigned int y) 2481ms (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2496 PROTOTYPE: $$$ 2482 PROTOTYPE: $$$;$
2497 CODE: 2483 CODE:
2498{ 2484{
2499 maptile *nmap = 0; 2485 mapxy pos (map, x, y);
2500 I16 nx, ny; 2486 if (!pos.move (dir).normalise ())
2501
2502 PUTBACK;
2503 get_map_flags (map, &nmap, x, y, &nx, &ny);
2504 SPAGAIN;
2505
2506 if (!nmap)
2507 XSRETURN_UNDEF; 2487 XSRETURN_UNDEF;
2508 2488
2509 RETVAL = &nmap->at (nx, ny); 2489 RETVAL = &*pos;
2510} 2490}
2511 OUTPUT: 2491 OUTPUT:
2512 RETVAL 2492 RETVAL
2513 2493
2514void 2494void
2515at (maptile *map, unsigned int x, unsigned int y) 2495at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2516 PROTOTYPE: $$$ 2496 PROTOTYPE: $$$;$
2517 PPCODE: 2497 PPCODE:
2518{ 2498 mapxy pos (map, x, y);
2519 maptile *nmap = 0; 2499 if (pos.move (dir).normalise ())
2520 I16 nx, ny;
2521
2522 PUTBACK;
2523 get_map_flags (map, &nmap, x, y, &nx, &ny);
2524 SPAGAIN;
2525
2526 if (nmap)
2527 for (object *o = nmap->at (nx, ny).bot; o; o = o->above) 2500 for (object *o = pos->bot; o; o = o->above)
2528 XPUSHs (sv_2mortal (to_sv (o))); 2501 XPUSHs (sv_2mortal (to_sv (o)));
2529}
2530 2502
2531SV * 2503SV *
2532bot_at (maptile *map, unsigned int x, unsigned int y) 2504bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2533 PROTOTYPE: $$$ 2505 PROTOTYPE: $$$;$
2534 ALIAS: 2506 ALIAS:
2535 top_at = 1 2507 top_at = 1
2536 flags_at = 2 2508 flags_at = 2
2537 light_at = 3 2509 light_at = 3
2538 move_block_at = 4 2510 move_block_at = 4
2539 move_slow_at = 5 2511 move_slow_at = 5
2540 move_on_at = 6 2512 move_on_at = 6
2541 move_off_at = 7 2513 move_off_at = 7
2542 CODE: 2514 CODE:
2543{ 2515{
2544 sint16 nx = x; 2516 mapxy pos (map, x, y);
2545 sint16 ny = y; 2517 if (!pos.move (dir).normalise ())
2546
2547 if (!xy_normalise (map, nx, ny))
2548 XSRETURN_UNDEF; 2518 XSRETURN_UNDEF;
2549 2519
2550 mapspace &ms = map->at (nx, ny); 2520 mapspace &ms = *pos;
2551 2521
2552 ms.update (); 2522 ms.update ();
2553 2523
2554 switch (ix) 2524 switch (ix)
2555 { 2525 {
2565} 2535}
2566 OUTPUT: RETVAL 2536 OUTPUT: RETVAL
2567 2537
2568# worst xs function of my life 2538# worst xs function of my life
2569bool 2539bool
2570_create_random_map (\ 2540_create_random_map (maptile *self, SV *options)
2571 maptile *self,\
2572 utf8_string wallstyle,\
2573 utf8_string wall_name,\
2574 utf8_string floorstyle,\
2575 utf8_string monsterstyle,\
2576 utf8_string treasurestyle,\
2577 utf8_string layoutstyle,\
2578 utf8_string doorstyle,\
2579 utf8_string decorstyle,\
2580 utf8_string miningstyle,\
2581 utf8_string origin_map,\
2582 utf8_string final_map,\
2583 utf8_string exitstyle,\
2584 utf8_string this_map,\
2585 utf8_string exit_on_final_map,\
2586 int xsize,\
2587 int ysize,\
2588 int expand2x,\
2589 int layoutoptions1,\
2590 int layoutoptions2,\
2591 int layoutoptions3,\
2592 int symmetry,\
2593 int difficulty,\
2594 int difficulty_given,\
2595 float difficulty_increase,\
2596 int dungeon_level,\
2597 int dungeon_depth,\
2598 int decoroptions,\
2599 int orientation,\
2600 int origin_y,\
2601 int origin_x,\
2602 U32 random_seed,\
2603 val64 total_map_hp,\
2604 int map_layout_style,\
2605 int treasureoptions,\
2606 int symmetry_used,\
2607 region *region,\
2608 utf8_string custom\
2609)
2610 CODE: 2541 CODE:
2611{ 2542{
2612 random_map_params rmp; 2543 random_map_params rmp ((HV *)SvRV (options));
2613
2614 assign (rmp.wallstyle , wallstyle);
2615 assign (rmp.wall_name , wall_name);
2616 assign (rmp.floorstyle , floorstyle);
2617 assign (rmp.monsterstyle , monsterstyle);
2618 assign (rmp.treasurestyle , treasurestyle);
2619 assign (rmp.layoutstyle , layoutstyle);
2620 assign (rmp.doorstyle , doorstyle);
2621 assign (rmp.decorstyle , decorstyle);
2622 assign (rmp.miningstyle , miningstyle);
2623 assign (rmp.exitstyle , exitstyle);
2624 assign (rmp.exit_on_final_map, exit_on_final_map);
2625
2626 rmp.origin_map = origin_map;
2627 rmp.final_map = final_map;
2628 rmp.this_map = this_map;
2629 rmp.xsize = xsize;
2630 rmp.ysize = ysize;
2631 rmp.expand2x = expand2x;
2632 rmp.layoutoptions1 = layoutoptions1;
2633 rmp.layoutoptions2 = layoutoptions2;
2634 rmp.layoutoptions3 = layoutoptions3;
2635 rmp.symmetry = symmetry;
2636 rmp.difficulty = difficulty;
2637 rmp.difficulty_given = difficulty_given;
2638 rmp.difficulty_increase = difficulty_increase;
2639 rmp.dungeon_level = dungeon_level;
2640 rmp.dungeon_depth = dungeon_depth;
2641 rmp.decoroptions = decoroptions;
2642 rmp.orientation = orientation;
2643 rmp.origin_y = origin_y;
2644 rmp.origin_x = origin_x;
2645 rmp.random_seed = random_seed;
2646 rmp.total_map_hp = (uint64_t) total_map_hp;
2647 rmp.map_layout_style = map_layout_style;
2648 rmp.treasureoptions = treasureoptions;
2649 rmp.symmetry_used = symmetry_used;
2650 rmp.region = region;
2651 rmp.custom = custom;
2652
2653 RETVAL = self->generate_random_map (&rmp); 2544 RETVAL = self->generate_random_map (&rmp);
2654} 2545}
2655 OUTPUT: 2546 OUTPUT:
2656 RETVAL 2547 RETVAL
2657 2548
2688void 2579void
2689list () 2580list ()
2690 PPCODE: 2581 PPCODE:
2691 for_all_regions (rgn) 2582 for_all_regions (rgn)
2692 XPUSHs (sv_2mortal (to_sv (rgn))); 2583 XPUSHs (sv_2mortal (to_sv (rgn)));
2693
2694region *find (utf8_string name)
2695 PROTOTYPE: $
2696 CODE:
2697 RETVAL = region::find (name);
2698 OUTPUT: RETVAL
2699 2584
2700int specificity (region *rgn) 2585int specificity (region *rgn)
2701 CODE: 2586 CODE:
2702 RETVAL = 0; 2587 RETVAL = 0;
2703 while (rgn = rgn->parent) 2588 while (rgn = rgn->parent)
2807 while (!RETVAL); // crude way to leave index 0 2692 while (!RETVAL); // crude way to leave index 0
2808 2693
2809 faces [RETVAL].name = name; 2694 faces [RETVAL].name = name;
2810 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); 2695 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL));
2811 2696
2812 if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; 2697 if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL;
2813 if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; 2698 if (!strcmp (name, EMPTY_FACE_NAME )) empty_face = RETVAL;
2699 if (!strcmp (name, MAGICMOUTH_FACE_NAME)) magicmouth_face = RETVAL;
2814} 2700}
2815 OUTPUT: RETVAL 2701 OUTPUT: RETVAL
2816 2702
2817void set_type (faceidx idx, int value) 2703void set_type (faceidx idx, int value)
2818 ALIAS: 2704 ALIAS:
2834 2720
2835void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2721void set_data (faceidx idx, int faceset, SV *data, SV *chksum)
2836 CODE: 2722 CODE:
2837{ 2723{
2838 faceinfo *f = face_info (idx); assert (f); 2724 faceinfo *f = face_info (idx); assert (f);
2839 facedata *d = &(faceset ? f->data64 : f->data32); 2725 facedata *d = f->face + faceset;
2840 sv_to (data, d->data); 2726 sv_to (data, d->data);
2841 STRLEN clen; 2727 STRLEN clen;
2842 char *cdata = SvPVbyte (chksum, clen); 2728 char *cdata = SvPVbyte (chksum, clen);
2843 clen = min (CHKSUM_MAXLEN, clen); 2729 clen = min (CHKSUM_MAXLEN, clen);
2844 2730
2952 sv_to (sv, self); 2838 sv_to (sv, self);
2953 delete self; 2839 delete self;
2954 2840
2955MODULE = cf PACKAGE = cf::object::thawer 2841MODULE = cf PACKAGE = cf::object::thawer
2956 2842
2957INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/cfperl.h | 2843INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h |
2844
2845bool
2846errors_are_fatal (bool fatal)
2847 CODE:
2848 RETVAL = object_thawer::errors_are_fatal;
2849 object_thawer::errors_are_fatal = fatal;
2850 OUTPUT:
2851 RETVAL
2958 2852
2959SV * 2853SV *
2960new_from_file (char *klass, octet_string path) 2854new_from_file (char *klass, octet_string path)
2961 CODE: 2855 CODE:
2962 object_thawer *f = new object_thawer (path); 2856 object_thawer *f = new object_thawer (path);
2988 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2882 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2989 2883
2990 self->skip (); 2884 self->skip ();
2991 } 2885 }
2992 2886
2887MODULE = cf PACKAGE = cf::layout
2888
2889INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2890

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines