… | |
… | |
246 | delete obj; |
246 | delete obj; |
247 | } |
247 | } |
248 | } |
248 | } |
249 | } |
249 | } |
250 | |
250 | |
|
|
251 | void |
|
|
252 | attachable::set_key (const char *key, const char *value) |
|
|
253 | { |
|
|
254 | if (!self) |
|
|
255 | self = newHV (); |
|
|
256 | |
|
|
257 | if (value) |
|
|
258 | hv_store (self, key, strlen (key), newSVpv (value, 0), 0); |
|
|
259 | else |
|
|
260 | hv_delete (self, key, strlen (key), G_DISCARD); |
|
|
261 | } |
|
|
262 | |
251 | attachable & |
263 | attachable & |
252 | attachable::operator =(const attachable &src) |
264 | attachable::operator =(const attachable &src) |
253 | { |
265 | { |
254 | //if (self || cb) |
266 | //if (self || cb) |
255 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
267 | //INVOKE_OBJECT (CLONE, this, ARG_OBJECT (dst)); |
… | |
… | |
330 | { |
342 | { |
331 | if (!obj) |
343 | if (!obj) |
332 | return &PL_sv_undef; |
344 | return &PL_sv_undef; |
333 | |
345 | |
334 | if (!obj->self) |
346 | if (!obj->self) |
|
|
347 | obj->self = newHV (); |
|
|
348 | |
|
|
349 | if (!SvOBJECT (obj->self)) |
335 | { |
350 | { |
336 | obj->self = newHV (); |
|
|
337 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
351 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
338 | |
352 | |
339 | // now bless the object _once_ |
353 | // now bless the object _once_ |
|
|
354 | //TODO: create a class registry with c++ type<=>perl name<=>stash and use it here and elsewhere |
340 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
355 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
341 | } |
356 | } |
342 | else |
357 | else |
343 | { |
358 | { |
344 | SV *sv = newRV_inc ((SV *)obj->self); |
359 | SV *sv = newRV_inc ((SV *)obj->self); |
… | |
… | |
417 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
432 | inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } |
418 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
433 | inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } |
419 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
434 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } |
420 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
435 | inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } |
421 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
436 | inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } |
|
|
437 | inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); } |
422 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
438 | inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } |
423 | inline SV *to_sv (region * v) { return newSVptr (v, stash_cf_region_wrap); } |
|
|
424 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
439 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
425 | |
440 | |
426 | inline SV *to_sv (object & v) { return to_sv (&v); } |
441 | inline SV *to_sv (object & v) { return to_sv (&v); } |
427 | inline SV *to_sv (living & v) { return to_sv (&v); } |
442 | inline SV *to_sv (living & v) { return to_sv (&v); } |
428 | |
443 | |
… | |
… | |
454 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
469 | inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } |
455 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
470 | inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } |
456 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
471 | inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } |
457 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
472 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
458 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
473 | inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
474 | inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); } |
459 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
475 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
460 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
476 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
461 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
|
|
462 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
477 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
463 | |
478 | |
464 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
479 | //inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; } |
465 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
480 | inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } |
466 | |
481 | |
… | |
… | |
2611 | set_visibility = 1 |
2626 | set_visibility = 1 |
2612 | set_magicmap = 2 |
2627 | set_magicmap = 2 |
2613 | set_smooth = 3 |
2628 | set_smooth = 3 |
2614 | set_smoothlevel = 4 |
2629 | set_smoothlevel = 4 |
2615 | CODE: |
2630 | CODE: |
2616 | faceinfo *f = face_info (idx); |
2631 | faceinfo *f = face_info (idx); assert (f); |
2617 | assert (f); |
|
|
2618 | switch (ix) |
2632 | switch (ix) |
2619 | { |
2633 | { |
2620 | case 0: f->type = value; break; |
2634 | case 0: f->type = value; break; |
2621 | case 1: f->visibility = value; break; |
2635 | case 1: f->visibility = value; break; |
2622 | case 2: f->magicmap = value; break; |
2636 | case 2: f->magicmap = value; break; |
… | |
… | |
2625 | } |
2639 | } |
2626 | |
2640 | |
2627 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2641 | void set_data (faceidx idx, int faceset, SV *data, SV *chksum) |
2628 | CODE: |
2642 | CODE: |
2629 | { |
2643 | { |
2630 | facedata *d = face_data (idx, faceset); |
2644 | facedata *d = face_data (idx, faceset); assert (d); |
2631 | assert (d); |
|
|
2632 | sv_to (data, d->data); |
2645 | sv_to (data, d->data); |
2633 | STRLEN clen; |
2646 | STRLEN clen; |
2634 | char *cdata = SvPVbyte (chksum, clen); |
2647 | char *cdata = SvPVbyte (chksum, clen); |
2635 | clen = min (CHKSUM_SIZE, clen); |
2648 | clen = min (CHKSUM_SIZE, clen); |
2636 | |
2649 | |
… | |
… | |
2646 | ns->force_newmap = true; |
2659 | ns->force_newmap = true; |
2647 | } |
2660 | } |
2648 | } |
2661 | } |
2649 | } |
2662 | } |
2650 | |
2663 | |
|
|
2664 | int get_data_size (faceidx idx, int faceset = 0) |
|
|
2665 | CODE: |
|
|
2666 | facedata *d = face_data (idx, faceset); assert (d); |
|
|
2667 | RETVAL = d->data.size (); |
|
|
2668 | OUTPUT: |
|
|
2669 | RETVAL |
|
|
2670 | |
|
|
2671 | SV *get_chksum (faceidx idx, int faceset = 0) |
|
|
2672 | CODE: |
|
|
2673 | facedata *d = face_data (idx, faceset); assert (d); |
|
|
2674 | RETVAL = newSVpvn ((char *)d->chksum, CHKSUM_SIZE); |
|
|
2675 | OUTPUT: |
|
|
2676 | RETVAL |
|
|
2677 | |
2651 | void invalidate (faceidx idx) |
2678 | void invalidate (faceidx idx) |
2652 | CODE: |
2679 | CODE: |
2653 | for_all_clients (ns) |
2680 | for_all_clients (ns) |
2654 | { |
2681 | { |
2655 | ns->faces_sent [idx] = false; |
2682 | ns->faces_sent [idx] = false; |