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.404 by root, Wed May 4 07:36:41 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
1485 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) 1486 const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE)
1486 1487
1487 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) 1488 const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE)
1488 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) 1489 const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY)
1489 1490
1490 const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING)
1491 const_iv (MAP_INACTIVE)
1492
1493 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) 1491 const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT)
1494 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) 1492 const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP)
1495 1493
1496 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1494 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1497 1495
1555 for_all_clients (ns) 1553 for_all_clients (ns)
1556 ns->reattach (); 1554 ns->reattach ();
1557 1555
1558 for_all_objects (op) 1556 for_all_objects (op)
1559 op->reattach (); 1557 op->reattach ();
1560}
1561
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} 1558}
1603 1559
1604void init_anim () 1560void init_anim ()
1605 1561
1606void init_globals () 1562void init_globals ()
2144# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2100# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
2145 2101
2146object *new (utf8_string archetype = 0) 2102object *new (utf8_string archetype = 0)
2147 PROTOTYPE: ;$ 2103 PROTOTYPE: ;$
2148 CODE: 2104 CODE:
2149 RETVAL = archetype ? get_archetype (archetype) : object::create (); 2105 RETVAL = archetype
2106 ? archetype::get (archetype)
2107 : object::create ();
2150 OUTPUT: 2108 OUTPUT:
2151 RETVAL 2109 RETVAL
2152 2110
2153object *generate (utf8_string arch, object *creator) 2111object *generate (utf8_string arch, object *creator)
2154 CODE: 2112 CODE:
2155 object *obj = get_archetype (arch); 2113 object *obj = archetype::get (arch);
2156 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2114 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2157 RETVAL = obj; 2115 RETVAL = obj;
2158 OUTPUT: 2116 OUTPUT:
2159 RETVAL 2117 RETVAL
2160 2118
2173 RETVAL = 0; 2131 RETVAL = 0;
2174} 2132}
2175 2133
2176shstr 2134shstr
2177object::kv_get (shstr key) 2135object::kv_get (shstr key)
2136 CODE:
2137 RETVAL = THIS->kv.get (key);
2138 OUTPUT:
2139 RETVAL
2178 2140
2179void 2141void
2180object::kv_del (shstr key) 2142object::kv_del (shstr key)
2143 CODE:
2144 THIS->kv.del (key);
2181 2145
2182void 2146void
2183object::kv_set (shstr key, shstr value) 2147object::kv_set (shstr key, shstr value)
2148 CODE:
2149 THIS->kv.set (key, value);
2184 2150
2185object *get_nearest_player (object *ob) 2151object *get_nearest_player (object *ob)
2186 ALIAS: nearest_player = 0 2152 ALIAS: nearest_player = 0
2187 PREINIT: 2153 PREINIT:
2188 extern object *get_nearest_player (object *); 2154 extern object *get_nearest_player (object *);
2391 if (pl->ob && pl->ob->map == THIS) 2357 if (pl->ob && pl->ob->map == THIS)
2392 PUSHs (sv_2mortal (to_sv (pl->ob))); 2358 PUSHs (sv_2mortal (to_sv (pl->ob)));
2393 } 2359 }
2394 2360
2395void 2361void
2362maptile::gen_quadmap (int x, int y, int z)
2363 CODE:
2364 gen_quadmap (THIS, x * 50, y * 50, z);
2365
2366void
2396maptile::add_underlay (SV *data, int offset, int stride, SV *palette) 2367maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2397 CODE: 2368 CODE:
2398{ 2369{
2399 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) 2370 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2400 croak ("maptile::add_underlay: palette must be arrayref"); 2371 croak ("maptile::add_underlay: palette must be arrayref");
2416 2387
2417 if (IN_RANGE_EXC (offs, 0, idxlen)) 2388 if (IN_RANGE_EXC (offs, 0, idxlen))
2418 { 2389 {
2419 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2390 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2420 { 2391 {
2421 object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); 2392 object *ob = archetype::get (cfSvPVutf8_nolen (*elem));
2422 ob->flag [FLAG_NO_MAP_SAVE] = true; 2393 ob->flag [FLAG_NO_MAP_SAVE] = true;
2423 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2394 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2424 2395
2425 if (ob->randomitems && !ob->above) 2396 if (ob->randomitems && !ob->above)
2426 { 2397 {
2430 op->flag [FLAG_NO_MAP_SAVE] = true; 2401 op->flag [FLAG_NO_MAP_SAVE] = true;
2431 // TODO: if this is a pickable object, then the item 2402 // TODO: if this is a pickable object, then the item
2432 // will at a bit weird - saving inside the player 2403 // will at a bit weird - saving inside the player
2433 // will clear the flag, but when the player drops 2404 // will clear the flag, but when the player drops
2434 // it without logging out, it keeps the flag. 2405 // it without logging out, it keeps the flag.
2435 // nobody ahs reported this, but this can be rather 2406 // nobody has reported this, but this can be rather
2436 // annoying on persistent maps. 2407 // annoying on persistent maps.
2437 } 2408 }
2438 } 2409 }
2439 } 2410 }
2440 } 2411 }
2441
2442 skip: ; 2412 skip: ;
2443 } 2413 }
2444} 2414}
2445 2415
2446void 2416void
2477 for (int x = 0; x < THIS->width; ++x) 2447 for (int x = 0; x < THIS->width; ++x)
2478 for (int y = 0; y < THIS->height; ++y) 2448 for (int y = 0; y < THIS->height; ++y)
2479 { 2449 {
2480 region *rgn = THIS->region (x, y); 2450 region *rgn = THIS->region (x, y);
2481 2451
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) 2452 if (object *op = THIS->at (x, y).top)
2484 if (rgn->treasure && rndm () < rgn->treasure_density) 2453 if (rgn->treasure && rndm () < rgn->treasure_density)
2485 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2454 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2486 } 2455 }
2487 2456

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines