… | |
… | |
4 | |
4 | |
5 | /* |
5 | /* |
6 | * This code is placed under the GNU General Public Licence (GPL) |
6 | * This code is placed under the GNU General Public Licence (GPL) |
7 | * |
7 | * |
8 | * Copyright (C) 2001-2005 by Chachkoff Yann |
8 | * Copyright (C) 2001-2005 by Chachkoff Yann |
9 | * Copyright (C) 2006 by Marc Lehmann <cf@schmorp.de> |
9 | * Copyright (C) 2006,2007 by Marc Lehmann <cf@schmorp.de> |
10 | * |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or |
13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. |
14 | * (at your option) any later version. |
… | |
… | |
29 | #include <plugin_common.h> |
29 | #include <plugin_common.h> |
30 | #include <sounds.h> |
30 | #include <sounds.h> |
31 | #include <cstdarg> |
31 | #include <cstdarg> |
32 | #include <sproto.h> |
32 | #include <sproto.h> |
33 | |
33 | |
|
|
34 | #include "loader.h" |
34 | #include "cfperl.h" |
35 | #include "cfperl.h" |
35 | #include "shstr.h" |
36 | #include "shstr.h" |
36 | |
37 | |
37 | #include <unistd.h> |
38 | #include <unistd.h> |
38 | #if _POSIX_MEMLOCK |
39 | #if _POSIX_MEMLOCK |
… | |
… | |
48 | |
49 | |
49 | extern sint64 *levels; // the experience table |
50 | extern sint64 *levels; // the experience table |
50 | |
51 | |
51 | typedef object object_ornull; |
52 | typedef object object_ornull; |
52 | 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; |
53 | |
59 | |
54 | #if IVSIZE >= 8 |
60 | #if IVSIZE >= 8 |
55 | typedef IV val64; |
61 | typedef IV val64; |
56 | # define newSVval64 newSViv |
62 | # define newSVval64 newSViv |
57 | # define SvVAL64 SvIV |
63 | # define SvVAL64 SvIV |
… | |
… | |
101 | |
107 | |
102 | unordered_vector<attachable *> attachable::mortals; |
108 | unordered_vector<attachable *> attachable::mortals; |
103 | |
109 | |
104 | attachable::~attachable () |
110 | attachable::~attachable () |
105 | { |
111 | { |
|
|
112 | flags |=0x3300;//D |
106 | assert (!self); |
113 | assert (!self); |
107 | assert (!cb); |
114 | assert (!cb); |
108 | } |
115 | } |
109 | |
116 | |
110 | int |
117 | int |
111 | attachable::refcnt_cnt () const |
118 | attachable::refcnt_cnt () const |
112 | { |
119 | { |
113 | return refcnt + (self ? SvREFCNT (self) - 1 : 0); |
120 | return refcnt + (self ? SvREFCNT (self) - 1 : 0); |
|
|
121 | } |
|
|
122 | |
|
|
123 | void |
|
|
124 | attachable::sever_self () |
|
|
125 | { |
|
|
126 | if (HV *self = this->self) |
|
|
127 | { |
|
|
128 | // keep a refcount because sv_unmagic might call attachable_free, |
|
|
129 | // which might clear self, causing sv_unmagic to crash on a now |
|
|
130 | // invalid object. |
|
|
131 | SvREFCNT_inc (self); |
|
|
132 | hv_clear (self); |
|
|
133 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
|
|
134 | SvREFCNT_dec (self); |
|
|
135 | |
|
|
136 | // self *must* be null now because thats sv_unmagic's job. |
|
|
137 | assert (!this->self); |
|
|
138 | flags |= 0x80; // severed //D |
|
|
139 | } |
114 | } |
140 | } |
115 | |
141 | |
116 | void |
142 | void |
117 | attachable::optimise () |
143 | attachable::optimise () |
118 | { |
144 | { |
119 | if (self |
145 | if (self |
120 | && SvREFCNT (self) == 1 |
146 | && SvREFCNT (self) == 1 |
121 | && !HvTOTALKEYS (self)) |
147 | && !HvTOTALKEYS (self)) |
122 | { |
148 | flags |= 0x40,//D |
123 | SV *self = (SV *)this->self; |
149 | sever_self (); |
124 | |
|
|
125 | SvREFCNT_inc (self); |
|
|
126 | sv_unmagic (self, PERL_MAGIC_ext); |
|
|
127 | SvREFCNT_dec (self); |
|
|
128 | assert (!this->self); |
|
|
129 | } |
|
|
130 | } |
150 | } |
131 | |
151 | |
132 | // check wether the object really is dead |
152 | // check wether the object really is dead |
133 | void |
153 | void |
134 | attachable::do_check () |
154 | attachable::do_check () |
… | |
… | |
149 | SvREFCNT_dec (cb); |
169 | SvREFCNT_dec (cb); |
150 | cb = 0; |
170 | cb = 0; |
151 | } |
171 | } |
152 | |
172 | |
153 | if (self) |
173 | if (self) |
154 | { |
174 | sever_self (); |
155 | hv_clear (self); |
|
|
156 | |
175 | |
157 | SV *self = (SV *)this->self; |
176 | flags |= 0x20; //D |
158 | SvREFCNT_inc (self); |
|
|
159 | sv_unmagic (self, PERL_MAGIC_ext); |
|
|
160 | SvREFCNT_dec (self); |
|
|
161 | // self is now 0 |
|
|
162 | assert (!this->self);//D//TODO remove soon |
|
|
163 | } |
|
|
164 | |
|
|
165 | mortals.push_back (this); |
177 | mortals.push_back (this); |
166 | } |
178 | } |
167 | |
179 | |
168 | void |
180 | void |
169 | attachable::destroy () |
181 | attachable::destroy () |
… | |
… | |
264 | |
276 | |
265 | if (!obj->self) |
277 | if (!obj->self) |
266 | { |
278 | { |
267 | obj->self = newHV (); |
279 | obj->self = newHV (); |
268 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
280 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
|
|
281 | obj->flags |= (obj->flags & 0xc0) << 8; |
|
|
282 | obj->flags &= ~0xc0;//D |
|
|
283 | obj->flags |= 0x10;//D |
269 | |
284 | |
270 | // now bless the object _once_ |
285 | // now bless the object _once_ |
271 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
286 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
272 | } |
287 | } |
273 | else |
288 | else |
… | |
… | |
339 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
354 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
340 | |
355 | |
341 | inline SV *to_sv (object & v) { return to_sv (&v); } |
356 | inline SV *to_sv (object & v) { return to_sv (&v); } |
342 | inline SV *to_sv (living & v) { return to_sv (&v); } |
357 | inline SV *to_sv (living & v) { return to_sv (&v); } |
343 | |
358 | |
344 | inline SV *to_sv (facetile * v) { return to_sv (v->name); } |
359 | //inline SV *to_sv (faceinfo * v) { return to_sv (v->name); } |
345 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
360 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
|
|
361 | inline SV *to_sv (std::string & v) { return newSVpvn (v.data (), v.size ()); } |
346 | |
362 | |
347 | inline SV *to_sv (UUID v) |
363 | inline SV *to_sv (UUID v) |
348 | { |
364 | { |
349 | char buf[128]; |
365 | char buf[128]; |
350 | snprintf (buf, 128, "<1,%" PRIx64 ">", v.seq); |
366 | snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); |
351 | return newSVpv (buf, 0); |
367 | return newSVpv (buf, 0); |
352 | } |
368 | } |
353 | |
369 | |
354 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
370 | inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } |
355 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
371 | inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } |
… | |
… | |
374 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
390 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
375 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
391 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
376 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
392 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
377 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
393 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
378 | |
394 | |
379 | inline void sv_to (SV *sv, facetile * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } |
395 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
380 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } |
396 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
381 | |
397 | |
382 | template<class T> |
398 | template<class T> |
383 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
399 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
384 | |
400 | |
385 | template<int N> |
401 | template<int N> |
… | |
… | |
388 | inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); } |
404 | inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); } |
389 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
405 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
390 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
406 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
391 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
407 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
392 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
408 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
|
|
409 | |
|
|
410 | inline void sv_to (SV *sv, std::string &v) |
|
|
411 | { |
|
|
412 | STRLEN len; |
|
|
413 | char *data = SvPVbyte (sv, len); |
|
|
414 | v.assign (data, len); |
|
|
415 | } |
393 | |
416 | |
394 | inline void sv_to (SV *sv, UUID &v) |
417 | inline void sv_to (SV *sv, UUID &v) |
395 | { |
418 | { |
396 | unsigned int version; |
419 | unsigned int version; |
397 | |
420 | |
… | |
… | |
588 | perl = perl_alloc (); |
611 | perl = perl_alloc (); |
589 | perl_construct (perl); |
612 | perl_construct (perl); |
590 | |
613 | |
591 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
614 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
592 | |
615 | |
593 | char *argv[] = { |
616 | const char *argv[] = { |
594 | "", |
617 | "", |
595 | "-e" |
618 | "-e" |
596 | "use Event; use Coro;" // required for bootstrap |
619 | "use Event; use Coro;" // required for bootstrap |
597 | "cf->bootstrap;" // required for datadir :*> |
620 | "cf->bootstrap;" // required for datadir :*> |
598 | "unshift @INC, cf::datadir ();" |
621 | "unshift @INC, cf::datadir ();" |
599 | "require cf;" |
622 | "require cf;" |
600 | }; |
623 | }; |
601 | |
624 | |
602 | 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)) |
603 | { |
627 | { |
604 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
628 | printf ("unable to initialize perl-interpreter, aborting.\n"); |
605 | exit (EXIT_FAILURE); |
629 | exit (EXIT_FAILURE); |
606 | } |
630 | } |
|
|
631 | |
|
|
632 | { |
|
|
633 | dSP; |
|
|
634 | |
|
|
635 | PUSHMARK (SP); |
|
|
636 | PUTBACK; |
|
|
637 | call_pv ("cf::init", G_DISCARD | G_VOID); |
|
|
638 | } |
607 | } |
639 | } |
608 | |
640 | |
609 | void cfperl_main () |
641 | void cfperl_main () |
610 | { |
642 | { |
611 | dSP; |
643 | dSP; |
… | |
… | |
832 | CALL_BEGIN (0); |
864 | CALL_BEGIN (0); |
833 | CALL_CALL ("cf::emergency_save", G_VOID); |
865 | CALL_CALL ("cf::emergency_save", G_VOID); |
834 | CALL_END; |
866 | CALL_END; |
835 | } |
867 | } |
836 | |
868 | |
|
|
869 | void |
|
|
870 | cfperl_cleanup (int make_core) |
|
|
871 | { |
|
|
872 | CALL_BEGIN (1); |
|
|
873 | CALL_ARG (make_core); |
|
|
874 | CALL_CALL ("cf::post_cleanup", G_VOID); |
|
|
875 | CALL_END; |
|
|
876 | } |
|
|
877 | |
837 | maptile * |
878 | maptile * |
838 | maptile::find_sync (const char *path, maptile *origin) |
879 | maptile::find_sync (const char *path, maptile *origin) |
839 | { |
880 | { |
840 | CALL_BEGIN (2); |
881 | CALL_BEGIN (2); |
841 | CALL_ARG (path); |
882 | CALL_ARG (path); |
… | |
… | |
910 | struct EventAPI *watcher_base::GEventAPI; |
951 | struct EventAPI *watcher_base::GEventAPI; |
911 | struct CoroAPI *coroapi::GCoroAPI; |
952 | struct CoroAPI *coroapi::GCoroAPI; |
912 | |
953 | |
913 | int coroapi::cede_counter; |
954 | int coroapi::cede_counter; |
914 | |
955 | |
|
|
956 | void |
|
|
957 | coroapi::wait_for_tick () |
|
|
958 | { |
|
|
959 | CALL_BEGIN (0); |
|
|
960 | CALL_CALL ("cf::wait_for_tick", G_DISCARD); |
|
|
961 | CALL_END; |
|
|
962 | } |
|
|
963 | |
|
|
964 | void |
|
|
965 | coroapi::wait_for_tick_begin () |
|
|
966 | { |
|
|
967 | CALL_BEGIN (0); |
|
|
968 | CALL_CALL ("cf::wait_for_tick_begin", G_DISCARD); |
|
|
969 | CALL_END; |
|
|
970 | } |
|
|
971 | |
|
|
972 | static void |
915 | static void iw_dispatch (pe_event *ev) |
973 | iw_dispatch (pe_event *ev) |
916 | { |
974 | { |
917 | iw *w = (iw *)ev->ext_data; |
975 | iw *w = (iw *)ev->ext_data; |
918 | w->call (*w); |
976 | w->call (*w); |
919 | } |
977 | } |
920 | |
978 | |
… | |
… | |
1015 | # define const_iv(name) { # name, (IV)name }, |
1073 | # define const_iv(name) { # name, (IV)name }, |
1016 | const_iv (llevError) |
1074 | const_iv (llevError) |
1017 | const_iv (llevInfo) |
1075 | const_iv (llevInfo) |
1018 | const_iv (llevDebug) |
1076 | const_iv (llevDebug) |
1019 | 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) |
1020 | |
1085 | |
1021 | const_iv (MAX_TIME) |
1086 | const_iv (MAX_TIME) |
1022 | const_iv (PLAYER) |
1087 | const_iv (PLAYER) |
1023 | const_iv (TRANSPORT) |
1088 | const_iv (TRANSPORT) |
1024 | const_iv (ROD) |
1089 | const_iv (ROD) |
… | |
… | |
1559 | { |
1624 | { |
1560 | // reattach to all attachable objects in the game. |
1625 | // reattach to all attachable objects in the game. |
1561 | for_all_clients (ns) |
1626 | for_all_clients (ns) |
1562 | ns->reattach (); |
1627 | ns->reattach (); |
1563 | |
1628 | |
1564 | for_all_players (pl) |
|
|
1565 | pl->reattach (); |
|
|
1566 | |
|
|
1567 | //TODO |
|
|
1568 | //for (map_container::iterator i = maps.begin (); i != maps.end (); ++i) |
|
|
1569 | // i->second->reattach (); |
|
|
1570 | |
|
|
1571 | for_all_objects (op) |
1629 | for_all_objects (op) |
1572 | op->reattach (); |
1630 | op->reattach (); |
1573 | } |
1631 | } |
1574 | |
1632 | |
1575 | NV floor (NV x) |
1633 | NV floor (NV x) |
… | |
… | |
1592 | CODE: |
1650 | CODE: |
1593 | runtime = SvNVx (sv_runtime); |
1651 | runtime = SvNVx (sv_runtime); |
1594 | server_tick (); |
1652 | server_tick (); |
1595 | |
1653 | |
1596 | void |
1654 | void |
1597 | LOG (int level, char *msg) |
1655 | LOG (int level, utf8_string msg) |
1598 | PROTOTYPE: $$ |
1656 | PROTOTYPE: $$ |
1599 | C_ARGS: (LogLevel)level, "%s", msg |
1657 | C_ARGS: (LogLevel)level, "%s", msg |
1600 | |
1658 | |
1601 | char *path_combine (char *base, char *path) |
1659 | octet_string path_combine (octet_string base, octet_string path) |
1602 | PROTOTYPE: $$ |
1660 | PROTOTYPE: $$ |
1603 | |
1661 | |
1604 | char *path_combine_and_normalize (char *base, char *path) |
1662 | octet_string path_combine_and_normalize (octet_string base, octet_string path) |
1605 | PROTOTYPE: $$ |
1663 | PROTOTYPE: $$ |
1606 | |
1664 | |
1607 | const char * |
1665 | const_octet_string |
1608 | get_maps_directory (char *path) |
1666 | get_maps_directory (octet_string path) |
1609 | PROTOTYPE: $ |
1667 | PROTOTYPE: $ |
1610 | ALIAS: maps_directory = 0 |
1668 | ALIAS: maps_directory = 0 |
1611 | CODE: |
1669 | CODE: |
1612 | RETVAL = create_pathname (path); |
1670 | RETVAL = create_pathname (path); |
1613 | OUTPUT: RETVAL |
1671 | OUTPUT: RETVAL |
… | |
… | |
1615 | void |
1673 | void |
1616 | sub_generation_inc () |
1674 | sub_generation_inc () |
1617 | CODE: |
1675 | CODE: |
1618 | PL_sub_generation++; |
1676 | PL_sub_generation++; |
1619 | |
1677 | |
1620 | char * |
1678 | const_octet_string |
1621 | mapdir () |
1679 | mapdir () |
1622 | PROTOTYPE: |
1680 | PROTOTYPE: |
1623 | ALIAS: |
1681 | ALIAS: |
1624 | mapdir = 0 |
1682 | mapdir = 0 |
1625 | uniquedir = 1 |
1683 | uniquedir = 1 |
… | |
… | |
1641 | } |
1699 | } |
1642 | OUTPUT: RETVAL |
1700 | OUTPUT: RETVAL |
1643 | |
1701 | |
1644 | void abort () |
1702 | void abort () |
1645 | |
1703 | |
1646 | void fork_abort (char *cause = "cf::fork_abort") |
1704 | void fork_abort (octet_string cause = "cf::fork_abort") |
1647 | |
1705 | |
1648 | void cleanup (const char *cause, bool make_core = false) |
1706 | void cleanup (octet_string cause, bool make_core = false) |
1649 | |
1707 | |
1650 | void emergency_save () |
1708 | void emergency_save () |
|
|
1709 | |
|
|
1710 | void _exit (int status = EXIT_SUCCESS) |
1651 | |
1711 | |
1652 | UV sv_2watcher (SV *w) |
1712 | UV sv_2watcher (SV *w) |
1653 | CODE: |
1713 | CODE: |
1654 | RETVAL = (UV)GEventAPI->sv_2watcher (w); |
1714 | RETVAL = (UV)GEventAPI->sv_2watcher (w); |
1655 | OUTPUT: |
1715 | OUTPUT: |
1656 | RETVAL |
1716 | RETVAL |
1657 | |
1717 | |
1658 | void _exit (int status = 0) |
|
|
1659 | |
|
|
1660 | #if _POSIX_MEMLOCK |
1718 | #if _POSIX_MEMLOCK |
1661 | |
1719 | |
1662 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1720 | int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) |
1663 | |
1721 | |
1664 | int munlockall () |
1722 | int munlockall () |
1665 | |
1723 | |
1666 | #endif |
1724 | #endif |
1667 | |
1725 | |
1668 | int find_animation (char *text) |
1726 | int find_animation (utf8_string text) |
1669 | PROTOTYPE: $ |
1727 | PROTOTYPE: $ |
1670 | |
1728 | |
1671 | int random_roll (int min, int max, object *op, int goodbad); |
1729 | int random_roll (int min, int max, object *op, int goodbad); |
1672 | |
1730 | |
1673 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1731 | const_utf8_string cost_string_from_value(uint64 cost, int approx = 0) |
1674 | |
1732 | |
1675 | int |
1733 | int |
1676 | exp_to_level (val64 exp) |
1734 | exp_to_level (val64 exp) |
1677 | CODE: |
1735 | CODE: |
1678 | { |
1736 | { |
… | |
… | |
1709 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1767 | RETVAL = newSVpv (resist_plus[atnr], 0); |
1710 | else |
1768 | else |
1711 | XSRETURN_UNDEF; |
1769 | XSRETURN_UNDEF; |
1712 | OUTPUT: RETVAL |
1770 | OUTPUT: RETVAL |
1713 | |
1771 | |
|
|
1772 | bool |
|
|
1773 | load_resource_file (octet_string filename) |
|
|
1774 | |
|
|
1775 | bool |
|
|
1776 | load_archetype_file (octet_string filename) |
|
|
1777 | |
|
|
1778 | bool |
|
|
1779 | load_treasure_file (octet_string filename) |
|
|
1780 | |
1714 | MODULE = cf PACKAGE = cf::attachable |
1781 | MODULE = cf PACKAGE = cf::attachable |
1715 | |
1782 | |
1716 | int |
1783 | int |
1717 | valid (SV *obj) |
1784 | valid (SV *obj) |
1718 | CODE: |
1785 | CODE: |
1719 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1786 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1720 | OUTPUT: |
1787 | OUTPUT: |
1721 | RETVAL |
1788 | RETVAL |
|
|
1789 | |
|
|
1790 | void |
|
|
1791 | debug_trace (attachable *obj, bool on = true) |
|
|
1792 | CODE: |
|
|
1793 | obj->flags &= ~attachable::F_DEBUG_TRACE; |
|
|
1794 | if (on) |
|
|
1795 | obj->flags |= attachable::F_DEBUG_TRACE; |
1722 | |
1796 | |
1723 | int mortals_size () |
1797 | int mortals_size () |
1724 | CODE: |
1798 | CODE: |
1725 | RETVAL = attachable::mortals.size (); |
1799 | RETVAL = attachable::mortals.size (); |
1726 | OUTPUT: RETVAL |
1800 | OUTPUT: RETVAL |
… | |
… | |
1728 | #object *mortals (U32 index) |
1802 | #object *mortals (U32 index) |
1729 | # CODE: |
1803 | # CODE: |
1730 | # RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; |
1804 | # RETVAL = index < attachable::mortals.size () ? attachable::mortals [index] : 0; |
1731 | # OUTPUT: RETVAL |
1805 | # OUTPUT: RETVAL |
1732 | |
1806 | |
1733 | INCLUDE: $PERL genacc attachable ../include/cfperl.h | |
1807 | INCLUDE: $PERL $srcdir/genacc attachable ../include/cfperl.h | |
1734 | |
1808 | |
1735 | MODULE = cf PACKAGE = cf::global |
1809 | MODULE = cf PACKAGE = cf::global |
1736 | |
1810 | |
1737 | int invoke (SV *klass, int event, ...) |
1811 | int invoke (SV *klass, int event, ...) |
1738 | CODE: |
1812 | CODE: |
… | |
… | |
1742 | RETVAL = gbl_ev.invoke ((event_type)event, ARG_AV (av), DT_END); |
1816 | RETVAL = gbl_ev.invoke ((event_type)event, ARG_AV (av), DT_END); |
1743 | OUTPUT: RETVAL |
1817 | OUTPUT: RETVAL |
1744 | |
1818 | |
1745 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1819 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1746 | |
1820 | |
1747 | INCLUDE: $PERL genacc object ../include/object.h | |
1821 | INCLUDE: $PERL $srcdir/genacc object ../include/object.h | |
1748 | |
1822 | |
1749 | int invoke (object *op, int event, ...) |
1823 | int invoke (object *op, int event, ...) |
1750 | CODE: |
1824 | CODE: |
1751 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1825 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1752 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1826 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
… | |
… | |
1803 | void |
1877 | void |
1804 | set_animation (object *op, int idx) |
1878 | set_animation (object *op, int idx) |
1805 | CODE: |
1879 | CODE: |
1806 | SET_ANIMATION (op, idx); |
1880 | SET_ANIMATION (op, idx); |
1807 | |
1881 | |
|
|
1882 | int |
|
|
1883 | num_animations (object *op) |
|
|
1884 | CODE: |
|
|
1885 | RETVAL = NUM_ANIMATIONS (op); |
|
|
1886 | OUTPUT: RETVAL |
|
|
1887 | |
1808 | object *find_best_object_match (object *op, const char *match) |
1888 | object *find_best_object_match (object *op, utf8_string match) |
1809 | |
1889 | |
1810 | object *find_marked_object (object *op) |
1890 | object *find_marked_object (object *op) |
1811 | |
1891 | |
1812 | int need_identify (object *obj); |
1892 | int need_identify (object *obj); |
1813 | |
1893 | |
1814 | int apply_shop_mat (object *shop_mat, object *op); |
1894 | int apply_shop_mat (object *shop_mat, object *op); |
|
|
1895 | |
|
|
1896 | int move_player (object *op, int dir) |
|
|
1897 | CODE: |
|
|
1898 | RETVAL = move_player (op, dir); |
|
|
1899 | OUTPUT: |
|
|
1900 | RETVAL |
1815 | |
1901 | |
1816 | int move (object *op, int dir, object *originator = op) |
1902 | int move (object *op, int dir, object *originator = op) |
1817 | CODE: |
1903 | CODE: |
1818 | RETVAL = move_ob (op, dir, originator); |
1904 | RETVAL = move_ob (op, dir, originator); |
1819 | OUTPUT: |
1905 | OUTPUT: |
… | |
… | |
1825 | |
1911 | |
1826 | void apply_below (object *op) |
1912 | void apply_below (object *op) |
1827 | CODE: |
1913 | CODE: |
1828 | player_apply_below (op); |
1914 | player_apply_below (op); |
1829 | |
1915 | |
|
|
1916 | int cast_heal (object *op, object *caster, object *spell, int dir = 0) |
|
|
1917 | |
1830 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1918 | object *cf_object_present_archname_inside (object *op, utf8_string whatstr) |
1831 | |
1919 | |
1832 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1920 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1833 | |
1921 | |
1834 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1922 | int cf_object_change_map (object *op, int x, int y, maptile *map) |
1835 | |
1923 | |
… | |
… | |
1855 | RETVAL = pay_for_amount (amount, op); |
1943 | RETVAL = pay_for_amount (amount, op); |
1856 | OUTPUT: RETVAL |
1944 | OUTPUT: RETVAL |
1857 | |
1945 | |
1858 | void pay_player (object *op, uint64 amount) |
1946 | void pay_player (object *op, uint64 amount) |
1859 | |
1947 | |
1860 | val64 pay_player_arch (object *op, const char *arch, uint64 amount) |
1948 | val64 pay_player_arch (object *op, utf8_string arch, uint64 amount) |
1861 | |
1949 | |
1862 | int cast_spell (object *op, object *caster, int dir, object *spell_ob, char *stringarg = 0) |
1950 | int cast_spell (object *op, object *caster, int dir, object *spell_ob, utf8_string stringarg = 0) |
1863 | |
1951 | |
1864 | void learn_spell (object *op, object *sp, int special_prayer = 0) |
1952 | void learn_spell (object *op, object *sp, int special_prayer = 0) |
1865 | CODE: |
1953 | CODE: |
1866 | do_learn_spell (op, sp, special_prayer); |
1954 | do_learn_spell (op, sp, special_prayer); |
1867 | |
1955 | |
1868 | void forget_spell (object *op, object *sp) |
1956 | void forget_spell (object *op, object *sp) |
1869 | CODE: |
1957 | CODE: |
1870 | do_forget_spell (op, query_name (sp)); |
1958 | do_forget_spell (op, query_name (sp)); |
1871 | |
1959 | |
1872 | object *check_for_spell (object *op, char *spellname) |
1960 | object *check_for_spell (object *op, utf8_string spellname) |
1873 | CODE: |
1961 | CODE: |
1874 | RETVAL = check_spell_known (op, spellname); |
1962 | RETVAL = check_spell_known (op, spellname); |
1875 | OUTPUT: RETVAL |
1963 | OUTPUT: RETVAL |
1876 | |
1964 | |
1877 | int query_money (object *op) |
1965 | int query_money (object *op) |
… | |
… | |
1890 | |
1978 | |
1891 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1979 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1892 | |
1980 | |
1893 | void update_object (object *op, int action) |
1981 | void update_object (object *op, int action) |
1894 | |
1982 | |
1895 | object *cf_create_object_by_name (const char *name) |
1983 | object *cf_create_object_by_name (utf8_string name) |
1896 | |
1984 | |
1897 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1985 | void change_exp (object *op, uint64 exp, utf8_string skill_name = 0, int flag = 0) |
1898 | |
1986 | |
1899 | void player_lvl_adj (object *who, object *skill = 0) |
1987 | void player_lvl_adj (object *who, object *skill = 0) |
1900 | |
1988 | |
1901 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1989 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1902 | |
1990 | |
… | |
… | |
1916 | object *cf_insert_ob_in_ob (object *ob, object *where) |
2004 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1917 | |
2005 | |
1918 | # 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 |
1919 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2007 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
1920 | |
2008 | |
1921 | object *new (const char *archetype = 0) |
2009 | object *new (utf8_string archetype = 0) |
1922 | PROTOTYPE: ;$ |
2010 | PROTOTYPE: ;$ |
1923 | CODE: |
2011 | CODE: |
1924 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
2012 | RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); |
1925 | OUTPUT: |
2013 | OUTPUT: |
1926 | RETVAL |
2014 | RETVAL |
… | |
… | |
1931 | { |
2019 | { |
1932 | int unused_type; |
2020 | int unused_type; |
1933 | 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); |
1934 | } |
2022 | } |
1935 | |
2023 | |
1936 | # syntatic sugar for easier use in event callbacks. |
|
|
1937 | const char *options (object *op) |
|
|
1938 | CODE: |
|
|
1939 | RETVAL = op->name; |
|
|
1940 | OUTPUT: |
|
|
1941 | RETVAL |
|
|
1942 | |
|
|
1943 | player *contr (object *op) |
2024 | player *contr (object *op) |
1944 | CODE: |
2025 | CODE: |
1945 | RETVAL = op->contr; |
2026 | RETVAL = op->contr; |
1946 | OUTPUT: RETVAL |
2027 | OUTPUT: RETVAL |
1947 | |
2028 | |
1948 | const char *get_ob_key_value (object *op, const char *key) |
2029 | const_utf8_string get_ob_key_value (object *op, utf8_string key) |
1949 | |
2030 | |
1950 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
2031 | bool set_ob_key_value (object *op, utf8_string key, utf8_string value = 0, int add_key = 1) |
1951 | |
2032 | |
1952 | object *get_nearest_player (object *ob) |
2033 | object *get_nearest_player (object *ob) |
1953 | ALIAS: nearest_player = 0 |
2034 | ALIAS: nearest_player = 0 |
1954 | PREINIT: |
2035 | PREINIT: |
1955 | extern object *get_nearest_player (object *); |
2036 | extern object *get_nearest_player (object *); |
… | |
… | |
1971 | bool on_same_map_as (object *ob, object *other) |
2052 | bool on_same_map_as (object *ob, object *other) |
1972 | CODE: |
2053 | CODE: |
1973 | RETVAL = on_same_map (ob, other); |
2054 | RETVAL = on_same_map (ob, other); |
1974 | OUTPUT: RETVAL |
2055 | OUTPUT: RETVAL |
1975 | |
2056 | |
1976 | const char * |
2057 | const_utf8_string |
1977 | base_name (object *op, int plural = op->nrof > 1) |
2058 | base_name (object *op, int plural = op->nrof > 1) |
1978 | CODE: |
2059 | CODE: |
1979 | RETVAL = query_base_name (op, plural); |
2060 | RETVAL = query_base_name (op, plural); |
1980 | OUTPUT: RETVAL |
2061 | OUTPUT: RETVAL |
1981 | |
2062 | |
… | |
… | |
1988 | RETVAL = op->contr; |
2069 | RETVAL = op->contr; |
1989 | OUTPUT: RETVAL |
2070 | OUTPUT: RETVAL |
1990 | |
2071 | |
1991 | void check_score (object *op) |
2072 | void check_score (object *op) |
1992 | |
2073 | |
1993 | void message (object *op, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2074 | void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
1994 | CODE: |
2075 | CODE: |
1995 | new_draw_info (flags, 0, op, txt); |
2076 | new_draw_info (flags, 0, op, txt); |
1996 | |
2077 | |
1997 | object *cf_player_send_inventory (object *op) |
2078 | object *cf_player_send_inventory (object *op) |
1998 | |
2079 | |
1999 | char *cf_player_get_ip (object *op) |
2080 | octet_string cf_player_get_ip (object *op) |
2000 | ALIAS: ip = 0 |
2081 | ALIAS: ip = 0 |
2001 | |
2082 | |
2002 | object *cf_player_get_marked_item (object *op) |
2083 | object *cf_player_get_marked_item (object *op) |
2003 | ALIAS: marked_item = 0 |
2084 | ALIAS: marked_item = 0 |
2004 | |
2085 | |
… | |
… | |
2014 | void esrv_update_item (object *op, int what, object *item) |
2095 | void esrv_update_item (object *op, int what, object *item) |
2015 | C_ARGS: what, op, item |
2096 | C_ARGS: what, op, item |
2016 | |
2097 | |
2017 | void clear_los (object *op) |
2098 | void clear_los (object *op) |
2018 | |
2099 | |
2019 | int command_summon (object *op, char *params) |
2100 | int command_summon (object *op, utf8_string params) |
2020 | |
2101 | |
2021 | int command_arrest (object *op, char *params) |
2102 | int command_arrest (object *op, utf8_string params) |
2022 | |
|
|
2023 | int command_kick (object *op, char *params) |
|
|
2024 | |
|
|
2025 | int command_banish (object *op, char *params) |
|
|
2026 | |
2103 | |
2027 | |
2104 | |
2028 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2105 | MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
2029 | |
2106 | |
2030 | INCLUDE: $PERL genacc player ../include/player.h | |
2107 | INCLUDE: $PERL $srcdir/genacc player ../include/player.h | |
2031 | |
2108 | |
2032 | int invoke (player *pl, int event, ...) |
2109 | int invoke (player *pl, int event, ...) |
2033 | CODE: |
2110 | CODE: |
2034 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2111 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2035 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2112 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
… | |
… | |
2048 | pl->orig_stats = pl->ob->stats; |
2125 | pl->orig_stats = pl->ob->stats; |
2049 | |
2126 | |
2050 | void cf_player_move (player *pl, int dir) |
2127 | void cf_player_move (player *pl, int dir) |
2051 | |
2128 | |
2052 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2129 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2053 | |
|
|
2054 | player *first () |
|
|
2055 | CODE: |
|
|
2056 | RETVAL = first_player; |
|
|
2057 | OUTPUT: RETVAL |
|
|
2058 | |
2130 | |
2059 | bool |
2131 | bool |
2060 | cell_visible (player *pl, int dx, int dy) |
2132 | cell_visible (player *pl, int dx, int dy) |
2061 | CODE: |
2133 | CODE: |
2062 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
2134 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
… | |
… | |
2115 | RETVAL = map->invoke ((event_type)event, ARG_AV (av), DT_END); |
2187 | RETVAL = map->invoke ((event_type)event, ARG_AV (av), DT_END); |
2116 | OUTPUT: RETVAL |
2188 | OUTPUT: RETVAL |
2117 | |
2189 | |
2118 | SV *registry (maptile *map) |
2190 | SV *registry (maptile *map) |
2119 | |
2191 | |
2120 | INCLUDE: $PERL genacc maptile ../include/map.h | |
2192 | INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | |
2121 | |
2193 | |
2122 | void |
2194 | void |
2123 | maptile::instantiate () |
2195 | maptile::instantiate () |
2124 | |
2196 | |
2125 | maptile *new () |
2197 | maptile *new () |
… | |
… | |
2139 | EXTEND (SP, THIS->players); |
2211 | EXTEND (SP, THIS->players); |
2140 | for_all_players (pl) |
2212 | for_all_players (pl) |
2141 | if (pl->ob && pl->ob->map == THIS) |
2213 | if (pl->ob && pl->ob->map == THIS) |
2142 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2214 | PUSHs (sv_2mortal (to_sv (pl->ob))); |
2143 | } |
2215 | } |
|
|
2216 | |
|
|
2217 | void |
|
|
2218 | maptile::add_underlay (SV *data, int offset, int stride, SV *palette) |
|
|
2219 | CODE: |
|
|
2220 | { |
|
|
2221 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
|
|
2222 | croak ("maptile::add_underlay: palette must be arrayref"); |
|
|
2223 | |
|
|
2224 | palette = SvRV (palette); |
|
|
2225 | |
|
|
2226 | STRLEN idxlen; |
|
|
2227 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
|
|
2228 | |
|
|
2229 | for (int x = 0; x < THIS->width; ++x) |
|
|
2230 | for (int y = 0; y < THIS->height; ++y) |
|
|
2231 | { |
|
|
2232 | for (object *op = THIS->at (x, y).bot; op; op = op->above) |
|
|
2233 | if (op->flag [FLAG_IS_FLOOR]) |
|
|
2234 | goto skip_space; |
|
|
2235 | |
|
|
2236 | { |
|
|
2237 | int offs = offset + y * stride + x; |
|
|
2238 | if (IN_RANGE_EXC (offs, 0, idxlen)) |
|
|
2239 | { |
|
|
2240 | if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) |
|
|
2241 | { |
|
|
2242 | object *ob = get_archetype (SvPVutf8_nolen (*elem)); |
|
|
2243 | ob->flag [FLAG_NO_MAP_SAVE] = true; |
|
|
2244 | THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); |
|
|
2245 | } |
|
|
2246 | } |
|
|
2247 | } |
|
|
2248 | |
|
|
2249 | skip_space: ; |
|
|
2250 | } |
|
|
2251 | } |
|
|
2252 | |
|
|
2253 | void |
|
|
2254 | maptile::set_regiondata (SV *data, int offset, int stride, SV *palette) |
|
|
2255 | CODE: |
|
|
2256 | { |
|
|
2257 | if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV) |
|
|
2258 | croak ("maptile::set_regiondata: palette must be arrayref"); |
|
|
2259 | |
|
|
2260 | palette = SvRV (palette); |
|
|
2261 | |
|
|
2262 | STRLEN idxlen; |
|
|
2263 | const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen); |
|
|
2264 | |
|
|
2265 | region **regionmap = (region **)malloc ( |
|
|
2266 | (av_len ((AV *)palette) + 1) * sizeof (region *)); |
|
|
2267 | uint8_t *regions = salloc<uint8_t> (THIS->size ()); |
|
|
2268 | |
|
|
2269 | for (int i = av_len ((AV *)palette) + 1; i--; ) |
|
|
2270 | regionmap [i] = region::find ( |
|
|
2271 | SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); |
|
|
2272 | |
|
|
2273 | for (int y = 0; y < THIS->height; ++y) |
|
|
2274 | memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); |
|
|
2275 | |
|
|
2276 | sfree (THIS->regions, THIS->size ()); |
|
|
2277 | free (THIS->regionmap); |
|
|
2278 | |
|
|
2279 | THIS->regions = regions; |
|
|
2280 | THIS->regionmap = regionmap; |
|
|
2281 | } |
2144 | |
2282 | |
2145 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
2283 | void play_sound_map (maptile *map, int x, int y, int sound_num) |
2146 | |
2284 | |
2147 | int out_of_map (maptile *map, int x, int y) |
2285 | int out_of_map (maptile *map, int x, int y) |
2148 | |
2286 | |
… | |
… | |
2230 | |
2368 | |
2231 | void fix_walls (maptile *map, int x, int y) |
2369 | void fix_walls (maptile *map, int x, int y) |
2232 | |
2370 | |
2233 | void fix_walls_around (maptile *map, int x, int y) |
2371 | void fix_walls_around (maptile *map, int x, int y) |
2234 | |
2372 | |
2235 | const char * |
|
|
2236 | region_name (maptile *m) |
|
|
2237 | CODE: |
|
|
2238 | RETVAL = get_name_of_region_for_map (m); |
|
|
2239 | OUTPUT: RETVAL |
|
|
2240 | |
|
|
2241 | # worst xs function of my life |
2373 | # worst xs function of my life |
2242 | bool |
2374 | bool |
2243 | _create_random_map (\ |
2375 | _create_random_map (\ |
2244 | maptile *self,\ |
2376 | maptile *self,\ |
2245 | char *wallstyle,\ |
2377 | utf8_string wallstyle,\ |
2246 | char *wall_name,\ |
2378 | utf8_string wall_name,\ |
2247 | char *floorstyle,\ |
2379 | utf8_string floorstyle,\ |
2248 | char *monsterstyle,\ |
2380 | utf8_string monsterstyle,\ |
2249 | char *treasurestyle,\ |
2381 | utf8_string treasurestyle,\ |
2250 | char *layoutstyle,\ |
2382 | utf8_string layoutstyle,\ |
2251 | char *doorstyle,\ |
2383 | utf8_string doorstyle,\ |
2252 | char *decorstyle,\ |
2384 | utf8_string decorstyle,\ |
2253 | char *origin_map,\ |
2385 | utf8_string origin_map,\ |
2254 | char *final_map,\ |
2386 | utf8_string final_map,\ |
2255 | char *exitstyle,\ |
2387 | utf8_string exitstyle,\ |
2256 | char *this_map,\ |
2388 | utf8_string this_map,\ |
2257 | char *exit_on_final_map,\ |
2389 | utf8_string exit_on_final_map,\ |
2258 | int xsize,\ |
2390 | int xsize,\ |
2259 | int ysize,\ |
2391 | int ysize,\ |
2260 | int expand2x,\ |
2392 | int expand2x,\ |
2261 | int layoutoptions1,\ |
2393 | int layoutoptions1,\ |
2262 | int layoutoptions2,\ |
2394 | int layoutoptions2,\ |
… | |
… | |
2275 | val64 total_map_hp,\ |
2407 | val64 total_map_hp,\ |
2276 | int map_layout_style,\ |
2408 | int map_layout_style,\ |
2277 | int treasureoptions,\ |
2409 | int treasureoptions,\ |
2278 | int symmetry_used,\ |
2410 | int symmetry_used,\ |
2279 | region *region,\ |
2411 | region *region,\ |
2280 | char *custom\ |
2412 | utf8_string custom\ |
2281 | ) |
2413 | ) |
2282 | CODE: |
2414 | CODE: |
2283 | { |
2415 | { |
2284 | random_map_params rmp; |
2416 | random_map_params rmp; |
2285 | |
2417 | |
… | |
… | |
2326 | OUTPUT: |
2458 | OUTPUT: |
2327 | RETVAL |
2459 | RETVAL |
2328 | |
2460 | |
2329 | MODULE = cf PACKAGE = cf::arch |
2461 | MODULE = cf PACKAGE = cf::arch |
2330 | |
2462 | |
2331 | archetype *find (const char *name) |
2463 | archetype *find (utf8_string name) |
2332 | CODE: |
2464 | CODE: |
2333 | RETVAL = archetype::find (name); |
2465 | RETVAL = archetype::find (name); |
2334 | OUTPUT: |
2466 | OUTPUT: |
2335 | RETVAL |
2467 | RETVAL |
2336 | |
2468 | |
… | |
… | |
2338 | PROTOTYPE: |
2470 | PROTOTYPE: |
2339 | CODE: |
2471 | CODE: |
2340 | RETVAL = first_archetype; |
2472 | RETVAL = first_archetype; |
2341 | OUTPUT: RETVAL |
2473 | OUTPUT: RETVAL |
2342 | |
2474 | |
2343 | INCLUDE: $PERL genacc archetype ../include/object.h | |
2475 | INCLUDE: $PERL $srcdir/genacc archetype ../include/object.h | |
2344 | |
2476 | |
2345 | MODULE = cf PACKAGE = cf::party |
2477 | MODULE = cf PACKAGE = cf::party |
2346 | |
2478 | |
2347 | partylist *first () |
2479 | partylist *first () |
2348 | PROTOTYPE: |
2480 | PROTOTYPE: |
2349 | CODE: |
2481 | CODE: |
2350 | RETVAL = get_firstparty (); |
2482 | RETVAL = get_firstparty (); |
2351 | OUTPUT: RETVAL |
2483 | OUTPUT: RETVAL |
2352 | |
2484 | |
2353 | INCLUDE: $PERL genacc partylist ../include/player.h | |
2485 | INCLUDE: $PERL $srcdir/genacc partylist ../include/player.h | |
2354 | |
2486 | |
2355 | MODULE = cf PACKAGE = cf::region |
2487 | MODULE = cf PACKAGE = cf::region |
2356 | |
2488 | |
2357 | region *first () |
2489 | void |
2358 | PROTOTYPE: |
2490 | list () |
2359 | CODE: |
2491 | PPCODE: |
2360 | RETVAL = first_region; |
2492 | for_all_regions (rgn) |
2361 | OUTPUT: RETVAL |
2493 | XPUSHs (sv_2mortal (to_sv (rgn))); |
2362 | |
2494 | |
2363 | region *find (char *name) |
2495 | region *find (utf8_string name) |
2364 | PROTOTYPE: $ |
2496 | PROTOTYPE: $ |
2365 | CODE: |
2497 | CODE: |
2366 | RETVAL = get_region_by_name (name); |
2498 | RETVAL = region::find (name); |
2367 | OUTPUT: RETVAL |
2499 | OUTPUT: RETVAL |
2368 | |
2500 | |
|
|
2501 | region *find_fuzzy (utf8_string name) |
|
|
2502 | PROTOTYPE: $ |
|
|
2503 | CODE: |
|
|
2504 | RETVAL = region::find_fuzzy (name); |
|
|
2505 | OUTPUT: RETVAL |
|
|
2506 | |
|
|
2507 | int specificity (region *rgn) |
|
|
2508 | CODE: |
|
|
2509 | RETVAL = 0; |
|
|
2510 | while (rgn = rgn->parent) |
|
|
2511 | RETVAL++; |
|
|
2512 | OUTPUT: RETVAL |
|
|
2513 | |
2369 | INCLUDE: $PERL genacc region ../include/map.h | |
2514 | INCLUDE: $PERL $srcdir/genacc region ../include/map.h | |
2370 | |
2515 | |
2371 | MODULE = cf PACKAGE = cf::living |
2516 | MODULE = cf PACKAGE = cf::living |
2372 | |
2517 | |
2373 | INCLUDE: $PERL genacc living ../include/living.h | |
2518 | INCLUDE: $PERL $srcdir/genacc living ../include/living.h | |
2374 | |
2519 | |
2375 | MODULE = cf PACKAGE = cf::settings |
2520 | MODULE = cf PACKAGE = cf::settings |
2376 | |
2521 | |
2377 | INCLUDE: $PERL genacc Settings ../include/global.h | |
2522 | INCLUDE: $PERL $srcdir/genacc Settings ../include/global.h | |
2378 | |
2523 | |
2379 | MODULE = cf PACKAGE = cf::client |
2524 | MODULE = cf PACKAGE = cf::client |
2380 | |
2525 | |
2381 | INCLUDE: $PERL genacc client ../include/client.h | |
2526 | INCLUDE: $PERL $srcdir/genacc client ../include/client.h | |
2382 | |
2527 | |
2383 | int invoke (client *ns, int event, ...) |
2528 | int invoke (client *ns, int event, ...) |
2384 | CODE: |
2529 | CODE: |
2385 | if (KLASS_OF (event) != KLASS_CLIENT) croak ("event class must be CLIENT"); |
2530 | if (KLASS_OF (event) != KLASS_CLIENT) croak ("event class must be CLIENT"); |
2386 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2531 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
… | |
… | |
2405 | char *buf = SvPVbyte (packet, len); |
2550 | char *buf = SvPVbyte (packet, len); |
2406 | |
2551 | |
2407 | THIS->send_packet (buf, len); |
2552 | THIS->send_packet (buf, len); |
2408 | } |
2553 | } |
2409 | |
2554 | |
|
|
2555 | MODULE = cf PACKAGE = cf::face PREFIX = face_ |
|
|
2556 | |
|
|
2557 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h | |
|
|
2558 | |
|
|
2559 | faceidx face_find (utf8_string name, faceidx defidx = 0) |
|
|
2560 | |
|
|
2561 | faceidx alloc (utf8_string name) |
|
|
2562 | CODE: |
|
|
2563 | { |
|
|
2564 | do |
|
|
2565 | { |
|
|
2566 | RETVAL = faces.size (); |
|
|
2567 | faces.resize (RETVAL + 1); |
|
|
2568 | } |
|
|
2569 | while (!RETVAL); // crude way to leave index 0 |
|
|
2570 | |
|
|
2571 | faces [RETVAL].name = name; |
|
|
2572 | facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL)); |
|
|
2573 | |
|
|
2574 | if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL; |
|
|
2575 | if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL; |
|
|
2576 | } |
|
|
2577 | OUTPUT: RETVAL |
|
|
2578 | |
|
|
2579 | void set (faceidx idx, int visibility, int magicmap) |
|
|
2580 | CODE: |
|
|
2581 | faceinfo *f = face_info (idx); |
|
|
2582 | assert (f); |
|
|
2583 | f->visibility = visibility; |
|
|
2584 | f->magicmap = magicmap; |
|
|
2585 | |
|
|
2586 | void set_smooth (faceidx idx, faceidx smooth, int smoothlevel) |
|
|
2587 | CODE: |
|
|
2588 | faceinfo *f = face_info (idx); assert (f); |
|
|
2589 | f->smooth = smooth; |
|
|
2590 | f->smoothlevel = smoothlevel; |
|
|
2591 | |
|
|
2592 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
|
|
2593 | CODE: |
|
|
2594 | { |
|
|
2595 | facedata *d = face_data (idx, faceset); |
|
|
2596 | assert (d); |
|
|
2597 | sv_to (data, d->data); |
|
|
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 | } |
|
|
2615 | |
|
|
2616 | void invalidate (faceidx idx) |
|
|
2617 | CODE: |
|
|
2618 | for_all_clients (ns) |
|
|
2619 | { |
|
|
2620 | ns->faces_sent [idx] = false; |
|
|
2621 | ns->force_newmap = true; |
|
|
2622 | } |
|
|
2623 | |
|
|
2624 | void invalidate_all () |
|
|
2625 | CODE: |
|
|
2626 | for_all_clients (ns) |
|
|
2627 | { |
|
|
2628 | ns->faces_sent.reset (); |
|
|
2629 | ns->force_newmap = true; |
|
|
2630 | } |
|
|
2631 | |
|
|
2632 | MODULE = cf PACKAGE = cf::anim PREFIX = anim_ |
|
|
2633 | |
|
|
2634 | #INCLUDE: $PERL $srcdir/genacc faceset ../include/anim.h | |
|
|
2635 | |
|
|
2636 | animidx anim_find (utf8_string name) |
|
|
2637 | CODE: |
|
|
2638 | RETVAL = animation::find (name).number; |
|
|
2639 | OUTPUT: RETVAL |
|
|
2640 | |
|
|
2641 | animidx 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 | |
|
|
2663 | void invalidate_all () |
|
|
2664 | CODE: |
|
|
2665 | for_all_clients (ns) |
|
|
2666 | ns->anims_sent.reset (); |
|
|
2667 | |