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.402 by root, Sun May 1 13:18:24 2011 UTC vs.
Revision 1.403 by root, Sun May 1 16:58:17 2011 UTC

2103# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2103# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2104 2104
2105object *new (utf8_string archetype = 0) 2105object *new (utf8_string archetype = 0)
2106 PROTOTYPE: ;$ 2106 PROTOTYPE: ;$
2107 CODE: 2107 CODE:
2108 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2108 RETVAL = archetype
2109 ? archetype::get (archetype)
2110 : object::create ();
2109 OUTPUT: 2111 OUTPUT:
2110 RETVAL 2112 RETVAL
2111 2113
2112object *generate (utf8_string arch, object *creator) 2114object *generate (utf8_string arch, object *creator)
2113 CODE: 2115 CODE:
2114 object *obj = get_archetype (arch); 2116 object *obj = archetype::get (arch);
2115 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2117 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2116 RETVAL = obj; 2118 RETVAL = obj;
2117 OUTPUT: 2119 OUTPUT:
2118 RETVAL 2120 RETVAL
2119 2121
2357 for_all_players (pl) 2359 for_all_players (pl)
2358 if (pl->ob && pl->ob->map == THIS) 2360 if (pl->ob && pl->ob->map == THIS)
2359 PUSHs (sv_2mortal (to_sv (pl->ob))); 2361 PUSHs (sv_2mortal (to_sv (pl->ob)));
2360 } 2362 }
2361 2363
2362#if 0
2363
2364void 2364void
2365maptile::add_quadland (int mx, int my, int mz, SV *biome_map, SV *biome_plt) 2365maptile::gen_quadmap (int x, int y, int z)
2366 CODE: 2366 CODE:
2367{ 2367 gen_quadmap (THIS, x * 50, y * 50, z);
2368 static frac_gen<vec2d> frac;
2369 2368
2369void
2370maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2371 CODE:
2372{
2370 if (!SvROK (biome_plt) || SvTYPE (SvRV (biome_plt)) != SVt_PVAV) 2373 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2371 croak ("maptile::add_quadland: biome_plt must be arrayref"); 2374 croak ("maptile::add_underlay: palette must be arrayref");
2372 2375
2373 biome_plt = SvRV (biome_plt); 2376 palette = SvRV (palette);
2374 2377
2378 STRLEN idxlen;
2375 const uint8_t *bmap = (const uint8_t *)SvPVbyte_nolen (biome_map); 2379 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen);
2376 2380
2377 for (int x = 0; x < THIS->width; ++x) 2381 for (int x = 0; x < THIS->width; ++x)
2378 for (int y = 0; y < THIS->height; ++y) 2382 for (int y = 0; y < THIS->height; ++y)
2379 { 2383 {
2380 for (object *op = THIS->at (x, y).bot; op; op = op->above) 2384 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2381 if (op->flag [FLAG_IS_FLOOR]) 2385 if (op->flag [FLAG_IS_FLOOR])
2382 goto skip; 2386 goto skip;
2383 2387
2384 { 2388 {
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
2420void
2421maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2422 CODE:
2423{
2424 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2425 croak ("maptile::add_underlay: palette must be arrayref");
2426
2427 palette = SvRV (palette);
2428
2429 STRLEN idxlen;
2430 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen);
2431
2432 for (int x = 0; x < THIS->width; ++x)
2433 for (int y = 0; y < THIS->height; ++y)
2434 {
2435 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2436 if (op->flag [FLAG_IS_FLOOR])
2437 goto skip;
2438
2439 {
2440 int offs = offset + y * stride + x; 2389 int offs = offset + y * stride + x;
2441 2390
2442 if (IN_RANGE_EXC (offs, 0, idxlen)) 2391 if (IN_RANGE_EXC (offs, 0, idxlen))
2443 { 2392 {
2444 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2393 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2445 { 2394 {
2446 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2395 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2447 ob->flag [FLAG_NO_MAP_SAVE] = true; 2396 ob->flag [FLAG_NO_MAP_SAVE] = true;
2448 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2397 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2449 2398
2450 if (ob->randomitems && !ob->above) 2399 if (ob->randomitems && !ob->above)
2451 { 2400 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines