… | |
… | |
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" |
… | |
… | |
382 | return SvPTR (sv, klass); |
381 | return SvPTR (sv, klass); |
383 | else |
382 | else |
384 | return 0; |
383 | return 0; |
385 | } |
384 | } |
386 | |
385 | |
|
|
386 | static inline SV * |
|
|
387 | newSVpv_utf8 (const char *s) |
|
|
388 | { |
|
|
389 | SV *sv = newSVpv (s, 0); |
|
|
390 | SvUTF8_on (sv); |
|
|
391 | return sv; |
|
|
392 | } |
|
|
393 | |
|
|
394 | static inline SV * |
|
|
395 | newSVpvn_utf8 (const char *s, STRLEN l) |
|
|
396 | { |
|
|
397 | SV *sv = newSVpvn (s, l); |
|
|
398 | SvUTF8_on (sv); |
|
|
399 | return sv; |
|
|
400 | } |
|
|
401 | |
387 | inline SV *to_sv (const shstr & v) { return v ? newSVpvn ((const char *)v, v.length ()) : &PL_sv_undef; } |
402 | 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); } |
403 | inline SV *to_sv (const char * v) { return newSVpv (v, 0); } |
389 | inline SV *to_sv (bool v) { return newSViv (v); } |
404 | inline SV *to_sv (bool v) { return newSViv (v); } |
390 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
405 | inline SV *to_sv ( signed char v) { return newSViv (v); } |
391 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
406 | inline SV *to_sv (unsigned char v) { return newSViv (v); } |
392 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
407 | inline SV *to_sv ( signed short v) { return newSViv (v); } |
… | |
… | |
419 | char buf[128]; |
434 | char buf[128]; |
420 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
435 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
421 | return newSVpv (buf, 0); |
436 | return newSVpv (buf, 0); |
422 | } |
437 | } |
423 | |
438 | |
424 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
439 | 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; } |
440 | 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); } |
441 | inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } |
427 | inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } |
442 | 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); } |
443 | 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); } |
444 | inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } |
… | |
… | |
993 | { |
1008 | { |
994 | CALL_BEGIN (4); |
1009 | CALL_BEGIN (4); |
995 | CALL_ARG (ns); |
1010 | CALL_ARG (ns); |
996 | CALL_ARG (color); |
1011 | CALL_ARG (color); |
997 | CALL_ARG (type); |
1012 | CALL_ARG (type); |
998 | CALL_ARG (msg); |
1013 | CALL_ARG_SV (newSVpv_utf8 (msg)); |
999 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1014 | CALL_CALL ("cf::client::send_msg", G_VOID); |
1000 | CALL_END; |
1015 | CALL_END; |
1001 | } |
1016 | } |
1002 | |
1017 | |
1003 | maptile * |
1018 | maptile * |
… | |
… | |
1994 | CODE: |
2009 | CODE: |
1995 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
2010 | RETVAL = archetype ? get_archetype (archetype) : object::create (); |
1996 | OUTPUT: |
2011 | OUTPUT: |
1997 | RETVAL |
2012 | RETVAL |
1998 | |
2013 | |
|
|
2014 | object *find_object (U32 tag) |
|
|
2015 | |
1999 | # TODO: nuke |
2016 | # TODO: nuke |
2000 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
2017 | object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) |
2001 | PROTOTYPE: $$$$$$ |
2018 | PROTOTYPE: $$$$$$ |
2002 | CODE: |
2019 | CODE: |
2003 | { |
2020 | { |
2004 | int unused_type; |
2021 | int unused_type; |
2005 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
2022 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
2006 | } |
2023 | } |
2007 | |
|
|
2008 | player *contr (object *op) |
|
|
2009 | CODE: |
|
|
2010 | RETVAL = op->contr; |
|
|
2011 | OUTPUT: RETVAL |
|
|
2012 | |
2024 | |
2013 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2025 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2014 | |
2026 | |
2015 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2027 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2016 | |
2028 | |
… | |
… | |
2591 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2603 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2592 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2604 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2593 | } |
2605 | } |
2594 | OUTPUT: RETVAL |
2606 | OUTPUT: RETVAL |
2595 | |
2607 | |
2596 | void set (faceidx idx, int visibility, int magicmap) |
2608 | void set_type (faceidx idx, int value) |
|
|
2609 | ALIAS: |
|
|
2610 | set_type = 0 |
|
|
2611 | set_visibility = 1 |
|
|
2612 | set_magicmap = 2 |
|
|
2613 | set_smooth = 3 |
|
|
2614 | set_smoothlevel = 4 |
2597 | CODE: |
2615 | CODE: |
2598 | faceinfo *f = face_info (idx); |
2616 | faceinfo *f = face_info (idx); |
2599 | assert (f); |
2617 | assert (f); |
2600 | f->visibility = visibility; |
2618 | switch (ix) |
2601 | f->magicmap = magicmap; |
2619 | { |
2602 | |
2620 | case 0: f->type = value; break; |
2603 | void set_smooth (faceidx idx, faceidx smooth, int smoothlevel) |
2621 | case 1: f->visibility = value; break; |
2604 | CODE: |
2622 | case 2: f->magicmap = value; break; |
2605 | faceinfo *f = face_info (idx); assert (f); |
2623 | case 3: f->smooth = value; break; |
2606 | f->smooth = smooth; |
2624 | case 4: f->smoothlevel = value; break; |
2607 | f->smoothlevel = smoothlevel; |
2625 | } |
2608 | |
2626 | |
2609 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2627 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2610 | CODE: |
2628 | CODE: |
2611 | { |
2629 | { |
2612 | facedata *d = face_data (idx, faceset); |
2630 | facedata *d = face_data (idx, faceset); |