… | |
… | |
20 | * |
20 | * |
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 | |
|
|
26 | #define PLUGIN_NAME "perl" |
|
|
27 | #define PLUGIN_VERSION "cfperl 0.5" |
|
|
28 | |
25 | |
29 | #if HAVE_EXECINFO_H |
26 | #if HAVE_EXECINFO_H |
30 | # include <execinfo.h> |
27 | # include <execinfo.h> |
31 | #endif |
28 | #endif |
32 | |
29 | |
… | |
… | |
944 | CALL_CALL ("ext::books::make_book", G_VOID); |
941 | CALL_CALL ("ext::books::make_book", G_VOID); |
945 | CALL_END; |
942 | CALL_END; |
946 | } |
943 | } |
947 | |
944 | |
948 | void |
945 | void |
|
|
946 | cfperl_expand_cfpod (player *pl, std::string &msg) |
|
|
947 | { |
|
|
948 | CALL_BEGIN (2); |
|
|
949 | CALL_ARG (pl); |
|
|
950 | CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ())); |
|
|
951 | CALL_CALL ("cf::player::expand_cfpod", G_SCALAR); |
|
|
952 | |
|
|
953 | if (count) |
|
|
954 | { |
|
|
955 | STRLEN len; |
|
|
956 | char *data = SvPVutf8 (TOPs, len); |
|
|
957 | msg.assign (data, len); |
|
|
958 | } |
|
|
959 | |
|
|
960 | CALL_END; |
|
|
961 | } |
|
|
962 | |
|
|
963 | void |
949 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
964 | cfperl_send_msg (client *ns, int color, const char *type, const char *msg) |
950 | { |
965 | { |
951 | CALL_BEGIN (4); |
966 | CALL_BEGIN (4); |
952 | CALL_ARG (ns); |
967 | CALL_ARG (ns); |
953 | CALL_ARG (type); |
968 | CALL_ARG (type); |
… | |
… | |
977 | { |
992 | { |
978 | CALL_BEGIN (1); |
993 | CALL_BEGIN (1); |
979 | CALL_ARG (name); |
994 | CALL_ARG (name); |
980 | CALL_CALL ("cf::player::find", G_SCALAR); |
995 | CALL_CALL ("cf::player::find", G_SCALAR); |
981 | |
996 | |
982 | player *retval; |
997 | player *retval = 0; |
983 | |
|
|
984 | if (count) |
|
|
985 | sv_to (POPs, retval); |
998 | if (count) sv_to (POPs, retval); |
986 | else |
999 | |
987 | retval = 0; |
1000 | CALL_END; |
|
|
1001 | |
|
|
1002 | return retval; |
|
|
1003 | } |
|
|
1004 | |
|
|
1005 | maptile * |
|
|
1006 | find_style (const char *dirname, const char *stylename, int difficulty) |
|
|
1007 | { |
|
|
1008 | CALL_BEGIN (3); |
|
|
1009 | CALL_ARG (dirname); |
|
|
1010 | CALL_ARG (stylename); |
|
|
1011 | CALL_ARG (difficulty); |
|
|
1012 | CALL_CALL ("ext::map_random::find_style", G_SCALAR); |
|
|
1013 | |
|
|
1014 | maptile *retval = 0; |
|
|
1015 | if (count) sv_to (POPs, retval); |
988 | |
1016 | |
989 | CALL_END; |
1017 | CALL_END; |
990 | |
1018 | |
991 | return retval; |
1019 | return retval; |
992 | } |
1020 | } |
… | |
… | |
997 | CALL_BEGIN (2); |
1025 | CALL_BEGIN (2); |
998 | CALL_ARG (path); |
1026 | CALL_ARG (path); |
999 | CALL_ARG (origin); |
1027 | CALL_ARG (origin); |
1000 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
1028 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
1001 | |
1029 | |
1002 | maptile *retval; |
1030 | maptile *retval = 0; |
1003 | |
|
|
1004 | if (count) |
|
|
1005 | sv_to (POPs, retval); |
1031 | if (count) sv_to (POPs, retval); |
1006 | else |
|
|
1007 | retval = 0; |
|
|
1008 | |
1032 | |
1009 | CALL_END; |
1033 | CALL_END; |
1010 | |
1034 | |
1011 | return retval; |
1035 | return retval; |
1012 | } |
1036 | } |
… | |
… | |
1018 | CALL_ARG (path); |
1042 | CALL_ARG (path); |
1019 | CALL_ARG (origin); |
1043 | CALL_ARG (origin); |
1020 | CALL_ARG (load); |
1044 | CALL_ARG (load); |
1021 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1045 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
1022 | |
1046 | |
1023 | maptile *retval; |
1047 | maptile *retval = 0; |
1024 | |
|
|
1025 | if (count) |
|
|
1026 | sv_to (POPs, retval); |
1048 | if (count) sv_to (POPs, retval); |
1027 | else |
|
|
1028 | retval = 0; |
|
|
1029 | |
1049 | |
1030 | CALL_END; |
1050 | CALL_END; |
1031 | |
1051 | |
1032 | return retval; |
1052 | return retval; |
1033 | } |
1053 | } |
… | |
… | |
1058 | |
1078 | |
1059 | CALL_BEGIN (2); |
1079 | CALL_BEGIN (2); |
1060 | CALL_ARG (this); |
1080 | CALL_ARG (this); |
1061 | CALL_ARG (exit); |
1081 | CALL_ARG (exit); |
1062 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
1082 | CALL_CALL ("cf::object::player::enter_exit", G_VOID); |
|
|
1083 | CALL_END; |
|
|
1084 | } |
|
|
1085 | |
|
|
1086 | void |
|
|
1087 | object::player_goto (const char *path, int x, int y) |
|
|
1088 | { |
|
|
1089 | if (type != PLAYER) |
|
|
1090 | return; |
|
|
1091 | |
|
|
1092 | CALL_BEGIN (4); |
|
|
1093 | CALL_ARG (this); |
|
|
1094 | CALL_ARG (path); |
|
|
1095 | CALL_ARG (x); |
|
|
1096 | CALL_ARG (y); |
|
|
1097 | CALL_CALL ("cf::object::player::goto", G_VOID); |
1063 | CALL_END; |
1098 | CALL_END; |
1064 | } |
1099 | } |
1065 | |
1100 | |
1066 | const char * |
1101 | const char * |
1067 | object::ref () const |
1102 | object::ref () const |
… | |
… | |
1573 | NV floor (NV x) |
1608 | NV floor (NV x) |
1574 | |
1609 | |
1575 | NV ceil (NV x) |
1610 | NV ceil (NV x) |
1576 | |
1611 | |
1577 | NV rndm (...) |
1612 | NV rndm (...) |
|
|
1613 | ALIAS: |
|
|
1614 | rmg_rndm = 1 |
1578 | CODE: |
1615 | CODE: |
|
|
1616 | { |
|
|
1617 | rand_gen &gen = ix ? rmg_rndm : rndm; |
1579 | switch (items) |
1618 | switch (items) |
1580 | { |
1619 | { |
1581 | case 0: RETVAL = rndm (); break; |
1620 | case 0: RETVAL = gen (); break; |
1582 | case 1: RETVAL = rndm (SvUV (ST (0))); break; |
1621 | case 1: RETVAL = gen (SvUV (ST (0))); break; |
1583 | case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; |
1622 | case 2: RETVAL = gen (SvIV (ST (0)), SvIV (ST (1))); break; |
1584 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1623 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
1585 | } |
1624 | } |
|
|
1625 | } |
1586 | OUTPUT: |
1626 | OUTPUT: |
1587 | RETVAL |
1627 | RETVAL |
1588 | |
1628 | |
1589 | NV clamp (NV value, NV min_value, NV max_value) |
1629 | NV clamp (NV value, NV min_value, NV max_value) |
1590 | CODE: |
1630 | CODE: |
… | |
… | |
1787 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1827 | PUSHs (sv_2mortal (to_sv (archetype::find (coins [i])))); |
1788 | |
1828 | |
1789 | bool |
1829 | bool |
1790 | load_resource_file_ (octet_string filename) |
1830 | load_resource_file_ (octet_string filename) |
1791 | |
1831 | |
|
|
1832 | void |
|
|
1833 | fix_weight () |
|
|
1834 | |
1792 | MODULE = cf PACKAGE = cf::attachable |
1835 | MODULE = cf PACKAGE = cf::attachable |
1793 | |
1836 | |
1794 | int |
1837 | int |
1795 | valid (SV *obj) |
1838 | valid (SV *obj) |
1796 | CODE: |
1839 | CODE: |
… | |
… | |
2057 | void rangevector (object *ob, object *other, int flags = 0) |
2100 | void rangevector (object *ob, object *other, int flags = 0) |
2058 | PROTOTYPE: $$;$ |
2101 | PROTOTYPE: $$;$ |
2059 | PPCODE: |
2102 | PPCODE: |
2060 | { |
2103 | { |
2061 | rv_vector rv; |
2104 | rv_vector rv; |
|
|
2105 | |
|
|
2106 | PUTBACK; |
2062 | get_rangevector (ob, other, &rv, flags); |
2107 | get_rangevector (ob, other, &rv, flags); |
|
|
2108 | SPAGAIN; |
|
|
2109 | |
2063 | EXTEND (SP, 5); |
2110 | EXTEND (SP, 5); |
2064 | PUSHs (newSVuv (rv.distance)); |
2111 | PUSHs (newSVuv (rv.distance)); |
2065 | PUSHs (newSViv (rv.distance_x)); |
2112 | PUSHs (newSViv (rv.distance_x)); |
2066 | PUSHs (newSViv (rv.distance_y)); |
2113 | PUSHs (newSViv (rv.distance_y)); |
2067 | PUSHs (newSViv (rv.direction)); |
2114 | PUSHs (newSViv (rv.direction)); |
… | |
… | |
2374 | get_map_flags (maptile *map, int x, int y) |
2421 | get_map_flags (maptile *map, int x, int y) |
2375 | PPCODE: |
2422 | PPCODE: |
2376 | { |
2423 | { |
2377 | maptile *nmap = 0; |
2424 | maptile *nmap = 0; |
2378 | I16 nx = 0, ny = 0; |
2425 | I16 nx = 0, ny = 0; |
|
|
2426 | |
|
|
2427 | PUTBACK; |
2379 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2428 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2429 | SPAGAIN; |
2380 | |
2430 | |
2381 | EXTEND (SP, 4); |
2431 | EXTEND (SP, 4); |
2382 | PUSHs (sv_2mortal (newSViv (flags))); |
2432 | PUSHs (sv_2mortal (newSViv (flags))); |
2383 | |
2433 | |
2384 | if (GIMME_V == G_ARRAY) |
2434 | if (GIMME_V == G_ARRAY) |
… | |
… | |
2392 | void |
2442 | void |
2393 | at (maptile *map, unsigned int x, unsigned int y) |
2443 | at (maptile *map, unsigned int x, unsigned int y) |
2394 | PROTOTYPE: $$$ |
2444 | PROTOTYPE: $$$ |
2395 | PPCODE: |
2445 | PPCODE: |
2396 | { |
2446 | { |
2397 | object *o; |
|
|
2398 | maptile *nmap = 0; |
2447 | maptile *nmap = 0; |
2399 | I16 nx, ny; |
2448 | I16 nx, ny; |
2400 | |
2449 | |
|
|
2450 | PUTBACK; |
2401 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
2451 | get_map_flags (map, &nmap, x, y, &nx, &ny); |
|
|
2452 | SPAGAIN; |
2402 | |
2453 | |
2403 | if (nmap) |
2454 | if (nmap) |
2404 | for (o = GET_MAP_OB (nmap, nx, ny); o; o = o->above) |
2455 | for (object *o = nmap->at (nx, ny).bot; o; o = o->above) |
2405 | XPUSHs (sv_2mortal (to_sv (o))); |
2456 | XPUSHs (sv_2mortal (to_sv (o))); |
2406 | } |
2457 | } |
2407 | |
2458 | |
2408 | SV * |
2459 | SV * |
2409 | bot_at (maptile *obj, unsigned int x, unsigned int y) |
2460 | bot_at (maptile *obj, unsigned int x, unsigned int y) |