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.371 by root, Thu Apr 15 02:51:39 2010 UTC vs.
Revision 1.388 by root, Wed Jun 30 01:57:54 2010 UTC

52#include <XSUB.h> 52#include <XSUB.h>
53 53
54#include "CoroAPI.h" 54#include "CoroAPI.h"
55#include "perlxsi.c" 55#include "perlxsi.c"
56 56
57extern sint64 *levels; // the experience table
58
59typedef object_thawer &object_thawer_ref; 57typedef object_thawer &object_thawer_ref;
60typedef object_freezer &object_freezer_ref; 58typedef object_freezer &object_freezer_ref;
61 59
62typedef std::string std__string; 60typedef std::string std__string;
63 61
85 *stash_cf_mapspace_wrap, 83 *stash_cf_mapspace_wrap,
86 *stash_cf_client_wrap, 84 *stash_cf_client_wrap,
87 *stash_cf_arch_wrap, 85 *stash_cf_arch_wrap,
88 *stash_cf_party_wrap, 86 *stash_cf_party_wrap,
89 *stash_cf_region_wrap, 87 *stash_cf_region_wrap,
90 *stash_cf_living_wrap; 88 *stash_cf_living_wrap,
89 *stash_ext_map_world;
91 90
92static SV 91static SV
93 *cv_cf_do_invoke, 92 *cv_cf_do_invoke,
94 *cv_cf__can_merge, 93 *cv_cf__can_merge,
95 *cv_cf_client_send_msg, 94 *cv_cf_client_send_msg,
123 122
124 return sv; 123 return sv;
125} 124}
126#endif 125#endif
127 126
128static noinline utf8_string 127noinline utf8_string
129cfSvPVutf8_nolen (SV *sv) 128cfSvPVutf8_nolen (SV *sv)
130{ 129{
131 SvGETMAGIC (sv); 130 SvGETMAGIC (sv);
132 131
133 if (SvPOK (sv)) 132 if (SvPOK (sv))
353#endif 352#endif
354 353
355////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 354//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
356 355
357static SV * 356static SV *
358newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) 357newSVptr (void *ptr, HV *stash, HV *hv)
359{ 358{
360 SV *sv;
361
362 if (!ptr) 359 if (!ptr)
363 return newSV (0); 360 return newSV (0);
364 361
365 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); 362 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0);
366 return sv_bless (newRV_noinc ((SV *)hv), stash); 363 return sv_bless (newRV_noinc ((SV *)hv), stash);
364}
365
366static SV * noinline
367newSVptr (void *ptr, HV *stash)
368{
369 return newSVptr (ptr, stash, newHV ());
367} 370}
368 371
369static int 372static int
370attachable_free (pTHX_ SV *sv, MAGIC *mg) 373attachable_free (pTHX_ SV *sv, MAGIC *mg)
371{ 374{
383 return 0; 386 return 0;
384} 387}
385 388
386MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; 389MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free};
387 390
388static SV * 391static SV * noinline
389newSVattachable (attachable *obj, HV *stash) 392newSVattachable (attachable *obj, HV *stash)
390{ 393{
391 if (!obj) 394 if (!obj)
392 return newSV (0); 395 return newSV (0);
393 396
479 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap 482 || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap
480 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap 483 && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap
481 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap 484 && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap
482 && !sv_derived_from (sv, "cf::object"))) 485 && !sv_derived_from (sv, "cf::object")))
483 croak ("object of type cf::object expected"); 486 croak ("object of type cf::object expected");
487
488 return SvPTR_nc (sv);
489}
490
491static long noinline
492SvPTR_ornull_maptile (SV *sv)
493{
494 if (expect_false (!SvOK (sv))) return 0;
495
496 if (!SvROK (sv)
497 || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap
498 && SvSTASH (SvRV (sv)) != stash_ext_map_world
499 && !sv_derived_from (sv, "cf::map")))
500 croak ("object of type cf::map expected");
484 501
485 return SvPTR_nc (sv); 502 return SvPTR_nc (sv);
486} 503}
487 504
488static long noinline 505static long noinline
513static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 530static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
514static inline SV *to_sv (float v) { return newSVnv (v); } 531static inline SV *to_sv (float v) { return newSVnv (v); }
515static inline SV *to_sv (double v) { return newSVnv (v); } 532static inline SV *to_sv (double v) { return newSVnv (v); }
516static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 533static 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); } 534static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
535// 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); } 536static noinline 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); }
519static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 538static 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); } 539static 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); } 540static 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); } 541static 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); } 542static inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
565static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 584static 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); } 585static 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); } 586static 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); } 587static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
569static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 588static 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); } 589static 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); } 590static 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); } 591static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); }
592static 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"); } 593static 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"); } 594static 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"); } 595static 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"); } 596static 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"); } 597static 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"); } 598static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); }
695template<class type> 714template<class type>
696static void noinline 715static void noinline
697cf_obj_to (SV *arg, type &var) 716cf_obj_to (SV *arg, type &var)
698{ 717{
699 sv_to (arg, var); 718 sv_to (arg, var);
700 if (!var) 719 if (expect_false (!var))
701 croak ("must not pass invalid/null cf_obj here"); 720 croak ("must not pass invalid/null cf_obj here");
702} 721}
703 722
704template<class object> 723template<class object>
705static void noinline 724static void noinline
706cf_obj_ornull_to (SV *arg, object *&var) 725cf_obj_ornull_to (SV *arg, object *&var)
707{ 726{
708 if (SvOK (arg)) 727 if (SvOK (arg))
709 { 728 {
710 sv_to (arg, var); 729 sv_to (arg, var);
711 if (!var) 730 if (expect_false (!var))
712 croak ("unable to convert perl object to C++ object"); 731 croak ("unable to convert perl object to C++ object");
713 } 732 }
714 else 733 else
715 var = 0; 734 var = 0;
716} 735}
751 exit (EXIT_FAILURE); 770 exit (EXIT_FAILURE);
752 } 771 }
753 772
754 eval_pv ( 773 eval_pv (
755 "#line 1 'cfperl init'\n" 774 "#line 1 'cfperl init'\n"
756 "use EV ();\n" 775 "use EV ();\n" // required by bootstrap
757 "use Coro ();\n" 776 "use Coro ();\n" // required by bootstrap
758 "cf->bootstrap;\n" 777 "cf->bootstrap;\n" // required for cf::datadir
759 "unshift @INC, cf::datadir ();\n" 778 "unshift @INC, cf::datadir ();\n" // required for 'require' :)
760 "require cf;\n", 779 "require cf;\n",
761 0 780 0
762 ); 781 );
763 782
764 if (SvTRUE (ERRSV)) 783 if (SvTRUE (ERRSV))
1378 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); 1397 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1);
1379 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); 1398 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1);
1380 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); 1399 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1);
1381 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1400 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1382 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); 1401 stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1);
1402 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1);
1383 1403
1384 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); 1404 sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV);
1385 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); 1405 sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV);
1386 sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); 1406 sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV);
1387 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); 1407 sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV);
1436# undef def 1456# undef def
1437# define def(uc, flags) const_iv (SK_ ## uc) 1457# define def(uc, flags) const_iv (SK_ ## uc)
1438# include "skillinc.h" 1458# include "skillinc.h"
1439# undef def 1459# undef def
1440 1460
1441 const_iv (llevError) const_iv (llevInfo) const_iv (llevDebug) const_iv (llevMonster)
1442 const_iv (logBacktrace)
1443
1444 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1461 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1445 1462
1446 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1463 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1447 1464
1448 const_iv (MAX_TIME) 1465 const_iv (MAX_TIME)
1474 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1491 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1475 1492
1476 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) 1493 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES)
1477 }; 1494 };
1478 1495
1479 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1496 for (civ = const_iv + array_length (const_iv); civ-- > const_iv; )
1480 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); 1497 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv));
1481 1498
1482 static const struct { 1499 static const struct {
1483 const char *name; 1500 const char *name;
1484 int skip; 1501 int skip;
1490# undef def 1507# undef def
1491 }; 1508 };
1492 1509
1493 AV *av = get_av ("cf::EVENT", 1); 1510 AV *av = get_av ("cf::EVENT", 1);
1494 1511
1495 for (eiv = event_iv + sizeof (event_iv) / sizeof (event_iv [0]); eiv-- > event_iv; ) 1512 for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; )
1496 { 1513 {
1497 AV *event = newAV (); 1514 AV *event = newAV ();
1498 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1515 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1499 av_push (event, newSViv (eiv->klass)); 1516 av_push (event, newSViv (eiv->klass));
1500 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1517 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1581 1598
1582void init_anim () 1599void init_anim ()
1583 1600
1584void init_globals () 1601void init_globals ()
1585 1602
1586void init_experience ()
1587
1588void init_attackmess () 1603void init_attackmess ()
1589 1604
1590void init_dynamic () 1605void init_dynamic ()
1591 1606
1592void load_settings () 1607void load_settings ()
1593 1608
1609void reload_exp_table ()
1610
1594void load_materials () 1611void reload_materials ()
1595 1612
1596void init_uuid () 1613void init_uuid ()
1597 CODE: 1614 CODE:
1598 UUID::init (); 1615 UUID::init ();
1599 1616
1799 1816
1800int random_roll (int min, int max, object *op, int goodbad); 1817int random_roll (int min, int max, object *op, int goodbad);
1801 1818
1802const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1819const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1803 1820
1804int
1805exp_to_level (val64 exp) 1821int exp_to_level (val64 exp)
1806 CODE:
1807{
1808 int i = 0;
1809 1822
1810 RETVAL = settings.max_level;
1811
1812 for (i = 1; i <= settings.max_level; i++)
1813 {
1814 if (levels[i] > exp)
1815 {
1816 RETVAL = i - 1;
1817 break;
1818 }
1819 }
1820}
1821 OUTPUT: RETVAL
1822
1823val64
1824level_to_min_exp (int level) 1823val64 level_to_min_exp (int level)
1825 CODE:
1826 if (level > settings.max_level)
1827 RETVAL = levels[settings.max_level];
1828 else if (level < 1)
1829 RETVAL = 0;
1830 else
1831 RETVAL = levels[level];
1832 OUTPUT: RETVAL
1833 1824
1834SV * 1825SV *
1835resistance_to_string (int atnr) 1826resistance_to_string (int atnr)
1836 CODE: 1827 CODE:
1837 if (atnr >= 0 && atnr < NROFATTACKS) 1828 if (atnr >= 0 && atnr < NROFATTACKS)
1895 CODE: 1886 CODE:
1896 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1887 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1897 OUTPUT: 1888 OUTPUT:
1898 RETVAL 1889 RETVAL
1899 1890
1891bool should_invoke (attachable *obj, int event)
1892 CODE:
1893 RETVAL = obj->should_invoke ((event_type)event);
1894 OUTPUT: RETVAL
1895
1900void 1896void
1901debug_trace (attachable *obj, bool on = true) 1897debug_trace (attachable *obj, bool on = true)
1902 CODE: 1898 CODE:
1903 obj->attachable_flags &= ~attachable::F_DEBUG_TRACE; 1899 obj->attachable_flags &= ~attachable::F_DEBUG_TRACE;
1904 if (on) 1900 if (on)
2090 2086
2091void pick_up (object *who, object *op) 2087void pick_up (object *who, object *op)
2092 2088
2093void update_object (object *op, int action) 2089void update_object (object *op, int action)
2094 2090
2095void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) 2091void change_exp (object *op, uint64 exp, shstr_tmp skill_name = shstr_tmp (), int flag = 0)
2096 2092
2097void player_lvl_adj (object *who, object *skill = 0) 2093void player_lvl_adj (object *who, object *skill = 0)
2098 2094
2099int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 2095int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
2100 2096
2465 if (oblinkpt *obp = map->find_link (connection)) 2461 if (oblinkpt *obp = map->find_link (connection))
2466 for (objectlink *ol = obp->link; ol; ol = ol->next) 2462 for (objectlink *ol = obp->link; ol; ol = ol->next)
2467 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); 2463 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob)));
2468 2464
2469void 2465void
2470get_map_flags (maptile *map, int x, int y) 2466xy_normalise (maptile *map, int x, int y, int dir = 0)
2471 PPCODE: 2467 PPCODE:
2472{ 2468{
2473 maptile *nmap = 0; 2469 mapxy pos (map, x, y);
2474 I16 nx = 0, ny = 0; 2470 if (!pos.move (dir).normalise ())
2471 XSRETURN_EMPTY;
2475 2472
2476 PUTBACK;
2477 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2478 SPAGAIN;
2479
2480 EXTEND (SP, 4); 2473 EXTEND (SP, 3);
2481 PUSHs (sv_2mortal (newSViv (flags)));
2482
2483 if (GIMME_V == G_ARRAY)
2484 {
2485 PUSHs (sv_2mortal (to_sv (nmap))); 2474 PUSHs (sv_2mortal (to_sv (pos.m)));
2486 PUSHs (sv_2mortal (newSViv (nx))); 2475 PUSHs (sv_2mortal (to_sv (pos.x)));
2487 PUSHs (sv_2mortal (newSViv (ny))); 2476 PUSHs (sv_2mortal (to_sv (pos.y)));
2488 }
2489} 2477}
2490 2478
2491mapspace * 2479mapspace *
2492ms (maptile *map, unsigned int x, unsigned int y) 2480ms (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2493 PROTOTYPE: $$$ 2481 PROTOTYPE: $$$;$
2494 CODE: 2482 CODE:
2495{ 2483{
2496 maptile *nmap = 0; 2484 mapxy pos (map, x, y);
2497 I16 nx, ny; 2485 if (!pos.move (dir).normalise ())
2498
2499 PUTBACK;
2500 get_map_flags (map, &nmap, x, y, &nx, &ny);
2501 SPAGAIN;
2502
2503 if (!nmap)
2504 XSRETURN_UNDEF; 2486 XSRETURN_UNDEF;
2505 2487
2506 RETVAL = &nmap->at (nx, ny); 2488 RETVAL = &*pos;
2507} 2489}
2508 OUTPUT: 2490 OUTPUT:
2509 RETVAL 2491 RETVAL
2510 2492
2511void 2493void
2512at (maptile *map, unsigned int x, unsigned int y) 2494at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2513 PROTOTYPE: $$$ 2495 PROTOTYPE: $$$;$
2514 PPCODE: 2496 PPCODE:
2515{ 2497 mapxy pos (map, x, y);
2516 maptile *nmap = 0; 2498 if (pos.move (dir).normalise ())
2517 I16 nx, ny;
2518
2519 PUTBACK;
2520 get_map_flags (map, &nmap, x, y, &nx, &ny);
2521 SPAGAIN;
2522
2523 if (nmap)
2524 for (object *o = nmap->at (nx, ny).bot; o; o = o->above) 2499 for (object *o = pos->bot; o; o = o->above)
2525 XPUSHs (sv_2mortal (to_sv (o))); 2500 XPUSHs (sv_2mortal (to_sv (o)));
2526}
2527 2501
2528SV * 2502SV *
2529bot_at (maptile *map, unsigned int x, unsigned int y) 2503bot_at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2530 PROTOTYPE: $$$ 2504 PROTOTYPE: $$$;$
2531 ALIAS: 2505 ALIAS:
2532 top_at = 1 2506 top_at = 1
2533 flags_at = 2 2507 flags_at = 2
2534 light_at = 3 2508 light_at = 3
2535 move_block_at = 4 2509 move_block_at = 4
2536 move_slow_at = 5 2510 move_slow_at = 5
2537 move_on_at = 6 2511 move_on_at = 6
2538 move_off_at = 7 2512 move_off_at = 7
2539 CODE: 2513 CODE:
2540{ 2514{
2541 sint16 nx = x; 2515 mapxy pos (map, x, y);
2542 sint16 ny = y; 2516 if (!pos.move (dir).normalise ())
2543
2544 if (!xy_normalise (map, nx, ny))
2545 XSRETURN_UNDEF; 2517 XSRETURN_UNDEF;
2546 2518
2547 mapspace &ms = map->at (nx, ny); 2519 mapspace &ms = *pos;
2548 2520
2549 ms.update (); 2521 ms.update ();
2550 2522
2551 switch (ix) 2523 switch (ix)
2552 { 2524 {
2564 2536
2565# worst xs function of my life 2537# worst xs function of my life
2566bool 2538bool
2567_create_random_map (\ 2539_create_random_map (\
2568 maptile *self,\ 2540 maptile *self,\
2569 utf8_string wallstyle,\ 2541 SV *options,\
2570 utf8_string wall_name,\
2571 utf8_string floorstyle,\
2572 utf8_string monsterstyle,\
2573 utf8_string treasurestyle,\
2574 utf8_string layoutstyle,\
2575 utf8_string doorstyle,\
2576 utf8_string decorstyle,\
2577 utf8_string miningstyle,\
2578 utf8_string origin_map,\
2579 utf8_string final_map,\
2580 utf8_string exitstyle,\
2581 utf8_string this_map,\
2582 utf8_string exit_on_final_map,\
2583 int xsize,\
2584 int ysize,\
2585 int expand2x,\
2586 int layoutoptions1,\
2587 int layoutoptions2,\
2588 int layoutoptions3,\
2589 int symmetry,\
2590 int difficulty,\
2591 int difficulty_given,\
2592 float difficulty_increase,\
2593 int dungeon_level,\
2594 int dungeon_depth,\
2595 int decoroptions,\
2596 int orientation,\
2597 int origin_y,\
2598 int origin_x,\
2599 U32 random_seed,\
2600 val64 total_map_hp,\ 2542 val64 total_map_hp,\
2601 int map_layout_style,\
2602 int treasureoptions,\
2603 int symmetry_used,\
2604 region *region,\ 2543 region *region\
2605 utf8_string custom\
2606) 2544)
2607 CODE: 2545 CODE:
2608{ 2546{
2609 random_map_params rmp; 2547 random_map_params rmp;
2610 2548
2611 assign (rmp.wallstyle , wallstyle); 2549 rmp.hv = (HV *)SvREFCNT_inc_NN (SvRV (options));
2550
2612 assign (rmp.wall_name , wall_name); 2551 assign (rmp.wall_name , rmp.get_str ("wall_name"));
2613 assign (rmp.floorstyle , floorstyle);
2614 assign (rmp.monsterstyle , monsterstyle); 2552 assign (rmp.monsterstyle , rmp.get_str ("monsterstyle"));
2615 assign (rmp.treasurestyle , treasurestyle);
2616 assign (rmp.layoutstyle , layoutstyle); 2553 assign (rmp.layoutstyle , rmp.get_str ("layoutstyle"));
2617 assign (rmp.doorstyle , doorstyle); 2554 assign (rmp.doorstyle , rmp.get_str ("doorstyle"));
2618 assign (rmp.decorstyle , decorstyle);
2619 assign (rmp.miningstyle , miningstyle);
2620 assign (rmp.exitstyle , exitstyle);
2621 assign (rmp.exit_on_final_map, exit_on_final_map); 2555 assign (rmp.exit_on_final_map, rmp.get_str ("exit_on_final_map"));
2622 2556
2623 rmp.origin_map = origin_map; 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");
2624 rmp.final_map = final_map; 2560 rmp.final_map = rmp.get_str ("final_map");
2625 rmp.this_map = this_map; 2561 rmp.this_map = rmp.get_str ("this_map");
2626 rmp.xsize = xsize; 2562 rmp.xsize = rmp.get_iv ("xsize");
2627 rmp.ysize = ysize; 2563 rmp.ysize = rmp.get_iv ("ysize");
2628 rmp.expand2x = expand2x; 2564 rmp.expand2x = rmp.get_iv ("expand2x");
2629 rmp.layoutoptions1 = layoutoptions1; 2565 rmp.layoutoptions1 = rmp.get_iv ("layoutoptions1");
2630 rmp.layoutoptions2 = layoutoptions2; 2566 rmp.layoutoptions2 = rmp.get_iv ("layoutoptions2");
2631 rmp.layoutoptions3 = layoutoptions3; 2567 rmp.layoutoptions3 = rmp.get_iv ("layoutoptions3");
2632 rmp.symmetry = symmetry; 2568 rmp.symmetry = rmp.get_iv ("symmetry");
2633 rmp.difficulty = difficulty; 2569 rmp.difficulty = rmp.get_iv ("difficulty");
2634 rmp.difficulty_given = difficulty_given; 2570 rmp.difficulty_given = rmp.get_iv ("difficulty_given");
2635 rmp.difficulty_increase = difficulty_increase; 2571 rmp.difficulty_increase = rmp.get_nv ("difficulty_increase");
2636 rmp.dungeon_level = dungeon_level; 2572 rmp.dungeon_level = rmp.get_iv ("dungeon_level");
2637 rmp.dungeon_depth = dungeon_depth; 2573 rmp.dungeon_depth = rmp.get_iv ("dungeon_depth");
2638 rmp.decoroptions = decoroptions;
2639 rmp.orientation = orientation; 2574 rmp.orientation = rmp.get_iv ("orientation");
2640 rmp.origin_y = origin_y;
2641 rmp.origin_x = origin_x;
2642 rmp.random_seed = random_seed; 2575 rmp.random_seed = rmp.get_uv ("random_seed");
2643 rmp.total_map_hp = (uint64_t) total_map_hp; 2576 rmp.total_map_hp = (uint64_t)total_map_hp;
2644 rmp.map_layout_style = map_layout_style; 2577 rmp.map_layout_style = rmp.get_iv ("map_layout_style");
2645 rmp.treasureoptions = treasureoptions;
2646 rmp.symmetry_used = symmetry_used; 2578 rmp.symmetry_used = rmp.get_iv ("symmetry_used");
2647 rmp.region = region; 2579 rmp.region = region;
2648 rmp.custom = custom;
2649 2580
2650 RETVAL = self->generate_random_map (&rmp); 2581 RETVAL = self->generate_random_map (&rmp);
2651} 2582}
2652 OUTPUT: 2583 OUTPUT:
2653 RETVAL 2584 RETVAL
2685void 2616void
2686list () 2617list ()
2687 PPCODE: 2618 PPCODE:
2688 for_all_regions (rgn) 2619 for_all_regions (rgn)
2689 XPUSHs (sv_2mortal (to_sv (rgn))); 2620 XPUSHs (sv_2mortal (to_sv (rgn)));
2690
2691region *find (utf8_string name)
2692 PROTOTYPE: $
2693 CODE:
2694 RETVAL = region::find (name);
2695 OUTPUT: RETVAL
2696 2621
2697int specificity (region *rgn) 2622int specificity (region *rgn)
2698 CODE: 2623 CODE:
2699 RETVAL = 0; 2624 RETVAL = 0;
2700 while (rgn = rgn->parent) 2625 while (rgn = rgn->parent)
2950 sv_to (sv, self); 2875 sv_to (sv, self);
2951 delete self; 2876 delete self;
2952 2877
2953MODULE = cf PACKAGE = cf::object::thawer 2878MODULE = cf PACKAGE = cf::object::thawer
2954 2879
2955INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/cfperl.h | 2880INCLUDE: $PERL $srcdir/genacc object_thawer $srcdir/../include/freezethaw.h |
2881
2882bool
2883errors_are_fatal (bool fatal)
2884 CODE:
2885 RETVAL = object_thawer::errors_are_fatal;
2886 object_thawer::errors_are_fatal = fatal;
2887 OUTPUT:
2888 RETVAL
2956 2889
2957SV * 2890SV *
2958new_from_file (char *klass, octet_string path) 2891new_from_file (char *klass, octet_string path)
2959 CODE: 2892 CODE:
2960 object_thawer *f = new object_thawer (path); 2893 object_thawer *f = new object_thawer (path);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines