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.397 by root, Tue Jan 25 22:39:54 2011 UTC vs.
Revision 1.403 by root, Sun May 1 16:58:17 2011 UTC

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
1557 1558
1558 for_all_objects (op) 1559 for_all_objects (op)
1559 op->reattach (); 1560 op->reattach ();
1560} 1561}
1561 1562
1562# support function for map-world.ext
1563void _quantise (SV *data_sv, SV *plt_sv)
1564 CODE:
1565{
1566 if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV)
1567 croak ("_quantise called with invalid agruments");
1568
1569 plt_sv = SvRV (plt_sv);
1570 SV **plt = AvARRAY (plt_sv);
1571 int plt_count = AvFILL (plt_sv) + 1;
1572
1573 STRLEN len;
1574 char *data = SvPVbyte (data_sv, len);
1575 char *dst = data;
1576
1577 while (len >= 3)
1578 {
1579 for (SV **val_sv = plt + plt_count; val_sv-- > plt; )
1580 {
1581 char *val = SvPVX (*val_sv);
1582
1583 if (val [0] == data [0]
1584 && val [1] == data [1]
1585 && val [2] == data [2])
1586 {
1587 *dst++ = val [3];
1588 goto next;
1589 }
1590 }
1591
1592 croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d",
1593 (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2],
1594 dst - SvPVX (data_sv), len);
1595
1596 next:
1597 data += 3;
1598 len -= 3;
1599 }
1600
1601 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1602}
1603
1604void init_anim () 1563void init_anim ()
1605 1564
1606void init_globals () 1565void init_globals ()
1607 1566
1608void init_attackmess () 1567void init_attackmess ()
2144# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2103# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2145 2104
2146object *new (utf8_string archetype = 0) 2105object *new (utf8_string archetype = 0)
2147 PROTOTYPE: ;$ 2106 PROTOTYPE: ;$
2148 CODE: 2107 CODE:
2149 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2108 RETVAL = archetype
2109 ? archetype::get (archetype)
2110 : object::create ();
2150 OUTPUT: 2111 OUTPUT:
2151 RETVAL 2112 RETVAL
2152 2113
2153object *generate (utf8_string arch, object *creator) 2114object *generate (utf8_string arch, object *creator)
2154 CODE: 2115 CODE:
2155 object *obj = get_archetype (arch); 2116 object *obj = archetype::get (arch);
2156 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2117 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2157 RETVAL = obj; 2118 RETVAL = obj;
2158 OUTPUT: 2119 OUTPUT:
2159 RETVAL 2120 RETVAL
2160 2121
2173 RETVAL = 0; 2134 RETVAL = 0;
2174} 2135}
2175 2136
2176shstr 2137shstr
2177object::kv_get (shstr key) 2138object::kv_get (shstr key)
2139 CODE:
2140 RETVAL = THIS->kv.get (key);
2141 OUTPUT:
2142 RETVAL
2178 2143
2179void 2144void
2180object::kv_del (shstr key) 2145object::kv_del (shstr key)
2146 CODE:
2147 THIS->kv.del (key);
2181 2148
2182void 2149void
2183object::kv_set (shstr key, shstr value) 2150object::kv_set (shstr key, shstr value)
2151 CODE:
2152 THIS->kv.set (key, value);
2184 2153
2185object *get_nearest_player (object *ob) 2154object *get_nearest_player (object *ob)
2186 ALIAS: nearest_player = 0 2155 ALIAS: nearest_player = 0
2187 PREINIT: 2156 PREINIT:
2188 extern object *get_nearest_player (object *); 2157 extern object *get_nearest_player (object *);
2391 if (pl->ob && pl->ob->map == THIS) 2360 if (pl->ob && pl->ob->map == THIS)
2392 PUSHs (sv_2mortal (to_sv (pl->ob))); 2361 PUSHs (sv_2mortal (to_sv (pl->ob)));
2393 } 2362 }
2394 2363
2395void 2364void
2365maptile::gen_quadmap (int x, int y, int z)
2366 CODE:
2367 gen_quadmap (THIS, x * 50, y * 50, z);
2368
2369void
2396maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2370maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2397 CODE: 2371 CODE:
2398{ 2372{
2399 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2373 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2400 croak ("maptile::add_underlay: palette must be arrayref"); 2374 croak ("maptile::add_underlay: palette must be arrayref");
2416 2390
2417 if (IN_RANGE_EXC (offs, 0, idxlen)) 2391 if (IN_RANGE_EXC (offs, 0, idxlen))
2418 { 2392 {
2419 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2393 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2420 { 2394 {
2421 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2395 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2422 ob->flag [FLAG_NO_MAP_SAVE] = true; 2396 ob->flag [FLAG_NO_MAP_SAVE] = true;
2423 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2397 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2424 2398
2425 if (ob->randomitems && !ob->above) 2399 if (ob->randomitems && !ob->above)
2426 { 2400 {
2430 op->flag [FLAG_NO_MAP_SAVE] = true; 2404 op->flag [FLAG_NO_MAP_SAVE] = true;
2431 // TODO: if this is a pickable object, then the item 2405 // TODO: if this is a pickable object, then the item
2432 // will at a bit weird - saving inside the player 2406 // will at a bit weird - saving inside the player
2433 // will clear the flag, but when the player drops 2407 // will clear the flag, but when the player drops
2434 // it without logging out, it keeps the flag. 2408 // it without logging out, it keeps the flag.
2435 // nobody ahs reported this, but this can be rather 2409 // nobody has reported this, but this can be rather
2436 // annoying on persistent maps. 2410 // annoying on persistent maps.
2437 } 2411 }
2438 } 2412 }
2439 } 2413 }
2440 } 2414 }
2441
2442 skip: ; 2415 skip: ;
2443 } 2416 }
2444} 2417}
2445 2418
2446void 2419void
2477 for (int x = 0; x < THIS->width; ++x) 2450 for (int x = 0; x < THIS->width; ++x)
2478 for (int y = 0; y < THIS->height; ++y) 2451 for (int y = 0; y < THIS->height; ++y)
2479 { 2452 {
2480 region *rgn = THIS->region (x, y); 2453 region *rgn = THIS->region (x, y);
2481 2454
2482 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2483 if (object *op = THIS->at (x, y).top) 2455 if (object *op = THIS->at (x, y).top)
2484 if (rgn->treasure && rndm () < rgn->treasure_density) 2456 if (rgn->treasure && rndm () < rgn->treasure_density)
2485 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2457 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2486 } 2458 }
2487 2459

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines