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.124 by root, Mon Jan 1 00:41:03 2007 UTC vs.
Revision 1.128 by root, Sun Jan 7 02:39:14 2007 UTC

32#include <sproto.h> 32#include <sproto.h>
33 33
34#include "cfperl.h" 34#include "cfperl.h"
35#include "shstr.h" 35#include "shstr.h"
36 36
37#include <unistd.h>
38#if _POSIX_MEMLOCK
39# include <sys/mman.h>
40#endif
41
37#include <EXTERN.h> 42#include <EXTERN.h>
38#include <perl.h> 43#include <perl.h>
39#include <XSUB.h> 44#include <XSUB.h>
40 45
41#include "CoroAPI.h" 46#include "CoroAPI.h"
140 145
141void 146void
142attachable::do_destroy () 147attachable::do_destroy ()
143{ 148{
144 invoke (EVENT_ATTACHABLE_DESTROY, DT_END); 149 invoke (EVENT_ATTACHABLE_DESTROY, DT_END);
150
151 if (self)
152 hv_clear (self);
145 153
146 //TODO: call generic destroy callback 154 //TODO: call generic destroy callback
147 mortals.push_back (this); 155 mortals.push_back (this);
148} 156}
149 157
328inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } 336inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); }
329inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } 337inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); }
330inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } 338inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); }
331inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 339inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
332inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } 340inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); }
341inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
333inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 342inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
334inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } 343inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
335inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 344inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
336 345
337inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO 346inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO
828 CALL_CALL ("cf::map::emergency_save", G_VOID); 837 CALL_CALL ("cf::map::emergency_save", G_VOID);
829 CALL_END; 838 CALL_END;
830} 839}
831 840
832maptile * 841maptile *
833maptile::load_map_sync (const char *path, maptile *origin) 842maptile::find_sync (const char *path, maptile *origin)
834{ 843{
835 CALL_BEGIN (2); 844 CALL_BEGIN (2);
836 CALL_ARG (path); 845 CALL_ARG (path);
837 CALL_ARG (origin); 846 CALL_ARG (origin);
838 CALL_CALL ("cf::map::load_map_sync", G_SCALAR); 847 CALL_CALL ("cf::map::find_sync", G_SCALAR);
839 848
840 maptile *retval; 849 maptile *retval;
841 850
842 if (count) 851 if (count)
843 sv_to (POPs, retval); 852 sv_to (POPs, retval);
845 retval = 0; 854 retval = 0;
846 855
847 CALL_END; 856 CALL_END;
848 857
849 return retval; 858 return retval;
859}
860
861void
862maptile::do_load_sync ()
863{
864 CALL_BEGIN (1);
865 CALL_ARG (this);
866 CALL_CALL ("cf::map::do_load_sync", G_SCALAR);
867 CALL_END;
850} 868}
851 869
852void 870void
853maptile::change_all_map_light (int change) 871maptile::change_all_map_light (int change)
854{ 872{
1461 const_iv (ST_SETUP) 1479 const_iv (ST_SETUP)
1462 const_iv (ST_PLAYING) 1480 const_iv (ST_PLAYING)
1463 const_iv (ST_CUSTOM) 1481 const_iv (ST_CUSTOM)
1464 1482
1465 const_iv (ST_CHANGE_CLASS) 1483 const_iv (ST_CHANGE_CLASS)
1466 const_iv (ST_CONFIRM_QUIT)
1467 const_iv (ST_GET_PARTY_PASSWORD)
1468 1484
1469 const_iv (IO_HEADER) 1485 const_iv (IO_HEADER)
1470 const_iv (IO_OBJECTS) 1486 const_iv (IO_OBJECTS)
1471 const_iv (IO_UNIQUES) 1487 const_iv (IO_UNIQUES)
1472 1488
1526 1542
1527void _global_reattach () 1543void _global_reattach ()
1528 CODE: 1544 CODE:
1529{ 1545{
1530 // reattach to all attachable objects in the game. 1546 // reattach to all attachable objects in the game.
1531 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) 1547 for_all_clients (ns)
1532 (*i)->reattach (); 1548 ns->reattach ();
1533 1549
1534 for_all_players (pl) 1550 for_all_players (pl)
1535 pl->reattach (); 1551 pl->reattach ();
1536 1552
1537 //TODO 1553 //TODO
1538 //for (map_container::iterator i = maps.begin (); i != maps.end (); ++i) 1554 //for (map_container::iterator i = maps.begin (); i != maps.end (); ++i)
1539 // i->second->reattach (); 1555 // i->second->reattach ();
1540 1556
1541 for (object *op = object::first; op; op = op->next) 1557 for_all_objects (op)
1542 op->reattach (); 1558 op->reattach ();
1543} 1559}
1544 1560
1545NV floor (NV x) 1561NV floor (NV x)
1546 1562
1603 1619
1604void emergency_save () 1620void emergency_save ()
1605 1621
1606void _exit (int status = 0) 1622void _exit (int status = 0)
1607 1623
1624#if _POSIX_MEMLOCK
1625
1626int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1627
1628int munlockall ()
1629
1630#endif
1631
1608int find_animation (char *text) 1632int find_animation (char *text)
1609 PROTOTYPE: $ 1633 PROTOTYPE: $
1610 1634
1611int random_roll (int min, int max, object *op, int goodbad); 1635int random_roll (int min, int max, object *op, int goodbad);
1612 1636
1658 CODE: 1682 CODE:
1659 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); 1683 RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext);
1660 OUTPUT: 1684 OUTPUT:
1661 RETVAL 1685 RETVAL
1662 1686
1663#bool 1687INCLUDE: $PERL genacc attachable ../include/cfperl.h |
1664#destroyed (attachable *at)
1665#
1666#void
1667#destroy (attachable *at)
1668 1688
1669MODULE = cf PACKAGE = cf::global 1689MODULE = cf PACKAGE = cf::global
1670 1690
1671int invoke (SV *klass, int event, ...) 1691int invoke (SV *klass, int event, ...)
1672 CODE: 1692 CODE:
1975 CODE: 1995 CODE:
1976 pl->ob->stats.hp = pl->ob->stats.maxhp; 1996 pl->ob->stats.hp = pl->ob->stats.maxhp;
1977 pl->ob->stats.sp = pl->ob->stats.maxsp; 1997 pl->ob->stats.sp = pl->ob->stats.maxsp;
1978 pl->ob->stats.grace = pl->ob->stats.maxgrace; 1998 pl->ob->stats.grace = pl->ob->stats.maxgrace;
1979 pl->orig_stats = pl->ob->stats; 1999 pl->orig_stats = pl->ob->stats;
1980
1981player *cf_player_find (char *name)
1982 PROTOTYPE: $
1983 2000
1984void cf_player_move (player *pl, int dir) 2001void cf_player_move (player *pl, int dir)
1985 2002
1986void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2003void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
1987 2004
2033 if (y) sv_to (y, pl->bed_y); 2050 if (y) sv_to (y, pl->bed_y);
2034 2051
2035void 2052void
2036list () 2053list ()
2037 PPCODE: 2054 PPCODE:
2038 for (player *pl = first_player; pl; pl = pl->next) 2055 for_all_players (pl)
2039 XPUSHs (sv_2mortal (to_sv (pl))); 2056 XPUSHs (sv_2mortal (to_sv (pl)));
2040 2057
2041bool 2058bool
2042peaceful (player *pl, bool new_setting = 0) 2059peaceful (player *pl, bool new_setting = 0)
2043 PROTOTYPE: $;$ 2060 PROTOTYPE: $;$
2082 PROTOTYPE: 2099 PROTOTYPE:
2083 CODE: 2100 CODE:
2084 RETVAL = new maptile; 2101 RETVAL = new maptile;
2085 OUTPUT: 2102 OUTPUT:
2086 RETVAL 2103 RETVAL
2087
2088void
2089maptile::destroy ()
2090 2104
2091void 2105void
2092maptile::players () 2106maptile::players ()
2093 PPCODE: 2107 PPCODE:
2094 if (GIMME_V == G_SCALAR) 2108 if (GIMME_V == G_SCALAR)
2362 char *buf = SvPVbyte (packet, len); 2376 char *buf = SvPVbyte (packet, len);
2363 2377
2364 THIS->send_packet (buf, len); 2378 THIS->send_packet (buf, len);
2365} 2379}
2366 2380
2367void
2368client::destroy ()
2369

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines