… | |
… | |
19 | * GNU General Public License for more details. |
19 | * GNU General Public License for more details. |
20 | * |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | */ |
24 | */ |
25 | |
25 | |
26 | #define PLUGIN_NAME "perl" |
26 | #define PLUGIN_NAME "perl" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
28 | |
28 | |
29 | #include <plugin_common.h> |
29 | #include <plugin_common.h> |
… | |
… | |
36 | |
36 | |
37 | #include <EXTERN.h> |
37 | #include <EXTERN.h> |
38 | #include <perl.h> |
38 | #include <perl.h> |
39 | #include <XSUB.h> |
39 | #include <XSUB.h> |
40 | |
40 | |
|
|
41 | #include "CoroAPI.h" |
41 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
42 | |
43 | |
43 | extern sint64 *levels; // the experience table |
44 | extern sint64 *levels; // the experience table |
44 | |
45 | |
45 | typedef object object_ornull; |
46 | typedef object object_ornull; |
… | |
… | |
59 | static f_plug_api object_set_property = cfapi_object_set_property; |
60 | static f_plug_api object_set_property = cfapi_object_set_property; |
60 | static f_plug_api object_insert = cfapi_object_insert; |
61 | static f_plug_api object_insert = cfapi_object_insert; |
61 | |
62 | |
62 | static PerlInterpreter *perl; |
63 | static PerlInterpreter *perl; |
63 | |
64 | |
|
|
65 | global gbl_ev; |
64 | static AV *cb_global, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
66 | static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; |
|
|
67 | |
|
|
68 | static HV |
|
|
69 | *stash_cf, |
|
|
70 | *stash_cf_object_wrap, |
|
|
71 | *stash_cf_object_player_wrap, |
|
|
72 | *stash_cf_player_wrap, |
|
|
73 | *stash_cf_map_wrap, |
|
|
74 | *stash_cf_client_wrap, |
|
|
75 | *stash_cf_arch_wrap, |
|
|
76 | *stash_cf_party_wrap, |
|
|
77 | *stash_cf_region_wrap, |
|
|
78 | *stash_cf_living_wrap; |
|
|
79 | |
|
|
80 | // helper cast function, returns super class * or 0 |
|
|
81 | template<class super> |
|
|
82 | static super * |
|
|
83 | is_a (attachable *at) |
|
|
84 | { |
|
|
85 | //return dynamic_cast<super *>(at); // slower, safer |
|
|
86 | if (typeid (*at) == typeid (super)) |
|
|
87 | return static_cast<super *>(at); |
|
|
88 | else |
|
|
89 | return 0; |
|
|
90 | } |
65 | |
91 | |
66 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
92 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
67 | |
93 | |
|
|
94 | unordered_vector<attachable *> attachable::mortals; |
|
|
95 | |
|
|
96 | #if 0 |
|
|
97 | attachable *attachable::rc_first; |
|
|
98 | |
|
|
99 | attachable::attachable () |
|
|
100 | { |
|
|
101 | refcnt = 0; |
|
|
102 | rc_next = rc_first; |
|
|
103 | rc_first = this; |
|
|
104 | } |
|
|
105 | #endif |
|
|
106 | |
|
|
107 | attachable::~attachable () |
|
|
108 | { |
|
|
109 | assert (!(flags & F_BORROWED));//D//TODO//remove when stable |
|
|
110 | #if 0 |
|
|
111 | assert (!rc_next); |
|
|
112 | assert (!refcnt); |
|
|
113 | #endif |
|
|
114 | } |
|
|
115 | |
|
|
116 | // check wether the object really is dead |
|
|
117 | void |
|
|
118 | attachable::do_check () |
|
|
119 | { |
|
|
120 | if (refcnt > 0) |
|
|
121 | return; |
|
|
122 | |
|
|
123 | // try to unborrow the refcnt from perl |
|
|
124 | if (flags & F_BORROWED) |
|
|
125 | { |
|
|
126 | assert (self);//D//TODO//remove when stable |
|
|
127 | flags &= ~F_BORROWED; |
|
|
128 | refcnt_inc (); |
|
|
129 | SvREFCNT_dec (self); |
|
|
130 | } |
|
|
131 | |
|
|
132 | if (refcnt > 0 || self) |
|
|
133 | return; |
|
|
134 | |
|
|
135 | destroy (); |
|
|
136 | } |
|
|
137 | |
|
|
138 | void |
|
|
139 | attachable::do_destroy () |
|
|
140 | { |
|
|
141 | invoke (EVENT_ATTACHABLE_DESTROY, DT_END); |
|
|
142 | |
|
|
143 | //TODO: call generic destroy callback |
|
|
144 | mortals.push_back (this); |
|
|
145 | } |
|
|
146 | |
|
|
147 | void |
|
|
148 | attachable::destroy () |
|
|
149 | { |
|
|
150 | if (destroyed ()) |
|
|
151 | return; |
|
|
152 | |
|
|
153 | flags |= F_DESTROYED; |
|
|
154 | do_destroy (); |
|
|
155 | } |
|
|
156 | |
|
|
157 | void attachable::check_mortals () |
|
|
158 | { |
|
|
159 | for (int i = 0; i < mortals.size (); ) |
|
|
160 | { |
|
|
161 | attachable *obj = mortals [i]; |
|
|
162 | |
|
|
163 | obj->refcnt_chk (); // unborrow from perl, if necessary |
|
|
164 | |
|
|
165 | if (obj->refcnt || obj->self) |
|
|
166 | { |
|
|
167 | #if 0 |
|
|
168 | if (mortals.size() > 5)fprintf (stderr, "%d delaying %d:%p:%s %d (self %p:%d)\n", time(0),i, obj, typeid (*obj).name (), |
|
|
169 | obj->refcnt, obj->self, obj->self ? SvREFCNT(obj->self): - 1);//D |
|
|
170 | #endif |
|
|
171 | |
|
|
172 | ++i; // further delay freeing |
|
|
173 | }//D |
|
|
174 | else |
|
|
175 | { |
|
|
176 | //Dfprintf (stderr, "deleteing %d:%p:%s\n", i, obj,typeid (*obj).name ());//D |
|
|
177 | delete obj; |
|
|
178 | mortals.erase (i); |
|
|
179 | } |
|
|
180 | } |
|
|
181 | } |
|
|
182 | |
|
|
183 | attachable & |
|
|
184 | attachable::operator =(const attachable &src) |
|
|
185 | { |
|
|
186 | //if (self || cb) |
|
|
187 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
|
|
188 | |
|
|
189 | attach = src.attach; |
|
|
190 | return *this; |
|
|
191 | } |
|
|
192 | |
|
|
193 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
194 | |
68 | static SV * |
195 | static SV * |
69 | newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) |
196 | newSVptr (void *ptr, HV *stash, HV *hv = newHV ()) |
70 | { |
197 | { |
71 | SV *sv; |
198 | SV *sv; |
72 | |
199 | |
73 | if (!ptr) |
200 | if (!ptr) |
74 | return &PL_sv_undef; |
201 | return &PL_sv_undef; |
75 | |
202 | |
76 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
203 | sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, 0, (char *)ptr, 0); |
77 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
204 | return sv_bless (newRV_noinc ((SV *)hv), stash); |
78 | } |
205 | } |
79 | |
206 | |
80 | template<class attachable> |
207 | static int |
|
|
208 | attachable_free (pTHX_ SV *sv, MAGIC *mg) |
|
|
209 | { |
|
|
210 | attachable *at = (attachable *)mg->mg_ptr; |
|
|
211 | assert (!(at->flags & attachable::F_BORROWED));//D//TODO//remove when stable |
|
|
212 | at->self = 0; |
|
|
213 | // next line makes sense, but most objects still have refcnt 0 by default |
|
|
214 | //at->refcnt_chk (); |
|
|
215 | return 0; |
|
|
216 | } |
|
|
217 | |
|
|
218 | static MGVTBL vtbl_attachable = {0, 0, 0, 0, attachable_free}; |
|
|
219 | |
81 | SV * |
220 | SV * |
82 | newSVattachable (attachable *obj, const char *klass) |
221 | newSVattachable (attachable *obj, HV *stash) |
83 | { |
222 | { |
84 | if (!obj) |
223 | if (!obj) |
85 | return &PL_sv_undef; |
224 | return &PL_sv_undef; |
86 | |
225 | |
87 | if (!obj->self) |
226 | if (!obj->self) |
88 | obj->self = newSVptr (obj, klass); |
227 | { |
|
|
228 | obj->self = newHV (); |
|
|
229 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &vtbl_attachable, (char *)obj, 0); |
89 | |
230 | |
90 | return newSVsv (obj->self); |
231 | // borrow the refcnt from the object |
|
|
232 | obj->flags |= attachable::F_BORROWED; |
|
|
233 | obj->refcnt_dec (); |
|
|
234 | } |
|
|
235 | |
|
|
236 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
91 | } |
237 | } |
92 | |
238 | |
93 | static void |
239 | static void |
94 | clearSVptr (SV *sv) |
240 | clearSVptr (SV *sv) |
95 | { |
241 | { |
… | |
… | |
136 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
282 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
137 | inline SV *to_sv ( signed long long v) { return newSVval64 (v); } |
283 | inline SV *to_sv ( signed long long v) { return newSVval64 (v); } |
138 | inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
284 | inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
139 | inline SV *to_sv (float v) { return newSVnv (v); } |
285 | inline SV *to_sv (float v) { return newSVnv (v); } |
140 | inline SV *to_sv (double v) { return newSVnv (v); } |
286 | inline SV *to_sv (double v) { return newSVnv (v); } |
141 | inline SV *to_sv (client * v) { return newSVattachable (v, "cf::client::wrap"); } |
287 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
142 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
288 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
143 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
289 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
144 | inline SV *to_sv (maptile * v) { return newSVattachable (v, "cf::map::wrap"); } |
290 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
145 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); } |
291 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
146 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
292 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
147 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
293 | inline SV *to_sv (region * v) { return newSVptr (v, stash_cf_region_wrap); } |
148 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
294 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
149 | |
295 | |
150 | inline SV *to_sv (object & v) { return to_sv (&v); } |
296 | inline SV *to_sv (object & v) { return to_sv (&v); } |
151 | inline SV *to_sv (living & v) { return to_sv (&v); } |
297 | inline SV *to_sv (living & v) { return to_sv (&v); } |
152 | |
298 | |
153 | //TODO: |
299 | //TODO: |
… | |
… | |
192 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
338 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
193 | |
339 | |
194 | template<int N> |
340 | template<int N> |
195 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
341 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
196 | |
342 | |
|
|
343 | inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); } |
|
|
344 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
|
|
345 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
|
|
346 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
|
|
347 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
|
|
348 | |
197 | inline void sv_to (SV *sv, UUID &v) |
349 | inline void sv_to (SV *sv, UUID &v) |
198 | { |
350 | { |
199 | unsigned int version; |
351 | unsigned int version; |
200 | |
352 | |
201 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
353 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
202 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
354 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
203 | } |
355 | } |
|
|
356 | |
|
|
357 | inline void sv_to (SV *sv, object::flags_t::reference v) { v = SvTRUE (sv); } |
204 | |
358 | |
205 | static SV * |
359 | static SV * |
206 | newSVdt_va (va_list &ap, data_type type) |
360 | newSVdt_va (va_list &ap, data_type type) |
207 | { |
361 | { |
208 | SV *sv; |
362 | SV *sv; |
… | |
… | |
315 | } |
469 | } |
316 | |
470 | |
317 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
471 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
318 | |
472 | |
319 | SV * |
473 | SV * |
320 | registry (attachable_base *ext) |
474 | registry (attachable *ext) |
321 | { |
475 | { |
322 | if (!ext->cb) |
476 | if (!ext->cb) |
323 | ext->cb = newAV (); |
477 | ext->cb = newAV (); |
324 | |
478 | |
325 | return newRV_inc ((SV *)ext->cb); |
479 | return newRV_inc ((SV *)ext->cb); |
326 | } |
480 | } |
327 | |
481 | |
|
|
482 | #if 0 |
328 | void attachable_base::clear () |
483 | void attachable::clear () |
329 | { |
484 | { |
330 | if (self) |
485 | if (self) |
331 | { |
486 | { |
332 | if (cb) |
|
|
333 | if (SvROK (*av_fetch (cb, EVENT_OBJECT_DESTROY, 1))) |
|
|
334 | INVOKE_OBJECT (DESTROY, static_cast<object *>(this)); |
|
|
335 | else if (SvROK (*av_fetch (cb, EVENT_MAP_DESTROY, 1))) |
|
|
336 | INVOKE_MAP (DESTROY, static_cast<maptile *>(this)); |
|
|
337 | |
|
|
338 | // disconnect Perl from C, to avoid crashes |
487 | // disconnect Perl from C, to avoid crashes |
339 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
488 | sv_unmagic (SvRV ((SV *)self), PERL_MAGIC_ext); |
340 | |
489 | |
341 | // clear the perl hash, might or might not be a good idea |
490 | // clear the perl hash, might or might not be a good idea |
342 | hv_clear ((HV *)SvRV ((SV *)self)); |
491 | hv_clear ((HV *)SvRV ((SV *)self)); |
… | |
… | |
351 | cb = 0; |
500 | cb = 0; |
352 | } |
501 | } |
353 | |
502 | |
354 | attach = 0; |
503 | attach = 0; |
355 | } |
504 | } |
|
|
505 | #endif |
356 | |
506 | |
357 | void attachable_base::optimise () |
507 | void attachable::optimise () |
358 | { |
508 | { |
359 | if (!self) |
509 | if (self |
360 | return; |
|
|
361 | |
|
|
362 | HV *hv = (HV *)SvRV ((SV *)self); |
|
|
363 | |
|
|
364 | if (SvREFCNT ((SV *)self) == 1 |
|
|
365 | && SvREFCNT ((SV *)hv) == 1 |
510 | && SvREFCNT (self) == 1 |
366 | && !HvKEYS (hv)) |
511 | && !HvTOTALKEYS (self)) |
367 | { |
512 | { |
|
|
513 | flags &= ~F_BORROWED; |
|
|
514 | refcnt_inc (); |
368 | SvREFCNT_dec ((SV *)self); |
515 | SvREFCNT_dec ((SV *)self); |
369 | self = 0; |
|
|
370 | } |
|
|
371 | } |
|
|
372 | |
|
|
373 | void attachable_base::instantiate (data_type type, void *obj) |
|
|
374 | { |
|
|
375 | dSP; |
|
|
376 | ENTER; |
|
|
377 | SAVETMPS; |
|
|
378 | PUSHMARK (SP); |
|
|
379 | EXTEND (SP, 2); |
|
|
380 | PUSHs (sv_2mortal (newSVdt (type, obj))); |
|
|
381 | PUSHs (sv_2mortal (newSVpv (attach, 0))); |
|
|
382 | |
|
|
383 | attach = 0; |
|
|
384 | |
|
|
385 | PUTBACK; |
|
|
386 | call_pv ("cf::instantiate", G_DISCARD | G_VOID | G_EVAL); |
|
|
387 | FREETMPS; |
|
|
388 | LEAVE; |
|
|
389 | |
|
|
390 | switch (type) |
|
|
391 | { |
|
|
392 | case DT_OBJECT: INVOKE_OBJECT (INSTANTIATE, obj); break; |
|
|
393 | case DT_MAP: INVOKE_MAP (INSTANTIATE, obj); break; |
|
|
394 | } |
516 | } |
395 | } |
517 | } |
396 | |
518 | |
397 | ///////////////////////////////////////////////////////////////////////////// |
519 | ///////////////////////////////////////////////////////////////////////////// |
398 | |
|
|
399 | void reattach (data_type type, void *obj) |
|
|
400 | { |
|
|
401 | //TODO only do this when the object has _attachment's |
|
|
402 | |
|
|
403 | dSP; |
|
|
404 | ENTER; |
|
|
405 | SAVETMPS; |
|
|
406 | PUSHMARK (SP); |
|
|
407 | XPUSHs (sv_2mortal (newSVdt (type, obj))); |
|
|
408 | PUTBACK; |
|
|
409 | call_pv ("cf::reattach", G_DISCARD | G_VOID | G_EVAL); |
|
|
410 | FREETMPS; |
|
|
411 | LEAVE; |
|
|
412 | |
|
|
413 | switch (type) |
|
|
414 | { |
|
|
415 | case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; |
|
|
416 | case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; |
|
|
417 | case DT_CLIENT: INVOKE_CLIENT (REATTACH, obj); break; |
|
|
418 | case DT_MAP: INVOKE_MAP (REATTACH, obj); break; |
|
|
419 | } |
|
|
420 | } |
|
|
421 | |
|
|
422 | template<class subclass> |
|
|
423 | void reattach (attachable<subclass> *obj) |
|
|
424 | { |
|
|
425 | obj->optimise (); |
|
|
426 | |
|
|
427 | if (obj->self) |
|
|
428 | reattach ((data_type) cftype<subclass>::dt, (subclass *)obj); |
|
|
429 | } |
|
|
430 | |
520 | |
431 | #include "kw_hash.h" |
521 | #include "kw_hash.h" |
432 | |
522 | |
433 | object_freezer::object_freezer () |
523 | object_freezer::object_freezer () |
434 | : dynbuf (128 * 1024, 64 * 1024) |
524 | : dynbuf (128 * 1024, 64 * 1024) |
… | |
… | |
439 | object_freezer::~object_freezer () |
529 | object_freezer::~object_freezer () |
440 | { |
530 | { |
441 | SvREFCNT_dec (av); |
531 | SvREFCNT_dec (av); |
442 | } |
532 | } |
443 | |
533 | |
444 | void object_freezer::put (attachable_base *ext) |
534 | void object_freezer::put (attachable *ext) |
445 | { |
535 | { |
446 | ext->optimise (); |
536 | ext->optimise (); |
447 | |
537 | |
448 | if (ext->self) |
538 | if (ext->self) |
449 | { |
539 | { |
450 | int idx = AvFILLp ((AV *)av) + 1; |
540 | int idx = AvFILLp ((AV *)av) + 1; |
451 | av_store (av, idx, SvREFCNT_inc (ext->self)); |
541 | av_store (av, idx, newRV_inc ((SV *)ext->self)); |
452 | |
542 | |
453 | add ((void *)"oid ", 4); |
543 | add ((void *)"oid ", 4); |
454 | add ((sint32)idx); |
544 | add ((sint32)idx); |
455 | add ('\n'); |
545 | add ('\n'); |
456 | } |
546 | } |
… | |
… | |
568 | text = newSVpv (data, 0); |
658 | text = newSVpv (data, 0); |
569 | sv_catpv (text, thawer_eof); |
659 | sv_catpv (text, thawer_eof); |
570 | line = SvPVbyte_nolen (text); |
660 | line = SvPVbyte_nolen (text); |
571 | } |
661 | } |
572 | |
662 | |
573 | void object_thawer::get (data_type type, void *obj, attachable_base *ext, int oid) |
663 | void object_thawer::get (attachable *obj, int oid) |
574 | { |
664 | { |
575 | if (!av || oid < 0) // this is actually an error of sorts |
665 | if (!av || oid < 0) // this is actually an error of sorts |
576 | return; |
666 | return; |
577 | |
667 | |
578 | // we have to "re-instantiate"/reattach to an object, so nuke ext->attach |
668 | // object must be virgin |
579 | ext->clear (); |
669 | assert (!obj->self); |
580 | |
670 | |
581 | SV **svp = av_fetch ((AV *)av, oid, 0); |
671 | SV **svp = av_fetch ((AV *)av, oid, 0); |
582 | |
672 | |
583 | if (!svp || !SvROK (*svp)) |
673 | if (!svp || !SvROK (*svp)) |
584 | { |
674 | { |
585 | printf ("trying to thaw duplicate or never-issued oid %d, ignoring.\n", oid); |
675 | printf ("trying to thaw duplicate or never-issued oid %d, ignoring.\n", oid); |
586 | return; |
676 | return; |
587 | } |
677 | } |
588 | |
678 | |
589 | ext->self = *svp; *svp = &PL_sv_undef; |
679 | obj->self = (HV *)SvRV (*svp); |
590 | sv_magic (SvRV (ext->self), 0, PERL_MAGIC_ext, (char *)obj, 0); |
680 | SvRV_set (*svp, &PL_sv_undef); |
591 | |
681 | |
592 | reattach (type, obj); |
682 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &vtbl_attachable, (char *)obj, 0); |
|
|
683 | obj->reattach (); |
|
|
684 | |
|
|
685 | // borrow a refcount for the perl object |
|
|
686 | obj->flags |= attachable::F_BORROWED; |
|
|
687 | obj->refcnt_dec (); |
593 | } |
688 | } |
594 | |
689 | |
595 | object_thawer::~object_thawer () |
690 | object_thawer::~object_thawer () |
596 | { |
691 | { |
597 | if (text) SvREFCNT_dec (text); |
692 | if (text) SvREFCNT_dec (text); |
… | |
… | |
835 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
930 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
836 | |
931 | |
837 | char *argv[] = { |
932 | char *argv[] = { |
838 | "", |
933 | "", |
839 | "-e" |
934 | "-e" |
840 | "use Event;" // required for bootstrap |
935 | "use Event; use Coro;" // required for bootstrap |
841 | "cf->bootstrap;" // required for datadir :*> |
936 | "cf->bootstrap;" // required for datadir :*> |
842 | "unshift @INC, cf::datadir ();" |
937 | "unshift @INC, cf::datadir ();" |
843 | "require cf;" |
938 | "require cf;" |
844 | }; |
939 | }; |
845 | |
940 | |
846 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
941 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
… | |
… | |
855 | dSP; |
950 | dSP; |
856 | |
951 | |
857 | PUSHMARK (SP); |
952 | PUSHMARK (SP); |
858 | PUTBACK; |
953 | PUTBACK; |
859 | call_pv ("cf::main", G_DISCARD | G_VOID); |
954 | call_pv ("cf::main", G_DISCARD | G_VOID); |
|
|
955 | } |
|
|
956 | |
|
|
957 | void |
|
|
958 | attachable::instantiate () |
|
|
959 | { |
|
|
960 | if (attach) |
|
|
961 | { |
|
|
962 | invoke (EVENT_ATTACHABLE_INSTANTIATE, ARG_STRING (attach), DT_END); |
|
|
963 | attach = 0; |
|
|
964 | } |
|
|
965 | } |
|
|
966 | |
|
|
967 | void |
|
|
968 | attachable::reattach () |
|
|
969 | { |
|
|
970 | optimise (); |
|
|
971 | //TODO: check for _attachment's, very important for restarts |
|
|
972 | invoke (EVENT_ATTACHABLE_REATTACH, DT_END); |
860 | } |
973 | } |
861 | |
974 | |
862 | static event_klass klass_of[NUM_EVENT_TYPES] = { |
975 | static event_klass klass_of[NUM_EVENT_TYPES] = { |
863 | # define def(type,name) KLASS_ ## type, |
976 | # define def(type,name) KLASS_ ## type, |
864 | # include "eventinc.h" |
977 | # include "eventinc.h" |
… | |
… | |
895 | } |
1008 | } |
896 | } |
1009 | } |
897 | } |
1010 | } |
898 | } |
1011 | } |
899 | |
1012 | |
|
|
1013 | void |
|
|
1014 | attachable::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1015 | { |
|
|
1016 | ::gather_callbacks (callbacks, cb_attachable, event); |
|
|
1017 | |
|
|
1018 | if (cb) |
|
|
1019 | ::gather_callbacks (callbacks, cb, event); |
|
|
1020 | } |
|
|
1021 | |
|
|
1022 | void |
|
|
1023 | global::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1024 | { |
|
|
1025 | ::gather_callbacks (callbacks, cb_object, event); |
|
|
1026 | } |
|
|
1027 | |
|
|
1028 | void |
|
|
1029 | object::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1030 | { |
|
|
1031 | if (subtype && type + subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) |
|
|
1032 | { |
|
|
1033 | SV *registry = AvARRAY (cb_type)[type + subtype * NUM_SUBTYPES]; |
|
|
1034 | |
|
|
1035 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
1036 | ::gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
1037 | } |
|
|
1038 | |
|
|
1039 | if (type <= AvFILLp (cb_type)) |
|
|
1040 | { |
|
|
1041 | SV *registry = AvARRAY (cb_type)[type]; |
|
|
1042 | |
|
|
1043 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
1044 | ::gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
1045 | } |
|
|
1046 | |
|
|
1047 | attachable::gather_callbacks (callbacks, event); |
|
|
1048 | ::gather_callbacks (callbacks, cb_object, event); |
|
|
1049 | } |
|
|
1050 | |
|
|
1051 | void |
|
|
1052 | archetype::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1053 | { |
|
|
1054 | attachable::gather_callbacks (callbacks, event); |
|
|
1055 | //TODO//::gather_callbacks (callbacks, cb_archetype, event); |
|
|
1056 | } |
|
|
1057 | |
|
|
1058 | void |
|
|
1059 | client::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1060 | { |
|
|
1061 | attachable::gather_callbacks (callbacks, event); |
|
|
1062 | ::gather_callbacks (callbacks, cb_client, event); |
|
|
1063 | } |
|
|
1064 | |
|
|
1065 | void |
|
|
1066 | player::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1067 | { |
|
|
1068 | attachable::gather_callbacks (callbacks, event); |
|
|
1069 | ::gather_callbacks (callbacks, cb_player, event); |
|
|
1070 | } |
|
|
1071 | |
|
|
1072 | void |
|
|
1073 | maptile::gather_callbacks (AV *&callbacks, event_type event) const |
|
|
1074 | { |
|
|
1075 | attachable::gather_callbacks (callbacks, event); |
|
|
1076 | ::gather_callbacks (callbacks, cb_map, event); |
|
|
1077 | } |
|
|
1078 | |
|
|
1079 | bool |
900 | bool cfperl_invoke (event_type event, ...) |
1080 | attachable::invoke (event_type event, ...) |
901 | { |
1081 | { |
902 | data_type dt; |
1082 | data_type dt; |
903 | va_list ap; |
1083 | va_list ap; |
904 | |
1084 | |
905 | va_start (ap, event); |
1085 | va_start (ap, event); |
906 | |
1086 | |
907 | AV *callbacks = 0; |
|
|
908 | |
|
|
909 | object *op; |
|
|
910 | player *pl; |
|
|
911 | maptile *map; |
|
|
912 | client *ns; |
|
|
913 | |
|
|
914 | // callback call ordering is: |
1087 | // callback call ordering should be: |
915 | // 1. per-object callback |
1088 | // 1. per-object callback |
916 | // 2. per-class object |
1089 | // 2. per-class object |
917 | // 3. per-type callback |
1090 | // 3. per-type callback |
918 | // 4. global callbacks |
1091 | // 4. global callbacks |
919 | |
1092 | |
|
|
1093 | AV *callbacks = 0; |
920 | gather_callbacks (callbacks, cb_global, event); |
1094 | gather_callbacks (callbacks, event); |
921 | |
|
|
922 | switch (KLASS_OF (event)) |
|
|
923 | { |
|
|
924 | case KLASS_GLOBAL: |
|
|
925 | break; |
|
|
926 | |
|
|
927 | case KLASS_OBJECT: |
|
|
928 | dt = (data_type) va_arg (ap, int); |
|
|
929 | assert (("first argument must be of type object", dt == DT_OBJECT)); |
|
|
930 | op = va_arg (ap, object *); |
|
|
931 | |
|
|
932 | if (op->cb) |
|
|
933 | gather_callbacks (callbacks, op->cb, event); |
|
|
934 | |
|
|
935 | if (op->type) |
|
|
936 | { |
|
|
937 | if (op->subtype && op->type + op->subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) |
|
|
938 | { |
|
|
939 | SV *registry = AvARRAY (cb_type)[op->type + op->subtype * NUM_SUBTYPES]; |
|
|
940 | |
|
|
941 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
942 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
943 | } |
|
|
944 | |
|
|
945 | if (op->type <= AvFILLp (cb_type)) |
|
|
946 | { |
|
|
947 | SV *registry = AvARRAY (cb_type)[op->type]; |
|
|
948 | |
|
|
949 | if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) |
|
|
950 | gather_callbacks (callbacks, (AV *)SvRV (registry), event); |
|
|
951 | } |
|
|
952 | } |
|
|
953 | |
|
|
954 | gather_callbacks (callbacks, cb_object, event); |
|
|
955 | |
|
|
956 | break; |
|
|
957 | |
|
|
958 | case KLASS_PLAYER: |
|
|
959 | dt = (data_type) va_arg (ap, int); |
|
|
960 | assert (("first argument must be of type player", dt == DT_PLAYER)); |
|
|
961 | pl = va_arg (ap, player *); |
|
|
962 | |
|
|
963 | if (pl->cb) |
|
|
964 | gather_callbacks (callbacks, pl->cb, event); |
|
|
965 | |
|
|
966 | gather_callbacks (callbacks, cb_player, event); |
|
|
967 | break; |
|
|
968 | |
|
|
969 | case KLASS_MAP: |
|
|
970 | dt = (data_type) va_arg (ap, int); |
|
|
971 | assert (("first argument must be of type object", dt == DT_MAP)); |
|
|
972 | map = va_arg (ap, maptile *); |
|
|
973 | |
|
|
974 | if (map->cb) |
|
|
975 | gather_callbacks (callbacks, map->cb, event); |
|
|
976 | |
|
|
977 | gather_callbacks (callbacks, cb_map, event); |
|
|
978 | break; |
|
|
979 | |
|
|
980 | case KLASS_CLIENT: |
|
|
981 | dt = (data_type) va_arg (ap, int); |
|
|
982 | assert (("first argument must be of type client", dt == DT_CLIENT)); |
|
|
983 | ns = va_arg (ap, client *); |
|
|
984 | |
|
|
985 | if (ns->cb) |
|
|
986 | gather_callbacks (callbacks, ns->cb, event); |
|
|
987 | |
|
|
988 | gather_callbacks (callbacks, cb_client, event); |
|
|
989 | break; |
|
|
990 | |
|
|
991 | default: |
|
|
992 | assert (("unsupported event klass in cfperl_invoke", 0)); |
|
|
993 | } |
|
|
994 | |
1095 | |
995 | // short-circuit processing if no callbacks found/defined |
1096 | // short-circuit processing if no callbacks found/defined |
996 | if (!callbacks) |
1097 | if (!callbacks) |
997 | return 0; |
1098 | return 0; |
998 | |
1099 | |
… | |
… | |
1004 | EXTEND (SP, 3); |
1105 | EXTEND (SP, 3); |
1005 | |
1106 | |
1006 | PUSHs (sv_2mortal (newSViv (event))); // only used for debugging nowadays |
1107 | PUSHs (sv_2mortal (newSViv (event))); // only used for debugging nowadays |
1007 | PUSHs (sv_2mortal (newRV_noinc ((SV *)callbacks))); |
1108 | PUSHs (sv_2mortal (newRV_noinc ((SV *)callbacks))); |
1008 | |
1109 | |
1009 | switch (KLASS_OF (event)) |
1110 | //TODO: unhack |
1010 | { |
1111 | if (object *op = is_a<object>(this)) PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); |
1011 | case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; |
1112 | else if (player *pl = is_a<player>(this)) PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); |
1012 | case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; |
1113 | else if (client *ns = is_a<client>(this)) PUSHs (sv_2mortal (newSVdt (DT_CLIENT, ns))); |
1013 | case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, pl))); break; |
1114 | else if (maptile *m = is_a<maptile>(this)) PUSHs (sv_2mortal (newSVdt (DT_MAP, m))); |
1014 | case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; |
1115 | else if (global *gl = is_a<global>(this)) /*nop*/; |
1015 | } |
1116 | else |
|
|
1117 | abort (); //TODO |
1016 | |
1118 | |
1017 | for (;;) |
1119 | for (;;) |
1018 | { |
1120 | { |
1019 | dt = (data_type) va_arg (ap, int); |
1121 | dt = (data_type) va_arg (ap, int); |
1020 | |
1122 | |
1021 | if (dt == DT_END) |
1123 | if (dt == DT_END) |
1022 | break; |
1124 | break; |
1023 | |
|
|
1024 | if (dt == DT_AV) |
1125 | else if (dt == DT_AV) |
1025 | { |
1126 | { |
1026 | AV *av = va_arg (ap, AV *); |
1127 | AV *av = va_arg (ap, AV *); |
1027 | |
1128 | |
1028 | for (int i = 0; i <= av_len (av); ++i) |
1129 | for (int i = 0; i <= av_len (av); ++i) |
1029 | XPUSHs (*av_fetch (av, i, 1)); |
1130 | XPUSHs (*av_fetch (av, i, 1)); |
… | |
… | |
1130 | pe->poll = events; |
1231 | pe->poll = events; |
1131 | if (pe->poll) start (); |
1232 | if (pe->poll) start (); |
1132 | } |
1233 | } |
1133 | } |
1234 | } |
1134 | |
1235 | |
|
|
1236 | void |
|
|
1237 | _connect_to_perl () |
|
|
1238 | { |
|
|
1239 | stash_cf = gv_stashpv ("cf" , 1); |
|
|
1240 | |
|
|
1241 | stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); |
|
|
1242 | stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); |
|
|
1243 | stash_cf_player_wrap = gv_stashpv ("cf::player::wrap", 1); |
|
|
1244 | stash_cf_map_wrap = gv_stashpv ("cf::map::wrap" , 1); |
|
|
1245 | stash_cf_client_wrap = gv_stashpv ("cf::client::wrap", 1); |
|
|
1246 | stash_cf_arch_wrap = gv_stashpv ("cf::arch::wrap" , 1); |
|
|
1247 | stash_cf_party_wrap = gv_stashpv ("cf::party::wrap" , 1); |
|
|
1248 | stash_cf_region_wrap = gv_stashpv ("cf::region::wrap", 1); |
|
|
1249 | stash_cf_living_wrap = gv_stashpv ("cf::living::wrap", 1); |
|
|
1250 | |
|
|
1251 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
|
|
1252 | cb_attachable = get_av ("cf::CB_ATTACHABLE", 1); |
|
|
1253 | cb_object = get_av ("cf::CB_OBJECT", 1); |
|
|
1254 | cb_player = get_av ("cf::CB_PLAYER", 1); |
|
|
1255 | cb_client = get_av ("cf::CB_CLIENT", 1); |
|
|
1256 | cb_type = get_av ("cf::CB_TYPE" , 1); |
|
|
1257 | cb_map = get_av ("cf::CB_MAP" , 1); |
|
|
1258 | } |
|
|
1259 | |
1135 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1260 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1136 | |
1261 | |
1137 | BOOT: |
1262 | BOOT: |
1138 | { |
1263 | { |
1139 | HV *stash = gv_stashpv ("cf", 1); |
1264 | _connect_to_perl (); |
1140 | |
1265 | |
1141 | I_EVENT_API (PACKAGE); |
1266 | I_EVENT_API (PACKAGE); |
1142 | watcher_base::GEventAPI = GEventAPI; |
1267 | watcher_base::GEventAPI = GEventAPI; |
|
|
1268 | I_CORO_API (PACKAGE); |
1143 | |
1269 | |
1144 | newCONSTSUB (stash, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1270 | newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); |
1145 | |
1271 | |
1146 | static const struct { |
1272 | static const struct { |
1147 | const char *name; |
1273 | const char *name; |
1148 | IV iv; |
1274 | IV iv; |
1149 | } *civ, const_iv[] = { |
1275 | } *civ, const_iv[] = { |
… | |
… | |
1410 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1536 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1411 | const_iv (FLAG_IS_WATER) |
1537 | const_iv (FLAG_IS_WATER) |
1412 | const_iv (FLAG_CONTENT_ON_GEN) |
1538 | const_iv (FLAG_CONTENT_ON_GEN) |
1413 | const_iv (FLAG_IS_A_TEMPLATE) |
1539 | const_iv (FLAG_IS_A_TEMPLATE) |
1414 | const_iv (FLAG_IS_BUILDABLE) |
1540 | const_iv (FLAG_IS_BUILDABLE) |
1415 | const_iv (FLAG_AFK) |
|
|
1416 | |
1541 | |
1417 | const_iv (NDI_BLACK) |
1542 | const_iv (NDI_BLACK) |
1418 | const_iv (NDI_WHITE) |
1543 | const_iv (NDI_WHITE) |
1419 | const_iv (NDI_NAVY) |
1544 | const_iv (NDI_NAVY) |
1420 | const_iv (NDI_RED) |
1545 | const_iv (NDI_RED) |
… | |
… | |
1616 | const_iv (MAP_IN_MEMORY) |
1741 | const_iv (MAP_IN_MEMORY) |
1617 | const_iv (MAP_SWAPPED) |
1742 | const_iv (MAP_SWAPPED) |
1618 | const_iv (MAP_LOADING) |
1743 | const_iv (MAP_LOADING) |
1619 | const_iv (MAP_SAVING) |
1744 | const_iv (MAP_SAVING) |
1620 | |
1745 | |
|
|
1746 | const_iv (KLASS_ATTACHABLE) |
1621 | const_iv (KLASS_GLOBAL) |
1747 | const_iv (KLASS_GLOBAL) |
1622 | const_iv (KLASS_OBJECT) |
1748 | const_iv (KLASS_OBJECT) |
1623 | const_iv (KLASS_CLIENT) |
1749 | const_iv (KLASS_CLIENT) |
1624 | const_iv (KLASS_PLAYER) |
1750 | const_iv (KLASS_PLAYER) |
1625 | const_iv (KLASS_MAP) |
1751 | const_iv (KLASS_MAP) |
|
|
1752 | |
|
|
1753 | const_iv (CS_QUERY_YESNO) |
|
|
1754 | const_iv (CS_QUERY_SINGLECHAR) |
|
|
1755 | const_iv (CS_QUERY_HIDEINPUT) |
|
|
1756 | |
|
|
1757 | const_iv (ST_DEAD) |
|
|
1758 | const_iv (ST_SETUP) |
|
|
1759 | const_iv (ST_PLAYING) |
|
|
1760 | const_iv (ST_CUSTOM) |
|
|
1761 | |
|
|
1762 | const_iv (ST_CHANGE_CLASS) |
|
|
1763 | const_iv (ST_CONFIRM_QUIT) |
|
|
1764 | const_iv (ST_GET_PARTY_PASSWORD) |
1626 | }; |
1765 | }; |
1627 | |
1766 | |
1628 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1767 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1629 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1768 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1630 | |
1769 | |
1631 | static const struct { |
1770 | static const struct { |
1632 | const char *name; |
1771 | const char *name; |
1633 | int skip; |
1772 | int skip; |
1634 | IV klass; |
1773 | IV klass; |
… | |
… | |
1645 | { |
1784 | { |
1646 | AV *event = newAV (); |
1785 | AV *event = newAV (); |
1647 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1786 | av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); |
1648 | av_push (event, newSViv (eiv->klass)); |
1787 | av_push (event, newSViv (eiv->klass)); |
1649 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1788 | av_store (av, eiv->iv, newRV_noinc ((SV *)event)); |
1650 | newCONSTSUB (stash, (char *)eiv->name, newSViv (eiv->iv)); |
1789 | newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); |
1651 | } |
1790 | } |
1652 | } |
1791 | } |
1653 | |
1792 | |
1654 | void _init_vars () |
1793 | void _connect_to_perl () |
1655 | CODE: |
|
|
1656 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
|
|
1657 | cb_object = get_av ("cf::CB_OBJECT", 1); |
|
|
1658 | cb_player = get_av ("cf::CB_PLAYER", 1); |
|
|
1659 | cb_client = get_av ("cf::CB_CLIENT", 1); |
|
|
1660 | cb_type = get_av ("cf::CB_TYPE" , 1); |
|
|
1661 | cb_map = get_av ("cf::CB_MAP" , 1); |
|
|
1662 | |
1794 | |
1663 | void _global_reattach () |
1795 | void _global_reattach () |
1664 | CODE: |
1796 | CODE: |
1665 | { |
1797 | { |
1666 | // reattach to all attachable objects in the game. |
1798 | // reattach to all attachable objects in the game. |
1667 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
1799 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
1668 | reattach (*i); |
1800 | (*i)->reattach (); |
1669 | |
1801 | |
1670 | for (player *pl = first_player; pl; pl = pl->next) |
1802 | for (player *pl = first_player; pl; pl = pl->next) |
1671 | reattach (pl); |
1803 | pl->reattach (); |
1672 | |
1804 | |
1673 | for (maptile *map = first_map; map; map = map->next) |
1805 | for (maptile *m = first_map; m; m = m->next) |
1674 | reattach (map); |
1806 | m->reattach (); |
1675 | |
1807 | |
1676 | for (object *op = object::first; op; op = op->next) |
1808 | for (object *op = object::first; op; op = op->next) |
1677 | reattach (op); |
1809 | op->reattach (); |
1678 | } |
1810 | } |
1679 | |
1811 | |
1680 | NV floor (NV x) |
1812 | NV floor (NV x) |
1681 | |
1813 | |
1682 | NV ceil (NV x) |
1814 | NV ceil (NV x) |
… | |
… | |
1738 | |
1870 | |
1739 | int random_roll (int min, int max, object *op, int goodbad); |
1871 | int random_roll (int min, int max, object *op, int goodbad); |
1740 | |
1872 | |
1741 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1873 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
1742 | |
1874 | |
1743 | int invoke (int event, ...) |
|
|
1744 | CODE: |
|
|
1745 | if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL"); |
|
|
1746 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1747 | for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
1748 | RETVAL = INVOKE_((event_type)event, ARG_AV (av)); |
|
|
1749 | OUTPUT: RETVAL |
|
|
1750 | |
|
|
1751 | int |
1875 | int |
1752 | exp_to_level (val64 exp) |
1876 | exp_to_level (val64 exp) |
1753 | CODE: |
1877 | CODE: |
1754 | { |
1878 | { |
1755 | int i = 0; |
1879 | int i = 0; |
… | |
… | |
1794 | CODE: |
1918 | CODE: |
1795 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1919 | RETVAL = SvROK (obj) && mg_find (SvRV (obj), PERL_MAGIC_ext); |
1796 | OUTPUT: |
1920 | OUTPUT: |
1797 | RETVAL |
1921 | RETVAL |
1798 | |
1922 | |
|
|
1923 | MODULE = cf PACKAGE = cf::global |
|
|
1924 | |
|
|
1925 | int invoke (SV *klass, int event, ...) |
|
|
1926 | CODE: |
|
|
1927 | if (KLASS_OF (event) != KLASS_GLOBAL) croak ("event class must be GLOBAL"); |
|
|
1928 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
|
|
1929 | for (int i = 1; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
|
|
1930 | RETVAL = gbl_ev.invoke ((event_type)event, ARG_AV (av), DT_END); |
|
|
1931 | OUTPUT: RETVAL |
|
|
1932 | |
1799 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1933 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1800 | |
1934 | |
1801 | INCLUDE: $PERL genacc object ../include/object.h | |
1935 | INCLUDE: $PERL genacc object ../include/object.h | |
1802 | |
1936 | |
1803 | int invoke (object *op, int event, ...) |
1937 | int invoke (object *op, int event, ...) |
1804 | CODE: |
1938 | CODE: |
1805 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1939 | if (KLASS_OF (event) != KLASS_OBJECT) croak ("event class must be OBJECT"); |
1806 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1940 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
1807 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1941 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
1808 | RETVAL = INVOKE_((event_type)event, ARG_OBJECT (op), ARG_AV (av)); |
1942 | RETVAL = op->invoke ((event_type)event, ARG_AV (av), DT_END); |
1809 | OUTPUT: RETVAL |
1943 | OUTPUT: RETVAL |
1810 | |
1944 | |
1811 | SV *registry (object *op) |
1945 | SV *registry (object *op) |
1812 | |
1946 | |
1813 | void mortals () |
1947 | void mortals () |
… | |
… | |
1821 | RETVAL = object::first; |
1955 | RETVAL = object::first; |
1822 | OUTPUT: RETVAL |
1956 | OUTPUT: RETVAL |
1823 | |
1957 | |
1824 | # missing properties |
1958 | # missing properties |
1825 | |
1959 | |
1826 | int flag (object *op, int flag, int value = 1) |
|
|
1827 | PROTOTYPE: $$;$ |
|
|
1828 | CODE: |
|
|
1829 | RETVAL = QUERY_FLAG (op, flag); |
|
|
1830 | if (items >= 3) |
|
|
1831 | if (value) |
|
|
1832 | SET_FLAG (op, flag); |
|
|
1833 | else |
|
|
1834 | CLEAR_FLAG (op, flag); |
|
|
1835 | OUTPUT: RETVAL |
|
|
1836 | |
|
|
1837 | object *head (object *op) |
1960 | object *head (object *op) |
1838 | PROTOTYPE: $ |
1961 | PROTOTYPE: $ |
1839 | CODE: |
1962 | CODE: |
1840 | RETVAL = op->head ? op->head : op; |
1963 | RETVAL = op->head ? op->head : op; |
1841 | OUTPUT: RETVAL |
1964 | OUTPUT: RETVAL |
… | |
… | |
1851 | PROTOTYPE: $ |
1974 | PROTOTYPE: $ |
1852 | PPCODE: |
1975 | PPCODE: |
1853 | { |
1976 | { |
1854 | object *o; |
1977 | object *o; |
1855 | for (o = obj->inv; o; o = o->below) |
1978 | for (o = obj->inv; o; o = o->below) |
1856 | XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1979 | XPUSHs (sv_2mortal (to_sv (o))); |
1857 | } |
1980 | } |
|
|
1981 | |
|
|
1982 | void |
|
|
1983 | set_animation (object *op, int idx) |
|
|
1984 | CODE: |
|
|
1985 | SET_ANIMATION (op, idx); |
|
|
1986 | |
|
|
1987 | void |
|
|
1988 | object::drain_stat () |
|
|
1989 | |
|
|
1990 | void |
|
|
1991 | object::drain_specific_stat (int stat) |
|
|
1992 | |
|
|
1993 | void |
|
|
1994 | object::change_luck (int change) |
|
|
1995 | |
|
|
1996 | void |
|
|
1997 | object::add_statbonus () |
|
|
1998 | |
|
|
1999 | void |
|
|
2000 | object::remove_statbonus () |
1858 | |
2001 | |
1859 | object *find_best_object_match (object *op, const char *match) |
2002 | object *find_best_object_match (object *op, const char *match) |
1860 | |
2003 | |
1861 | object *find_marked_object (object *op) |
2004 | object *find_marked_object (object *op) |
1862 | |
2005 | |
1863 | int resistance (object *op, int rtype, int newval = 0) |
|
|
1864 | CODE: |
|
|
1865 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1866 | croak ("resistance out of bounds"); |
|
|
1867 | RETVAL = op->resist [rtype]; |
|
|
1868 | if (items >= 3) |
|
|
1869 | op->resist [rtype] = newval; |
|
|
1870 | OUTPUT: RETVAL |
|
|
1871 | |
|
|
1872 | void set_resistance (object *op, int rtype, int val) |
|
|
1873 | CODE: |
|
|
1874 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1875 | op->resist[rtype] = val; |
|
|
1876 | |
|
|
1877 | int need_identify (const object *obj); |
2006 | int need_identify (object *obj); |
1878 | |
2007 | |
1879 | int apply_shop_mat (object *shop_mat, object *op); |
2008 | int apply_shop_mat (object *shop_mat, object *op); |
1880 | |
2009 | |
1881 | int move (object *op, int dir, object *originator = op) |
2010 | int move (object *op, int dir, object *originator = op) |
1882 | CODE: |
2011 | CODE: |
… | |
… | |
1895 | void remove (object *op) |
2024 | void remove (object *op) |
1896 | CODE: |
2025 | CODE: |
1897 | op->remove (); |
2026 | op->remove (); |
1898 | |
2027 | |
1899 | void |
2028 | void |
1900 | object::destroy (int recursive = 0) |
2029 | object::destroy (bool destroy_inventory = false) |
|
|
2030 | |
|
|
2031 | void |
|
|
2032 | object::destroy_inv (bool drop_to_ground = false) |
1901 | |
2033 | |
1902 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
2034 | object *cf_object_present_archname_inside (object *op, char *whatstr) |
1903 | |
2035 | |
1904 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
2036 | int cf_object_transfer (object *op, int x, int y, int r = 0, object_ornull *orig = 0) |
1905 | |
2037 | |
… | |
… | |
1946 | OUTPUT: RETVAL |
2078 | OUTPUT: RETVAL |
1947 | |
2079 | |
1948 | int query_money (object *op) |
2080 | int query_money (object *op) |
1949 | ALIAS: money = 0 |
2081 | ALIAS: money = 0 |
1950 | |
2082 | |
1951 | int query_cost (object *op, object *who, int flags) |
2083 | val64 query_cost (object *op, object *who, int flags) |
1952 | ALIAS: cost = 0 |
2084 | ALIAS: cost = 0 |
1953 | |
2085 | |
1954 | void spring_trap (object *op, object *victim) |
2086 | void spring_trap (object *op, object *victim) |
1955 | |
2087 | |
1956 | int check_trigger (object *op, object *cause) |
2088 | int check_trigger (object *op, object *cause) |
… | |
… | |
1963 | |
2095 | |
1964 | object *cf_object_insert_in_ob (object *ob, object *where) |
2096 | object *cf_object_insert_in_ob (object *ob, object *where) |
1965 | |
2097 | |
1966 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
2098 | int cf_object_teleport (object *op, maptile *map, int x, int y) |
1967 | |
2099 | |
1968 | void update (object *op, int action) |
2100 | void update_object (object *op, int action) |
1969 | CODE: |
|
|
1970 | update_object (op, action); |
|
|
1971 | |
2101 | |
1972 | object *cf_create_object_by_name (const char *name) |
2102 | object *cf_create_object_by_name (const char *name) |
1973 | |
2103 | |
1974 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
2104 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1975 | |
2105 | |
… | |
… | |
1987 | |
2117 | |
1988 | void remove_button_link (object *op); |
2118 | void remove_button_link (object *op); |
1989 | |
2119 | |
1990 | |
2120 | |
1991 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
2121 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1992 | |
|
|
1993 | void cf_fix_object (object *pl) |
|
|
1994 | ALIAS: fix = 0 |
|
|
1995 | |
2122 | |
1996 | object *cf_insert_ob_in_ob (object *ob, object *where) |
2123 | object *cf_insert_ob_in_ob (object *ob, object *where) |
1997 | |
2124 | |
1998 | # no clean way to get an object from an archetype - stupid idiotic |
2125 | # no clean way to get an object from an archetype - stupid idiotic |
1999 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
2126 | # dumb kludgy misdesigned plug-in api slowly gets on my nerves. |
… | |
… | |
2022 | |
2149 | |
2023 | player *contr (object *op) |
2150 | player *contr (object *op) |
2024 | CODE: |
2151 | CODE: |
2025 | RETVAL = op->contr; |
2152 | RETVAL = op->contr; |
2026 | OUTPUT: RETVAL |
2153 | OUTPUT: RETVAL |
|
|
2154 | |
|
|
2155 | void |
|
|
2156 | object::roll_stats () |
|
|
2157 | |
|
|
2158 | void |
|
|
2159 | object::update_stats () |
|
|
2160 | |
|
|
2161 | void |
|
|
2162 | object::swap_stats (int a, int b) |
2027 | |
2163 | |
2028 | const char *get_ob_key_value (object *op, const char *key) |
2164 | const char *get_ob_key_value (object *op, const char *key) |
2029 | |
2165 | |
2030 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
2166 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
2031 | |
2167 | |
… | |
… | |
2066 | player *player (object *op) |
2202 | player *player (object *op) |
2067 | CODE: |
2203 | CODE: |
2068 | RETVAL = op->contr; |
2204 | RETVAL = op->contr; |
2069 | OUTPUT: RETVAL |
2205 | OUTPUT: RETVAL |
2070 | |
2206 | |
|
|
2207 | void check_score (object *op) |
|
|
2208 | |
2071 | void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2209 | void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
2072 | |
2210 | |
2073 | object *cf_player_send_inventory (object *op) |
2211 | object *cf_player_send_inventory (object *op) |
2074 | |
2212 | |
2075 | char *cf_player_get_ip (object *op) |
2213 | char *cf_player_get_ip (object *op) |
… | |
… | |
2112 | int invoke (player *pl, int event, ...) |
2250 | int invoke (player *pl, int event, ...) |
2113 | CODE: |
2251 | CODE: |
2114 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2252 | if (KLASS_OF (event) != KLASS_PLAYER) croak ("event class must be PLAYER"); |
2115 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2253 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2116 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2254 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2117 | RETVAL = INVOKE_((event_type)event, ARG_PLAYER (pl), ARG_AV (av)); |
2255 | RETVAL = pl->invoke ((event_type)event, ARG_AV (av), DT_END); |
2118 | OUTPUT: RETVAL |
2256 | OUTPUT: RETVAL |
2119 | |
2257 | |
2120 | SV *registry (player *pl) |
2258 | SV *registry (player *pl) |
|
|
2259 | |
|
|
2260 | player * |
|
|
2261 | create () |
|
|
2262 | CODE: |
|
|
2263 | RETVAL = player::create (); |
|
|
2264 | OUTPUT: |
|
|
2265 | RETVAL |
|
|
2266 | |
|
|
2267 | player * |
|
|
2268 | load (const char *path) |
|
|
2269 | CODE: |
|
|
2270 | RETVAL = player::load (path); |
|
|
2271 | OUTPUT: |
|
|
2272 | RETVAL |
|
|
2273 | |
|
|
2274 | void |
|
|
2275 | player::save (bool final = false) |
|
|
2276 | |
|
|
2277 | void |
|
|
2278 | player::connect (client *ns) |
|
|
2279 | |
|
|
2280 | void |
|
|
2281 | save_stats (player *pl) |
|
|
2282 | CODE: |
|
|
2283 | pl->ob->stats.hp = pl->ob->stats.maxhp; |
|
|
2284 | pl->ob->stats.sp = pl->ob->stats.maxsp; |
|
|
2285 | pl->ob->stats.grace = pl->ob->stats.maxgrace; |
|
|
2286 | pl->orig_stats = pl->ob->stats; |
2121 | |
2287 | |
2122 | player *cf_player_find (char *name) |
2288 | player *cf_player_find (char *name) |
2123 | PROTOTYPE: $ |
2289 | PROTOTYPE: $ |
2124 | |
2290 | |
2125 | void cf_player_move (player *pl, int dir) |
2291 | void cf_player_move (player *pl, int dir) |
… | |
… | |
2129 | player *first () |
2295 | player *first () |
2130 | CODE: |
2296 | CODE: |
2131 | RETVAL = first_player; |
2297 | RETVAL = first_player; |
2132 | OUTPUT: RETVAL |
2298 | OUTPUT: RETVAL |
2133 | |
2299 | |
2134 | player *next (player *pl) |
|
|
2135 | CODE: |
|
|
2136 | RETVAL = pl->next; |
|
|
2137 | OUTPUT: RETVAL |
|
|
2138 | |
|
|
2139 | bool |
2300 | bool |
2140 | cell_visible (player *pl, int dx, int dy) |
2301 | cell_visible (player *pl, int dx, int dy) |
2141 | CODE: |
2302 | CODE: |
2142 | RETVAL = FABS (dx) <= pl->socket->mapx / 2 && FABS (dy) <= pl->socket->mapy / 2 |
2303 | RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 |
2143 | && !pl->blocked_los [dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]; |
2304 | && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]; |
2144 | OUTPUT: |
2305 | OUTPUT: |
2145 | RETVAL |
2306 | RETVAL |
2146 | |
2307 | |
2147 | void |
2308 | void |
2148 | send (player *pl, SV *packet) |
2309 | send (player *pl, SV *packet) |
2149 | CODE: |
2310 | CODE: |
2150 | { |
2311 | { |
2151 | STRLEN len; |
2312 | STRLEN len; |
2152 | char *buf = SvPVbyte (packet, len); |
2313 | char *buf = SvPVbyte (packet, len); |
2153 | |
2314 | |
|
|
2315 | if (pl->ns) |
2154 | pl->socket->send_packet (buf, len); |
2316 | pl->ns->send_packet (buf, len); |
2155 | } |
2317 | } |
2156 | |
2318 | |
2157 | int |
2319 | int |
2158 | listening (player *pl, int new_value = -1) |
2320 | listening (player *pl, int new_value = -1) |
2159 | CODE: |
2321 | CODE: |
… | |
… | |
2178 | if (y) sv_to (y, pl->bed_y); |
2340 | if (y) sv_to (y, pl->bed_y); |
2179 | |
2341 | |
2180 | void |
2342 | void |
2181 | list () |
2343 | list () |
2182 | PPCODE: |
2344 | PPCODE: |
2183 | { |
|
|
2184 | player *pl; |
|
|
2185 | for (pl = first_player; pl; pl = pl->next) |
2345 | for (player *pl = first_player; pl; pl = pl->next) |
2186 | XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); |
2346 | XPUSHs (sv_2mortal (to_sv (pl))); |
2187 | } |
|
|
2188 | |
2347 | |
2189 | bool |
2348 | bool |
2190 | peaceful (player *pl, bool new_setting = 0) |
2349 | peaceful (player *pl, bool new_setting = 0) |
2191 | PROTOTYPE: $;$ |
2350 | PROTOTYPE: $;$ |
2192 | CODE: |
2351 | CODE: |
… | |
… | |
2220 | int invoke (maptile *map, int event, ...) |
2379 | int invoke (maptile *map, int event, ...) |
2221 | CODE: |
2380 | CODE: |
2222 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
2381 | if (KLASS_OF (event) != KLASS_MAP) croak ("event class must be MAP"); |
2223 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2382 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2224 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2383 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2225 | RETVAL = INVOKE_((event_type)event, ARG_MAP (map), ARG_AV (av)); |
2384 | RETVAL = map->invoke ((event_type)event, ARG_AV (av), DT_END); |
2226 | OUTPUT: RETVAL |
2385 | OUTPUT: RETVAL |
2227 | |
2386 | |
2228 | SV *registry (maptile *map) |
2387 | SV *registry (maptile *map) |
2229 | |
2388 | |
2230 | INCLUDE: $PERL genacc maptile ../include/map.h | |
2389 | INCLUDE: $PERL genacc maptile ../include/map.h | |
… | |
… | |
2340 | move_block_at = 4 |
2499 | move_block_at = 4 |
2341 | move_slow_at = 5 |
2500 | move_slow_at = 5 |
2342 | move_on_at = 6 |
2501 | move_on_at = 6 |
2343 | move_off_at = 7 |
2502 | move_off_at = 7 |
2344 | INIT: |
2503 | INIT: |
2345 | if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF; |
2504 | if (x >= obj->width || y >= obj->height) XSRETURN_UNDEF; |
2346 | CODE: |
2505 | CODE: |
2347 | switch (ix) |
2506 | switch (ix) |
2348 | { |
2507 | { |
2349 | case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break; |
2508 | case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break; |
2350 | case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break; |
2509 | case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break; |
… | |
… | |
2449 | int invoke (client *ns, int event, ...) |
2608 | int invoke (client *ns, int event, ...) |
2450 | CODE: |
2609 | CODE: |
2451 | if (KLASS_OF (event) != KLASS_CLIENT) croak ("event class must be CLIENT"); |
2610 | if (KLASS_OF (event) != KLASS_CLIENT) croak ("event class must be CLIENT"); |
2452 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2611 | AV *av = (AV *)sv_2mortal ((SV *)newAV ()); |
2453 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2612 | for (int i = 2; i < items; i++) av_push (av, SvREFCNT_inc (ST (i))); |
2454 | RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); |
2613 | RETVAL = ns->invoke ((event_type)event, ARG_AV (av), DT_END); |
2455 | OUTPUT: RETVAL |
2614 | OUTPUT: RETVAL |
2456 | |
2615 | |
2457 | SV *registry (client *ns) |
2616 | SV *registry (client *ns) |
|
|
2617 | |
|
|
2618 | void |
|
|
2619 | list () |
|
|
2620 | PPCODE: |
|
|
2621 | EXTEND (SP, clients.size ()); |
|
|
2622 | for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i) |
|
|
2623 | PUSHs (sv_2mortal (to_sv (*i))); |
2458 | |
2624 | |
2459 | client * |
2625 | client * |
2460 | create (int fd, const char *peername) |
2626 | create (int fd, const char *peername) |
2461 | CODE: |
2627 | CODE: |
2462 | RETVAL = client::create (fd, peername); |
2628 | RETVAL = client::create (fd, peername); |
2463 | OUTPUT: |
2629 | OUTPUT: |
2464 | RETVAL |
2630 | RETVAL |
2465 | |
2631 | |
2466 | void |
2632 | void |
|
|
2633 | client::send_packet (SV *packet) |
|
|
2634 | CODE: |
|
|
2635 | { |
|
|
2636 | STRLEN len; |
|
|
2637 | char *buf = SvPVbyte (packet, len); |
|
|
2638 | |
|
|
2639 | THIS->send_packet (buf, len); |
|
|
2640 | } |
|
|
2641 | |
|
|
2642 | void |
2467 | client::destroy () |
2643 | client::destroy () |
2468 | |
2644 | |