1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2006,2007,2008,2009,2010,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
10 | * |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
14 | * GNU General Public License for more details. |
15 | * |
15 | * |
16 | * You should have received a copy of the Affero GNU General Public License |
16 | * You should have received a copy of the Affero GNU General Public License |
17 | * and the GNU General Public License along with this program. If not, see |
17 | * and the GNU General Public License along with this program. If not, see |
18 | * <http://www.gnu.org/licenses/>. |
18 | * <http://www.gnu.org/licenses/>. |
19 | * |
19 | * |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #include "autoconf.h" |
23 | #include "autoconf.h" |
24 | |
24 | |
… | |
… | |
67 | static int tick_inhibit; |
67 | static int tick_inhibit; |
68 | static int tick_pending; |
68 | static int tick_pending; |
69 | |
69 | |
70 | global gbl_ev; |
70 | global gbl_ev; |
71 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
71 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
72 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; |
72 | static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now, *sv_server_tick; |
73 | static AV *av_reflect; |
73 | static AV *av_reflect; |
74 | |
74 | |
75 | bitset<NUM_EVENT_TYPES> ev_want_event; |
75 | bitset<NUM_EVENT_TYPES> ev_want_event; |
76 | bitset<NUM_TYPES> ev_want_type; |
76 | bitset<NUM_TYPES> ev_want_type; |
77 | |
77 | |
… | |
… | |
253 | { |
253 | { |
254 | static int last_mortalcount; |
254 | static int last_mortalcount; |
255 | if (mortals.size () != last_mortalcount) |
255 | if (mortals.size () != last_mortalcount) |
256 | { |
256 | { |
257 | last_mortalcount = mortals.size (); |
257 | last_mortalcount = mortals.size (); |
258 | LOG (llevInfo, "%d mortals.\n", (int)mortals.size ()); |
258 | object *specimen = is_a<object> (mortals [rndm (mortals.size ())]); |
|
|
259 | |
|
|
260 | LOG (llevInfo, "%d mortals (random specimen: %s).\n", |
|
|
261 | (int)mortals.size (), specimen ? specimen->debug_desc () : "(not an object)"); |
259 | |
262 | |
260 | if (0) |
263 | if (0) |
261 | { |
264 | { |
262 | for (int j = 0; j < mortals.size (); ++j)//D |
265 | for (int j = 0; j < mortals.size (); ++j)//D |
263 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
266 | fprintf (stderr, "%d:%s %p ", j, &((object *)mortals[j])->name, mortals[j]);//D |
… | |
… | |
622 | STRLEN len; |
625 | STRLEN len; |
623 | char *data = SvPVbyte (sv, len); |
626 | char *data = SvPVbyte (sv, len); |
624 | v.assign (data, len); |
627 | v.assign (data, len); |
625 | } |
628 | } |
626 | |
629 | |
|
|
630 | static inline void sv_to (SV *sv, refcnt_buf &v) |
|
|
631 | { |
|
|
632 | STRLEN len; |
|
|
633 | char *data = SvPVbyte (sv, len); |
|
|
634 | refcnt_buf buf (data, len); |
|
|
635 | v = buf; |
|
|
636 | } |
|
|
637 | |
627 | static inline void sv_to (SV *sv, UUID &v) |
638 | static inline void sv_to (SV *sv, UUID &v) |
628 | { |
639 | { |
629 | if (!v.parse (SvPV_nolen (sv))) |
640 | if (!v.parse (SvPV_nolen (sv))) |
630 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
641 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
631 | } |
642 | } |
… | |
… | |
1404 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1415 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
1405 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1416 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
1406 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1417 | stash_cf_layout_wrap = gv_stashpv ("cf::layout::wrap", 1); |
1407 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1418 | stash_ext_map_world = gv_stashpv ("ext::map_world" , 1); |
1408 | |
1419 | |
1409 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1420 | sv_now = get_sv ("cf::NOW" , 1); SvUPGRADE (sv_now , SVt_NV); |
1410 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
1421 | sv_runtime = get_sv ("cf::RUNTIME" , 1); SvUPGRADE (sv_runtime , SVt_NV); |
|
|
1422 | sv_server_tick = get_sv ("cf::SERVER_TICK", 1); SvUPGRADE (sv_server_tick, SVt_IV); |
1411 | sv_tick_start = get_sv ("cf::TICK_START", 1); SvUPGRADE (sv_tick_start, SVt_NV); |
1423 | sv_tick_start = get_sv ("cf::TICK_START" , 1); SvUPGRADE (sv_tick_start , SVt_NV); |
1412 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1424 | sv_next_tick = get_sv ("cf::NEXT_TICK" , 1); SvUPGRADE (sv_next_tick , SVt_NV); |
1413 | |
1425 | |
1414 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1426 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1415 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1427 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
1416 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1428 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1417 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1429 | cb_player = get_av ("cf::CB_PLAYER", 1); |
… | |
… | |
1486 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1498 | const_iv (SAVE_MODE) const_iv (SAVE_DIR_MODE) |
1487 | |
1499 | |
1488 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1500 | const_iv (SK_EXP_ADD_SKILL) const_iv (SK_EXP_TOTAL) const_iv (SK_EXP_NONE) |
1489 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1501 | const_iv (SK_SUBTRACT_SKILL_EXP) const_iv (SK_EXP_SKILL_ONLY) |
1490 | |
1502 | |
1491 | const_iv (MAP_ACTIVE) const_iv (MAP_SWAPPED) const_iv (MAP_LOADING) const_iv (MAP_SAVING) |
|
|
1492 | const_iv (MAP_INACTIVE) |
|
|
1493 | |
|
|
1494 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1503 | const_iv (KLASS_ATTACHABLE) const_iv (KLASS_GLOBAL) const_iv (KLASS_OBJECT) |
1495 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1504 | const_iv (KLASS_CLIENT) const_iv (KLASS_PLAYER) const_iv (KLASS_MAP) |
1496 | |
1505 | |
1497 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1506 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1498 | |
1507 | |
… | |
… | |
1530 | |
1539 | |
1531 | void _gv_clear (SV *gv) |
1540 | void _gv_clear (SV *gv) |
1532 | CODE: |
1541 | CODE: |
1533 | assert (SvTYPE (gv) == SVt_PVGV); |
1542 | assert (SvTYPE (gv) == SVt_PVGV); |
1534 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
1543 | # define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); } |
|
|
1544 | SvREFCNT_inc (gv); |
1535 | f (GvGP (gv)->gp_form); |
1545 | f (GvGP (gv)->gp_form); |
1536 | f (GvGP (gv)->gp_io); |
1546 | f (GvGP (gv)->gp_io); |
1537 | f (GvGP (gv)->gp_sv); |
1547 | f (GvGP (gv)->gp_sv); |
1538 | f (GvGP (gv)->gp_av); |
1548 | f (GvGP (gv)->gp_av); |
1539 | f (GvGP (gv)->gp_hv); |
1549 | f (GvGP (gv)->gp_hv); |
1540 | f (GvGP (gv)->gp_cv); |
1550 | f (GvGP (gv)->gp_cv); |
1541 | GvCVGEN (gv) = 0; |
1551 | GvCVGEN (gv) = 0; |
1542 | GvMULTI_off (gv); |
1552 | GvMULTI_off (gv); |
|
|
1553 | SvREFCNT_dec (gv); |
1543 | # undef f |
1554 | # undef f |
1544 | |
1555 | |
1545 | void _connect_to_perl_1 () |
1556 | void _connect_to_perl_1 () |
1546 | |
1557 | |
1547 | void _connect_to_perl_2 () |
1558 | void _connect_to_perl_2 () |
… | |
… | |
1613 | { |
1624 | { |
1614 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1625 | ev_async_send (EV_DEFAULT, &tick_watcher); |
1615 | coroapi::cede (); |
1626 | coroapi::cede (); |
1616 | } |
1627 | } |
1617 | |
1628 | |
1618 | void server_tick () |
1629 | void one_tick () |
1619 | CODE: |
1630 | CODE: |
1620 | { |
1631 | { |
1621 | ev_now_update (EV_DEFAULT); |
1632 | ev_now_update (EV_DEFAULT); |
1622 | NOW = ev_now (EV_DEFAULT); |
1633 | NOW = ev_now (EV_DEFAULT); |
1623 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1634 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1624 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1635 | SvNV_set (sv_tick_start, NOW); SvNOK_only (sv_tick_start); |
1625 | runtime = SvNVX (sv_runtime); |
1636 | runtime = SvNVX (sv_runtime); |
1626 | |
1637 | |
|
|
1638 | one_tick (); |
|
|
1639 | |
1627 | server_tick (); |
1640 | ++server_tick; |
|
|
1641 | SvUV_set (sv_server_tick, server_tick); SvIOK_only_UV (sv_server_tick); |
1628 | |
1642 | |
1629 | ev_now_update (EV_DEFAULT); |
1643 | ev_now_update (EV_DEFAULT); |
1630 | NOW = ev_now (EV_DEFAULT); |
1644 | NOW = ev_now (EV_DEFAULT); |
1631 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
1645 | SvNV_set (sv_now, NOW); SvNOK_only (sv_now); |
|
|
1646 | |
1632 | runtime += TICK; |
1647 | runtime += TICK; |
1633 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1648 | SvNV_set (sv_runtime, runtime); SvNOK_only (sv_runtime); |
1634 | } |
1649 | } |
1635 | |
1650 | |
1636 | NV floor (NV x) |
1651 | NV floor (NV x) |
… | |
… | |
2103 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2118 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2104 | |
2119 | |
2105 | object *new (utf8_string archetype = 0) |
2120 | object *new (utf8_string archetype = 0) |
2106 | PROTOTYPE: ;$ |
2121 | PROTOTYPE: ;$ |
2107 | CODE: |
2122 | CODE: |
2108 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2123 | RETVAL = archetype |
|
|
2124 | ? archetype::get (archetype) |
|
|
2125 | : object::create (); |
2109 | OUTPUT: |
2126 | OUTPUT: |
2110 | RETVAL |
2127 | RETVAL |
2111 | |
2128 | |
2112 | object *generate (utf8_string arch, object *creator) |
2129 | object *generate (utf8_string arch, object *creator) |
2113 | CODE: |
2130 | CODE: |
2114 | object *obj = get_archetype (arch); |
2131 | object *obj = archetype::get (arch); |
2115 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2132 | fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); |
2116 | RETVAL = obj; |
2133 | RETVAL = obj; |
2117 | OUTPUT: |
2134 | OUTPUT: |
2118 | RETVAL |
2135 | RETVAL |
2119 | |
2136 | |
… | |
… | |
2129 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2146 | RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); |
2130 | |
2147 | |
2131 | if (RETVAL->destroyed ()) |
2148 | if (RETVAL->destroyed ()) |
2132 | RETVAL = 0; |
2149 | RETVAL = 0; |
2133 | } |
2150 | } |
|
|
2151 | OUTPUT: |
|
|
2152 | RETVAL |
2134 | |
2153 | |
2135 | shstr |
2154 | shstr |
2136 | object::kv_get (shstr key) |
2155 | object::kv_get (shstr key) |
2137 | CODE: |
2156 | CODE: |
2138 | RETVAL = THIS->kv.get (key); |
2157 | RETVAL = THIS->kv.get (key); |
… | |
… | |
2357 | for_all_players (pl) |
2376 | for_all_players (pl) |
2358 | if (pl->ob && pl->ob->map == THIS) |
2377 | if (pl->ob && pl->ob->map == THIS) |
2359 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2378 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2360 | } |
2379 | } |
2361 | |
2380 | |
2362 | #if 0 |
|
|
2363 | |
|
|
2364 | void |
2381 | void |
2365 | maptile::add_quadland (int mx, int my, int mz, SV *biome_map, SV *biome_plt) |
2382 | maptile::gen_quadmap (int x, int y, int z) |
2366 | CODE: |
2383 | CODE: |
2367 | { |
2384 | gen_quadmap (THIS, x * 50, y * 50, z); |
2368 | static frac_gen<vec2d> frac; |
|
|
2369 | |
2385 | |
|
|
2386 | void |
|
|
2387 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
|
|
2388 | CODE: |
|
|
2389 | { |
2370 | if (!SvROK (biome_plt) || SvTYPE (SvRV (biome_plt)) != SVt_PVAV) |
2390 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
2371 | croak ("maptile::add_quadland: biome_plt must be arrayref"); |
2391 | croak ("maptile::add_underlay: palette must be arrayref"); |
2372 | |
2392 | |
2373 | biome_plt = SvRV (biome_plt); |
2393 | palette = SvRV (palette); |
2374 | |
2394 | |
|
|
2395 | STRLEN idxlen; |
2375 | const uint8_t *bmap = (const uint8_t *)SvPVbyte_nolen (biome_map); |
2396 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2376 | |
2397 | |
2377 | for (int x = 0; x < THIS->width; ++x) |
2398 | for (int x = 0; x < THIS->width; ++x) |
2378 | for (int y = 0; y < THIS->height; ++y) |
2399 | for (int y = 0; y < THIS->height; ++y) |
2379 | { |
2400 | { |
2380 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
2401 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
2381 | if (op->flag [FLAG_IS_FLOOR]) |
2402 | if (op->flag [FLAG_IS_FLOOR]) |
2382 | goto skip; |
2403 | goto skip; |
2383 | |
2404 | |
2384 | { |
2405 | { |
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 | |
|
|
2420 | void |
|
|
2421 | maptile::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; |
2406 | int offs = offset + y * stride + x; |
2441 | |
2407 | |
2442 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2408 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
2443 | { |
2409 | { |
2444 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2410 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
2445 | { |
2411 | { |
2446 | object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); |
2412 | object *ob = archetype::get (cfSvPVutf8_nolen (*elem)); |
2447 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2413 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
2448 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2414 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
2449 | |
2415 | |
2450 | if (ob->randomitems && !ob->above) |
2416 | if (ob->randomitems && !ob->above) |
2451 | { |
2417 | { |
… | |
… | |
2736 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2702 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2737 | |
2703 | |
2738 | faceidx alloc (utf8_string name) |
2704 | faceidx alloc (utf8_string name) |
2739 | CODE: |
2705 | CODE: |
2740 | { |
2706 | { |
2741 | do |
2707 | RETVAL = face_alloc (); |
2742 | { |
|
|
2743 | RETVAL = faces.size (); |
|
|
2744 | faces.resize (RETVAL + 1); |
|
|
2745 | } |
|
|
2746 | while (!RETVAL); // crude way to leave index 0 |
|
|
2747 | |
2708 | |
2748 | faces [RETVAL].name = name; |
2709 | faces [RETVAL].name = name; |
2749 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2710 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2750 | |
2711 | |
2751 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
2712 | if (!strcmp (name, BLANK_FACE_NAME )) blank_face = RETVAL; |
… | |
… | |
2805 | if (!d) XSRETURN_UNDEF; |
2766 | if (!d) XSRETURN_UNDEF; |
2806 | RETVAL = d->data.size (); |
2767 | RETVAL = d->data.size (); |
2807 | OUTPUT: |
2768 | OUTPUT: |
2808 | RETVAL |
2769 | RETVAL |
2809 | |
2770 | |
|
|
2771 | void set_meta (faceidx idx, SV *sv) |
|
|
2772 | CODE: |
|
|
2773 | { |
|
|
2774 | faceinfo *f = face_info (idx); assert (f); |
|
|
2775 | SvREFCNT_dec (f->meta_hv); |
|
|
2776 | f->meta_hv = SvOK (sv) ? (HV *)SvREFCNT_inc (SvRV (sv)) : 0; |
|
|
2777 | } |
|
|
2778 | |
2810 | SV *get_chksum (faceidx idx, int faceset = 0) |
2779 | SV *get_chksum (faceidx idx, int faceset = 0) |
2811 | CODE: |
2780 | CODE: |
2812 | facedata *d = face_data (idx, faceset); |
2781 | facedata *d = face_data (idx, faceset); |
2813 | if (!d) XSRETURN_UNDEF; |
2782 | if (!d) XSRETURN_UNDEF; |
2814 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
2783 | RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); |
… | |
… | |
2817 | |
2786 | |
2818 | SV *get_data (faceidx idx, int faceset = 0) |
2787 | SV *get_data (faceidx idx, int faceset = 0) |
2819 | CODE: |
2788 | CODE: |
2820 | facedata *d = face_data (idx, faceset); |
2789 | facedata *d = face_data (idx, faceset); |
2821 | if (!d) XSRETURN_UNDEF; |
2790 | if (!d) XSRETURN_UNDEF; |
2822 | RETVAL = newSVpvn (d->data.data (), d->data.length ()); |
2791 | RETVAL = newSVpvn (d->data, d->data.size ()); |
2823 | OUTPUT: |
2792 | OUTPUT: |
2824 | RETVAL |
2793 | RETVAL |
2825 | |
2794 | |
|
|
2795 | SV *get_meta (faceidx idx) |
|
|
2796 | CODE: |
|
|
2797 | faceinfo *f = face_info (idx); assert (f); |
|
|
2798 | if (!f || !f->meta_hv) XSRETURN_UNDEF; |
|
|
2799 | RETVAL = newRV_inc ((SV *)f->meta_hv); |
|
|
2800 | OUTPUT: |
|
|
2801 | RETVAL |
|
|
2802 | |
2826 | void invalidate (faceidx idx) |
2803 | void invalidate (faceidx idx) |
2827 | CODE: |
2804 | CODE: |
2828 | for_all_clients (ns) |
2805 | for_all_clients (ns) |
2829 | { |
2806 | ns->invalidate_face (idx); |
2830 | ns->faces_sent [idx] = false; |
|
|
2831 | ns->force_newmap = true; |
|
|
2832 | } |
|
|
2833 | |
2807 | |
2834 | void invalidate_all () |
2808 | void invalidate_all () |
2835 | CODE: |
2809 | CODE: |
2836 | for_all_clients (ns) |
2810 | for_all_clients (ns) |
2837 | { |
2811 | ns->invalidate_all_faces (); |
2838 | ns->faces_sent.reset (); |
|
|
2839 | ns->force_newmap = true; |
|
|
2840 | } |
|
|
2841 | |
2812 | |
2842 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2813 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
2843 | |
2814 | |
2844 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2815 | #INCLUDE: $PERL $srcdir/genacc faceset $srcdir/../include/anim.h | |
2845 | |
2816 | |