… | |
… | |
49 | |
49 | |
50 | extern sint64 *levels; // the experience table |
50 | extern sint64 *levels; // the experience table |
51 | |
51 | |
52 | typedef object object_ornull; |
52 | typedef object object_ornull; |
53 | typedef maptile maptile_ornull; |
53 | typedef maptile maptile_ornull; |
|
|
54 | |
|
|
55 | typedef char *octet_string; |
|
|
56 | typedef char *utf8_string; |
|
|
57 | typedef const char *const_octet_string; |
|
|
58 | typedef const char *const_utf8_string; |
54 | |
59 | |
55 | #if IVSIZE >= 8 |
60 | #if IVSIZE >= 8 |
56 | typedef IV val64; |
61 | typedef IV val64; |
57 | # define newSVval64 newSViv |
62 | # define newSVval64 newSViv |
58 | # define SvVAL64 SvIV |
63 | # define SvVAL64 SvIV |
… | |
… | |
606 | perl = perl_alloc (); |
611 | perl = perl_alloc (); |
607 | perl_construct (perl); |
612 | perl_construct (perl); |
608 | |
613 | |
609 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
614 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
610 | |
615 | |
611 | char *argv[] = { |
616 | const char *argv[] = { |
612 | "", |
617 | "", |
613 | "-e" |
618 | "-e" |
614 | "use Event; use Coro;" // required for bootstrap |
619 | "use Event; use Coro;" // required for bootstrap |
615 | "cf->bootstrap;" // required for datadir :*> |
620 | "cf->bootstrap;" // required for datadir :*> |
616 | "unshift @INC, cf::datadir ();" |
621 | "unshift @INC, cf::datadir ();" |
617 | "require cf;" |
622 | "require cf;" |
618 | }; |
623 | }; |
619 | |
624 | |
620 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
625 | if (perl_parse (perl, xs_init, 2, (char **)argv, (char **)NULL) |
|
|
626 | || perl_run (perl)) |
621 | { |
627 | { |
622 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
628 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
623 | exit (EXIT_FAILURE); |
629 | exit (EXIT_FAILURE); |
624 | } |
630 | } |
625 | |
631 | |
… | |
… | |
1050 | # define const_iv(name) { # name, (IV)name }, |
1056 | # define const_iv(name) { # name, (IV)name }, |
1051 | const_iv (llevError) |
1057 | const_iv (llevError) |
1052 | const_iv (llevInfo) |
1058 | const_iv (llevInfo) |
1053 | const_iv (llevDebug) |
1059 | const_iv (llevDebug) |
1054 | const_iv (llevMonster) |
1060 | const_iv (llevMonster) |
|
|
1061 | |
|
|
1062 | const_iv (Map0Cmd) |
|
|
1063 | const_iv (Map1Cmd) |
|
|
1064 | const_iv (Map1aCmd) |
|
|
1065 | |
|
|
1066 | const_iv (MAP_CLIENT_X) |
|
|
1067 | const_iv (MAP_CLIENT_Y) |
1055 | |
1068 | |
1056 | const_iv (MAX_TIME) |
1069 | const_iv (MAX_TIME) |
1057 | const_iv (PLAYER) |
1070 | const_iv (PLAYER) |
1058 | const_iv (TRANSPORT) |
1071 | const_iv (TRANSPORT) |
1059 | const_iv (ROD) |
1072 | const_iv (ROD) |
… | |
… | |
1620 | CODE: |
1633 | CODE: |
1621 | runtime = SvNVx (sv_runtime); |
1634 | runtime = SvNVx (sv_runtime); |
1622 | server_tick (); |
1635 | server_tick (); |
1623 | |
1636 | |
1624 | void |
1637 | void |
1625 | LOG (int level, char *msg) |
1638 | LOG (int level, utf8_string msg) |
1626 | PROTOTYPE: $$ |
1639 | PROTOTYPE: $$ |
1627 | C_ARGS: (LogLevel)level, "%s", msg |
1640 | C_ARGS: (LogLevel)level, "%s", msg |
1628 | |
1641 | |
1629 | char *path_combine (char *base, char *path) |
1642 | octet_string path_combine (octet_string base, octet_string path) |
1630 | PROTOTYPE: $$ |
1643 | PROTOTYPE: $$ |
1631 | |
1644 | |
1632 | char *path_combine_and_normalize (char *base, char *path) |
1645 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1633 | PROTOTYPE: $$ |
1646 | PROTOTYPE: $$ |
1634 | |
1647 | |
1635 | const char * |
1648 | const_octet_string |
1636 | get_maps_directory (char *path) |
1649 | get_maps_directory (octet_string path) |
1637 | PROTOTYPE: $ |
1650 | PROTOTYPE: $ |
1638 | ALIAS: maps_directory = 0 |
1651 | ALIAS: maps_directory = 0 |
1639 | CODE: |
1652 | CODE: |
1640 | RETVAL = create_pathname (path); |
1653 | RETVAL = create_pathname (path); |
1641 | OUTPUT: RETVAL |
1654 | OUTPUT: RETVAL |
… | |
… | |
1643 | void |
1656 | void |
1644 | sub_generation_inc () |
1657 | sub_generation_inc () |
1645 | CODE: |
1658 | CODE: |
1646 | PL_sub_generation++; |
1659 | PL_sub_generation++; |
1647 | |
1660 | |
1648 | char * |
1661 | const_octet_string |
1649 | mapdir () |
1662 | mapdir () |
1650 | PROTOTYPE: |
1663 | PROTOTYPE: |
1651 | ALIAS: |
1664 | ALIAS: |
1652 | mapdir = 0 |
1665 | mapdir = 0 |
1653 | uniquedir = 1 |
1666 | uniquedir = 1 |
… | |
… | |
1669 | } |
1682 | } |
1670 | OUTPUT: RETVAL |
1683 | OUTPUT: RETVAL |
1671 | |
1684 | |
1672 | void abort () |
1685 | void abort () |
1673 | |
1686 | |
1674 | void fork_abort (char *cause = "cf::fork_abort") |
1687 | void fork_abort (octet_string cause = "cf::fork_abort") |
1675 | |
1688 | |
1676 | void cleanup (const char *cause, bool make_core = false) |
1689 | void cleanup (octet_string cause, bool make_core = false) |
1677 | |
1690 | |
1678 | void emergency_save () |
1691 | void emergency_save () |
1679 | |
1692 | |
1680 | void _exit (int status = EXIT_SUCCESS) |
1693 | void _exit (int status = EXIT_SUCCESS) |
1681 | |
1694 | |
… | |
… | |
1691 | |
1704 | |
1692 | int munlockall () |
1705 | int munlockall () |
1693 | |
1706 | |
1694 | #endif |
1707 | #endif |
1695 | |
1708 | |
1696 | int find_animation (char *text) |
1709 | int find_animation (utf8_string text) |
1697 | PROTOTYPE: $ |
1710 | PROTOTYPE: $ |
1698 | |
1711 | |
1699 | int random_roll (int min, int max, object *op, int goodbad); |
1712 | int random_roll (int min, int max, object *op, int goodbad); |
1700 | |
1713 | |
1701 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1714 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1702 | |
1715 | |
1703 | int |
1716 | int |
1704 | exp_to_level (val64 exp) |
1717 | exp_to_level (val64 exp) |
1705 | CODE: |
1718 | CODE: |
1706 | { |
1719 | { |
… | |
… | |
1738 | else |
1751 | else |
1739 | XSRETURN_UNDEF; |
1752 | XSRETURN_UNDEF; |
1740 | OUTPUT: RETVAL |
1753 | OUTPUT: RETVAL |
1741 | |
1754 | |
1742 | bool |
1755 | bool |
1743 | load_resource_file (const char *filename) |
1756 | load_resource_file (octet_string filename) |
1744 | |
1757 | |
1745 | MODULE = cf PACKAGE = cf::attachable |
1758 | MODULE = cf PACKAGE = cf::attachable |
1746 | |
1759 | |
1747 | int |
1760 | int |
1748 | valid (SV *obj) |
1761 | valid (SV *obj) |
… | |
… | |
1847 | num_animations (object *op) |
1860 | num_animations (object *op) |
1848 | CODE: |
1861 | CODE: |
1849 | RETVAL = NUM_ANIMATIONS (op); |
1862 | RETVAL = NUM_ANIMATIONS (op); |
1850 | OUTPUT: RETVAL |
1863 | OUTPUT: RETVAL |
1851 | |
1864 | |
1852 | object *find_best_object_match (object *op, const char *match) |
1865 | object *find_best_object_match (object *op, utf8_string match) |
1853 | |
1866 | |
1854 | object *find_marked_object (object *op) |
1867 | object *find_marked_object (object *op) |
1855 | |
1868 | |
1856 | int need_identify (object *obj); |
1869 | int need_identify (object *obj); |
1857 | |
1870 | |
… | |
… | |
1877 | CODE: |
1890 | CODE: |
1878 | player_apply_below (op); |
1891 | player_apply_below (op); |
1879 | |
1892 | |
1880 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
1893 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
1881 | |
1894 | |
1882 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1895 | object *cf_object_present_archname_inside (object *op, utf8_string whatstr) |
1883 | |
1896 | |
1884 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1897 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1885 | |
1898 | |
1886 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1899 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1887 | |
1900 | |
… | |
… | |
1907 | RETVAL = pay_for_amount (amount, op); |
1920 | RETVAL = pay_for_amount (amount, op); |
1908 | OUTPUT: RETVAL |
1921 | OUTPUT: RETVAL |
1909 | |
1922 | |
1910 | void pay_player (object *op, uint64 amount) |
1923 | void pay_player (object *op, uint64 amount) |
1911 | |
1924 | |
1912 | val64 pay_player_arch (object *op, const char *arch, uint64 amount) |
1925 | val64 pay_player_arch (object *op, utf8_string arch, uint64 amount) |
1913 | |
1926 | |
1914 | int cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg = 0) |
1927 | int cast_spell (object *op, object *caster, int dir, object *spell_ob, utf8_string stringarg = 0) |
1915 | |
1928 | |
1916 | void learn_spell (object *op, object *sp, int special_prayer = 0) |
1929 | void learn_spell (object *op, object *sp, int special_prayer = 0) |
1917 | CODE: |
1930 | CODE: |
1918 | do_learn_spell (op, sp, special_prayer); |
1931 | do_learn_spell (op, sp, special_prayer); |
1919 | |
1932 | |
1920 | void forget_spell (object *op, object *sp) |
1933 | void forget_spell (object *op, object *sp) |
1921 | CODE: |
1934 | CODE: |
1922 | do_forget_spell (op, query_name (sp)); |
1935 | do_forget_spell (op, query_name (sp)); |
1923 | |
1936 | |
1924 | object *check_for_spell (object *op, char *spellname) |
1937 | object *check_for_spell (object *op, utf8_string spellname) |
1925 | CODE: |
1938 | CODE: |
1926 | RETVAL = check_spell_known (op, spellname); |
1939 | RETVAL = check_spell_known (op, spellname); |
1927 | OUTPUT: RETVAL |
1940 | OUTPUT: RETVAL |
1928 | |
1941 | |
1929 | int query_money (object *op) |
1942 | int query_money (object *op) |
… | |
… | |
1942 | |
1955 | |
1943 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1956 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1944 | |
1957 | |
1945 | void update_object (object *op, int action) |
1958 | void update_object (object *op, int action) |
1946 | |
1959 | |
1947 | object *cf_create_object_by_name (const char *name) |
1960 | object *cf_create_object_by_name (utf8_string name) |
1948 | |
1961 | |
1949 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1962 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
1950 | |
1963 | |
1951 | void player_lvl_adj (object *who, object *skill = 0) |
1964 | void player_lvl_adj (object *who, object *skill = 0) |
1952 | |
1965 | |
1953 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1966 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1954 | |
1967 | |
… | |
… | |
1968 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1981 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1969 | |
1982 | |
1970 | # no clean way to get an object from an archetype - stupid idiotic |
1983 | # no clean way to get an object from an archetype - stupid idiotic |
1971 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
1984 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
1972 | |
1985 | |
1973 | object *new (const char *archetype = 0) |
1986 | object *new (utf8_string archetype = 0) |
1974 | PROTOTYPE: ;$ |
1987 | PROTOTYPE: ;$ |
1975 | CODE: |
1988 | CODE: |
1976 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
1989 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
1977 | OUTPUT: |
1990 | OUTPUT: |
1978 | RETVAL |
1991 | RETVAL |
… | |
… | |
1983 | { |
1996 | { |
1984 | int unused_type; |
1997 | int unused_type; |
1985 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
1998 | RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); |
1986 | } |
1999 | } |
1987 | |
2000 | |
1988 | # syntatic sugar for easier use in event callbacks. |
|
|
1989 | const char *options (object *op) |
|
|
1990 | CODE: |
|
|
1991 | RETVAL = op->name; |
|
|
1992 | OUTPUT: |
|
|
1993 | RETVAL |
|
|
1994 | |
|
|
1995 | player *contr (object *op) |
2001 | player *contr (object *op) |
1996 | CODE: |
2002 | CODE: |
1997 | RETVAL = op->contr; |
2003 | RETVAL = op->contr; |
1998 | OUTPUT: RETVAL |
2004 | OUTPUT: RETVAL |
1999 | |
2005 | |
2000 | const char *get_ob_key_value (object *op, const char *key) |
2006 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
2001 | |
2007 | |
2002 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
2008 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
2003 | |
2009 | |
2004 | object *get_nearest_player (object *ob) |
2010 | object *get_nearest_player (object *ob) |
2005 | ALIAS: nearest_player = 0 |
2011 | ALIAS: nearest_player = 0 |
2006 | PREINIT: |
2012 | PREINIT: |
2007 | extern object *get_nearest_player (object *); |
2013 | extern object *get_nearest_player (object *); |
… | |
… | |
2023 | bool on_same_map_as (object *ob, object *other) |
2029 | bool on_same_map_as (object *ob, object *other) |
2024 | CODE: |
2030 | CODE: |
2025 | RETVAL = on_same_map (ob, other); |
2031 | RETVAL = on_same_map (ob, other); |
2026 | OUTPUT: RETVAL |
2032 | OUTPUT: RETVAL |
2027 | |
2033 | |
2028 | const char * |
2034 | const_utf8_string |
2029 | base_name (object *op, int plural = op->nrof > 1) |
2035 | base_name (object *op, int plural = op->nrof > 1) |
2030 | CODE: |
2036 | CODE: |
2031 | RETVAL = query_base_name (op, plural); |
2037 | RETVAL = query_base_name (op, plural); |
2032 | OUTPUT: RETVAL |
2038 | OUTPUT: RETVAL |
2033 | |
2039 | |
… | |
… | |
2040 | RETVAL = op->contr; |
2046 | RETVAL = op->contr; |
2041 | OUTPUT: RETVAL |
2047 | OUTPUT: RETVAL |
2042 | |
2048 | |
2043 | void check_score (object *op) |
2049 | void check_score (object *op) |
2044 | |
2050 | |
2045 | void message (object *op, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2051 | void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2046 | CODE: |
2052 | CODE: |
2047 | new_draw_info (flags, 0, op, txt); |
2053 | new_draw_info (flags, 0, op, txt); |
2048 | |
2054 | |
2049 | object *cf_player_send_inventory (object *op) |
2055 | object *cf_player_send_inventory (object *op) |
2050 | |
2056 | |
2051 | char *cf_player_get_ip (object *op) |
2057 | octet_string cf_player_get_ip (object *op) |
2052 | ALIAS: ip = 0 |
2058 | ALIAS: ip = 0 |
2053 | |
2059 | |
2054 | object *cf_player_get_marked_item (object *op) |
2060 | object *cf_player_get_marked_item (object *op) |
2055 | ALIAS: marked_item = 0 |
2061 | ALIAS: marked_item = 0 |
2056 | |
2062 | |
… | |
… | |
2066 | void esrv_update_item (object *op, int what, object *item) |
2072 | void esrv_update_item (object *op, int what, object *item) |
2067 | C_ARGS: what, op, item |
2073 | C_ARGS: what, op, item |
2068 | |
2074 | |
2069 | void clear_los (object *op) |
2075 | void clear_los (object *op) |
2070 | |
2076 | |
2071 | int command_summon (object *op, char *params) |
2077 | int command_summon (object *op, utf8_string params) |
2072 | |
2078 | |
2073 | int command_arrest (object *op, char *params) |
2079 | int command_arrest (object *op, utf8_string params) |
2074 | |
2080 | |
2075 | |
2081 | |
2076 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2082 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2077 | |
2083 | |
2078 | INCLUDE: $PERL $srcdir/genacc player ../include/player.h | |
2084 | INCLUDE: $PERL $srcdir/genacc player ../include/player.h | |
… | |
… | |
2343 | |
2349 | |
2344 | # worst xs function of my life |
2350 | # worst xs function of my life |
2345 | bool |
2351 | bool |
2346 | _create_random_map (\ |
2352 | _create_random_map (\ |
2347 | maptile *self,\ |
2353 | maptile *self,\ |
2348 | char *wallstyle,\ |
2354 | utf8_string wallstyle,\ |
2349 | char *wall_name,\ |
2355 | utf8_string wall_name,\ |
2350 | char *floorstyle,\ |
2356 | utf8_string floorstyle,\ |
2351 | char *monsterstyle,\ |
2357 | utf8_string monsterstyle,\ |
2352 | char *treasurestyle,\ |
2358 | utf8_string treasurestyle,\ |
2353 | char *layoutstyle,\ |
2359 | utf8_string layoutstyle,\ |
2354 | char *doorstyle,\ |
2360 | utf8_string doorstyle,\ |
2355 | char *decorstyle,\ |
2361 | utf8_string decorstyle,\ |
2356 | char *origin_map,\ |
2362 | utf8_string origin_map,\ |
2357 | char *final_map,\ |
2363 | utf8_string final_map,\ |
2358 | char *exitstyle,\ |
2364 | utf8_string exitstyle,\ |
2359 | char *this_map,\ |
2365 | utf8_string this_map,\ |
2360 | char *exit_on_final_map,\ |
2366 | utf8_string exit_on_final_map,\ |
2361 | int xsize,\ |
2367 | int xsize,\ |
2362 | int ysize,\ |
2368 | int ysize,\ |
2363 | int expand2x,\ |
2369 | int expand2x,\ |
2364 | int layoutoptions1,\ |
2370 | int layoutoptions1,\ |
2365 | int layoutoptions2,\ |
2371 | int layoutoptions2,\ |
… | |
… | |
2378 | val64 total_map_hp,\ |
2384 | val64 total_map_hp,\ |
2379 | int map_layout_style,\ |
2385 | int map_layout_style,\ |
2380 | int treasureoptions,\ |
2386 | int treasureoptions,\ |
2381 | int symmetry_used,\ |
2387 | int symmetry_used,\ |
2382 | region *region,\ |
2388 | region *region,\ |
2383 | char *custom\ |
2389 | utf8_string custom\ |
2384 | ) |
2390 | ) |
2385 | CODE: |
2391 | CODE: |
2386 | { |
2392 | { |
2387 | random_map_params rmp; |
2393 | random_map_params rmp; |
2388 | |
2394 | |
… | |
… | |
2429 | OUTPUT: |
2435 | OUTPUT: |
2430 | RETVAL |
2436 | RETVAL |
2431 | |
2437 | |
2432 | MODULE = cf PACKAGE = cf::arch |
2438 | MODULE = cf PACKAGE = cf::arch |
2433 | |
2439 | |
2434 | archetype *find (const char *name) |
2440 | archetype *find (utf8_string name) |
2435 | CODE: |
2441 | CODE: |
2436 | RETVAL = archetype::find (name); |
2442 | RETVAL = archetype::find (name); |
2437 | OUTPUT: |
2443 | OUTPUT: |
2438 | RETVAL |
2444 | RETVAL |
2439 | |
2445 | |
… | |
… | |
2461 | list () |
2467 | list () |
2462 | PPCODE: |
2468 | PPCODE: |
2463 | for_all_regions (rgn) |
2469 | for_all_regions (rgn) |
2464 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2470 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2465 | |
2471 | |
2466 | region *find (char *name) |
2472 | region *find (utf8_string name) |
2467 | PROTOTYPE: $ |
2473 | PROTOTYPE: $ |
2468 | CODE: |
2474 | CODE: |
2469 | RETVAL = region::find (name); |
2475 | RETVAL = region::find (name); |
2470 | OUTPUT: RETVAL |
2476 | OUTPUT: RETVAL |
2471 | |
2477 | |
2472 | region *find_fuzzy (char *name) |
2478 | region *find_fuzzy (utf8_string name) |
2473 | PROTOTYPE: $ |
2479 | PROTOTYPE: $ |
2474 | CODE: |
2480 | CODE: |
2475 | RETVAL = region::find_fuzzy (name); |
2481 | RETVAL = region::find_fuzzy (name); |
|
|
2482 | OUTPUT: RETVAL |
|
|
2483 | |
|
|
2484 | int specificity (region *rgn) |
|
|
2485 | CODE: |
|
|
2486 | RETVAL = 0; |
|
|
2487 | while (rgn = rgn->parent) |
|
|
2488 | RETVAL++; |
2476 | OUTPUT: RETVAL |
2489 | OUTPUT: RETVAL |
2477 | |
2490 | |
2478 | INCLUDE: $PERL $srcdir/genacc region ../include/map.h | |
2491 | INCLUDE: $PERL $srcdir/genacc region ../include/map.h | |
2479 | |
2492 | |
2480 | MODULE = cf PACKAGE = cf::living |
2493 | MODULE = cf PACKAGE = cf::living |
… | |
… | |
2516 | THIS->send_packet (buf, len); |
2529 | THIS->send_packet (buf, len); |
2517 | } |
2530 | } |
2518 | |
2531 | |
2519 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2532 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
2520 | |
2533 | |
2521 | INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2534 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
2522 | |
2535 | |
2523 | int face_find (const char *name, int defidx = 0) |
2536 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
2524 | |
2537 | |
2525 | int alloc (const char *name) |
2538 | faceidx alloc (utf8_string name) |
2526 | CODE: |
2539 | CODE: |
2527 | { |
2540 | { |
2528 | do |
2541 | do |
2529 | { |
2542 | { |
2530 | RETVAL = faces.size (); |
2543 | RETVAL = faces.size (); |
2531 | faces.resize (RETVAL + 1); |
2544 | faces.resize (RETVAL + 1); |
2532 | face32.resize (RETVAL + 1); |
|
|
2533 | face64.resize (RETVAL + 1); |
|
|
2534 | } |
2545 | } |
2535 | while (!RETVAL); // crude way to leave index 0 |
2546 | while (!RETVAL); // crude way to leave index 0 |
2536 | |
2547 | |
2537 | faces [RETVAL].name = name; |
2548 | faces [RETVAL].name = name; |
2538 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
2549 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
… | |
… | |
2540 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2551 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
2541 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2552 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
2542 | } |
2553 | } |
2543 | OUTPUT: RETVAL |
2554 | OUTPUT: RETVAL |
2544 | |
2555 | |
2545 | void set (int idx, int visibility, int magicmap) |
2556 | void set (faceidx idx, int visibility, int magicmap) |
2546 | CODE: |
2557 | CODE: |
|
|
2558 | faceinfo *f = face_info (idx); |
|
|
2559 | assert (f); |
2547 | faces [idx].visibility = visibility; |
2560 | f->visibility = visibility; |
2548 | faces [idx].magicmap = magicmap; |
2561 | f->magicmap = magicmap; |
2549 | |
2562 | |
|
|
2563 | void set_smooth (faceidx idx, faceidx smooth, int smoothlevel) |
|
|
2564 | CODE: |
|
|
2565 | faceinfo *f = face_info (idx); assert (f); |
|
|
2566 | f->smooth = smooth; |
|
|
2567 | f->smoothlevel = smoothlevel; |
|
|
2568 | |
2550 | void set_data (int idx, int faceset, SV *data, SV *chksum) |
2569 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2551 | CODE: |
2570 | CODE: |
|
|
2571 | { |
2552 | facedata *d = face_data (idx, faceset); |
2572 | facedata *d = face_data (idx, faceset); |
2553 | assert (sv_len (chksum) == CHKSUM_SIZE); |
2573 | assert (d); |
2554 | sv_to (data, d->data); memcpy (d->chksum, SvPVbyte_nolen (chksum), CHKSUM_SIZE); |
2574 | sv_to (data, d->data); |
|
|
2575 | STRLEN clen; |
|
|
2576 | char *cdata = SvPVbyte (chksum, clen); |
|
|
2577 | clen = min (CHKSUM_SIZE, clen); |
2555 | |
2578 | |
|
|
2579 | if (memcmp (d->chksum, cdata, clen)) |
|
|
2580 | { |
|
|
2581 | memcpy (d->chksum, cdata, clen); |
|
|
2582 | |
|
|
2583 | // invalidate existing client face info |
|
|
2584 | for_all_clients (ns) |
|
|
2585 | if (ns->faceset == faceset) |
|
|
2586 | { |
|
|
2587 | ns->faces_sent [idx] = false; |
|
|
2588 | ns->force_newmap = true; |
|
|
2589 | } |
|
|
2590 | } |
|
|
2591 | } |
|
|
2592 | |
|
|
2593 | void invalidate (faceidx idx) |
|
|
2594 | CODE: |
|
|
2595 | for_all_clients (ns) |
|
|
2596 | { |
|
|
2597 | ns->faces_sent [idx] = false; |
|
|
2598 | ns->force_newmap = true; |
|
|
2599 | } |
|
|
2600 | |
|
|
2601 | void invalidate_all () |
|
|
2602 | CODE: |
|
|
2603 | for_all_clients (ns) |
|
|
2604 | { |
|
|
2605 | ns->faces_sent.reset (); |
|
|
2606 | ns->force_newmap = true; |
|
|
2607 | } |
|
|
2608 | |
|
|
2609 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
|
|
2610 | |
|
|
2611 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/anim.h | |
|
|
2612 | |
|
|
2613 | animidx anim_find (utf8_string name) |
|
|
2614 | CODE: |
|
|
2615 | RETVAL = animation::find (name).number; |
|
|
2616 | OUTPUT: RETVAL |
|
|
2617 | |
|
|
2618 | animidx set (utf8_string name, SV *frames, int facings = 1) |
|
|
2619 | CODE: |
|
|
2620 | { |
|
|
2621 | if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV) |
|
|
2622 | croak ("frames must be an arrayref"); |
|
|
2623 | |
|
|
2624 | AV *av = (AV *)SvRV (frames); |
|
|
2625 | |
|
|
2626 | animation *anim = &animation::find (name); |
|
|
2627 | if (anim->number) |
|
|
2628 | { |
|
|
2629 | anim->resize (av_len (av) + 1); |
|
|
2630 | anim->facings = facings; |
|
|
2631 | } |
|
|
2632 | else |
|
|
2633 | anim = &animation::create (name, av_len (av) + 1, facings); |
|
|
2634 | |
|
|
2635 | for (int i = 0; i < anim->num_animations; ++i) |
|
|
2636 | anim->faces [i] = face_find (SvPVutf8_nolen (*av_fetch (av, i, 1))); |
|
|
2637 | } |
|
|
2638 | OUTPUT: RETVAL |
|
|
2639 | |
|
|
2640 | void invalidate_all () |
|
|
2641 | CODE: |
|
|
2642 | for_all_clients (ns) |
|
|
2643 | ns->anims_sent.reset (); |
|
|
2644 | |