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.425 by root, Wed Nov 14 06:21:39 2012 UTC vs.
Revision 1.431 by root, Sat Dec 1 20:22:13 2018 UTC

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 (©) 2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2006,2007,2008,2009,2010,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2006,2007,2008,2009,2010,2012,2015 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 6 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 7 * 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 8 * 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 9 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 10 * option) any later version.
20 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 22 */
22 23
23#include "autoconf.h" 24#include "autoconf.h"
24 25
26#define CFPERL 1
27
25#if HAVE_EXECINFO_H 28#if HAVE_EXECINFO_H
26# include <execinfo.h> 29# include <execinfo.h>
27#endif 30#endif
28 31
29#include <cstdarg> 32#include <cstdarg>
125 128
126 return sv; 129 return sv;
127} 130}
128#endif 131#endif
129 132
130noinline utf8_string 133ecb_noinline utf8_string
131cfSvPVutf8_nolen (SV *sv) 134cfSvPVutf8_nolen (SV *sv)
132{ 135{
133 SvGETMAGIC (sv); 136 SvGETMAGIC (sv);
134 137
135 if (SvPOK (sv)) 138 if (SvPOK (sv))
367 370
368 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); 371 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0);
369 return sv_bless (newRV_noinc ((SV *)hv), stash); 372 return sv_bless (newRV_noinc ((SV *)hv), stash);
370} 373}
371 374
372static SV * noinline 375ecb_noinline static SV *
373newSVptr (void *ptr, HV *stash) 376newSVptr (void *ptr, HV *stash)
374{ 377{
375 return newSVptr (ptr, stash, newHV ()); 378 return newSVptr (ptr, stash, newHV ());
376} 379}
377 380
392 return 0; 395 return 0;
393} 396}
394 397
395MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free}; 398MGVTBL attachable::vtbl = {0, 0, 0, 0, attachable_free};
396 399
397static SV * noinline 400ecb_noinline static SV *
398newSVattachable (attachable *obj, HV *stash) 401newSVattachable (attachable *obj, HV *stash)
399{ 402{
400 if (!obj) 403 if (!obj)
401 return newSV (0); 404 return newSV (0);
402 405
456 croak ("object of type %s expected", klass); 459 croak ("object of type %s expected", klass);
457 460
458 return SvPTR_nc (sv); 461 return SvPTR_nc (sv);
459} 462}
460 463
461static long noinline 464ecb_noinline static long
462SvPTR_ornull (SV *sv, const char *klass) 465SvPTR_ornull (SV *sv, const char *klass)
463{ 466{
464 if (expect_false (!SvOK (sv))) return 0; 467 if (expect_false (!SvOK (sv))) return 0;
465 468
466 return SvPTR (sv, klass); 469 return SvPTR (sv, klass);
467} 470}
468 471
469static long noinline 472ecb_noinline static long
470SvPTR_ornull_client (SV *sv) 473SvPTR_ornull_client (SV *sv)
471{ 474{
472 if (expect_false (!SvOK (sv))) return 0; 475 if (expect_false (!SvOK (sv))) return 0;
473 476
474 if (!SvROK (sv) 477 if (!SvROK (sv)
477 croak ("object of type cf::client expected"); 480 croak ("object of type cf::client expected");
478 481
479 return SvPTR_nc (sv); 482 return SvPTR_nc (sv);
480} 483}
481 484
482static long noinline 485ecb_noinline static long
483SvPTR_ornull_object (SV *sv) 486SvPTR_ornull_object (SV *sv)
484{ 487{
485 if (expect_false (!SvOK (sv))) return 0; 488 if (expect_false (!SvOK (sv))) return 0;
486 489
487 if (!SvROK (sv) 490 if (!SvROK (sv)
492 croak ("object of type cf::object expected"); 495 croak ("object of type cf::object expected");
493 496
494 return SvPTR_nc (sv); 497 return SvPTR_nc (sv);
495} 498}
496 499
497static long noinline 500ecb_noinline static long
498SvPTR_ornull_maptile (SV *sv) 501SvPTR_ornull_maptile (SV *sv)
499{ 502{
500 if (expect_false (!SvOK (sv))) return 0; 503 if (expect_false (!SvOK (sv))) return 0;
501 504
502 if (!SvROK (sv) 505 if (!SvROK (sv)
506 croak ("object of type cf::map expected"); 509 croak ("object of type cf::map expected");
507 510
508 return SvPTR_nc (sv); 511 return SvPTR_nc (sv);
509} 512}
510 513
511static long noinline 514ecb_noinline static long
512SvPTR_ornull_player (SV *sv) 515SvPTR_ornull_player (SV *sv)
513{ 516{
514 if (expect_false (!SvOK (sv))) return 0; 517 if (expect_false (!SvOK (sv))) return 0;
515 518
516 if (!SvROK (sv) 519 if (!SvROK (sv)
536static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } 539static inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
537static inline SV *to_sv (float v) { return newSVnv (v); } 540static inline SV *to_sv (float v) { return newSVnv (v); }
538static inline SV *to_sv (double v) { return newSVnv (v); } 541static inline SV *to_sv (double v) { return newSVnv (v); }
539static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 542static inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); }
540static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } 543static inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
541// gcc dislikes noilnine on to_sv 544// gcc dislikes noinline on to_sv
542static noinline SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } 545ecb_noinline static SV *to_sv_ni (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); }
543static inline SV *to_sv (object * v) { return to_sv_ni (v); } 546static inline SV *to_sv (object * v) { return to_sv_ni (v); }
544static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 547static inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
545static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 548static inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
546static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } 549static inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
547static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 550static inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
726 return sv; 729 return sv;
727} 730}
728 731
729// typemap support, mostly to avoid excessive inlining 732// typemap support, mostly to avoid excessive inlining
730template<class type> 733template<class type>
731static void noinline 734ecb_noinline static void
732cf_obj_to (SV *arg, type &var) 735cf_obj_to (SV *arg, type &var)
733{ 736{
734 sv_to (arg, var); 737 sv_to (arg, var);
735 if (expect_false (!var)) 738 if (expect_false (!var))
736 croak ("must not pass invalid/null cf_obj here"); 739 croak ("must not pass invalid/null cf_obj here");
737} 740}
738 741
739template<class object> 742template<class object>
740static void noinline 743ecb_noinline static void
741cf_obj_ornull_to (SV *arg, object *&var) 744cf_obj_ornull_to (SV *arg, object *&var)
742{ 745{
743 if (SvOK (arg)) 746 if (SvOK (arg))
744 { 747 {
745 sv_to (arg, var); 748 sv_to (arg, var);
837# undef def 840# undef def
838}; 841};
839 842
840#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) 843#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE)
841 844
842static void noinline 845ecb_noinline static void
843gather_callbacks (AV *&callbacks, AV *registry, event_type event) 846gather_callbacks (AV *&callbacks, AV *registry, event_type event)
844{ 847{
845 // event must be in array 848 // event must be in array
846 if (event >= 0 && event <= AvFILLp (registry)) 849 if (event >= 0 && event <= AvFILLp (registry))
847 { 850 {
933{ 936{
934 attachable::gather_callbacks (callbacks, event); 937 attachable::gather_callbacks (callbacks, event);
935 ::gather_callbacks (callbacks, cb_map, event); 938 ::gather_callbacks (callbacks, cb_map, event);
936} 939}
937 940
938static void noinline 941ecb_noinline static void
939_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) 942_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
940{ 943{
941 for (int event = 0; event <= AvFILLp (registry); ++event) 944 for (int event = 0; event <= AvFILLp (registry); ++event)
942 { 945 {
943 SV *cbs_ = AvARRAY (registry)[event]; 946 SV *cbs_ = AvARRAY (registry)[event];
1272 CALL_ARG (y); 1275 CALL_ARG (y);
1273 CALL_CALL ("cf::object::player::goto", G_VOID); 1276 CALL_CALL ("cf::object::player::goto", G_VOID);
1274 CALL_END; 1277 CALL_END;
1275} 1278}
1276 1279
1277const_utf8_string 1280const_utf8_string
1278object::ref () const 1281object::ref () const
1279{ 1282{
1280 if (type == PLAYER) 1283 if (type == PLAYER)
1281 return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name); 1284 return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name);
1282 else 1285 else
1510 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) 1513 const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT)
1511 1514
1512 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) 1515 const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES)
1513 }; 1516 };
1514 1517
1515 for (civ = const_iv + array_length (const_iv); civ-- > const_iv; ) 1518 for (civ = const_iv + ecb_array_length (const_iv); civ-- > const_iv; )
1516 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); 1519 newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv));
1517 1520
1518 static const struct { 1521 static const struct {
1519 const char *name; 1522 const char *name;
1520 int skip; 1523 int skip;
1526# undef def 1529# undef def
1527 }; 1530 };
1528 1531
1529 AV *av = get_av ("cf::EVENT", 1); 1532 AV *av = get_av ("cf::EVENT", 1);
1530 1533
1531 for (eiv = event_iv + array_length (event_iv); eiv-- > event_iv; ) 1534 for (eiv = event_iv + ecb_array_length (event_iv); eiv-- > event_iv; )
1532 { 1535 {
1533 AV *event = newAV (); 1536 AV *event = newAV ();
1534 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1537 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1535 av_push (event, newSViv (eiv->klass)); 1538 av_push (event, newSViv (eiv->klass));
1536 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1539 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1606 coroapi::cede_to_tick (); 1609 coroapi::cede_to_tick ();
1607 1610
1608NV till_tick () 1611NV till_tick ()
1609 CODE: 1612 CODE:
1610 RETVAL = SvNVX (sv_next_tick) - now (); 1613 RETVAL = SvNVX (sv_next_tick) - now ();
1611 OUTPUT: 1614 OUTPUT: RETVAL
1612 RETVAL
1613 1615
1614int tick_inhibit () 1616int tick_inhibit ()
1615 CODE: 1617 CODE:
1616 RETVAL = tick_inhibit; 1618 RETVAL = tick_inhibit;
1617 OUTPUT: 1619 OUTPUT: RETVAL
1618 RETVAL
1619 1620
1620void tick_inhibit_inc () 1621void tick_inhibit_inc ()
1621 CODE: 1622 CODE:
1622 ++tick_inhibit; 1623 ++tick_inhibit;
1623 1624
1668 case 1: RETVAL = gen (SvUV (ST (0))); break; 1669 case 1: RETVAL = gen (SvUV (ST (0))); break;
1669 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1670 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1670 default: croak ("cf::rndm requires zero, one or two parameters."); break; 1671 default: croak ("cf::rndm requires zero, one or two parameters."); break;
1671 } 1672 }
1672} 1673}
1673 OUTPUT: 1674 OUTPUT: RETVAL
1674 RETVAL
1675 1675
1676NV clamp (NV value, NV min_value, NV max_value) 1676NV clamp (NV value, NV min_value, NV max_value)
1677 CODE: 1677 CODE:
1678 RETVAL = clamp (value, min_value, max_value); 1678 RETVAL = clamp (value, min_value, max_value);
1679 OUTPUT: 1679 OUTPUT: RETVAL
1680 RETVAL
1681 1680
1682NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out) 1681NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out)
1683 CODE: 1682 CODE:
1684 RETVAL = lerp (value, min_in, max_in, min_out, max_out); 1683 RETVAL = lerp (value, min_in, max_in, min_out, max_out);
1685 OUTPUT: 1684 OUTPUT: RETVAL
1686 RETVAL
1687 1685
1688const char *ordinal (int i) 1686const char *ordinal (int i)
1689 1687
1690void weaken (...) 1688void weaken (...)
1691 PROTOTYPE: @ 1689 PROTOTYPE: @
1790 EXTEND (SP, 5*2); 1788 EXTEND (SP, 5*2);
1791 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); 1789 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc)));
1792 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); 1790 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc)));
1793 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); 1791 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object))));
1794 PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count))); 1792 PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count)));
1795 PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount)));
1796} 1793}
1797 1794
1798int random_roll (int min, int max, object *op, int goodbad); 1795int random_roll (int min, int max, object *op, int goodbad);
1799 1796
1800const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1797const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1839 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) 1836 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1840 ? newSVpv (change_resist_msg [atnr], 0) 1837 ? newSVpv (change_resist_msg [atnr], 0)
1841 : &PL_sv_undef; 1838 : &PL_sv_undef;
1842 OUTPUT: RETVAL 1839 OUTPUT: RETVAL
1843 1840
1841int
1842skill_flags (int idx)
1843 CODE:
1844 if (idx < 0 || idx >= ecb_array_length (skill_flags))
1845 croak ("skill_flags: index out of bounds");
1846 RETVAL = skill_flags [idx];
1847 OUTPUT: RETVAL
1848
1844UUID 1849UUID
1845uuid_cur () 1850uuid_cur ()
1846 CODE: 1851 CODE:
1847 RETVAL = UUID::cur; 1852 RETVAL = UUID::cur;
1848 OUTPUT: 1853 OUTPUT: RETVAL
1849 RETVAL
1850 1854
1851UUID 1855UUID
1852uuid_gen () 1856uuid_gen ()
1853 CODE: 1857 CODE:
1854 RETVAL = UUID::gen (); 1858 RETVAL = UUID::gen ();
1855 OUTPUT: 1859 OUTPUT: RETVAL
1856 RETVAL
1857 1860
1858val64 1861val64
1859uuid_seq (UUID uuid) 1862uuid_seq (UUID uuid)
1860 CODE: 1863 CODE:
1861 RETVAL = uuid.seq; 1864 RETVAL = uuid.seq;
1862 OUTPUT: 1865 OUTPUT: RETVAL
1863 RETVAL
1864 1866
1865UUID 1867UUID
1866uuid_str (val64 seq) 1868uuid_str (val64 seq)
1867 CODE: 1869 CODE:
1868 RETVAL.seq = seq; 1870 RETVAL.seq = seq;
1869 OUTPUT: 1871 OUTPUT: RETVAL
1870 RETVAL
1871 1872
1872void 1873void
1873coin_names () 1874coin_names ()
1874 PPCODE: 1875 PPCODE:
1875 EXTEND (SP, NUM_COINS); 1876 EXTEND (SP, NUM_COINS);
1898 1899
1899int 1900int
1900valid (SV *obj) 1901valid (SV *obj)
1901 CODE: 1902 CODE:
1902 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1903 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1903 OUTPUT: 1904 OUTPUT: RETVAL
1904 RETVAL
1905 1905
1906bool should_invoke (attachable *obj, int event) 1906bool should_invoke (attachable *obj, int event)
1907 CODE: 1907 CODE:
1908 RETVAL = obj->should_invoke ((event_type)event); 1908 RETVAL = obj->should_invoke ((event_type)event);
1909 OUTPUT: RETVAL 1909 OUTPUT: RETVAL
1991 case 0: RETVAL = body_locations[slot].name ; break; 1991 case 0: RETVAL = body_locations[slot].name ; break;
1992 case 1: RETVAL = body_locations[slot].use_name ; break; 1992 case 1: RETVAL = body_locations[slot].use_name ; break;
1993 case 2: RETVAL = body_locations[slot].nonuse_name; break; 1993 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1994 } 1994 }
1995} 1995}
1996 OUTPUT: 1996 OUTPUT: RETVAL
1997 RETVAL
1998 1997
1999# missing properties 1998# missing properties
2000 1999
2001object *head (object *op) 2000object *head (object *op)
2002 PROTOTYPE: $ 2001 PROTOTYPE: $
2010 PPCODE: 2009 PPCODE:
2011{ 2010{
2012 for (object *o = obj->inv; o; o = o->below) 2011 for (object *o = obj->inv; o; o = o->below)
2013 XPUSHs (sv_2mortal (to_sv (o))); 2012 XPUSHs (sv_2mortal (to_sv (o)));
2014} 2013}
2015
2016void
2017set_animation (object *op, int idx)
2018 CODE:
2019 SET_ANIMATION (op, idx);
2020
2021int
2022num_animations (object *op)
2023 CODE:
2024 RETVAL = NUM_ANIMATIONS (op);
2025 OUTPUT: RETVAL
2026 2014
2027int slot_info (object *op, UV slot, int value = 0) 2015int slot_info (object *op, UV slot, int value = 0)
2028 ALIAS: 2016 ALIAS:
2029 slot_used = 1 2017 slot_used = 1
2030 CODE: 2018 CODE:
2038 if (ix) 2026 if (ix)
2039 op->slot[slot].used = value; 2027 op->slot[slot].used = value;
2040 else 2028 else
2041 op->slot[slot].info = value; 2029 op->slot[slot].info = value;
2042} 2030}
2043 OUTPUT: 2031 OUTPUT: RETVAL
2044 RETVAL
2045 2032
2046object *find_best_object_match (object *op, utf8_string match) 2033object *find_best_object_match (object *op, utf8_string match)
2047 2034
2048int apply_shop_mat (object *shop_mat, object *op); 2035int apply_shop_mat (object *shop_mat, object *op);
2049 2036
2050int move (object *op, int dir, object *originator = op) 2037int move (object *op, int dir, object *originator = op)
2051 CODE: 2038 CODE:
2052 RETVAL = op->move (dir, originator); 2039 RETVAL = op->move (dir, originator);
2053 OUTPUT: 2040 OUTPUT: RETVAL
2054 RETVAL
2055 2041
2056void apply_below (object *op) 2042void apply_below (object *op)
2057 CODE: 2043 CODE:
2058 player_apply_below (op); 2044 player_apply_below (op);
2059 2045
2130 PROTOTYPE: ;$ 2116 PROTOTYPE: ;$
2131 CODE: 2117 CODE:
2132 RETVAL = archetype 2118 RETVAL = archetype
2133 ? archetype::get (archetype) 2119 ? archetype::get (archetype)
2134 : object::create (); 2120 : object::create ();
2135 OUTPUT: 2121 OUTPUT: RETVAL
2136 RETVAL
2137 2122
2138object *generate (utf8_string arch, object *creator) 2123object *generate (utf8_string arch, object *creator)
2139 CODE: 2124 CODE:
2140 object *obj = archetype::get (arch); 2125 object *obj = archetype::get (arch);
2141 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2126 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2142 RETVAL = obj; 2127 RETVAL = obj;
2143 OUTPUT: 2128 OUTPUT: RETVAL
2144 RETVAL
2145 2129
2146object *find_object (U32 tag) 2130object *find_object (U32 tag)
2147 2131
2148object *find_object_uuid (UUID i) 2132object *find_object_uuid (UUID i)
2149 2133
2155 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2139 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2156 2140
2157 if (RETVAL->destroyed ()) 2141 if (RETVAL->destroyed ())
2158 RETVAL = 0; 2142 RETVAL = 0;
2159} 2143}
2160 OUTPUT: 2144 OUTPUT: RETVAL
2161 RETVAL
2162 2145
2163shstr 2146shstr
2164object::kv_get (shstr key) 2147object::kv_get (shstr key)
2165 CODE: 2148 CODE:
2166 RETVAL = THIS->kv.get (key); 2149 RETVAL = THIS->kv.get (key);
2167 OUTPUT: 2150 OUTPUT: RETVAL
2168 RETVAL
2169 2151
2170void 2152void
2171object::kv_del (shstr key) 2153object::kv_del (shstr key)
2172 CODE: 2154 CODE:
2173 THIS->kv.del (key); 2155 THIS->kv.del (key);
2272#d# TODO: replace by blocked_los accessor, fix code using this 2254#d# TODO: replace by blocked_los accessor, fix code using this
2273bool 2255bool
2274cell_visible (player *pl, int dx, int dy) 2256cell_visible (player *pl, int dx, int dy)
2275 CODE: 2257 CODE:
2276 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; 2258 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED;
2277 OUTPUT: 2259 OUTPUT: RETVAL
2278 RETVAL
2279 2260
2280void 2261void
2281send (player *pl, SV *packet) 2262send (player *pl, SV *packet)
2282 CODE: 2263 CODE:
2283{ 2264{
2359outdoor_darkness (int darkness = 0) 2340outdoor_darkness (int darkness = 0)
2360 CODE: 2341 CODE:
2361 RETVAL = maptile::outdoor_darkness; 2342 RETVAL = maptile::outdoor_darkness;
2362 if (items) 2343 if (items)
2363 maptile::outdoor_darkness = darkness; 2344 maptile::outdoor_darkness = darkness;
2364 OUTPUT: 2345 OUTPUT: RETVAL
2365 RETVAL
2366 2346
2367void 2347void
2368maptile::instantiate () 2348maptile::instantiate ()
2369 2349
2370maptile *new () 2350maptile *new ()
2371 PROTOTYPE: 2351 PROTOTYPE:
2372 CODE: 2352 CODE:
2373 RETVAL = new maptile; 2353 RETVAL = new maptile;
2374 OUTPUT: 2354 OUTPUT: RETVAL
2375 RETVAL
2376 2355
2377void 2356void
2378maptile::players () 2357maptile::players ()
2379 PPCODE: 2358 PPCODE:
2380 if (GIMME_V == G_SCALAR) 2359 if (GIMME_V == G_SCALAR)
2515 if (!pos.move (dir).normalise ()) 2494 if (!pos.move (dir).normalise ())
2516 XSRETURN_UNDEF; 2495 XSRETURN_UNDEF;
2517 2496
2518 RETVAL = &*pos; 2497 RETVAL = &*pos;
2519} 2498}
2520 OUTPUT: 2499 OUTPUT: RETVAL
2521 RETVAL
2522 2500
2523void 2501void
2524at (maptile *map, unsigned int x, unsigned int y, int dir = 0) 2502at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2525 PROTOTYPE: $$$;$ 2503 PROTOTYPE: $$$;$
2526 PPCODE: 2504 PPCODE:
2567# worst xs function of my life 2545# worst xs function of my life
2568bool 2546bool
2569_create_random_map (maptile *self, SV *options) 2547_create_random_map (maptile *self, SV *options)
2570 CODE: 2548 CODE:
2571{ 2549{
2572 random_map_params rmp ((HV *)SvRV (options)); 2550 random_map_params rmp ((HV *)SvRV (options));
2573 RETVAL = self->generate_random_map (&rmp); 2551 RETVAL = self->generate_random_map (&rmp);
2574} 2552}
2575 OUTPUT: 2553 OUTPUT: RETVAL
2576 RETVAL
2577 2554
2578MODULE = cf PACKAGE = cf::mapspace 2555MODULE = cf PACKAGE = cf::mapspace
2579 2556
2580INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h | 2557INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h |
2581 2558
2707 if (RETVAL) 2684 if (RETVAL)
2708 { 2685 {
2709 THIS->send_face (RETVAL, pri); 2686 THIS->send_face (RETVAL, pri);
2710 THIS->flush_fx (); 2687 THIS->flush_fx ();
2711 } 2688 }
2712 OUTPUT: 2689 OUTPUT: RETVAL
2713 RETVAL
2714 2690
2715int 2691int
2716client::fx_want (int idx, int value = -1) 2692client::fx_want (int idx, int value = -1)
2717 CODE: 2693 CODE:
2718 if (0 < idx && idx < FT_NUM) 2694 if (0 < idx && idx < FT_NUM)
2721 if (items > 2) 2697 if (items > 2)
2722 THIS->fx_want [idx] = value; 2698 THIS->fx_want [idx] = value;
2723 } 2699 }
2724 else 2700 else
2725 RETVAL = 0; 2701 RETVAL = 0;
2726 OUTPUT: 2702 OUTPUT: RETVAL
2727 RETVAL
2728 2703
2729MODULE = cf PACKAGE = cf::sound PREFIX = sound_ 2704MODULE = cf PACKAGE = cf::sound PREFIX = sound_
2730 2705
2731faceidx sound_find (utf8_string name) 2706faceidx sound_find (utf8_string name)
2732 2707
2806SV *mangle_csum (SV *chksum) 2781SV *mangle_csum (SV *chksum)
2807 CODE: 2782 CODE:
2808 STRLEN len; 2783 STRLEN len;
2809 char *data = SvPVbyte (chksum, len); 2784 char *data = SvPVbyte (chksum, len);
2810 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN)); 2785 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN));
2811 OUTPUT: 2786 OUTPUT: RETVAL
2812 RETVAL
2813 2787
2814SV *get_csum (faceidx idx, int faceset = 0) 2788SV *get_csum (faceidx idx, int faceset = 0)
2815 CODE: 2789 CODE:
2816 facedata *d = face_data (idx, faceset); 2790 facedata *d = face_data (idx, faceset);
2817 if (!d) XSRETURN_UNDEF; 2791 if (!d) XSRETURN_UNDEF;
2818 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2792 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2819 OUTPUT: 2793 OUTPUT: RETVAL
2820 RETVAL
2821 2794
2822int get_type (faceidx idx) 2795int get_type (faceidx idx)
2823 CODE: 2796 CODE:
2824 faceinfo *f = face_info (idx); 2797 faceinfo *f = face_info (idx);
2825 if (!f) XSRETURN_UNDEF; 2798 if (!f) XSRETURN_UNDEF;
2826 RETVAL = f->type; 2799 RETVAL = f->type;
2827 OUTPUT: 2800 OUTPUT: RETVAL
2828 RETVAL
2829 2801
2830SV *get_name (faceidx idx) 2802SV *get_name (faceidx idx)
2831 CODE: 2803 CODE:
2832 faceinfo *f = face_info (idx); 2804 faceinfo *f = face_info (idx);
2833 if (!f) XSRETURN_UNDEF; 2805 if (!f) XSRETURN_UNDEF;
2834 RETVAL = to_sv (f->name); 2806 RETVAL = to_sv (f->name);
2835 OUTPUT: 2807 OUTPUT: RETVAL
2836 RETVAL
2837 2808
2838void invalidate (faceidx idx) 2809void invalidate (faceidx idx)
2839 CODE: 2810 CODE:
2840 for_all_clients (ns) 2811 for_all_clients (ns)
2841 ns->invalidate_face (idx); 2812 ns->invalidate_face (idx);
2905bool 2876bool
2906errors_are_fatal (bool fatal) 2877errors_are_fatal (bool fatal)
2907 CODE: 2878 CODE:
2908 RETVAL = object_thawer::errors_are_fatal; 2879 RETVAL = object_thawer::errors_are_fatal;
2909 object_thawer::errors_are_fatal = fatal; 2880 object_thawer::errors_are_fatal = fatal;
2910 OUTPUT: 2881 OUTPUT: RETVAL
2911 RETVAL
2912 2882
2913SV * 2883SV *
2914new_from_file (char *klass, octet_string path) 2884new_from_file (char *klass, octet_string path)
2915 CODE: 2885 CODE:
2916 object_thawer *f = new object_thawer (path); 2886 object_thawer *f = new object_thawer (path);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines