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.177 by root, Wed Mar 14 00:04:59 2007 UTC vs.
Revision 1.188 by root, Mon Apr 16 11:09:32 2007 UTC

49 49
50extern sint64 *levels; // the experience table 50extern sint64 *levels; // the experience table
51 51
52typedef object object_ornull; 52typedef object object_ornull;
53typedef maptile maptile_ornull; 53typedef maptile maptile_ornull;
54
55typedef char *octet_string;
56typedef char *utf8_string;
57typedef const char *const_octet_string;
58typedef 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
386inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 391inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
387inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } 392inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
388inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 393inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
389 394
390//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } 395//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
391inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } 396inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); }
392 397
393template<class T> 398template<class T>
394inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 399inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
395 400
396template<int N> 401template<int N>
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
945struct EventAPI *watcher_base::GEventAPI; 951struct EventAPI *watcher_base::GEventAPI;
946struct CoroAPI *coroapi::GCoroAPI; 952struct CoroAPI *coroapi::GCoroAPI;
947 953
948int coroapi::cede_counter; 954int coroapi::cede_counter;
949 955
956void
957coroapi::wait_for_tick ()
958{
959 CALL_BEGIN (0);
960 CALL_CALL ("cf::wait_for_tick", G_DISCARD);
961 CALL_END;
962}
963
964void
965coroapi::wait_for_tick_begin ()
966{
967 CALL_BEGIN (0);
968 CALL_CALL ("cf::wait_for_tick_begin", G_DISCARD);
969 CALL_END;
970}
971
972static void
950static void iw_dispatch (pe_event *ev) 973iw_dispatch (pe_event *ev)
951{ 974{
952 iw *w = (iw *)ev->ext_data; 975 iw *w = (iw *)ev->ext_data;
953 w->call (*w); 976 w->call (*w);
954} 977}
955 978
1050# define const_iv(name) { # name, (IV)name }, 1073# define const_iv(name) { # name, (IV)name },
1051 const_iv (llevError) 1074 const_iv (llevError)
1052 const_iv (llevInfo) 1075 const_iv (llevInfo)
1053 const_iv (llevDebug) 1076 const_iv (llevDebug)
1054 const_iv (llevMonster) 1077 const_iv (llevMonster)
1078
1079 const_iv (Map0Cmd)
1080 const_iv (Map1Cmd)
1081 const_iv (Map1aCmd)
1082
1083 const_iv (MAP_CLIENT_X)
1084 const_iv (MAP_CLIENT_Y)
1055 1085
1056 const_iv (MAX_TIME) 1086 const_iv (MAX_TIME)
1057 const_iv (PLAYER) 1087 const_iv (PLAYER)
1058 const_iv (TRANSPORT) 1088 const_iv (TRANSPORT)
1059 const_iv (ROD) 1089 const_iv (ROD)
1620 CODE: 1650 CODE:
1621 runtime = SvNVx (sv_runtime); 1651 runtime = SvNVx (sv_runtime);
1622 server_tick (); 1652 server_tick ();
1623 1653
1624void 1654void
1625LOG (int level, char *msg) 1655LOG (int level, utf8_string msg)
1626 PROTOTYPE: $$ 1656 PROTOTYPE: $$
1627 C_ARGS: (LogLevel)level, "%s", msg 1657 C_ARGS: (LogLevel)level, "%s", msg
1628 1658
1629char *path_combine (char *base, char *path) 1659octet_string path_combine (octet_string base, octet_string path)
1630 PROTOTYPE: $$ 1660 PROTOTYPE: $$
1631 1661
1632char *path_combine_and_normalize (char *base, char *path) 1662octet_string path_combine_and_normalize (octet_string base, octet_string path)
1633 PROTOTYPE: $$ 1663 PROTOTYPE: $$
1634 1664
1635const char * 1665const_octet_string
1636get_maps_directory (char *path) 1666get_maps_directory (octet_string path)
1637 PROTOTYPE: $ 1667 PROTOTYPE: $
1638 ALIAS: maps_directory = 0 1668 ALIAS: maps_directory = 0
1639 CODE: 1669 CODE:
1640 RETVAL = create_pathname (path); 1670 RETVAL = create_pathname (path);
1641 OUTPUT: RETVAL 1671 OUTPUT: RETVAL
1643void 1673void
1644sub_generation_inc () 1674sub_generation_inc ()
1645 CODE: 1675 CODE:
1646 PL_sub_generation++; 1676 PL_sub_generation++;
1647 1677
1648char * 1678const_octet_string
1649mapdir () 1679mapdir ()
1650 PROTOTYPE: 1680 PROTOTYPE:
1651 ALIAS: 1681 ALIAS:
1652 mapdir = 0 1682 mapdir = 0
1653 uniquedir = 1 1683 uniquedir = 1
1669 } 1699 }
1670 OUTPUT: RETVAL 1700 OUTPUT: RETVAL
1671 1701
1672void abort () 1702void abort ()
1673 1703
1674void fork_abort (char *cause = "cf::fork_abort") 1704void fork_abort (octet_string cause = "cf::fork_abort")
1675 1705
1676void cleanup (const char *cause, bool make_core = false) 1706void cleanup (octet_string cause, bool make_core = false)
1677 1707
1678void emergency_save () 1708void emergency_save ()
1679 1709
1680void _exit (int status = EXIT_SUCCESS) 1710void _exit (int status = EXIT_SUCCESS)
1681 1711
1691 1721
1692int munlockall () 1722int munlockall ()
1693 1723
1694#endif 1724#endif
1695 1725
1696int find_animation (char *text) 1726int find_animation (utf8_string text)
1697 PROTOTYPE: $ 1727 PROTOTYPE: $
1698 1728
1699int random_roll (int min, int max, object *op, int goodbad); 1729int random_roll (int min, int max, object *op, int goodbad);
1700 1730
1701const char *cost_string_from_value(uint64 cost, int approx = 0) 1731const_utf8_string cost_string_from_value(uint64 cost, int approx = 0)
1702 1732
1703int 1733int
1704exp_to_level (val64 exp) 1734exp_to_level (val64 exp)
1705 CODE: 1735 CODE:
1706{ 1736{
1738 else 1768 else
1739 XSRETURN_UNDEF; 1769 XSRETURN_UNDEF;
1740 OUTPUT: RETVAL 1770 OUTPUT: RETVAL
1741 1771
1742bool 1772bool
1743load_resource_file (const char *filename) 1773load_resource_file (octet_string filename)
1774
1775bool
1776load_archetype_file (octet_string filename)
1777
1778bool
1779load_treasure_file (octet_string filename)
1744 1780
1745MODULE = cf PACKAGE = cf::attachable 1781MODULE = cf PACKAGE = cf::attachable
1746 1782
1747int 1783int
1748valid (SV *obj) 1784valid (SV *obj)
1847num_animations (object *op) 1883num_animations (object *op)
1848 CODE: 1884 CODE:
1849 RETVAL = NUM_ANIMATIONS (op); 1885 RETVAL = NUM_ANIMATIONS (op);
1850 OUTPUT: RETVAL 1886 OUTPUT: RETVAL
1851 1887
1852object *find_best_object_match (object *op, const char *match) 1888object *find_best_object_match (object *op, utf8_string match)
1853 1889
1854object *find_marked_object (object *op) 1890object *find_marked_object (object *op)
1855 1891
1856int need_identify (object *obj); 1892int need_identify (object *obj);
1857 1893
1877 CODE: 1913 CODE:
1878 player_apply_below (op); 1914 player_apply_below (op);
1879 1915
1880int cast_heal (object *op, object *caster, object *spell, int dir = 0) 1916int cast_heal (object *op, object *caster, object *spell, int dir = 0)
1881 1917
1882object *cf_object_present_archname_inside (object *op, char *whatstr) 1918object *cf_object_present_archname_inside (object *op, utf8_string whatstr)
1883 1919
1884int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) 1920int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0)
1885 1921
1886int cf_object_change_map (object *op, int x, int y, maptile *map) 1922int cf_object_change_map (object *op, int x, int y, maptile *map)
1887 1923
1907 RETVAL = pay_for_amount (amount, op); 1943 RETVAL = pay_for_amount (amount, op);
1908 OUTPUT: RETVAL 1944 OUTPUT: RETVAL
1909 1945
1910void pay_player (object *op, uint64 amount) 1946void pay_player (object *op, uint64 amount)
1911 1947
1912val64 pay_player_arch (object *op, const char *arch, uint64 amount) 1948val64 pay_player_arch (object *op, utf8_string arch, uint64 amount)
1913 1949
1914int cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg = 0) 1950int cast_spell (object *op, object *caster, int dir, object *spell_ob, utf8_string stringarg = 0)
1915 1951
1916void learn_spell (object *op, object *sp, int special_prayer = 0) 1952void learn_spell (object *op, object *sp, int special_prayer = 0)
1917 CODE: 1953 CODE:
1918 do_learn_spell (op, sp, special_prayer); 1954 do_learn_spell (op, sp, special_prayer);
1919 1955
1920void forget_spell (object *op, object *sp) 1956void forget_spell (object *op, object *sp)
1921 CODE: 1957 CODE:
1922 do_forget_spell (op, query_name (sp)); 1958 do_forget_spell (op, query_name (sp));
1923 1959
1924object *check_for_spell (object *op, char *spellname) 1960object *check_for_spell (object *op, utf8_string spellname)
1925 CODE: 1961 CODE:
1926 RETVAL = check_spell_known (op, spellname); 1962 RETVAL = check_spell_known (op, spellname);
1927 OUTPUT: RETVAL 1963 OUTPUT: RETVAL
1928 1964
1929int query_money (object *op) 1965int query_money (object *op)
1942 1978
1943int cf_object_teleport (object *op, maptile *map, int x, int y) 1979int cf_object_teleport (object *op, maptile *map, int x, int y)
1944 1980
1945void update_object (object *op, int action) 1981void update_object (object *op, int action)
1946 1982
1947object *cf_create_object_by_name (const char *name) 1983object *cf_create_object_by_name (utf8_string name)
1948 1984
1949void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) 1985void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0)
1950 1986
1951void player_lvl_adj (object *who, object *skill = 0) 1987void player_lvl_adj (object *who, object *skill = 0)
1952 1988
1953int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 1989int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
1954 1990
1968object *cf_insert_ob_in_ob (object *ob, object *where) 2004object *cf_insert_ob_in_ob (object *ob, object *where)
1969 2005
1970# no clean way to get an object from an archetype - stupid idiotic 2006# no clean way to get an object from an archetype - stupid idiotic
1971# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 2007# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
1972 2008
1973object *new (const char *archetype = 0) 2009object *new (utf8_string archetype = 0)
1974 PROTOTYPE: ;$ 2010 PROTOTYPE: ;$
1975 CODE: 2011 CODE:
1976 RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); 2012 RETVAL = archetype ? get_archetype (archetype) : cf_create_object ();
1977 OUTPUT: 2013 OUTPUT:
1978 RETVAL 2014 RETVAL
1983{ 2019{
1984 int unused_type; 2020 int unused_type;
1985 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y); 2021 RETVAL = (object *)object_insert (&unused_type, ob, 0, where, orig, flag, x, y);
1986} 2022}
1987 2023
1988# syntatic sugar for easier use in event callbacks.
1989const char *options (object *op)
1990 CODE:
1991 RETVAL = op->name;
1992 OUTPUT:
1993 RETVAL
1994
1995player *contr (object *op) 2024player *contr (object *op)
1996 CODE: 2025 CODE:
1997 RETVAL = op->contr; 2026 RETVAL = op->contr;
1998 OUTPUT: RETVAL 2027 OUTPUT: RETVAL
1999 2028
2000const char *get_ob_key_value (object *op, const char *key) 2029const_utf8_string get_ob_key_value (object *op, utf8_string key)
2001 2030
2002bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) 2031bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1)
2003 2032
2004object *get_nearest_player (object *ob) 2033object *get_nearest_player (object *ob)
2005 ALIAS: nearest_player = 0 2034 ALIAS: nearest_player = 0
2006 PREINIT: 2035 PREINIT:
2007 extern object *get_nearest_player (object *); 2036 extern object *get_nearest_player (object *);
2023bool on_same_map_as (object *ob, object *other) 2052bool on_same_map_as (object *ob, object *other)
2024 CODE: 2053 CODE:
2025 RETVAL = on_same_map (ob, other); 2054 RETVAL = on_same_map (ob, other);
2026 OUTPUT: RETVAL 2055 OUTPUT: RETVAL
2027 2056
2028const char * 2057const_utf8_string
2029base_name (object *op, int plural = op->nrof > 1) 2058base_name (object *op, int plural = op->nrof > 1)
2030 CODE: 2059 CODE:
2031 RETVAL = query_base_name (op, plural); 2060 RETVAL = query_base_name (op, plural);
2032 OUTPUT: RETVAL 2061 OUTPUT: RETVAL
2033 2062
2040 RETVAL = op->contr; 2069 RETVAL = op->contr;
2041 OUTPUT: RETVAL 2070 OUTPUT: RETVAL
2042 2071
2043void check_score (object *op) 2072void check_score (object *op)
2044 2073
2045void message (object *op, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) 2074void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE)
2046 CODE: 2075 CODE:
2047 new_draw_info (flags, 0, op, txt); 2076 new_draw_info (flags, 0, op, txt);
2048 2077
2049object *cf_player_send_inventory (object *op) 2078object *cf_player_send_inventory (object *op)
2050 2079
2051char *cf_player_get_ip (object *op) 2080octet_string cf_player_get_ip (object *op)
2052 ALIAS: ip = 0 2081 ALIAS: ip = 0
2053 2082
2054object *cf_player_get_marked_item (object *op) 2083object *cf_player_get_marked_item (object *op)
2055 ALIAS: marked_item = 0 2084 ALIAS: marked_item = 0
2056 2085
2066void esrv_update_item (object *op, int what, object *item) 2095void esrv_update_item (object *op, int what, object *item)
2067 C_ARGS: what, op, item 2096 C_ARGS: what, op, item
2068 2097
2069void clear_los (object *op) 2098void clear_los (object *op)
2070 2099
2071int command_summon (object *op, char *params) 2100int command_summon (object *op, utf8_string params)
2072 2101
2073int command_arrest (object *op, char *params) 2102int command_arrest (object *op, utf8_string params)
2074 2103
2075 2104
2076MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ 2105MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
2077 2106
2078INCLUDE: $PERL $srcdir/genacc player ../include/player.h | 2107INCLUDE: $PERL $srcdir/genacc player ../include/player.h |
2343 2372
2344# worst xs function of my life 2373# worst xs function of my life
2345bool 2374bool
2346_create_random_map (\ 2375_create_random_map (\
2347 maptile *self,\ 2376 maptile *self,\
2348 char *wallstyle,\ 2377 utf8_string wallstyle,\
2349 char *wall_name,\ 2378 utf8_string wall_name,\
2350 char *floorstyle,\ 2379 utf8_string floorstyle,\
2351 char *monsterstyle,\ 2380 utf8_string monsterstyle,\
2352 char *treasurestyle,\ 2381 utf8_string treasurestyle,\
2353 char *layoutstyle,\ 2382 utf8_string layoutstyle,\
2354 char *doorstyle,\ 2383 utf8_string doorstyle,\
2355 char *decorstyle,\ 2384 utf8_string decorstyle,\
2356 char *origin_map,\ 2385 utf8_string origin_map,\
2357 char *final_map,\ 2386 utf8_string final_map,\
2358 char *exitstyle,\ 2387 utf8_string exitstyle,\
2359 char *this_map,\ 2388 utf8_string this_map,\
2360 char *exit_on_final_map,\ 2389 utf8_string exit_on_final_map,\
2361 int xsize,\ 2390 int xsize,\
2362 int ysize,\ 2391 int ysize,\
2363 int expand2x,\ 2392 int expand2x,\
2364 int layoutoptions1,\ 2393 int layoutoptions1,\
2365 int layoutoptions2,\ 2394 int layoutoptions2,\
2378 val64 total_map_hp,\ 2407 val64 total_map_hp,\
2379 int map_layout_style,\ 2408 int map_layout_style,\
2380 int treasureoptions,\ 2409 int treasureoptions,\
2381 int symmetry_used,\ 2410 int symmetry_used,\
2382 region *region,\ 2411 region *region,\
2383 char *custom\ 2412 utf8_string custom\
2384) 2413)
2385 CODE: 2414 CODE:
2386{ 2415{
2387 random_map_params rmp; 2416 random_map_params rmp;
2388 2417
2429 OUTPUT: 2458 OUTPUT:
2430 RETVAL 2459 RETVAL
2431 2460
2432MODULE = cf PACKAGE = cf::arch 2461MODULE = cf PACKAGE = cf::arch
2433 2462
2434archetype *find (const char *name) 2463archetype *find (utf8_string name)
2435 CODE: 2464 CODE:
2436 RETVAL = archetype::find (name); 2465 RETVAL = archetype::find (name);
2437 OUTPUT: 2466 OUTPUT:
2438 RETVAL 2467 RETVAL
2439 2468
2461list () 2490list ()
2462 PPCODE: 2491 PPCODE:
2463 for_all_regions (rgn) 2492 for_all_regions (rgn)
2464 XPUSHs (sv_2mortal (to_sv (rgn))); 2493 XPUSHs (sv_2mortal (to_sv (rgn)));
2465 2494
2466region *find (char *name) 2495region *find (utf8_string name)
2467 PROTOTYPE: $ 2496 PROTOTYPE: $
2468 CODE: 2497 CODE:
2469 RETVAL = region::find (name); 2498 RETVAL = region::find (name);
2470 OUTPUT: RETVAL 2499 OUTPUT: RETVAL
2471 2500
2472region *find_fuzzy (char *name) 2501region *find_fuzzy (utf8_string name)
2473 PROTOTYPE: $ 2502 PROTOTYPE: $
2474 CODE: 2503 CODE:
2475 RETVAL = region::find_fuzzy (name); 2504 RETVAL = region::find_fuzzy (name);
2505 OUTPUT: RETVAL
2506
2507int specificity (region *rgn)
2508 CODE:
2509 RETVAL = 0;
2510 while (rgn = rgn->parent)
2511 RETVAL++;
2476 OUTPUT: RETVAL 2512 OUTPUT: RETVAL
2477 2513
2478INCLUDE: $PERL $srcdir/genacc region ../include/map.h | 2514INCLUDE: $PERL $srcdir/genacc region ../include/map.h |
2479 2515
2480MODULE = cf PACKAGE = cf::living 2516MODULE = cf PACKAGE = cf::living
2516 THIS->send_packet (buf, len); 2552 THIS->send_packet (buf, len);
2517} 2553}
2518 2554
2519MODULE = cf PACKAGE = cf::face PREFIX = face_ 2555MODULE = cf PACKAGE = cf::face PREFIX = face_
2520 2556
2521INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | 2557#INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h |
2522 2558
2523faceidx face_find (const char *name, faceidx defidx = 0) 2559faceidx face_find (utf8_string name, faceidx defidx = 0)
2524 2560
2525faceidx alloc (const char *name) 2561faceidx alloc (utf8_string name)
2526 CODE: 2562 CODE:
2527{ 2563{
2528 do 2564 do
2529 { 2565 {
2530 RETVAL = faces.size (); 2566 RETVAL = faces.size ();
2545 faceinfo *f = face_info (idx); 2581 faceinfo *f = face_info (idx);
2546 assert (f); 2582 assert (f);
2547 f->visibility = visibility; 2583 f->visibility = visibility;
2548 f->magicmap = magicmap; 2584 f->magicmap = magicmap;
2549 2585
2550void set_smooth (faceidx idx, faceidx smooth) 2586void set_smooth (faceidx idx, faceidx smooth, int smoothlevel)
2551 CODE: 2587 CODE:
2552 faceinfo *f = face_info (idx); 2588 faceinfo *f = face_info (idx); assert (f);
2553 assert (f);
2554 f->smooth = smooth; 2589 f->smooth = smooth;
2590 f->smoothlevel = smoothlevel;
2555 2591
2556void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2592void set_data (faceidx idx, int faceset, SV *data, SV *chksum)
2557 CODE: 2593 CODE:
2594{
2558 facedata *d = face_data (idx, faceset); 2595 facedata *d = face_data (idx, faceset);
2559 assert (d); 2596 assert (d);
2560 assert (sv_len (chksum) == CHKSUM_SIZE); 2597 sv_to (data, d->data);
2561 sv_to (data, d->data); memcpy (d->chksum, SvPVbyte_nolen (chksum), CHKSUM_SIZE); 2598 STRLEN clen;
2599 char *cdata = SvPVbyte (chksum, clen);
2600 clen = min (CHKSUM_SIZE, clen);
2601
2602 if (memcmp (d->chksum, cdata, clen))
2603 {
2604 memcpy (d->chksum, cdata, clen);
2605
2606 // invalidate existing client face info
2607 for_all_clients (ns)
2608 if (ns->faceset == faceset)
2609 {
2610 ns->faces_sent [idx] = false;
2611 ns->force_newmap = true;
2612 }
2613 }
2614}
2562 2615
2563void invalidate (faceidx idx) 2616void invalidate (faceidx idx)
2564 CODE: 2617 CODE:
2565 for_all_clients (ns) 2618 for_all_clients (ns)
2619 {
2566 ns->faces_sent [idx] = 0; 2620 ns->faces_sent [idx] = false;
2621 ns->force_newmap = true;
2622 }
2567 2623
2568void invalidate_all () 2624void invalidate_all ()
2569 CODE: 2625 CODE:
2570 for_all_clients (ns) 2626 for_all_clients (ns)
2571 memset (ns->faces_sent, 0, sizeof (ns->faces_sent)); 2627 {
2628 ns->faces_sent.reset ();
2629 ns->force_newmap = true;
2630 }
2572 2631
2632MODULE = cf PACKAGE = cf::anim PREFIX = anim_
2633
2634#INCLUDE: $PERL $srcdir/genacc faceset ../include/anim.h |
2635
2636animidx anim_find (utf8_string name)
2637 CODE:
2638 RETVAL = animation::find (name).number;
2639 OUTPUT: RETVAL
2640
2641animidx set (utf8_string name, SV *frames, int facings = 1)
2642 CODE:
2643{
2644 if (!SvROK (frames) && SvTYPE (SvRV (frames)) != SVt_PVAV)
2645 croak ("frames must be an arrayref");
2646
2647 AV *av = (AV *)SvRV (frames);
2648
2649 animation *anim = &animation::find (name);
2650 if (anim->number)
2651 {
2652 anim->resize (av_len (av) + 1);
2653 anim->facings = facings;
2654 }
2655 else
2656 anim = &animation::create (name, av_len (av) + 1, facings);
2657
2658 for (int i = 0; i < anim->num_animations; ++i)
2659 anim->faces [i] = face_find (SvPVutf8_nolen (*av_fetch (av, i, 1)));
2660}
2661 OUTPUT: RETVAL
2662
2663void invalidate_all ()
2664 CODE:
2665 for_all_clients (ns)
2666 ns->anims_sent.reset ();
2667

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines