… | |
… | |
56 | |
56 | |
57 | typedef char *octet_string; |
57 | typedef char *octet_string; |
58 | typedef char *utf8_string; |
58 | typedef char *utf8_string; |
59 | typedef const char *const_octet_string; |
59 | typedef const char *const_octet_string; |
60 | typedef const char *const_utf8_string; |
60 | typedef const char *const_utf8_string; |
|
|
61 | |
|
|
62 | typedef std::string std__string; |
61 | |
63 | |
62 | #if IVSIZE >= 8 |
64 | #if IVSIZE >= 8 |
63 | typedef IV val64; |
65 | typedef IV val64; |
64 | # define newSVval64 newSViv |
66 | # define newSVval64 newSViv |
65 | # define SvVAL64 SvIV |
67 | # define SvVAL64 SvIV |
… | |
… | |
356 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
358 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
357 | |
359 | |
358 | inline SV *to_sv (object & v) { return to_sv (&v); } |
360 | inline SV *to_sv (object & v) { return to_sv (&v); } |
359 | inline SV *to_sv (living & v) { return to_sv (&v); } |
361 | inline SV *to_sv (living & v) { return to_sv (&v); } |
360 | |
362 | |
361 | //inline SV *to_sv (faceinfo * v) { return to_sv (v->name); } |
|
|
362 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
|
|
363 | inline SV *to_sv (std::string & v) { return newSVpvn (v.data (), v.size ()); } |
363 | inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } |
|
|
364 | inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } |
364 | |
365 | |
365 | inline SV *to_sv (UUID v) |
366 | inline SV *to_sv (UUID v) |
366 | { |
367 | { |
367 | char buf[128]; |
368 | char buf[128]; |
368 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
369 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
… | |
… | |
1324 | |
1325 | |
1325 | void _post_tick () |
1326 | void _post_tick () |
1326 | CODE: |
1327 | CODE: |
1327 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
1328 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
1328 | |
1329 | |
|
|
1330 | # support function for map-world.ext |
|
|
1331 | void _quantise (SV *data_sv, SV *plt_sv) |
|
|
1332 | CODE: |
|
|
1333 | { |
|
|
1334 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
|
|
1335 | croak ("_quantise called with invalid agruments"); |
|
|
1336 | |
|
|
1337 | plt_sv = SvRV (plt_sv); |
|
|
1338 | SV **plt = AvARRAY (plt_sv); |
|
|
1339 | int plt_count = AvFILL (plt_sv) + 1; |
|
|
1340 | |
|
|
1341 | STRLEN len; |
|
|
1342 | char *data = SvPVbyte (data_sv, len); |
|
|
1343 | char *dst = data; |
|
|
1344 | |
|
|
1345 | while (len >= 3) |
|
|
1346 | { |
|
|
1347 | for (SV **val_sv = plt + plt_count; val_sv-- > plt; ) |
|
|
1348 | { |
|
|
1349 | char *val = SvPVX (*val_sv); |
|
|
1350 | |
|
|
1351 | if (val [0] == data [0] |
|
|
1352 | && val [1] == data [1] |
|
|
1353 | && val [2] == data [2]) |
|
|
1354 | { |
|
|
1355 | *dst++ = val [3]; |
|
|
1356 | goto next; |
|
|
1357 | } |
|
|
1358 | } |
|
|
1359 | |
|
|
1360 | croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d", |
|
|
1361 | (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2], |
|
|
1362 | dst - SvPVX (data_sv), len); |
|
|
1363 | |
|
|
1364 | next: |
|
|
1365 | data += 3; |
|
|
1366 | len -= 3; |
|
|
1367 | } |
|
|
1368 | |
|
|
1369 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
|
|
1370 | } |
|
|
1371 | |
1329 | NV floor (NV x) |
1372 | NV floor (NV x) |
1330 | |
1373 | |
1331 | NV ceil (NV x) |
1374 | NV ceil (NV x) |
1332 | |
1375 | |
1333 | NV rndm (...) |
1376 | NV rndm (...) |
… | |
… | |
1966 | sfree (THIS->regions, THIS->size ()); |
2009 | sfree (THIS->regions, THIS->size ()); |
1967 | free (THIS->regionmap); |
2010 | free (THIS->regionmap); |
1968 | |
2011 | |
1969 | THIS->regions = regions; |
2012 | THIS->regions = regions; |
1970 | THIS->regionmap = regionmap; |
2013 | THIS->regionmap = regionmap; |
|
|
2014 | } |
|
|
2015 | |
|
|
2016 | void |
|
|
2017 | maptile::create_region_treasure () |
|
|
2018 | CODE: |
|
|
2019 | { |
|
|
2020 | object *op = object::create (); |
|
|
2021 | op->type = FLOOR; |
|
|
2022 | op->map = THIS; |
|
|
2023 | |
|
|
2024 | for (int x = 0; x < THIS->width; ++x) |
|
|
2025 | for (int y = 0; y < THIS->height; ++y) |
|
|
2026 | { |
|
|
2027 | region *rgn = THIS->region (x, y); |
|
|
2028 | |
|
|
2029 | //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D |
|
|
2030 | if (rgn->treasure && rndm () < rgn->treasure_density) |
|
|
2031 | { |
|
|
2032 | op->x = x; |
|
|
2033 | op->y = y; |
|
|
2034 | create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); |
|
|
2035 | } |
|
|
2036 | } |
|
|
2037 | |
|
|
2038 | op->destroy (); |
1971 | } |
2039 | } |
1972 | |
2040 | |
1973 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
2041 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
1974 | |
2042 | |
1975 | int out_of_map (maptile *map, int x, int y) |
2043 | int out_of_map (maptile *map, int x, int y) |
… | |
… | |
2199 | RETVAL = 0; |
2267 | RETVAL = 0; |
2200 | while (rgn = rgn->parent) |
2268 | while (rgn = rgn->parent) |
2201 | RETVAL++; |
2269 | RETVAL++; |
2202 | OUTPUT: RETVAL |
2270 | OUTPUT: RETVAL |
2203 | |
2271 | |
2204 | INCLUDE: $PERL $srcdir/genacc region ../include/map.h | |
2272 | INCLUDE: $PERL $srcdir/genacc region ../include/region.h | |
2205 | |
2273 | |
2206 | MODULE = cf PACKAGE = cf::living |
2274 | MODULE = cf PACKAGE = cf::living |
2207 | |
2275 | |
2208 | INCLUDE: $PERL $srcdir/genacc living ../include/living.h | |
2276 | INCLUDE: $PERL $srcdir/genacc living ../include/living.h | |
2209 | |
2277 | |