… | |
… | |
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 |
… | |
… | |
2131 | RETVAL = 0; |
2132 | RETVAL = 0; |
2132 | } |
2133 | } |
2133 | |
2134 | |
2134 | shstr |
2135 | shstr |
2135 | object::kv_get (shstr key) |
2136 | object::kv_get (shstr key) |
|
|
2137 | CODE: |
|
|
2138 | RETVAL = THIS->kv.get (key); |
|
|
2139 | OUTPUT: |
|
|
2140 | RETVAL |
2136 | |
2141 | |
2137 | void |
2142 | void |
2138 | object::kv_del (shstr key) |
2143 | object::kv_del (shstr key) |
|
|
2144 | CODE: |
|
|
2145 | THIS->kv.del (key); |
2139 | |
2146 | |
2140 | void |
2147 | void |
2141 | object::kv_set (shstr key, shstr value) |
2148 | object::kv_set (shstr key, shstr value) |
|
|
2149 | CODE: |
|
|
2150 | THIS->kv.set (key, value); |
2142 | |
2151 | |
2143 | object *get_nearest_player (object *ob) |
2152 | object *get_nearest_player (object *ob) |
2144 | ALIAS: nearest_player = 0 |
2153 | ALIAS: nearest_player = 0 |
2145 | PREINIT: |
2154 | PREINIT: |
2146 | extern object *get_nearest_player (object *); |
2155 | extern object *get_nearest_player (object *); |
… | |
… | |
2348 | for_all_players (pl) |
2357 | for_all_players (pl) |
2349 | if (pl->ob && pl->ob->map == THIS) |
2358 | if (pl->ob && pl->ob->map == THIS) |
2350 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2359 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2351 | } |
2360 | } |
2352 | |
2361 | |
|
|
2362 | #if 0 |
|
|
2363 | |
|
|
2364 | void |
|
|
2365 | maptile::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 | |
2353 | void |
2420 | void |
2354 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2421 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
2355 | CODE: |
2422 | CODE: |
2356 | { |
2423 | { |
2357 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2424 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
… | |
… | |
2388 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2455 | op->flag [FLAG_NO_MAP_SAVE] = true; |
2389 | // TODO: if this is a pickable object, then the item |
2456 | // TODO: if this is a pickable object, then the item |
2390 | // will at a bit weird - saving inside the player |
2457 | // will at a bit weird - saving inside the player |
2391 | // will clear the flag, but when the player drops |
2458 | // will clear the flag, but when the player drops |
2392 | // it without logging out, it keeps the flag. |
2459 | // it without logging out, it keeps the flag. |
2393 | // nobody ahs reported this, but this can be rather |
2460 | // nobody has reported this, but this can be rather |
2394 | // annoying on persistent maps. |
2461 | // annoying on persistent maps. |
2395 | } |
2462 | } |
2396 | } |
2463 | } |
2397 | } |
2464 | } |
2398 | } |
2465 | } |
2399 | |
|
|
2400 | skip: ; |
2466 | skip: ; |
2401 | } |
2467 | } |
2402 | } |
2468 | } |
2403 | |
2469 | |
2404 | void |
2470 | void |