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.280 by root, Mon Apr 21 06:35:26 2008 UTC vs.
Revision 1.292 by root, Tue Jul 29 02:00:55 2008 UTC

21 * 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>
22 */ 22 */
23 23
24#include "autoconf.h" 24#include "autoconf.h"
25 25
26#define PLUGIN_NAME "perl"
27#define PLUGIN_VERSION "cfperl 0.5"
28
29#if HAVE_EXECINFO_H 26#if HAVE_EXECINFO_H
30# include <execinfo.h> 27# include <execinfo.h>
31#endif 28#endif
32 29
33#include <cstdarg> 30#include <cstdarg>
31#include <typeinfo>
34 32
35#include "global.h" 33#include "global.h"
36#include "loader.h" 34#include "loader.h"
37#include "../random_maps/random_map.h" 35#include "../random_maps/random_map.h"
38#include "evthread.h" 36#include "evthread.h"
944 CALL_CALL ("ext::books::make_book", G_VOID); 942 CALL_CALL ("ext::books::make_book", G_VOID);
945 CALL_END; 943 CALL_END;
946} 944}
947 945
948void 946void
947cfperl_expand_cfpod (player *pl, std::string &msg)
948{
949 CALL_BEGIN (2);
950 CALL_ARG (pl);
951 CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ()));
952 CALL_CALL ("cf::player::expand_cfpod", G_SCALAR);
953
954 if (count)
955 {
956 STRLEN len;
957 char *data = SvPVutf8 (TOPs, len);
958 msg.assign (data, len);
959 }
960
961 CALL_END;
962}
963
964void
949cfperl_send_msg (client *ns, int color, const char *type, const char *msg) 965cfperl_send_msg (client *ns, int color, const char *type, const char *msg)
950{ 966{
951 CALL_BEGIN (4); 967 CALL_BEGIN (4);
952 CALL_ARG (ns); 968 CALL_ARG (ns);
953 CALL_ARG (type); 969 CALL_ARG (type);
977{ 993{
978 CALL_BEGIN (1); 994 CALL_BEGIN (1);
979 CALL_ARG (name); 995 CALL_ARG (name);
980 CALL_CALL ("cf::player::find", G_SCALAR); 996 CALL_CALL ("cf::player::find", G_SCALAR);
981 997
982 player *retval; 998 player *retval = 0;
983
984 if (count)
985 sv_to (POPs, retval); 999 if (count) sv_to (POPs, retval);
986 else 1000
987 retval = 0; 1001 CALL_END;
1002
1003 return retval;
1004}
1005
1006maptile *
1007find_style (const char *dirname, const char *stylename, int difficulty)
1008{
1009 CALL_BEGIN (3);
1010 CALL_ARG (dirname);
1011 CALL_ARG (stylename);
1012 CALL_ARG (difficulty);
1013 CALL_CALL ("ext::map_random::find_style", G_SCALAR);
1014
1015 maptile *retval = 0;
1016 if (count) sv_to (POPs, retval);
988 1017
989 CALL_END; 1018 CALL_END;
990 1019
991 return retval; 1020 return retval;
992} 1021}
997 CALL_BEGIN (2); 1026 CALL_BEGIN (2);
998 CALL_ARG (path); 1027 CALL_ARG (path);
999 CALL_ARG (origin); 1028 CALL_ARG (origin);
1000 CALL_CALL ("cf::map::find_sync", G_SCALAR); 1029 CALL_CALL ("cf::map::find_sync", G_SCALAR);
1001 1030
1002 maptile *retval; 1031 maptile *retval = 0;
1003
1004 if (count)
1005 sv_to (POPs, retval); 1032 if (count) sv_to (POPs, retval);
1006 else
1007 retval = 0;
1008 1033
1009 CALL_END; 1034 CALL_END;
1010 1035
1011 return retval; 1036 return retval;
1012} 1037}
1018 CALL_ARG (path); 1043 CALL_ARG (path);
1019 CALL_ARG (origin); 1044 CALL_ARG (origin);
1020 CALL_ARG (load); 1045 CALL_ARG (load);
1021 CALL_CALL ("cf::map::find_async", G_SCALAR); 1046 CALL_CALL ("cf::map::find_async", G_SCALAR);
1022 1047
1023 maptile *retval; 1048 maptile *retval = 0;
1024
1025 if (count)
1026 sv_to (POPs, retval); 1049 if (count) sv_to (POPs, retval);
1027 else
1028 retval = 0;
1029 1050
1030 CALL_END; 1051 CALL_END;
1031 1052
1032 return retval; 1053 return retval;
1033} 1054}
1058 1079
1059 CALL_BEGIN (2); 1080 CALL_BEGIN (2);
1060 CALL_ARG (this); 1081 CALL_ARG (this);
1061 CALL_ARG (exit); 1082 CALL_ARG (exit);
1062 CALL_CALL ("cf::object::player::enter_exit", G_VOID); 1083 CALL_CALL ("cf::object::player::enter_exit", G_VOID);
1084 CALL_END;
1085}
1086
1087void
1088object::player_goto (const char *path, int x, int y)
1089{
1090 if (type != PLAYER)
1091 return;
1092
1093 CALL_BEGIN (4);
1094 CALL_ARG (this);
1095 CALL_ARG (path);
1096 CALL_ARG (x);
1097 CALL_ARG (y);
1098 CALL_CALL ("cf::object::player::goto", G_VOID);
1063 CALL_END; 1099 CALL_END;
1064} 1100}
1065 1101
1066const char * 1102const char *
1067object::ref () const 1103object::ref () const
1432 1468
1433 const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) 1469 const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X)
1434 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) 1470 const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY)
1435 1471
1436 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) 1472 const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP)
1437 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) 1473 const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_MINIMAL)
1438 const_iv (GT_MINIMAL)
1439 1474
1440 const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND) 1475 const_iv (FT_FACE) const_iv (FT_MUSIC) const_iv (FT_SOUND)
1441 const_iv (FT_RSRC) const_iv (FT_NUM) 1476 const_iv (FT_RSRC) const_iv (FT_NUM)
1442 }; 1477 };
1443 1478
1574NV floor (NV x) 1609NV floor (NV x)
1575 1610
1576NV ceil (NV x) 1611NV ceil (NV x)
1577 1612
1578NV rndm (...) 1613NV rndm (...)
1614 ALIAS:
1615 rmg_rndm = 1
1579 CODE: 1616 CODE:
1617{
1618 rand_gen &gen = ix ? rmg_rndm : rndm;
1580 switch (items) 1619 switch (items)
1581 { 1620 {
1582 case 0: RETVAL = rndm (); break; 1621 case 0: RETVAL = gen (); break;
1583 case 1: RETVAL = rndm (SvUV (ST (0))); break; 1622 case 1: RETVAL = gen (SvUV (ST (0))); break;
1584 case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; 1623 case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break;
1585 default: croak ("cf::rndm requires none, one or two parameters."); break; 1624 default: croak ("cf::rndm requires none, one or two parameters."); break;
1586 } 1625 }
1626}
1587 OUTPUT: 1627 OUTPUT:
1588 RETVAL 1628 RETVAL
1589 1629
1590NV clamp (NV value, NV min_value, NV max_value) 1630NV clamp (NV value, NV min_value, NV max_value)
1591 CODE: 1631 CODE:
1694 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); 1734 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost)));
1695#endif 1735#endif
1696 EXTEND (SP, 2*2); 1736 EXTEND (SP, 2*2);
1697 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); 1737 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc)));
1698 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); 1738 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc)));
1739 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object))));
1699} 1740}
1700 1741
1701int find_animation (utf8_string text) 1742int find_animation (utf8_string text)
1702 PROTOTYPE: $ 1743 PROTOTYPE: $
1703 1744
1787 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); 1828 PUSHs (sv_2mortal (to_sv (archetype::find (coins [i]))));
1788 1829
1789bool 1830bool
1790load_resource_file_ (octet_string filename) 1831load_resource_file_ (octet_string filename)
1791 1832
1833void
1834fix_weight ()
1835
1792MODULE = cf PACKAGE = cf::attachable 1836MODULE = cf PACKAGE = cf::attachable
1793 1837
1794int 1838int
1795valid (SV *obj) 1839valid (SV *obj)
1796 CODE: 1840 CODE:
1859object *actives (U32 index) 1903object *actives (U32 index)
1860 CODE: 1904 CODE:
1861 RETVAL = index < actives.size () ? actives [index] : 0; 1905 RETVAL = index < actives.size () ? actives [index] : 0;
1862 OUTPUT: RETVAL 1906 OUTPUT: RETVAL
1863 1907
1908int mortals_size ()
1909 CODE:
1910 RETVAL = attachable::mortals.size ();
1911 OUTPUT: RETVAL
1912
1864const char *slot_use_name (U32 slot) 1913const char *slot_use_name (U32 slot)
1865 ALIAS: 1914 ALIAS:
1866 slot_nonuse_name = 1 1915 slot_nonuse_name = 1
1867 CODE: 1916 CODE:
1868{ 1917{
1946void apply_below (object *op) 1995void apply_below (object *op)
1947 CODE: 1996 CODE:
1948 player_apply_below (op); 1997 player_apply_below (op);
1949 1998
1950int cast_heal (object *op, object *caster, object *spell, int dir = 0) 1999int cast_heal (object *op, object *caster, object *spell, int dir = 0)
1951
1952#//TODO
1953object *clone_ (object *op, int recursive = 0)
1954 CODE:
1955 if (recursive)
1956 RETVAL = object_create_clone (op);
1957 else
1958 {
1959 RETVAL = object::create ();
1960 op->copy_to (RETVAL);
1961 }
1962 OUTPUT: RETVAL
1963 2000
1964int pay_item (object *op, object *buyer) 2001int pay_item (object *op, object *buyer)
1965 CODE: 2002 CODE:
1966 RETVAL = pay_for_item (op, buyer); 2003 RETVAL = pay_for_item (op, buyer);
1967 OUTPUT: RETVAL 2004 OUTPUT: RETVAL
2045 CODE: 2082 CODE:
2046{ 2083{
2047 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2084 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2048} 2085}
2049 2086
2050const_utf8_string get_ob_key_value (object *op, utf8_string key) 2087shstr
2088object::kv_get (shstr key)
2051 2089
2052bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) 2090void
2091object::kv_del (shstr key)
2092
2093void
2094object::kv_set (shstr key, shstr value)
2053 2095
2054object *get_nearest_player (object *ob) 2096object *get_nearest_player (object *ob)
2055 ALIAS: nearest_player = 0 2097 ALIAS: nearest_player = 0
2056 PREINIT: 2098 PREINIT:
2057 extern object *get_nearest_player (object *); 2099 extern object *get_nearest_player (object *);
2059void rangevector (object *ob, object *other, int flags = 0) 2101void rangevector (object *ob, object *other, int flags = 0)
2060 PROTOTYPE: $$;$ 2102 PROTOTYPE: $$;$
2061 PPCODE: 2103 PPCODE:
2062{ 2104{
2063 rv_vector rv; 2105 rv_vector rv;
2106
2107 PUTBACK;
2064 get_rangevector (ob, other, &rv, flags); 2108 get_rangevector (ob, other, &rv, flags);
2109 SPAGAIN;
2110
2065 EXTEND (SP, 5); 2111 EXTEND (SP, 5);
2066 PUSHs (newSVuv (rv.distance)); 2112 PUSHs (newSVuv (rv.distance));
2067 PUSHs (newSViv (rv.distance_x)); 2113 PUSHs (newSViv (rv.distance_x));
2068 PUSHs (newSViv (rv.distance_y)); 2114 PUSHs (newSViv (rv.distance_y));
2069 PUSHs (newSViv (rv.direction)); 2115 PUSHs (newSViv (rv.direction));
2376get_map_flags (maptile *map, int x, int y) 2422get_map_flags (maptile *map, int x, int y)
2377 PPCODE: 2423 PPCODE:
2378{ 2424{
2379 maptile *nmap = 0; 2425 maptile *nmap = 0;
2380 I16 nx = 0, ny = 0; 2426 I16 nx = 0, ny = 0;
2427
2428 PUTBACK;
2381 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); 2429 int flags = get_map_flags (map, &nmap, x, y, &nx, &ny);
2430 SPAGAIN;
2382 2431
2383 EXTEND (SP, 4); 2432 EXTEND (SP, 4);
2384 PUSHs (sv_2mortal (newSViv (flags))); 2433 PUSHs (sv_2mortal (newSViv (flags)));
2385 2434
2386 if (GIMME_V == G_ARRAY) 2435 if (GIMME_V == G_ARRAY)
2394void 2443void
2395at (maptile *map, unsigned int x, unsigned int y) 2444at (maptile *map, unsigned int x, unsigned int y)
2396 PROTOTYPE: $$$ 2445 PROTOTYPE: $$$
2397 PPCODE: 2446 PPCODE:
2398{ 2447{
2399 object *o;
2400 maptile *nmap = 0; 2448 maptile *nmap = 0;
2401 I16 nx, ny; 2449 I16 nx, ny;
2402 2450
2451 PUTBACK;
2403 get_map_flags (map, &nmap, x, y, &nx, &ny); 2452 get_map_flags (map, &nmap, x, y, &nx, &ny);
2453 SPAGAIN;
2404 2454
2405 if (nmap) 2455 if (nmap)
2406 for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) 2456 for (object *o = nmap->at (nx, ny).bot; o; o = o->above)
2407 XPUSHs (sv_2mortal (to_sv (o))); 2457 XPUSHs (sv_2mortal (to_sv (o)));
2408} 2458}
2409 2459
2410SV * 2460SV *
2411bot_at (maptile *obj, unsigned int x, unsigned int y) 2461bot_at (maptile *obj, unsigned int x, unsigned int y)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines