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.385 by root, Thu May 6 22:35:41 2010 UTC vs.
Revision 1.402 by root, Sun May 1 13:18:24 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
84 *stash_cf_client_wrap, 85 *stash_cf_client_wrap,
85 *stash_cf_arch_wrap, 86 *stash_cf_arch_wrap,
86 *stash_cf_party_wrap, 87 *stash_cf_party_wrap,
87 *stash_cf_region_wrap, 88 *stash_cf_region_wrap,
88 *stash_cf_living_wrap, 89 *stash_cf_living_wrap,
90 *stash_cf_layout_wrap,
89 *stash_ext_map_world; 91 *stash_ext_map_world;
90 92
91static SV 93static SV
92 *cv_cf_do_invoke, 94 *cv_cf_do_invoke,
93 *cv_cf__can_merge, 95 *cv_cf__can_merge,
122 124
123 return sv; 125 return sv;
124} 126}
125#endif 127#endif
126 128
127static noinline utf8_string 129noinline utf8_string
128cfSvPVutf8_nolen (SV *sv) 130cfSvPVutf8_nolen (SV *sv)
129{ 131{
130 SvGETMAGIC (sv); 132 SvGETMAGIC (sv);
131 133
132 if (SvPOK (sv)) 134 if (SvPOK (sv))
354////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 356//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
355 357
356static SV * 358static SV *
357newSVptr (void *ptr, HV *stash, HV *hv) 359newSVptr (void *ptr, HV *stash, HV *hv)
358{ 360{
359 SV *sv;
360
361 if (!ptr) 361 if (!ptr)
362 return newSV (0); 362 return newSV (0);
363 363
364 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);
365 return sv_bless (newRV_noinc ((SV *)hv), stash); 365 return sv_bless (newRV_noinc ((SV *)hv), stash);
366} 366}
367 367
368static SV * 368static SV * noinline
369newSVptr (void *ptr, HV *stash) 369newSVptr (void *ptr, HV *stash)
370{ 370{
371 return newSVptr (ptr, stash, newHV ()); 371 return newSVptr (ptr, stash, newHV ());
372} 372}
373 373
388 return 0; 388 return 0;
389} 389}
390 390
391MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; 391MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free};
392 392
393static SV * 393static SV * noinline
394newSVattachable (attachable *obj, HV *stash) 394newSVattachable (attachable *obj, HV *stash)
395{ 395{
396 if (!obj) 396 if (!obj)
397 return newSV (0); 397 return newSV (0);
398 398
532static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 532static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
533static inline SV *to_sv (float v) { return newSVnv (v); } 533static inline SV *to_sv (float v) { return newSVnv (v); }
534static inline SV *to_sv (double v) { return newSVnv (v); } 534static inline SV *to_sv (double v) { return newSVnv (v); }
535static 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); }
536static 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
537static 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); }
538static 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); }
539static 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); }
540static 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); }
541static 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); }
542static 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); }
543static 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); }
544 547
545static inline SV *to_sv (object & v) { return to_sv (&v); } 548static inline SV *to_sv (object & v) { return to_sv (&v); }
546static inline SV *to_sv (living & v) { return to_sv (&v); } 549static inline SV *to_sv (living & v) { return to_sv (&v); }
547 550
548static 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 ()); }
594static 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"); }
595static 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"); }
596static 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"); }
597static 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"); }
598static 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"); }
599static 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"); }
600static 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" ); }
601 605
602//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)]; }
603static 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)); }
1397 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); 1401 stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1);
1398 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); 1402 stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1);
1399 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); 1403 stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1);
1400 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); 1404 stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1);
1401 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);
1402 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); 1407 stash_ext_map_world = gv_stashpv ("ext::map_world" , 1);
1403 1408
1404 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);
1405 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);
1406 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);
1455# include "attackinc.h" 1460# include "attackinc.h"
1456# undef def 1461# undef def
1457# define def(uc, flags) const_iv (SK_ ## uc) 1462# define def(uc, flags) const_iv (SK_ ## uc)
1458# include "skillinc.h" 1463# include "skillinc.h"
1459# undef def 1464# undef def
1460 1465# define def(name, use, nonuse) const_iv (body_ ## name)
1461 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1466# include "slotinc.h"
1467# undef def
1462 1468
1463 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1469 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1464 1470
1465 const_iv (MAX_TIME) 1471 const_iv (MAX_TIME)
1466 const_iv (MAXSOCKBUF) 1472 const_iv (MAXSOCKBUF)
1550 for_all_clients (ns) 1556 for_all_clients (ns)
1551 ns->reattach (); 1557 ns->reattach ();
1552 1558
1553 for_all_objects (op) 1559 for_all_objects (op)
1554 op->reattach (); 1560 op->reattach ();
1555}
1556
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} 1561}
1598 1562
1599void init_anim () 1563void init_anim ()
1600 1564
1601void init_globals () 1565void init_globals ()
1771 1735
1772int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1736int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1773 INIT: 1737 INIT:
1774#if __GLIBC__ 1738#if __GLIBC__
1775 mallopt (M_TOP_PAD, 1024 * 1024); 1739 mallopt (M_TOP_PAD, 1024 * 1024);
1776 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); 1740 mallopt (M_MMAP_THRESHOLD, 1024 * 1024);
1777 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory 1741 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1742 if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10))
1778 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1743 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1779#endif 1744#endif
1780 1745
1781int munlockall () 1746int munlockall ()
1782 1747
1783#endif 1748#endif
1821int exp_to_level (val64 exp) 1786int exp_to_level (val64 exp)
1822 1787
1823val64 level_to_min_exp (int level) 1788val64 level_to_min_exp (int level)
1824 1789
1825SV * 1790SV *
1826resistance_to_string (int atnr) 1791attacktype_name (int atnr)
1827 CODE: 1792 CODE:
1828 if (atnr >= 0 && atnr < NROFATTACKS) 1793 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1794 ? newSVpv (attacktype_name [atnr], 0)
1795 : &PL_sv_undef;
1796 OUTPUT: RETVAL
1797
1798SV *
1799attacktype_desc (int atnr)
1800 CODE:
1801 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1802 ? newSVpv (attacktype_desc [atnr], 0)
1803 : &PL_sv_undef;
1804 OUTPUT: RETVAL
1805
1806SV *
1807resist_plus (int atnr)
1808 CODE:
1809 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1829 RETVAL = newSVpv (resist_plus[atnr], 0); 1810 ? newSVpv (resist_plus [atnr], 0)
1830 else 1811 : &PL_sv_undef;
1831 XSRETURN_UNDEF; 1812 OUTPUT: RETVAL
1813
1814SV *
1815change_resist_msg (int atnr)
1816 CODE:
1817 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1818 ? newSVpv (change_resist_msg [atnr], 0)
1819 : &PL_sv_undef;
1832 OUTPUT: RETVAL 1820 OUTPUT: RETVAL
1833 1821
1834UUID 1822UUID
1835uuid_cur () 1823uuid_cur ()
1836 CODE: 1824 CODE:
1959int mortals_size () 1947int mortals_size ()
1960 CODE: 1948 CODE:
1961 RETVAL = attachable::mortals.size (); 1949 RETVAL = attachable::mortals.size ();
1962 OUTPUT: RETVAL 1950 OUTPUT: RETVAL
1963 1951
1964const_utf8_string slot_use_name (U32 slot) 1952const_utf8_string slot_name (U32 slot)
1965 ALIAS: 1953 ALIAS:
1954 slot_name = 0
1955 slot_use_name = 1
1966 slot_nonuse_name = 1 1956 slot_nonuse_name = 2
1967 CODE: 1957 CODE:
1968{ 1958{
1969 if (slot >= NUM_BODY_LOCATIONS) 1959 if (slot >= NUM_BODY_LOCATIONS)
1970 croak ("body slot index out of range"); 1960 croak ("body slot index out of range");
1971 1961
1972 switch (ix) 1962 switch (ix)
1973 { 1963 {
1964 case 0: RETVAL = body_locations[slot].name ; break;
1974 case 0: RETVAL = body_locations[slot].use_name; break; 1965 case 1: RETVAL = body_locations[slot].use_name ; break;
1975 case 1: RETVAL = body_locations[slot].nonuse_name; break; 1966 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1976 } 1967 }
1977} 1968}
1978 OUTPUT: 1969 OUTPUT:
1979 RETVAL 1970 RETVAL
1980 1971
2141 RETVAL = 0; 2132 RETVAL = 0;
2142} 2133}
2143 2134
2144shstr 2135shstr
2145object::kv_get (shstr key) 2136object::kv_get (shstr key)
2137 CODE:
2138 RETVAL = THIS->kv.get (key);
2139 OUTPUT:
2140 RETVAL
2146 2141
2147void 2142void
2148object::kv_del (shstr key) 2143object::kv_del (shstr key)
2144 CODE:
2145 THIS->kv.del (key);
2149 2146
2150void 2147void
2151object::kv_set (shstr key, shstr value) 2148object::kv_set (shstr key, shstr value)
2149 CODE:
2150 THIS->kv.set (key, value);
2152 2151
2153object *get_nearest_player (object *ob) 2152object *get_nearest_player (object *ob)
2154 ALIAS: nearest_player = 0 2153 ALIAS: nearest_player = 0
2155 PREINIT: 2154 PREINIT:
2156 extern object *get_nearest_player (object *); 2155 extern object *get_nearest_player (object *);
2358 for_all_players (pl) 2357 for_all_players (pl)
2359 if (pl->ob && pl->ob->map == THIS) 2358 if (pl->ob && pl->ob->map == THIS)
2360 PUSHs (sv_2mortal (to_sv (pl->ob))); 2359 PUSHs (sv_2mortal (to_sv (pl->ob)));
2361 } 2360 }
2362 2361
2362#if 0
2363
2364void
2365maptile::add_quadland (int mx, int my, int mz, SV *biome_map, SV *biome_plt)
2366 CODE:
2367{
2368 static frac_gen<vec2d> frac;
2369
2370 if (!SvROK (biome_plt) || SvTYPE (SvRV (biome_plt)) != SVt_PVAV)
2371 croak ("maptile::add_quadland: biome_plt must be arrayref");
2372
2373 biome_plt = SvRV (biome_plt);
2374
2375 const uint8_t *bmap = (const uint8_t *)SvPVbyte_nolen (biome_map);
2376
2377 for (int x = 0; x < THIS->width; ++x)
2378 for (int y = 0; y < THIS->height; ++y)
2379 {
2380 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2381 if (op->flag [FLAG_IS_FLOOR])
2382 goto skip;
2383
2384 {
2385 float fx = mx * THIS->width + x;
2386 float fy = my * THIS->height + y;
2387
2388 int temp = clamp (int (32 * frac.fBm (vec2d (fx * 0.001, fy * 0.001), 2) ) - 8, 0, 15);
2389 int rain = clamp (int (16 * frac.ridgedmultifractal (vec2d (fx * 0.01, fy * 0.01), 3, 1.03, 2)) - 8, 0, 15);
2390
2391 rain = lerp (rain, 0, 15, 0, temp);
2392 printf ("rain %d\n", temp);//D
2393
2394 int biome = bmap [rain * 16 + temp];
2395
2396 //printf ("%2d %2d => %s\n", temp, rain, SvPV_nolen (AvARRAY ((AV *)biome_plt)[biome]));//D
2397#if 1
2398 if (SV **elem = av_fetch ((AV *)biome_plt, bmap [rain * 16 + temp], 0))
2399 {
2400 object *ob = get_archetype (cfSvPVutf8_nolen (*elem));
2401 ob->flag [FLAG_NO_MAP_SAVE] = true;
2402 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2403
2404 if (ob->randomitems && !ob->above)
2405 {
2406 ob->create_treasure (ob->randomitems);
2407
2408 for (object *op = ob->above; op; op = op->above)
2409 op->flag [FLAG_NO_MAP_SAVE] = true;
2410 }
2411 }
2412#endif
2413 }
2414 skip: ;
2415 }
2416}
2417
2418#endif
2419
2363void 2420void
2364maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2421maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2365 CODE: 2422 CODE:
2366{ 2423{
2367 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2424 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2398 op->flag [FLAG_NO_MAP_SAVE] = true; 2455 op->flag [FLAG_NO_MAP_SAVE] = true;
2399 // TODO: if this is a pickable object, then the item 2456 // TODO: if this is a pickable object, then the item
2400 // will at a bit weird - saving inside the player 2457 // will at a bit weird - saving inside the player
2401 // will clear the flag, but when the player drops 2458 // will clear the flag, but when the player drops
2402 // it without logging out, it keeps the flag. 2459 // it without logging out, it keeps the flag.
2403 // nobody ahs reported this, but this can be rather 2460 // nobody has reported this, but this can be rather
2404 // annoying on persistent maps. 2461 // annoying on persistent maps.
2405 } 2462 }
2406 } 2463 }
2407 } 2464 }
2408 } 2465 }
2409
2410 skip: ; 2466 skip: ;
2411 } 2467 }
2412} 2468}
2413 2469
2414void 2470void
2445 for (int x = 0; x < THIS->width; ++x) 2501 for (int x = 0; x < THIS->width; ++x)
2446 for (int y = 0; y < THIS->height; ++y) 2502 for (int y = 0; y < THIS->height; ++y)
2447 { 2503 {
2448 region *rgn = THIS->region (x, y); 2504 region *rgn = THIS->region (x, y);
2449 2505
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) 2506 if (object *op = THIS->at (x, y).top)
2452 if (rgn->treasure && rndm () < rgn->treasure_density) 2507 if (rgn->treasure && rndm () < rgn->treasure_density)
2453 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2508 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2454 } 2509 }
2455 2510
2534} 2589}
2535 OUTPUT: RETVAL 2590 OUTPUT: RETVAL
2536 2591
2537# worst xs function of my life 2592# worst xs function of my life
2538bool 2593bool
2539_create_random_map (\ 2594_create_random_map (maptile *self, SV *options)
2540 maptile *self,\
2541 utf8_string wallstyle,\
2542 utf8_string wall_name,\
2543 utf8_string floorstyle,\
2544 utf8_string monsterstyle,\
2545 utf8_string treasurestyle,\
2546 utf8_string layoutstyle,\
2547 utf8_string doorstyle,\
2548 utf8_string decorstyle,\
2549 utf8_string miningstyle,\
2550 utf8_string origin_map,\
2551 utf8_string final_map,\
2552 utf8_string exitstyle,\
2553 utf8_string this_map,\
2554 utf8_string exit_on_final_map,\
2555 int xsize,\
2556 int ysize,\
2557 int expand2x,\
2558 int layoutoptions1,\
2559 int layoutoptions2,\
2560 int layoutoptions3,\
2561 int symmetry,\
2562 int difficulty,\
2563 int difficulty_given,\
2564 float difficulty_increase,\
2565 int dungeon_level,\
2566 int dungeon_depth,\
2567 int decoroptions,\
2568 int orientation,\
2569 int origin_y,\
2570 int origin_x,\
2571 U32 random_seed,\
2572 val64 total_map_hp,\
2573 int map_layout_style,\
2574 int treasureoptions,\
2575 int symmetry_used,\
2576 region *region,\
2577 utf8_string custom\
2578)
2579 CODE: 2595 CODE:
2580{ 2596{
2581 random_map_params rmp; 2597 random_map_params rmp ((HV *)SvRV (options));
2582
2583 assign (rmp.wallstyle , wallstyle);
2584 assign (rmp.wall_name , wall_name);
2585 assign (rmp.floorstyle , floorstyle);
2586 assign (rmp.monsterstyle , monsterstyle);
2587 assign (rmp.treasurestyle , treasurestyle);
2588 assign (rmp.layoutstyle , layoutstyle);
2589 assign (rmp.doorstyle , doorstyle);
2590 assign (rmp.decorstyle , decorstyle);
2591 assign (rmp.miningstyle , miningstyle);
2592 assign (rmp.exitstyle , exitstyle);
2593 assign (rmp.exit_on_final_map, exit_on_final_map);
2594
2595 rmp.origin_map = origin_map;
2596 rmp.final_map = final_map;
2597 rmp.this_map = this_map;
2598 rmp.xsize = xsize;
2599 rmp.ysize = ysize;
2600 rmp.expand2x = expand2x;
2601 rmp.layoutoptions1 = layoutoptions1;
2602 rmp.layoutoptions2 = layoutoptions2;
2603 rmp.layoutoptions3 = layoutoptions3;
2604 rmp.symmetry = symmetry;
2605 rmp.difficulty = difficulty;
2606 rmp.difficulty_given = difficulty_given;
2607 rmp.difficulty_increase = difficulty_increase;
2608 rmp.dungeon_level = dungeon_level;
2609 rmp.dungeon_depth = dungeon_depth;
2610 rmp.decoroptions = decoroptions;
2611 rmp.orientation = orientation;
2612 rmp.origin_y = origin_y;
2613 rmp.origin_x = origin_x;
2614 rmp.random_seed = random_seed;
2615 rmp.total_map_hp = (uint64_t) total_map_hp;
2616 rmp.map_layout_style = map_layout_style;
2617 rmp.treasureoptions = treasureoptions;
2618 rmp.symmetry_used = symmetry_used;
2619 rmp.region = region;
2620 rmp.custom = custom;
2621
2622 RETVAL = self->generate_random_map (&rmp); 2598 RETVAL = self->generate_random_map (&rmp);
2623} 2599}
2624 OUTPUT: 2600 OUTPUT:
2625 RETVAL 2601 RETVAL
2626 2602
2798 2774
2799void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2775void set_data (faceidx idx, int faceset, SV *data, SV *chksum)
2800 CODE: 2776 CODE:
2801{ 2777{
2802 faceinfo *f = face_info (idx); assert (f); 2778 faceinfo *f = face_info (idx); assert (f);
2803 facedata *d = &(faceset ? f->data64 : f->data32); 2779 facedata *d = f->face + faceset;
2804 sv_to (data, d->data); 2780 sv_to (data, d->data);
2805 STRLEN clen; 2781 STRLEN clen;
2806 char *cdata = SvPVbyte (chksum, clen); 2782 char *cdata = SvPVbyte (chksum, clen);
2807 clen = min (CHKSUM_MAXLEN, clen); 2783 clen = min (CHKSUM_MAXLEN, clen);
2808 2784
2960 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ()))); 2936 XPUSHs (sv_2mortal (newSVpv_utf8 (self->get_str ())));
2961 2937
2962 self->skip (); 2938 self->skip ();
2963 } 2939 }
2964 2940
2941MODULE = cf PACKAGE = cf::layout
2942
2943INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2944

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines