ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.227 by root, Tue Jul 10 16:24:00 2007 UTC vs.
Revision 1.229 by root, Thu Jul 12 08:40:14 2007 UTC

246 delete obj; 246 delete obj;
247 } 247 }
248 } 248 }
249} 249}
250 250
251void
252attachable::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
251attachable & 263attachable &
252attachable::operator =(const attachable &src) 264attachable::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);
417inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); } 432inline SV *to_sv (client * v) { return newSVattachable (v, stash_cf_client_wrap); }
418inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); } 433inline SV *to_sv (player * v) { return newSVattachable (v, stash_cf_player_wrap); }
419inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); } 434inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? stash_cf_object_player_wrap : stash_cf_object_wrap); }
420inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); } 435inline SV *to_sv (maptile * v) { return newSVattachable (v, stash_cf_map_wrap); }
421inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); } 436inline SV *to_sv (archetype * v) { return newSVattachable (v, stash_cf_arch_wrap); }
437inline SV *to_sv (region * v) { return newSVattachable (v, stash_cf_region_wrap); }
422inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); } 438inline SV *to_sv (partylist * v) { return newSVptr (v, stash_cf_party_wrap); }
423inline SV *to_sv (region * v) { return newSVptr (v, stash_cf_region_wrap); }
424inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 439inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
425 440
426inline SV *to_sv (object & v) { return to_sv (&v); } 441inline SV *to_sv (object & v) { return to_sv (&v); }
427inline SV *to_sv (living & v) { return to_sv (&v); } 442inline SV *to_sv (living & v) { return to_sv (&v); }
428 443
454inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); } 469inline void sv_to (SV *sv, client * &v) { v = (client *)(attachable *)SvPTR_ornull (sv, "cf::client"); }
455inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); } 470inline void sv_to (SV *sv, player * &v) { v = (player *)(attachable *)SvPTR_ornull (sv, "cf::player"); }
456inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); } 471inline void sv_to (SV *sv, object * &v) { v = (object *)(attachable *)SvPTR_ornull (sv, "cf::object"); }
457inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } 472inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); }
458inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); } 473inline void sv_to (SV *sv, maptile * &v) { v = (maptile *)(attachable *)SvPTR_ornull (sv, "cf::map"); }
474inline void sv_to (SV *sv, region * &v) { v = (region *)(attachable *)SvPTR_ornull (sv, "cf::region"); }
459inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 475inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
460inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 476inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
461inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
462inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 477inline 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)]; }
465inline void sv_to (SV *sv, treasurelist * &v) { v = treasurelist::find (SvPV_nolen (sv)); } 480inline 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
2627void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2641void 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
2664int 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
2671SV *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
2651void invalidate (faceidx idx) 2678void 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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines