… | |
… | |
29 | #include <cstdarg> |
29 | #include <cstdarg> |
30 | #include <typeinfo> |
30 | #include <typeinfo> |
31 | |
31 | |
32 | #include "global.h" |
32 | #include "global.h" |
33 | #include "rmg.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 |
… | |
… | |
2349 | if (pl->ob && pl->ob->map == THIS) |
2350 | if (pl->ob && pl->ob->map == THIS) |
2350 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2351 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2351 | } |
2352 | } |
2352 | |
2353 | |
2353 | void |
2354 | void |
|
|
2355 | maptile::add_quadland (int mx, int my, int mz, SV *biome_map, SV *biome_plt) |
|
|
2356 | CODE: |
|
|
2357 | { |
|
|
2358 | static frac_gen<vec2d> frac; |
|
|
2359 | |
|
|
2360 | if (!SvROK (biome_plt) || SvTYPE (SvRV (biome_plt)) != SVt_PVAV) |
|
|
2361 | croak ("maptile::add_quadland: biome_plt must be arrayref"); |
|
|
2362 | |
|
|
2363 | biome_plt = SvRV (biome_plt); |
|
|
2364 | |
|
|
2365 | const uint8_t *bmap = (const uint8_t *)SvPVbyte_nolen (biome_map); |
|
|
2366 | |
|
|
2367 | for (int x = 0; x < THIS->width; ++x) |
|
|
2368 | for (int y = 0; y < THIS->height; ++y) |
|
|
2369 | { |
|
|
2370 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
|
|
2371 | if (op->flag [FLAG_IS_FLOOR]) |
|
|
2372 | goto skip; |
|
|
2373 | |
|
|
2374 | { |
|
|
2375 | float fx = mx * THIS->width + x; |
|
|
2376 | float fy = my * THIS->height + y; |
|
|
2377 | |
|
|
2378 | int temp = clamp (int (32 * frac.fBm (vec2d (fx * 0.001, fy * 0.001), 2) ) - 8, 0, 15); |
|
|
2379 | int rain = clamp (int (16 * frac.ridgedmultifractal (vec2d (fx * 0.01, fy * 0.01), 3, 1.03, 2)) - 8, 0, 15); |
|
|
2380 | |
|
|
2381 | rain = lerp (rain, 0, 15, 0, temp); |
|
|
2382 | printf ("rain %d\n", temp);//D |
|
|
2383 | |
|
|
2384 | int biome = bmap [rain * 16 + temp]; |
|
|
2385 | |
|
|
2386 | //printf ("%2d %2d => %s\n", temp, rain, SvPV_nolen (AvARRAY ((AV *)biome_plt)[biome]));//D |
|
|
2387 | #if 1 |
|
|
2388 | if (SV **elem = av_fetch ((AV *)biome_plt, bmap [rain * 16 + temp], 0)) |
|
|
2389 | { |
|
|
2390 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
|
|
2391 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
|
|
2392 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
|
|
2393 | |
|
|
2394 | if (ob->randomitems && !ob->above) |
|
|
2395 | { |
|
|
2396 | ob->create_treasure (ob->randomitems); |
|
|
2397 | |
|
|
2398 | for (object *op = ob->above; op; op = op->above) |
|
|
2399 | op->flag [FLAG_NO_MAP_SAVE] = true; |
|
|
2400 | } |
|
|
2401 | } |
|
|
2402 | #endif |
|
|
2403 | } |
|
|
2404 | skip: ; |
|
|
2405 | } |
|
|
2406 | } |
|
|
2407 | |
|
|
2408 | void |
2354 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2409 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2355 | CODE: |
2410 | CODE: |
2356 | { |
2411 | { |
2357 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2412 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2358 | croak ("maptile::add_underlay: palette must be arrayref"); |
2413 | croak ("maptile::add_underlay: palette must be arrayref"); |
… | |
… | |
2388 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2443 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2389 | // TODO: if this is a pickable object, then the item |
2444 | // TODO: if this is a pickable object, then the item |
2390 | // will at a bit weird - saving inside the player |
2445 | // will at a bit weird - saving inside the player |
2391 | // will clear the flag, but when the player drops |
2446 | // will clear the flag, but when the player drops |
2392 | // it without logging out, it keeps the flag. |
2447 | // it without logging out, it keeps the flag. |
2393 | // nobody ahs reported this, but this can be rather |
2448 | // nobody has reported this, but this can be rather |
2394 | // annoying on persistent maps. |
2449 | // annoying on persistent maps. |
2395 | } |
2450 | } |
2396 | } |
2451 | } |
2397 | } |
2452 | } |
2398 | } |
2453 | } |
2399 | |
|
|
2400 | skip: ; |
2454 | skip: ; |
2401 | } |
2455 | } |
2402 | } |
2456 | } |
2403 | |
2457 | |
2404 | void |
2458 | void |