… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
5 | * Copyright (©) 2001-2005,2007 by Chachkoff Yann |
5 | * Copyright (©) 2001-2005,2007 by Chachkoff Yann |
6 | * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de> |
6 | * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de> |
7 | * |
7 | * |
8 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
9 | * under the terms of the GNU General Public License as published by the Free |
9 | * it under the terms of the GNU General Public License as published by |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, but |
13 | * This program is distributed in the hope that it will be useful, |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
18 | * You should have received a copy of the GNU General Public License |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | #include "autoconf.h" |
24 | #include "autoconf.h" |
… | |
… | |
247 | delete obj; |
246 | delete obj; |
248 | } |
247 | } |
249 | } |
248 | } |
250 | } |
249 | } |
251 | |
250 | |
|
|
251 | void |
|
|
252 | attachable::set_key (const char *key, const char *value) |
|
|
253 | { |
|
|
254 | if (!self) |
|
|
255 | self = newHV (); |
|
|
256 | |
|
|
257 | if (value) |
|
|
258 | hv_store (self, key, strlen (key), newSVpv (value, 0), 0); |
|
|
259 | else |
|
|
260 | hv_delete (self, key, strlen (key), G_DISCARD); |
|
|
261 | } |
|
|
262 | |
252 | attachable & |
263 | attachable & |
253 | attachable::operator =(const attachable &src) |
264 | attachable::operator =(const attachable &src) |
254 | { |
265 | { |
255 | //if (self || cb) |
266 | //if (self || cb) |
256 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
267 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
… | |
… | |
331 | { |
342 | { |
332 | if (!obj) |
343 | if (!obj) |
333 | return &PL_sv_undef; |
344 | return &PL_sv_undef; |
334 | |
345 | |
335 | if (!obj->self) |
346 | if (!obj->self) |
|
|
347 | obj->self = newHV (); |
|
|
348 | |
|
|
349 | if (!SvOBJECT (obj->self)) |
336 | { |
350 | { |
337 | obj->self = newHV (); |
|
|
338 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
351 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
339 | |
352 | |
340 | // now bless the object _once_ |
353 | // now bless the object _once_ |
|
|
354 | //TODO: create a class registry with c++ type<=>perl name<=>stash and use it here and elsewhere |
341 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
355 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
342 | } |
356 | } |
343 | else |
357 | else |
344 | { |
358 | { |
345 | SV *sv = newRV_inc ((SV *)obj->self); |
359 | SV *sv = newRV_inc ((SV *)obj->self); |
… | |
… | |
382 | return SvPTR (sv, klass); |
396 | return SvPTR (sv, klass); |
383 | else |
397 | else |
384 | return 0; |
398 | return 0; |
385 | } |
399 | } |
386 | |
400 | |
|
|
401 | static inline SV * |
|
|
402 | newSVpv_utf8 (const char *s) |
|
|
403 | { |
|
|
404 | SV *sv = newSVpv (s, 0); |
|
|
405 | SvUTF8_on (sv); |
|
|
406 | return sv; |
|
|
407 | } |
|
|
408 | |
|
|
409 | static inline SV * |
|
|
410 | newSVpvn_utf8 (const char *s, STRLEN l) |
|
|
411 | { |
|
|
412 | SV *sv = newSVpvn (s, l); |
|
|
413 | SvUTF8_on (sv); |
|
|
414 | return sv; |
|
|
415 | } |
|
|
416 | |
387 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn ((const char *)v, v.length ()) : &PL_sv_undef; } |
417 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; } |
388 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
418 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
389 | inline SV *to_sv (bool v) { return newSViv (v); } |
419 | inline SV *to_sv (bool v) { return newSViv (v); } |
390 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
420 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
391 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
421 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
392 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
422 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
… | |
… | |
402 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
432 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
403 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
433 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
404 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
434 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
405 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
435 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
406 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
436 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
|
|
437 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
407 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
438 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
408 | inline SV *to_sv (region * v) { return newSVptr (v, stash_cf_region_wrap); } |
|
|
409 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
439 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
410 | |
440 | |
411 | inline SV *to_sv (object & v) { return to_sv (&v); } |
441 | inline SV *to_sv (object & v) { return to_sv (&v); } |
412 | inline SV *to_sv (living & v) { return to_sv (&v); } |
442 | inline SV *to_sv (living & v) { return to_sv (&v); } |
413 | |
443 | |
… | |
… | |
419 | char buf[128]; |
449 | char buf[128]; |
420 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
450 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
421 | return newSVpv (buf, 0); |
451 | return newSVpv (buf, 0); |
422 | } |
452 | } |
423 | |
453 | |
424 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
454 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } |
425 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
455 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
426 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
456 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
427 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
457 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
428 | inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } |
458 | inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } |
429 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
459 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
… | |
… | |
439 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
469 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
440 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
470 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
441 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
471 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
442 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
472 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
443 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
473 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
474 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
444 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
475 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
445 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
476 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
446 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
|
|
447 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
477 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
448 | |
478 | |
449 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
479 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
450 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
480 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
451 | |
481 | |
… | |
… | |
934 | } |
964 | } |
935 | |
965 | |
936 | SV * |
966 | SV * |
937 | cfperl_result (int idx) |
967 | cfperl_result (int idx) |
938 | { |
968 | { |
939 | AV *av = get_av ("cfperl::invoke_results", 0); |
969 | AV *av = get_av ("cf::INVOKE_RESULTS", 0); |
940 | if (!av) |
970 | if (!av) |
941 | return &PL_sv_undef; |
971 | return &PL_sv_undef; |
942 | |
972 | |
943 | SV **sv = av_fetch (av, idx, 0); |
973 | SV **sv = av_fetch (av, idx, 0); |
944 | if (!sv) |
974 | if (!sv) |
… | |
… | |
984 | CALL_BEGIN (2); |
1014 | CALL_BEGIN (2); |
985 | CALL_ARG (book); |
1015 | CALL_ARG (book); |
986 | CALL_ARG (level); |
1016 | CALL_ARG (level); |
987 | CALL_CALL ("ext::books::make_book", G_VOID); |
1017 | CALL_CALL ("ext::books::make_book", G_VOID); |
988 | CALL_END; |
1018 | CALL_END; |
|
|
1019 | } |
|
|
1020 | |
|
|
1021 | void |
|
|
1022 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
|
|
1023 | { |
|
|
1024 | CALL_BEGIN (4); |
|
|
1025 | CALL_ARG (ns); |
|
|
1026 | CALL_ARG (type); |
|
|
1027 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
|
|
1028 | CALL_ARG (color); |
|
|
1029 | CALL_CALL ("cf::client::send_msg", G_VOID); |
|
|
1030 | CALL_END; |
|
|
1031 | } |
|
|
1032 | |
|
|
1033 | int |
|
|
1034 | cfperl_can_merge (object *ob1, object *ob2) |
|
|
1035 | { |
|
|
1036 | int can; |
|
|
1037 | |
|
|
1038 | CALL_BEGIN (2); |
|
|
1039 | CALL_ARG (ob1); |
|
|
1040 | CALL_ARG (ob2); |
|
|
1041 | CALL_CALL ("cf::_can_merge", G_SCALAR); |
|
|
1042 | can = count && SvTRUE (TOPs); |
|
|
1043 | CALL_END; |
|
|
1044 | |
|
|
1045 | return can; |
989 | } |
1046 | } |
990 | |
1047 | |
991 | maptile * |
1048 | maptile * |
992 | maptile::find_sync (const char *path, maptile *origin) |
1049 | maptile::find_sync (const char *path, maptile *origin) |
993 | { |
1050 | { |
… | |
… | |
1507 | |
1564 | |
1508 | for_all_objects (op) |
1565 | for_all_objects (op) |
1509 | op->reattach (); |
1566 | op->reattach (); |
1510 | } |
1567 | } |
1511 | |
1568 | |
1512 | void _post_tick () |
|
|
1513 | CODE: |
|
|
1514 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
|
|
1515 | |
|
|
1516 | # support function for map-world.ext |
1569 | # support function for map-world.ext |
1517 | void _quantise (SV *data_sv, SV *plt_sv) |
1570 | void _quantise (SV *data_sv, SV *plt_sv) |
1518 | CODE: |
1571 | CODE: |
1519 | { |
1572 | { |
1520 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
1573 | if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV) |
… | |
… | |
1552 | len -= 3; |
1605 | len -= 3; |
1553 | } |
1606 | } |
1554 | |
1607 | |
1555 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1608 | SvCUR_set (data_sv, dst - SvPVX (data_sv)); |
1556 | } |
1609 | } |
|
|
1610 | |
|
|
1611 | void _post_tick () |
|
|
1612 | CODE: |
|
|
1613 | coroapi::next_cede = SvNV (sv_next_tick) - TICK * (1. - 1. / CEDES_PER_TICK); |
|
|
1614 | |
|
|
1615 | NV till_cede () |
|
|
1616 | CODE: |
|
|
1617 | RETVAL = coroapi::next_cede - now (); |
|
|
1618 | OUTPUT: |
|
|
1619 | RETVAL |
|
|
1620 | |
|
|
1621 | NV till_tick () |
|
|
1622 | CODE: |
|
|
1623 | RETVAL = SvNV (sv_next_tick) - now (); |
|
|
1624 | OUTPUT: |
|
|
1625 | RETVAL |
1557 | |
1626 | |
1558 | NV floor (NV x) |
1627 | NV floor (NV x) |
1559 | |
1628 | |
1560 | NV ceil (NV x) |
1629 | NV ceil (NV x) |
1561 | |
1630 | |
… | |
… | |
1967 | |
2036 | |
1968 | void add_button_link (object *button, maptile *map, int connected); |
2037 | void add_button_link (object *button, maptile *map, int connected); |
1969 | |
2038 | |
1970 | void remove_button_link (object *op); |
2039 | void remove_button_link (object *op); |
1971 | |
2040 | |
|
|
2041 | void handle_apply_yield (object *op); |
|
|
2042 | |
1972 | |
2043 | |
1973 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2044 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1974 | |
2045 | |
1975 | object *cf_insert_ob_in_ob (object *ob, object *where) |
2046 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1976 | |
2047 | |
… | |
… | |
1982 | CODE: |
2053 | CODE: |
1983 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2054 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
1984 | OUTPUT: |
2055 | OUTPUT: |
1985 | RETVAL |
2056 | RETVAL |
1986 | |
2057 | |
|
|
2058 | object *find_object (U32 tag) |
|
|
2059 | |
1987 | # TODO: nuke |
2060 | # TODO: nuke |
1988 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
2061 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
1989 | PROTOTYPE: $$$$$$ |
2062 | PROTOTYPE: $$$$$$ |
1990 | CODE: |
2063 | CODE: |
1991 | { |
2064 | { |
1992 | int unused_type; |
2065 | int unused_type; |
1993 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
2066 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
1994 | } |
2067 | } |
1995 | |
|
|
1996 | player *contr (object *op) |
|
|
1997 | CODE: |
|
|
1998 | RETVAL = op->contr; |
|
|
1999 | OUTPUT: RETVAL |
|
|
2000 | |
2068 | |
2001 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2069 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2002 | |
2070 | |
2003 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2071 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2004 | |
2072 | |
… | |
… | |
2230 | palette = SvRV (palette); |
2298 | palette = SvRV (palette); |
2231 | |
2299 | |
2232 | STRLEN idxlen; |
2300 | STRLEN idxlen; |
2233 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2301 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
2234 | |
2302 | |
2235 | region **regionmap = (region **)malloc ( |
2303 | region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; |
2236 | (av_len ((AV *)palette) + 1) * sizeof (region *)); |
|
|
2237 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2304 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
2238 | |
2305 | |
2239 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2306 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
2240 | regionmap [i] = region::find ( |
2307 | regionmap [i] = region::find (SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
2241 | SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
|
|
2242 | |
2308 | |
2243 | for (int y = 0; y < THIS->height; ++y) |
2309 | for (int y = 0; y < THIS->height; ++y) |
2244 | memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); |
2310 | memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); |
2245 | |
2311 | |
2246 | sfree (THIS->regions, THIS->size ()); |
2312 | sfree (THIS->regions, THIS->size ()); |
2247 | free (THIS->regionmap); |
2313 | delete [] THIS->regionmap; |
2248 | |
2314 | |
2249 | THIS->regions = regions; |
2315 | THIS->regions = regions; |
2250 | THIS->regionmap = regionmap; |
2316 | THIS->regionmap = regionmap; |
2251 | } |
2317 | } |
2252 | |
2318 | |
… | |
… | |
2555 | char *buf = SvPVbyte (packet, len); |
2621 | char *buf = SvPVbyte (packet, len); |
2556 | |
2622 | |
2557 | THIS->send_packet (buf, len); |
2623 | THIS->send_packet (buf, len); |
2558 | } |
2624 | } |
2559 | |
2625 | |
|
|
2626 | faceidx |
|
|
2627 | client::find_face (utf8_string name, faceidx defidx = 0) |
|
|
2628 | CODE: |
|
|
2629 | RETVAL = face_find (name, defidx); |
|
|
2630 | THIS->send_face (RETVAL); |
|
|
2631 | THIS->flush_fx (); |
|
|
2632 | OUTPUT: |
|
|
2633 | RETVAL |
|
|
2634 | |
2560 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2635 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2561 | |
2636 | |
2562 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2637 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2563 | |
2638 | |
2564 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2639 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
… | |
… | |
2579 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2654 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2580 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2655 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2581 | } |
2656 | } |
2582 | OUTPUT: RETVAL |
2657 | OUTPUT: RETVAL |
2583 | |
2658 | |
2584 | void set (faceidx idx, int visibility, int magicmap) |
2659 | void set_type (faceidx idx, int value) |
2585 | CODE: |
2660 | ALIAS: |
2586 | faceinfo *f = face_info (idx); |
2661 | set_type = 0 |
2587 | assert (f); |
2662 | set_visibility = 1 |
2588 | f->visibility = visibility; |
2663 | set_magicmap = 2 |
2589 | f->magicmap = magicmap; |
2664 | set_smooth = 3 |
2590 | |
2665 | set_smoothlevel = 4 |
2591 | void set_smooth (faceidx idx, faceidx smooth, int smoothlevel) |
|
|
2592 | CODE: |
2666 | CODE: |
2593 | faceinfo *f = face_info (idx); assert (f); |
2667 | faceinfo *f = face_info (idx); assert (f); |
2594 | f->smooth = smooth; |
2668 | switch (ix) |
2595 | f->smoothlevel = smoothlevel; |
2669 | { |
|
|
2670 | case 0: f->type = value; break; |
|
|
2671 | case 1: f->visibility = value; break; |
|
|
2672 | case 2: f->magicmap = value; break; |
|
|
2673 | case 3: f->smooth = value; break; |
|
|
2674 | case 4: f->smoothlevel = value; break; |
|
|
2675 | } |
2596 | |
2676 | |
2597 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2677 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2598 | CODE: |
2678 | CODE: |
2599 | { |
2679 | { |
2600 | facedata *d = face_data (idx, faceset); |
2680 | faceinfo *f = face_info (idx); assert (f); |
2601 | assert (d); |
2681 | facedata *d = &(faceset ? f->data64 : f->data32); |
2602 | sv_to (data, d->data); |
2682 | sv_to (data, d->data); |
2603 | STRLEN clen; |
2683 | STRLEN clen; |
2604 | char *cdata = SvPVbyte (chksum, clen); |
2684 | char *cdata = SvPVbyte (chksum, clen); |
2605 | clen = min (CHKSUM_SIZE, clen); |
2685 | clen = min (CHKSUM_SIZE, clen); |
2606 | |
2686 | |
… | |
… | |
2616 | ns->force_newmap = true; |
2696 | ns->force_newmap = true; |
2617 | } |
2697 | } |
2618 | } |
2698 | } |
2619 | } |
2699 | } |
2620 | |
2700 | |
|
|
2701 | int get_data_size (faceidx idx, int faceset = 0) |
|
|
2702 | CODE: |
|
|
2703 | facedata *d = face_data (idx, faceset); assert (d); |
|
|
2704 | RETVAL = d->data.size (); |
|
|
2705 | OUTPUT: |
|
|
2706 | RETVAL |
|
|
2707 | |
|
|
2708 | SV *get_chksum (faceidx idx, int faceset = 0) |
|
|
2709 | CODE: |
|
|
2710 | facedata *d = face_data (idx, faceset); assert (d); |
|
|
2711 | RETVAL = newSVpvn ((char *)d->chksum, CHKSUM_SIZE); |
|
|
2712 | OUTPUT: |
|
|
2713 | RETVAL |
|
|
2714 | |
2621 | void invalidate (faceidx idx) |
2715 | void invalidate (faceidx idx) |
2622 | CODE: |
2716 | CODE: |
2623 | for_all_clients (ns) |
2717 | for_all_clients (ns) |
2624 | { |
2718 | { |
2625 | ns->faces_sent [idx] = false; |
2719 | ns->faces_sent [idx] = false; |