… | |
… | |
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 | |
141 | void |
146 | void |
142 | attachable::do_destroy () |
147 | attachable::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 | |
… | |
… | |
328 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
336 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
329 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
337 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
330 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
338 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
331 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
339 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
332 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
340 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
341 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
333 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
342 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
334 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
343 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
335 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
344 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
336 | |
345 | |
337 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
346 | inline 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 | |
832 | maptile * |
841 | maptile * |
833 | maptile::load_map_sync (const char *path, maptile *origin) |
842 | maptile::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 | |
|
|
861 | void |
|
|
862 | maptile::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 | |
852 | void |
870 | void |
853 | maptile::change_all_map_light (int change) |
871 | maptile::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 | |
1527 | void _global_reattach () |
1543 | void _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 | |
1545 | NV floor (NV x) |
1561 | NV floor (NV x) |
1546 | |
1562 | |
… | |
… | |
1603 | |
1619 | |
1604 | void emergency_save () |
1620 | void emergency_save () |
1605 | |
1621 | |
1606 | void _exit (int status = 0) |
1622 | void _exit (int status = 0) |
1607 | |
1623 | |
|
|
1624 | #if _POSIX_MEMLOCK |
|
|
1625 | |
|
|
1626 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
|
|
1627 | |
|
|
1628 | int munlockall () |
|
|
1629 | |
|
|
1630 | #endif |
|
|
1631 | |
1608 | int find_animation (char *text) |
1632 | int find_animation (char *text) |
1609 | PROTOTYPE: $ |
1633 | PROTOTYPE: $ |
1610 | |
1634 | |
1611 | int random_roll (int min, int max, object *op, int goodbad); |
1635 | int 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 |
1687 | INCLUDE: $PERL genacc attachable ../include/cfperl.h | |
1664 | #destroyed (attachable *at) |
|
|
1665 | # |
|
|
1666 | #void |
|
|
1667 | #destroy (attachable *at) |
|
|
1668 | |
1688 | |
1669 | MODULE = cf PACKAGE = cf::global |
1689 | MODULE = cf PACKAGE = cf::global |
1670 | |
1690 | |
1671 | int invoke (SV *klass, int event, ...) |
1691 | int 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 | |
|
|
1981 | player *cf_player_find (char *name) |
|
|
1982 | PROTOTYPE: $ |
|
|
1983 | |
2000 | |
1984 | void cf_player_move (player *pl, int dir) |
2001 | void cf_player_move (player *pl, int dir) |
1985 | |
2002 | |
1986 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2003 | void 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 | |
2035 | void |
2052 | void |
2036 | list () |
2053 | list () |
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 | |
2041 | bool |
2058 | bool |
2042 | peaceful (player *pl, bool new_setting = 0) |
2059 | peaceful (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 | |
|
|
2088 | void |
|
|
2089 | maptile::destroy () |
|
|
2090 | |
2104 | |
2091 | void |
2105 | void |
2092 | maptile::players () |
2106 | maptile::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 | |
2367 | void |
|
|
2368 | client::destroy () |
|
|
2369 | |
|
|