… | |
… | |
99 | |
99 | |
100 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
101 | |
101 | |
102 | unordered_vector<attachable *> attachable::mortals; |
102 | unordered_vector<attachable *> attachable::mortals; |
103 | |
103 | |
104 | #if 0 |
|
|
105 | attachable *attachable::rc_first; |
|
|
106 | |
|
|
107 | attachable::attachable () |
|
|
108 | { |
|
|
109 | refcnt = 0; |
|
|
110 | rc_next = rc_first; |
|
|
111 | rc_first = this; |
|
|
112 | } |
|
|
113 | #endif |
|
|
114 | |
|
|
115 | attachable::~attachable () |
104 | attachable::~attachable () |
116 | { |
105 | { |
117 | assert (!(flags & F_BORROWED));//D//TODO//remove when stable |
|
|
118 | #if 0 |
|
|
119 | assert (!rc_next); |
|
|
120 | assert (!refcnt); |
106 | assert (!self); |
121 | #endif |
107 | } |
|
|
108 | |
|
|
109 | int |
|
|
110 | attachable::refcnt_cnt () const |
|
|
111 | { |
|
|
112 | return refcnt + (self ? SvREFCNT (self) : 0); |
|
|
113 | } |
|
|
114 | |
|
|
115 | void |
|
|
116 | attachable::optimise () |
|
|
117 | { |
|
|
118 | if (self |
|
|
119 | && SvREFCNT (self) == 1 |
|
|
120 | && !HvTOTALKEYS (self)) |
|
|
121 | { |
|
|
122 | refcnt_inc (); |
|
|
123 | SvREFCNT_dec ((SV *)self); |
|
|
124 | } |
122 | } |
125 | } |
123 | |
126 | |
124 | // check wether the object really is dead |
127 | // check wether the object really is dead |
125 | void |
128 | void |
126 | attachable::do_check () |
129 | attachable::do_check () |
127 | { |
130 | { |
128 | if (refcnt > 0) |
131 | if (refcnt > 0 || refcnt_cnt () > 0) |
129 | return; |
132 | return; |
130 | |
133 | |
131 | // try to unborrow the refcnt from perl |
134 | destroy (); |
132 | if (flags & F_BORROWED) |
135 | |
|
|
136 | if (self) |
133 | { |
137 | { |
134 | assert (self);//D//TODO//remove when stable |
138 | hv_clear (self); |
135 | flags &= ~F_BORROWED; |
139 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
136 | refcnt_inc (); |
|
|
137 | SvREFCNT_dec (self); |
140 | SvREFCNT_dec (self); |
|
|
141 | self = 0; |
138 | } |
142 | } |
139 | |
|
|
140 | if (refcnt > 0 || self) |
|
|
141 | return; |
|
|
142 | |
|
|
143 | destroy (); |
|
|
144 | } |
143 | } |
145 | |
144 | |
146 | void |
145 | void |
147 | attachable::do_destroy () |
146 | attachable::do_destroy () |
148 | { |
147 | { |
149 | invoke (EVENT_ATTACHABLE_DESTROY, DT_END); |
148 | invoke (EVENT_ATTACHABLE_DESTROY, DT_END); |
150 | |
149 | |
151 | //TODO: call generic destroy callback |
150 | if (self) |
|
|
151 | hv_clear (self); |
|
|
152 | |
152 | mortals.push_back (this); |
153 | mortals.push_back (this); |
153 | } |
154 | } |
154 | |
155 | |
155 | void |
156 | void |
156 | attachable::destroy () |
157 | attachable::destroy () |
… | |
… | |
160 | |
161 | |
161 | flags |= F_DESTROYED; |
162 | flags |= F_DESTROYED; |
162 | do_destroy (); |
163 | do_destroy (); |
163 | } |
164 | } |
164 | |
165 | |
|
|
166 | void |
165 | void attachable::check_mortals () |
167 | attachable::check_mortals () |
166 | { |
168 | { |
167 | for (int i = 0; i < mortals.size (); ) |
169 | for (int i = 0; i < mortals.size (); ) |
168 | { |
170 | { |
169 | attachable *obj = mortals [i]; |
171 | attachable *obj = mortals [i]; |
170 | |
172 | |
… | |
… | |
214 | |
216 | |
215 | static int |
217 | static int |
216 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
218 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
217 | { |
219 | { |
218 | attachable *at = (attachable *)mg->mg_ptr; |
220 | attachable *at = (attachable *)mg->mg_ptr; |
219 | assert (!(at->flags & attachable::F_BORROWED));//D//TODO//remove when stable |
|
|
220 | at->self = 0; |
221 | at->self = 0; |
221 | // next line makes sense, but most objects still have refcnt 0 by default |
222 | // next line makes sense, but most objects still have refcnt 0 by default |
222 | //at->refcnt_chk (); |
223 | //at->refcnt_chk (); |
223 | return 0; |
224 | return 0; |
224 | } |
225 | } |
… | |
… | |
235 | { |
236 | { |
236 | obj->self = newHV (); |
237 | obj->self = newHV (); |
237 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
238 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
238 | |
239 | |
239 | // borrow the refcnt from the object |
240 | // borrow the refcnt from the object |
240 | obj->flags |= attachable::F_BORROWED; |
241 | // it is important thta no refcnt_chk is being executed here |
241 | obj->refcnt_dec (); |
242 | obj->refcnt_dec (); |
|
|
243 | |
|
|
244 | // now bless the object _once_ |
|
|
245 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
242 | } |
246 | } |
|
|
247 | else |
|
|
248 | { |
|
|
249 | SV *sv = newRV_inc ((SV *)obj->self); |
243 | |
250 | |
244 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
251 | if (Gv_AMG (stash)) // handle overload correctly, as the perl core does not |
|
|
252 | SvAMAGIC_on (sv); |
|
|
253 | |
|
|
254 | return sv; |
|
|
255 | } |
245 | } |
256 | } |
246 | |
257 | |
247 | static void |
258 | static void |
248 | clearSVptr (SV *sv) |
259 | clearSVptr (SV *sv) |
249 | { |
260 | { |
… | |
… | |
302 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
313 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
303 | |
314 | |
304 | inline SV *to_sv (object & v) { return to_sv (&v); } |
315 | inline SV *to_sv (object & v) { return to_sv (&v); } |
305 | inline SV *to_sv (living & v) { return to_sv (&v); } |
316 | inline SV *to_sv (living & v) { return to_sv (&v); } |
306 | |
317 | |
307 | //TODO: |
|
|
308 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
318 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
309 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
319 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
310 | |
320 | |
311 | inline SV *to_sv (UUID v) |
321 | inline SV *to_sv (UUID v) |
312 | { |
322 | { |
… | |
… | |
333 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
343 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
334 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
344 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
335 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
345 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
336 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
346 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
337 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
347 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
348 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
338 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
349 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
339 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
350 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
340 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
351 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
341 | |
352 | |
342 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
353 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } |
343 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
354 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } |
344 | |
355 | |
345 | template<class T> |
356 | template<class T> |
346 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
357 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
347 | |
358 | |
348 | template<int N> |
359 | template<int N> |
… | |
… | |
483 | { |
494 | { |
484 | if (!ext->cb) |
495 | if (!ext->cb) |
485 | ext->cb = newAV (); |
496 | ext->cb = newAV (); |
486 | |
497 | |
487 | return newRV_inc ((SV *)ext->cb); |
498 | return newRV_inc ((SV *)ext->cb); |
488 | } |
|
|
489 | |
|
|
490 | #if 0 |
|
|
491 | void attachable::clear () |
|
|
492 | { |
|
|
493 | if (self) |
|
|
494 | { |
|
|
495 | // disconnect Perl from C, to avoid crashes |
|
|
496 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
|
|
497 | |
|
|
498 | // clear the perl hash, might or might not be a good idea |
|
|
499 | hv_clear ((HV *)SvRV ((SV *)self)); |
|
|
500 | |
|
|
501 | SvREFCNT_dec (self); |
|
|
502 | self = 0; |
|
|
503 | } |
|
|
504 | |
|
|
505 | if (cb) |
|
|
506 | { |
|
|
507 | SvREFCNT_dec (cb); |
|
|
508 | cb = 0; |
|
|
509 | } |
|
|
510 | |
|
|
511 | attach = 0; |
|
|
512 | } |
|
|
513 | #endif |
|
|
514 | |
|
|
515 | void attachable::optimise () |
|
|
516 | { |
|
|
517 | if (self |
|
|
518 | && SvREFCNT (self) == 1 |
|
|
519 | && !HvTOTALKEYS (self)) |
|
|
520 | { |
|
|
521 | flags &= ~F_BORROWED; |
|
|
522 | refcnt_inc (); |
|
|
523 | SvREFCNT_dec ((SV *)self); |
|
|
524 | } |
|
|
525 | } |
499 | } |
526 | |
500 | |
527 | ///////////////////////////////////////////////////////////////////////////// |
501 | ///////////////////////////////////////////////////////////////////////////// |
528 | |
502 | |
529 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
503 | extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr) |
… | |
… | |
825 | } |
799 | } |
826 | |
800 | |
827 | ///////////////////////////////////////////////////////////////////////////// |
801 | ///////////////////////////////////////////////////////////////////////////// |
828 | |
802 | |
829 | void |
803 | void |
830 | maptile::emergency_save () |
804 | cfperl_emergency_save () |
831 | { |
805 | { |
832 | CALL_BEGIN (0); |
806 | CALL_BEGIN (0); |
833 | CALL_CALL ("cf::map::emergency_save", G_VOID); |
807 | CALL_CALL ("cf::emergency_save", G_VOID); |
834 | CALL_END; |
808 | CALL_END; |
835 | } |
809 | } |
836 | |
810 | |
837 | maptile * |
811 | maptile * |
838 | maptile::find_sync (const char *path, maptile *origin) |
812 | maptile::find_sync (const char *path, maptile *origin) |
839 | { |
813 | { |
840 | CALL_BEGIN (2); |
814 | CALL_BEGIN (2); |
841 | CALL_ARG (path); |
815 | CALL_ARG (path); |
842 | CALL_ARG (origin); |
816 | CALL_ARG (origin); |
843 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
817 | CALL_CALL ("cf::map::find_sync", G_SCALAR); |
|
|
818 | |
|
|
819 | maptile *retval; |
|
|
820 | |
|
|
821 | if (count) |
|
|
822 | sv_to (POPs, retval); |
|
|
823 | else |
|
|
824 | retval = 0; |
|
|
825 | |
|
|
826 | CALL_END; |
|
|
827 | |
|
|
828 | return retval; |
|
|
829 | } |
|
|
830 | |
|
|
831 | maptile * |
|
|
832 | maptile::find_async (const char *path, maptile *origin) |
|
|
833 | { |
|
|
834 | CALL_BEGIN (2); |
|
|
835 | CALL_ARG (path); |
|
|
836 | CALL_ARG (origin); |
|
|
837 | CALL_CALL ("cf::map::find_async", G_SCALAR); |
844 | |
838 | |
845 | maptile *retval; |
839 | maptile *retval; |
846 | |
840 | |
847 | if (count) |
841 | if (count) |
848 | sv_to (POPs, retval); |
842 | sv_to (POPs, retval); |
… | |
… | |
1253 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1247 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1254 | const_iv (FLAG_IS_WATER) |
1248 | const_iv (FLAG_IS_WATER) |
1255 | const_iv (FLAG_CONTENT_ON_GEN) |
1249 | const_iv (FLAG_CONTENT_ON_GEN) |
1256 | const_iv (FLAG_IS_A_TEMPLATE) |
1250 | const_iv (FLAG_IS_A_TEMPLATE) |
1257 | const_iv (FLAG_IS_BUILDABLE) |
1251 | const_iv (FLAG_IS_BUILDABLE) |
|
|
1252 | const_iv (FLAG_DESTROY_ON_DEATH) |
|
|
1253 | const_iv (FLAG_NO_SAVE) |
1258 | |
1254 | |
1259 | const_iv (NDI_BLACK) |
1255 | const_iv (NDI_BLACK) |
1260 | const_iv (NDI_WHITE) |
1256 | const_iv (NDI_WHITE) |
1261 | const_iv (NDI_NAVY) |
1257 | const_iv (NDI_NAVY) |
1262 | const_iv (NDI_RED) |
1258 | const_iv (NDI_RED) |
… | |
… | |
1475 | const_iv (ST_SETUP) |
1471 | const_iv (ST_SETUP) |
1476 | const_iv (ST_PLAYING) |
1472 | const_iv (ST_PLAYING) |
1477 | const_iv (ST_CUSTOM) |
1473 | const_iv (ST_CUSTOM) |
1478 | |
1474 | |
1479 | const_iv (ST_CHANGE_CLASS) |
1475 | const_iv (ST_CHANGE_CLASS) |
1480 | const_iv (ST_CONFIRM_QUIT) |
|
|
1481 | const_iv (ST_GET_PARTY_PASSWORD) |
|
|
1482 | |
1476 | |
1483 | const_iv (IO_HEADER) |
1477 | const_iv (IO_HEADER) |
1484 | const_iv (IO_OBJECTS) |
1478 | const_iv (IO_OBJECTS) |
1485 | const_iv (IO_UNIQUES) |
1479 | const_iv (IO_UNIQUES) |
1486 | |
1480 | |
… | |
… | |
1540 | |
1534 | |
1541 | void _global_reattach () |
1535 | void _global_reattach () |
1542 | CODE: |
1536 | CODE: |
1543 | { |
1537 | { |
1544 | // reattach to all attachable objects in the game. |
1538 | // reattach to all attachable objects in the game. |
1545 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
1539 | for_all_clients (ns) |
1546 | (*i)->reattach (); |
1540 | ns->reattach (); |
1547 | |
1541 | |
1548 | for_all_players (pl) |
1542 | for_all_players (pl) |
1549 | pl->reattach (); |
1543 | pl->reattach (); |
1550 | |
1544 | |
1551 | //TODO |
1545 | //TODO |
1552 | //for (map_container::iterator i = maps.begin (); i != maps.end (); ++i) |
1546 | //for (map_container::iterator i = maps.begin (); i != maps.end (); ++i) |
1553 | // i->second->reattach (); |
1547 | // i->second->reattach (); |
1554 | |
1548 | |
1555 | for (object *op = object::first; op; op = op->next) |
1549 | for_all_objects (op) |
1556 | op->reattach (); |
1550 | op->reattach (); |
1557 | } |
1551 | } |
1558 | |
1552 | |
1559 | NV floor (NV x) |
1553 | NV floor (NV x) |
1560 | |
1554 | |
1561 | NV ceil (NV x) |
1555 | NV ceil (NV x) |
|
|
1556 | |
|
|
1557 | NV rndm (...) |
|
|
1558 | CODE: |
|
|
1559 | switch (items) |
|
|
1560 | { |
|
|
1561 | case 0: RETVAL = rndm (); break; |
|
|
1562 | case 1: RETVAL = rndm (SvUV (ST (0))); break; |
|
|
1563 | case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; |
|
|
1564 | default: croak ("cf::rndm requires none, one or two parameters."); break; |
|
|
1565 | } |
|
|
1566 | OUTPUT: |
|
|
1567 | RETVAL |
1562 | |
1568 | |
1563 | void server_tick () |
1569 | void server_tick () |
1564 | CODE: |
1570 | CODE: |
1565 | runtime = SvNVx (sv_runtime); |
1571 | runtime = SvNVx (sv_runtime); |
1566 | server_tick (); |
1572 | server_tick (); |
… | |
… | |
1613 | } |
1619 | } |
1614 | OUTPUT: RETVAL |
1620 | OUTPUT: RETVAL |
1615 | |
1621 | |
1616 | void abort () |
1622 | void abort () |
1617 | |
1623 | |
|
|
1624 | void fork_abort (char *cause = "cf::fork_abort") |
|
|
1625 | |
|
|
1626 | void cleanup (const char *cause, bool make_core = false) |
|
|
1627 | |
1618 | void emergency_save () |
1628 | void emergency_save () |
1619 | |
1629 | |
1620 | void _exit (int status = 0) |
1630 | void _exit (int status = 0) |
1621 | |
1631 | |
1622 | #if _POSIX_MEMLOCK |
1632 | #if _POSIX_MEMLOCK |
… | |
… | |
1680 | CODE: |
1690 | CODE: |
1681 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1691 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1682 | OUTPUT: |
1692 | OUTPUT: |
1683 | RETVAL |
1693 | RETVAL |
1684 | |
1694 | |
1685 | #bool |
1695 | INCLUDE: $PERL genacc attachable ../include/cfperl.h | |
1686 | #destroyed (attachable *at) |
|
|
1687 | # |
|
|
1688 | #void |
|
|
1689 | #destroy (attachable *at) |
|
|
1690 | |
1696 | |
1691 | MODULE = cf PACKAGE = cf::global |
1697 | MODULE = cf PACKAGE = cf::global |
1692 | |
1698 | |
1693 | int invoke (SV *klass, int event, ...) |
1699 | int invoke (SV *klass, int event, ...) |
1694 | CODE: |
1700 | CODE: |
… | |
… | |
1716 | PPCODE: |
1722 | PPCODE: |
1717 | EXTEND (SP, object::mortals.size ()); |
1723 | EXTEND (SP, object::mortals.size ()); |
1718 | for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i) |
1724 | for (AUTODECL (i, object::mortals.begin ()); i != object::mortals.end (); ++i) |
1719 | PUSHs (to_sv (*i)); |
1725 | PUSHs (to_sv (*i)); |
1720 | |
1726 | |
1721 | object *first () |
1727 | int objects_size () |
1722 | CODE: |
1728 | CODE: |
1723 | RETVAL = object::first; |
1729 | RETVAL = objects.size (); |
|
|
1730 | OUTPUT: RETVAL |
|
|
1731 | |
|
|
1732 | object *objects (U32 index) |
|
|
1733 | CODE: |
|
|
1734 | RETVAL = index < objects.size () ? objects [index] : 0; |
|
|
1735 | OUTPUT: RETVAL |
|
|
1736 | |
|
|
1737 | int actives_size () |
|
|
1738 | CODE: |
|
|
1739 | RETVAL = actives.size (); |
|
|
1740 | OUTPUT: RETVAL |
|
|
1741 | |
|
|
1742 | object *actives (U32 index) |
|
|
1743 | CODE: |
|
|
1744 | RETVAL = index < actives.size () ? actives [index] : 0; |
1724 | OUTPUT: RETVAL |
1745 | OUTPUT: RETVAL |
1725 | |
1746 | |
1726 | # missing properties |
1747 | # missing properties |
1727 | |
1748 | |
1728 | object *head (object *op) |
1749 | object *head (object *op) |
1729 | PROTOTYPE: $ |
1750 | PROTOTYPE: $ |
1730 | CODE: |
1751 | CODE: |
1731 | RETVAL = op->head ? op->head : op; |
1752 | RETVAL = op->head_ (); |
1732 | OUTPUT: RETVAL |
1753 | OUTPUT: RETVAL |
1733 | |
1754 | |
1734 | int is_head (object *op) |
1755 | int is_head (object *op) |
1735 | PROTOTYPE: $ |
1756 | PROTOTYPE: $ |
1736 | CODE: |
1757 | CODE: |
1737 | RETVAL = !op->head; |
1758 | RETVAL = op->head_ () == op; |
1738 | OUTPUT: RETVAL |
1759 | OUTPUT: RETVAL |
1739 | |
1760 | |
1740 | void |
1761 | void |
1741 | inv (object *obj) |
1762 | inv (object *obj) |
1742 | PROTOTYPE: $ |
1763 | PROTOTYPE: $ |
… | |
… | |
1833 | |
1854 | |
1834 | void drop (object *who, object *op) |
1855 | void drop (object *who, object *op) |
1835 | |
1856 | |
1836 | void pick_up (object *who, object *op) |
1857 | void pick_up (object *who, object *op) |
1837 | |
1858 | |
1838 | object *cf_object_insert_object (object *op, object *container) |
|
|
1839 | |
|
|
1840 | object *cf_object_insert_in_ob (object *ob, object *where) |
|
|
1841 | |
|
|
1842 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1859 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1843 | |
1860 | |
1844 | void update_object (object *op, int action) |
1861 | void update_object (object *op, int action) |
1845 | |
1862 | |
1846 | object *cf_create_object_by_name (const char *name) |
1863 | object *cf_create_object_by_name (const char *name) |
… | |
… | |
1965 | void esrv_update_item (object *op, int what, object *item) |
1982 | void esrv_update_item (object *op, int what, object *item) |
1966 | C_ARGS: what, op, item |
1983 | C_ARGS: what, op, item |
1967 | |
1984 | |
1968 | void clear_los (object *op) |
1985 | void clear_los (object *op) |
1969 | |
1986 | |
1970 | int command_teleport (object *op, char *params) |
|
|
1971 | |
|
|
1972 | int command_summon (object *op, char *params) |
1987 | int command_summon (object *op, char *params) |
1973 | |
1988 | |
1974 | int command_arrest (object *op, char *params) |
1989 | int command_arrest (object *op, char *params) |
1975 | |
1990 | |
1976 | int command_kick (object *op, char *params) |
1991 | int command_kick (object *op, char *params) |
… | |
… | |
1997 | CODE: |
2012 | CODE: |
1998 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
2013 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
1999 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
2014 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
2000 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
2015 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
2001 | pl->orig_stats = pl->ob->stats; |
2016 | pl->orig_stats = pl->ob->stats; |
2002 | |
|
|
2003 | player *cf_player_find (char *name) |
|
|
2004 | PROTOTYPE: $ |
|
|
2005 | |
2017 | |
2006 | void cf_player_move (player *pl, int dir) |
2018 | void cf_player_move (player *pl, int dir) |
2007 | |
2019 | |
2008 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2020 | void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); |
2009 | |
2021 | |
… | |
… | |
2055 | if (y) sv_to (y, pl->bed_y); |
2067 | if (y) sv_to (y, pl->bed_y); |
2056 | |
2068 | |
2057 | void |
2069 | void |
2058 | list () |
2070 | list () |
2059 | PPCODE: |
2071 | PPCODE: |
2060 | for (player *pl = first_player; pl; pl = pl->next) |
2072 | for_all_players (pl) |
2061 | XPUSHs (sv_2mortal (to_sv (pl))); |
2073 | XPUSHs (sv_2mortal (to_sv (pl))); |
2062 | |
|
|
2063 | bool |
|
|
2064 | peaceful (player *pl, bool new_setting = 0) |
|
|
2065 | PROTOTYPE: $;$ |
|
|
2066 | CODE: |
|
|
2067 | RETVAL = pl->peaceful; |
|
|
2068 | if (items > 1) |
|
|
2069 | pl->peaceful = new_setting; |
|
|
2070 | OUTPUT: |
|
|
2071 | RETVAL |
|
|
2072 | |
|
|
2073 | living * |
|
|
2074 | orig_stats (player *pl) |
|
|
2075 | CODE: |
|
|
2076 | RETVAL = &pl->orig_stats; |
|
|
2077 | OUTPUT: RETVAL |
|
|
2078 | |
|
|
2079 | living * |
|
|
2080 | last_stats (player *pl) |
|
|
2081 | CODE: |
|
|
2082 | RETVAL = &pl->last_stats; |
|
|
2083 | OUTPUT: RETVAL |
|
|
2084 | |
2074 | |
2085 | |
2075 | |
2086 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2076 | MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
2087 | |
2077 | |
2088 | int invoke (maptile *map, int event, ...) |
2078 | int invoke (maptile *map, int event, ...) |
… | |
… | |
2104 | PROTOTYPE: |
2094 | PROTOTYPE: |
2105 | CODE: |
2095 | CODE: |
2106 | RETVAL = new maptile; |
2096 | RETVAL = new maptile; |
2107 | OUTPUT: |
2097 | OUTPUT: |
2108 | RETVAL |
2098 | RETVAL |
2109 | |
|
|
2110 | void |
|
|
2111 | maptile::destroy () |
|
|
2112 | |
2099 | |
2113 | void |
2100 | void |
2114 | maptile::players () |
2101 | maptile::players () |
2115 | PPCODE: |
2102 | PPCODE: |
2116 | if (GIMME_V == G_SCALAR) |
2103 | if (GIMME_V == G_SCALAR) |
… | |
… | |
2146 | |
2133 | |
2147 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2134 | object* cf_map_present_arch_by_name (maptile *map, const char* str, int nx, int ny) |
2148 | C_ARGS: str, map, nx, ny |
2135 | C_ARGS: str, map, nx, ny |
2149 | |
2136 | |
2150 | void |
2137 | void |
2151 | cf_map_normalise (maptile *map, int x, int y) |
2138 | get_map_flags (maptile *map, int x, int y) |
2152 | PPCODE: |
2139 | PPCODE: |
2153 | { |
2140 | { |
2154 | maptile *nmap = 0; |
2141 | maptile *nmap = 0; |
2155 | I16 nx = 0, ny = 0; |
2142 | I16 nx = 0, ny = 0; |
2156 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
2143 | int flags = get_map_flags (map, &nmap, x, y, &nx, &ny); |
… | |
… | |
2218 | CODE: |
2205 | CODE: |
2219 | RETVAL = get_name_of_region_for_map (m); |
2206 | RETVAL = get_name_of_region_for_map (m); |
2220 | OUTPUT: RETVAL |
2207 | OUTPUT: RETVAL |
2221 | |
2208 | |
2222 | # worst xs function of my life |
2209 | # worst xs function of my life |
2223 | maptile * |
2210 | bool |
2224 | _create_random_map (\ |
2211 | _create_random_map (\ |
2225 | char *path,\ |
2212 | maptile *self,\ |
2226 | char *wallstyle,\ |
2213 | char *wallstyle,\ |
2227 | char *wall_name,\ |
2214 | char *wall_name,\ |
2228 | char *floorstyle,\ |
2215 | char *floorstyle,\ |
2229 | char *monsterstyle,\ |
2216 | char *monsterstyle,\ |
2230 | char *treasurestyle,\ |
2217 | char *treasurestyle,\ |
… | |
… | |
2255 | int random_seed,\ |
2242 | int random_seed,\ |
2256 | val64 total_map_hp,\ |
2243 | val64 total_map_hp,\ |
2257 | int map_layout_style,\ |
2244 | int map_layout_style,\ |
2258 | int treasureoptions,\ |
2245 | int treasureoptions,\ |
2259 | int symmetry_used,\ |
2246 | int symmetry_used,\ |
2260 | region *region\ |
2247 | region *region,\ |
|
|
2248 | char *custom\ |
2261 | ) |
2249 | ) |
2262 | CODE: |
2250 | CODE: |
2263 | { |
2251 | { |
2264 | random_map_params rmp; |
2252 | random_map_params rmp; |
2265 | |
2253 | |
… | |
… | |
2297 | rmp.total_map_hp = total_map_hp; |
2285 | rmp.total_map_hp = total_map_hp; |
2298 | rmp.map_layout_style = map_layout_style; |
2286 | rmp.map_layout_style = map_layout_style; |
2299 | rmp.treasureoptions = treasureoptions; |
2287 | rmp.treasureoptions = treasureoptions; |
2300 | rmp.symmetry_used = symmetry_used; |
2288 | rmp.symmetry_used = symmetry_used; |
2301 | rmp.region = region; |
2289 | rmp.region = region; |
|
|
2290 | rmp.custom = custom; |
2302 | |
2291 | |
2303 | RETVAL = generate_random_map (path, &rmp); |
2292 | RETVAL = self->generate_random_map (&rmp); |
2304 | } |
2293 | } |
2305 | OUTPUT: |
2294 | OUTPUT: |
2306 | RETVAL |
2295 | RETVAL |
2307 | |
2296 | |
2308 | MODULE = cf PACKAGE = cf::arch |
2297 | MODULE = cf PACKAGE = cf::arch |
… | |
… | |
2384 | char *buf = SvPVbyte (packet, len); |
2373 | char *buf = SvPVbyte (packet, len); |
2385 | |
2374 | |
2386 | THIS->send_packet (buf, len); |
2375 | THIS->send_packet (buf, len); |
2387 | } |
2376 | } |
2388 | |
2377 | |
2389 | void |
|
|
2390 | client::destroy () |
|
|
2391 | |
|
|