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.428 by root, Mon Aug 10 03:05:30 2015 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 (©) 2006,2007,2008,2009,2010,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2006,2007,2008,2009,2010,2012,2015 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.
1272 CALL_ARG (y); 1272 CALL_ARG (y);
1273 CALL_CALL ("cf::object::player::goto", G_VOID); 1273 CALL_CALL ("cf::object::player::goto", G_VOID);
1274 CALL_END; 1274 CALL_END;
1275} 1275}
1276 1276
1277const_utf8_string 1277const_utf8_string
1278object::ref () const 1278object::ref () const
1279{ 1279{
1280 if (type == PLAYER) 1280 if (type == PLAYER)
1281 return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name); 1281 return format ("player/<1.%llx>/%s", (unsigned long long)uuid.seq, &name);
1282 else 1282 else
1606 coroapi::cede_to_tick (); 1606 coroapi::cede_to_tick ();
1607 1607
1608NV till_tick () 1608NV till_tick ()
1609 CODE: 1609 CODE:
1610 RETVAL = SvNVX (sv_next_tick) - now (); 1610 RETVAL = SvNVX (sv_next_tick) - now ();
1611 OUTPUT: 1611 OUTPUT: RETVAL
1612 RETVAL
1613 1612
1614int tick_inhibit () 1613int tick_inhibit ()
1615 CODE: 1614 CODE:
1616 RETVAL = tick_inhibit; 1615 RETVAL = tick_inhibit;
1617 OUTPUT: 1616 OUTPUT: RETVAL
1618 RETVAL
1619 1617
1620void tick_inhibit_inc () 1618void tick_inhibit_inc ()
1621 CODE: 1619 CODE:
1622 ++tick_inhibit; 1620 ++tick_inhibit;
1623 1621
1668 case 1: RETVAL = gen (SvUV (ST (0))); break; 1666 case 1: RETVAL = gen (SvUV (ST (0))); break;
1669 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; 1667 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1670 default: croak ("cf::rndm requires zero, one or two parameters."); break; 1668 default: croak ("cf::rndm requires zero, one or two parameters."); break;
1671 } 1669 }
1672} 1670}
1673 OUTPUT: 1671 OUTPUT: RETVAL
1674 RETVAL
1675 1672
1676NV clamp (NV value, NV min_value, NV max_value) 1673NV clamp (NV value, NV min_value, NV max_value)
1677 CODE: 1674 CODE:
1678 RETVAL = clamp (value, min_value, max_value); 1675 RETVAL = clamp (value, min_value, max_value);
1679 OUTPUT: 1676 OUTPUT: RETVAL
1680 RETVAL
1681 1677
1682NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out) 1678NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out)
1683 CODE: 1679 CODE:
1684 RETVAL = lerp (value, min_in, max_in, min_out, max_out); 1680 RETVAL = lerp (value, min_in, max_in, min_out, max_out);
1685 OUTPUT: 1681 OUTPUT: RETVAL
1686 RETVAL
1687 1682
1688const char *ordinal (int i) 1683const char *ordinal (int i)
1689 1684
1690void weaken (...) 1685void weaken (...)
1691 PROTOTYPE: @ 1686 PROTOTYPE: @
1790 EXTEND (SP, 5*2); 1785 EXTEND (SP, 5*2);
1791 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); 1786 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))); 1787 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)))); 1788 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))); 1789 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} 1790}
1797 1791
1798int random_roll (int min, int max, object *op, int goodbad); 1792int random_roll (int min, int max, object *op, int goodbad);
1799 1793
1800const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) 1794const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1839 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS) 1833 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1840 ? newSVpv (change_resist_msg [atnr], 0) 1834 ? newSVpv (change_resist_msg [atnr], 0)
1841 : &PL_sv_undef; 1835 : &PL_sv_undef;
1842 OUTPUT: RETVAL 1836 OUTPUT: RETVAL
1843 1837
1838int
1839skill_flags (int idx)
1840 CODE:
1841 if (idx < 0 || idx >= array_length (skill_flags))
1842 croak ("skill_flags: index out of bounds");
1843 RETVAL = skill_flags [idx];
1844 OUTPUT: RETVAL
1845
1844UUID 1846UUID
1845uuid_cur () 1847uuid_cur ()
1846 CODE: 1848 CODE:
1847 RETVAL = UUID::cur; 1849 RETVAL = UUID::cur;
1848 OUTPUT: 1850 OUTPUT: RETVAL
1849 RETVAL
1850 1851
1851UUID 1852UUID
1852uuid_gen () 1853uuid_gen ()
1853 CODE: 1854 CODE:
1854 RETVAL = UUID::gen (); 1855 RETVAL = UUID::gen ();
1855 OUTPUT: 1856 OUTPUT: RETVAL
1856 RETVAL
1857 1857
1858val64 1858val64
1859uuid_seq (UUID uuid) 1859uuid_seq (UUID uuid)
1860 CODE: 1860 CODE:
1861 RETVAL = uuid.seq; 1861 RETVAL = uuid.seq;
1862 OUTPUT: 1862 OUTPUT: RETVAL
1863 RETVAL
1864 1863
1865UUID 1864UUID
1866uuid_str (val64 seq) 1865uuid_str (val64 seq)
1867 CODE: 1866 CODE:
1868 RETVAL.seq = seq; 1867 RETVAL.seq = seq;
1869 OUTPUT: 1868 OUTPUT: RETVAL
1870 RETVAL
1871 1869
1872void 1870void
1873coin_names () 1871coin_names ()
1874 PPCODE: 1872 PPCODE:
1875 EXTEND (SP, NUM_COINS); 1873 EXTEND (SP, NUM_COINS);
1898 1896
1899int 1897int
1900valid (SV *obj) 1898valid (SV *obj)
1901 CODE: 1899 CODE:
1902 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1900 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1903 OUTPUT: 1901 OUTPUT: RETVAL
1904 RETVAL
1905 1902
1906bool should_invoke (attachable *obj, int event) 1903bool should_invoke (attachable *obj, int event)
1907 CODE: 1904 CODE:
1908 RETVAL = obj->should_invoke ((event_type)event); 1905 RETVAL = obj->should_invoke ((event_type)event);
1909 OUTPUT: RETVAL 1906 OUTPUT: RETVAL
1991 case 0: RETVAL = body_locations[slot].name ; break; 1988 case 0: RETVAL = body_locations[slot].name ; break;
1992 case 1: RETVAL = body_locations[slot].use_name ; break; 1989 case 1: RETVAL = body_locations[slot].use_name ; break;
1993 case 2: RETVAL = body_locations[slot].nonuse_name; break; 1990 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1994 } 1991 }
1995} 1992}
1996 OUTPUT: 1993 OUTPUT: RETVAL
1997 RETVAL
1998 1994
1999# missing properties 1995# missing properties
2000 1996
2001object *head (object *op) 1997object *head (object *op)
2002 PROTOTYPE: $ 1998 PROTOTYPE: $
2038 if (ix) 2034 if (ix)
2039 op->slot[slot].used = value; 2035 op->slot[slot].used = value;
2040 else 2036 else
2041 op->slot[slot].info = value; 2037 op->slot[slot].info = value;
2042} 2038}
2043 OUTPUT: 2039 OUTPUT: RETVAL
2044 RETVAL
2045 2040
2046object *find_best_object_match (object *op, utf8_string match) 2041object *find_best_object_match (object *op, utf8_string match)
2047 2042
2048int apply_shop_mat (object *shop_mat, object *op); 2043int apply_shop_mat (object *shop_mat, object *op);
2049 2044
2050int move (object *op, int dir, object *originator = op) 2045int move (object *op, int dir, object *originator = op)
2051 CODE: 2046 CODE:
2052 RETVAL = op->move (dir, originator); 2047 RETVAL = op->move (dir, originator);
2053 OUTPUT: 2048 OUTPUT: RETVAL
2054 RETVAL
2055 2049
2056void apply_below (object *op) 2050void apply_below (object *op)
2057 CODE: 2051 CODE:
2058 player_apply_below (op); 2052 player_apply_below (op);
2059 2053
2130 PROTOTYPE: ;$ 2124 PROTOTYPE: ;$
2131 CODE: 2125 CODE:
2132 RETVAL = archetype 2126 RETVAL = archetype
2133 ? archetype::get (archetype) 2127 ? archetype::get (archetype)
2134 : object::create (); 2128 : object::create ();
2135 OUTPUT: 2129 OUTPUT: RETVAL
2136 RETVAL
2137 2130
2138object *generate (utf8_string arch, object *creator) 2131object *generate (utf8_string arch, object *creator)
2139 CODE: 2132 CODE:
2140 object *obj = archetype::get (arch); 2133 object *obj = archetype::get (arch);
2141 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL); 2134 fix_generated_item (obj, creator, 0, 0, GT_MINIMAL);
2142 RETVAL = obj; 2135 RETVAL = obj;
2143 OUTPUT: 2136 OUTPUT: RETVAL
2144 RETVAL
2145 2137
2146object *find_object (U32 tag) 2138object *find_object (U32 tag)
2147 2139
2148object *find_object_uuid (UUID i) 2140object *find_object_uuid (UUID i)
2149 2141
2155 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2147 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2156 2148
2157 if (RETVAL->destroyed ()) 2149 if (RETVAL->destroyed ())
2158 RETVAL = 0; 2150 RETVAL = 0;
2159} 2151}
2160 OUTPUT: 2152 OUTPUT: RETVAL
2161 RETVAL
2162 2153
2163shstr 2154shstr
2164object::kv_get (shstr key) 2155object::kv_get (shstr key)
2165 CODE: 2156 CODE:
2166 RETVAL = THIS->kv.get (key); 2157 RETVAL = THIS->kv.get (key);
2167 OUTPUT: 2158 OUTPUT: RETVAL
2168 RETVAL
2169 2159
2170void 2160void
2171object::kv_del (shstr key) 2161object::kv_del (shstr key)
2172 CODE: 2162 CODE:
2173 THIS->kv.del (key); 2163 THIS->kv.del (key);
2272#d# TODO: replace by blocked_los accessor, fix code using this 2262#d# TODO: replace by blocked_los accessor, fix code using this
2273bool 2263bool
2274cell_visible (player *pl, int dx, int dy) 2264cell_visible (player *pl, int dx, int dy)
2275 CODE: 2265 CODE:
2276 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED; 2266 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED;
2277 OUTPUT: 2267 OUTPUT: RETVAL
2278 RETVAL
2279 2268
2280void 2269void
2281send (player *pl, SV *packet) 2270send (player *pl, SV *packet)
2282 CODE: 2271 CODE:
2283{ 2272{
2359outdoor_darkness (int darkness = 0) 2348outdoor_darkness (int darkness = 0)
2360 CODE: 2349 CODE:
2361 RETVAL = maptile::outdoor_darkness; 2350 RETVAL = maptile::outdoor_darkness;
2362 if (items) 2351 if (items)
2363 maptile::outdoor_darkness = darkness; 2352 maptile::outdoor_darkness = darkness;
2364 OUTPUT: 2353 OUTPUT: RETVAL
2365 RETVAL
2366 2354
2367void 2355void
2368maptile::instantiate () 2356maptile::instantiate ()
2369 2357
2370maptile *new () 2358maptile *new ()
2371 PROTOTYPE: 2359 PROTOTYPE:
2372 CODE: 2360 CODE:
2373 RETVAL = new maptile; 2361 RETVAL = new maptile;
2374 OUTPUT: 2362 OUTPUT: RETVAL
2375 RETVAL
2376 2363
2377void 2364void
2378maptile::players () 2365maptile::players ()
2379 PPCODE: 2366 PPCODE:
2380 if (GIMME_V == G_SCALAR) 2367 if (GIMME_V == G_SCALAR)
2515 if (!pos.move (dir).normalise ()) 2502 if (!pos.move (dir).normalise ())
2516 XSRETURN_UNDEF; 2503 XSRETURN_UNDEF;
2517 2504
2518 RETVAL = &*pos; 2505 RETVAL = &*pos;
2519} 2506}
2520 OUTPUT: 2507 OUTPUT: RETVAL
2521 RETVAL
2522 2508
2523void 2509void
2524at (maptile *map, unsigned int x, unsigned int y, int dir = 0) 2510at (maptile *map, unsigned int x, unsigned int y, int dir = 0)
2525 PROTOTYPE: $$$;$ 2511 PROTOTYPE: $$$;$
2526 PPCODE: 2512 PPCODE:
2567# worst xs function of my life 2553# worst xs function of my life
2568bool 2554bool
2569_create_random_map (maptile *self, SV *options) 2555_create_random_map (maptile *self, SV *options)
2570 CODE: 2556 CODE:
2571{ 2557{
2572 random_map_params rmp ((HV *)SvRV (options)); 2558 random_map_params rmp ((HV *)SvRV (options));
2573 RETVAL = self->generate_random_map (&rmp); 2559 RETVAL = self->generate_random_map (&rmp);
2574} 2560}
2575 OUTPUT: 2561 OUTPUT: RETVAL
2576 RETVAL
2577 2562
2578MODULE = cf PACKAGE = cf::mapspace 2563MODULE = cf PACKAGE = cf::mapspace
2579 2564
2580INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h | 2565INCLUDE: $PERL $srcdir/genacc mapspace $srcdir/../include/map.h |
2581 2566
2707 if (RETVAL) 2692 if (RETVAL)
2708 { 2693 {
2709 THIS->send_face (RETVAL, pri); 2694 THIS->send_face (RETVAL, pri);
2710 THIS->flush_fx (); 2695 THIS->flush_fx ();
2711 } 2696 }
2712 OUTPUT: 2697 OUTPUT: RETVAL
2713 RETVAL
2714 2698
2715int 2699int
2716client::fx_want (int idx, int value = -1) 2700client::fx_want (int idx, int value = -1)
2717 CODE: 2701 CODE:
2718 if (0 < idx && idx < FT_NUM) 2702 if (0 < idx && idx < FT_NUM)
2721 if (items > 2) 2705 if (items > 2)
2722 THIS->fx_want [idx] = value; 2706 THIS->fx_want [idx] = value;
2723 } 2707 }
2724 else 2708 else
2725 RETVAL = 0; 2709 RETVAL = 0;
2726 OUTPUT: 2710 OUTPUT: RETVAL
2727 RETVAL
2728 2711
2729MODULE = cf PACKAGE = cf::sound PREFIX = sound_ 2712MODULE = cf PACKAGE = cf::sound PREFIX = sound_
2730 2713
2731faceidx sound_find (utf8_string name) 2714faceidx sound_find (utf8_string name)
2732 2715
2806SV *mangle_csum (SV *chksum) 2789SV *mangle_csum (SV *chksum)
2807 CODE: 2790 CODE:
2808 STRLEN len; 2791 STRLEN len;
2809 char *data = SvPVbyte (chksum, len); 2792 char *data = SvPVbyte (chksum, len);
2810 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN)); 2793 RETVAL = newSVpvn (data, min (len, CHKSUM_MAXLEN));
2811 OUTPUT: 2794 OUTPUT: RETVAL
2812 RETVAL
2813 2795
2814SV *get_csum (faceidx idx, int faceset = 0) 2796SV *get_csum (faceidx idx, int faceset = 0)
2815 CODE: 2797 CODE:
2816 facedata *d = face_data (idx, faceset); 2798 facedata *d = face_data (idx, faceset);
2817 if (!d) XSRETURN_UNDEF; 2799 if (!d) XSRETURN_UNDEF;
2818 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len); 2800 RETVAL = newSVpvn ((char *)d->chksum, d->chksum_len);
2819 OUTPUT: 2801 OUTPUT: RETVAL
2820 RETVAL
2821 2802
2822int get_type (faceidx idx) 2803int get_type (faceidx idx)
2823 CODE: 2804 CODE:
2824 faceinfo *f = face_info (idx); 2805 faceinfo *f = face_info (idx);
2825 if (!f) XSRETURN_UNDEF; 2806 if (!f) XSRETURN_UNDEF;
2826 RETVAL = f->type; 2807 RETVAL = f->type;
2827 OUTPUT: 2808 OUTPUT: RETVAL
2828 RETVAL
2829 2809
2830SV *get_name (faceidx idx) 2810SV *get_name (faceidx idx)
2831 CODE: 2811 CODE:
2832 faceinfo *f = face_info (idx); 2812 faceinfo *f = face_info (idx);
2833 if (!f) XSRETURN_UNDEF; 2813 if (!f) XSRETURN_UNDEF;
2834 RETVAL = to_sv (f->name); 2814 RETVAL = to_sv (f->name);
2835 OUTPUT: 2815 OUTPUT: RETVAL
2836 RETVAL
2837 2816
2838void invalidate (faceidx idx) 2817void invalidate (faceidx idx)
2839 CODE: 2818 CODE:
2840 for_all_clients (ns) 2819 for_all_clients (ns)
2841 ns->invalidate_face (idx); 2820 ns->invalidate_face (idx);
2905bool 2884bool
2906errors_are_fatal (bool fatal) 2885errors_are_fatal (bool fatal)
2907 CODE: 2886 CODE:
2908 RETVAL = object_thawer::errors_are_fatal; 2887 RETVAL = object_thawer::errors_are_fatal;
2909 object_thawer::errors_are_fatal = fatal; 2888 object_thawer::errors_are_fatal = fatal;
2910 OUTPUT: 2889 OUTPUT: RETVAL
2911 RETVAL
2912 2890
2913SV * 2891SV *
2914new_from_file (char *klass, octet_string path) 2892new_from_file (char *klass, octet_string path)
2915 CODE: 2893 CODE:
2916 object_thawer *f = new object_thawer (path); 2894 object_thawer *f = new object_thawer (path);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines