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.153 by root, Fri Jan 26 20:59:57 2007 UTC vs.
Revision 1.160 by elmex, Wed Jan 31 14:11:02 2007 UTC

112{ 112{
113 return refcnt + (self ? SvREFCNT (self) - 1 : 0); 113 return refcnt + (self ? SvREFCNT (self) - 1 : 0);
114} 114}
115 115
116void 116void
117attachable::sever_self ()
118{
119 if (HV *self = this->self)
120 {
121 // keep a refcount because sv_unmagic might call attachable_free,
122 // which might clear self, causing sv_unmagic to crash on a now
123 // invalid object.
124 SvREFCNT_inc (self);
125 hv_clear (self);
126 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
127 SvREFCNT_dec (self);
128
129 // self *must* be null now because thats sv_unmagic's job.
130 assert (!this->self);
131 }
132}
133
134void
117attachable::optimise () 135attachable::optimise ()
118{ 136{
119 if (self 137 if (self
120 && SvREFCNT (self) == 1 138 && SvREFCNT (self) == 1
121 && !HvTOTALKEYS (self)) 139 && !HvTOTALKEYS (self))
122 { 140 sever_self ();
123 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
124 assert (!self);
125 }
126} 141}
127 142
128// check wether the object really is dead 143// check wether the object really is dead
129void 144void
130attachable::do_check () 145attachable::do_check ()
145 SvREFCNT_dec (cb); 160 SvREFCNT_dec (cb);
146 cb = 0; 161 cb = 0;
147 } 162 }
148 163
149 if (self) 164 if (self)
150 { 165 sever_self ();
151 hv_clear (self);
152 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
153 // self is now 0
154 assert (!self);//D//TODO remove soon
155 }
156 166
157 mortals.push_back (this); 167 mortals.push_back (this);
158} 168}
159 169
160void 170void
337inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } 347inline SV *to_sv (treasurelist * v) { return to_sv (v->name); }
338 348
339inline SV *to_sv (UUID v) 349inline SV *to_sv (UUID v)
340{ 350{
341 char buf[128]; 351 char buf[128];
342 snprintf (buf, 128, "<1,%" PRIx64 ">", v.seq); 352 snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq);
343 return newSVpv (buf, 0); 353 return newSVpv (buf, 0);
344} 354}
345 355
346inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; } 356inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPV_nolen (sv) : 0; }
347inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 357inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
1639 1649
1640void cleanup (const char *cause, bool make_core = false) 1650void cleanup (const char *cause, bool make_core = false)
1641 1651
1642void emergency_save () 1652void emergency_save ()
1643 1653
1654void _exit (int status = EXIT_SUCCESS)
1655
1644UV sv_2watcher (SV *w) 1656UV sv_2watcher (SV *w)
1645 CODE: 1657 CODE:
1646 RETVAL = (UV)GEventAPI->sv_2watcher (w); 1658 RETVAL = (UV)GEventAPI->sv_2watcher (w);
1647 OUTPUT: 1659 OUTPUT:
1648 RETVAL 1660 RETVAL
1649
1650void _exit (int status = 0)
1651 1661
1652#if _POSIX_MEMLOCK 1662#if _POSIX_MEMLOCK
1653 1663
1654int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1664int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1655 1665
1794 1804
1795void 1805void
1796set_animation (object *op, int idx) 1806set_animation (object *op, int idx)
1797 CODE: 1807 CODE:
1798 SET_ANIMATION (op, idx); 1808 SET_ANIMATION (op, idx);
1809
1810int
1811num_animations (object *op)
1812 CODE:
1813 RETVAL = NUM_ANIMATIONS (op);
1814 OUTPUT: RETVAL
1799 1815
1800object *find_best_object_match (object *op, const char *match) 1816object *find_best_object_match (object *op, const char *match)
1801 1817
1802object *find_marked_object (object *op) 1818object *find_marked_object (object *op)
1803 1819
2131 EXTEND (SP, THIS->players); 2147 EXTEND (SP, THIS->players);
2132 for_all_players (pl) 2148 for_all_players (pl)
2133 if (pl->ob && pl->ob->map == THIS) 2149 if (pl->ob && pl->ob->map == THIS)
2134 PUSHs (sv_2mortal (to_sv (pl->ob))); 2150 PUSHs (sv_2mortal (to_sv (pl->ob)));
2135 } 2151 }
2152
2153void
2154maptile::set_regiondata (SV *data, SV *plt)
2155 CODE:
2156{
2157 if (!SvROK (plt) || SvTYPE (SvRV (plt)) != SVt_PVAV)
2158 croak ("maptile::set_regiondata needs arrayref as plt arg");
2159
2160 AV *av = (AV *)SvRV (plt);
2161
2162 region **regionmap = (region **)malloc ((av_len (av) + 1) * sizeof (region *));
2163
2164 for (int i = av_len (av) + 1; i--; )
2165 regionmap [i] = region::find (SvPVutf8_nolen (*av_fetch (av, i, 1)));
2166
2167 THIS->regions = salloc<uint8_t> (THIS->size (), (uint8_t *)SvPVbyte_nolen (data));
2168 THIS->regionmap = regionmap;
2169}
2136 2170
2137void play_sound_map (maptile *map, int x, int y, int sound_num) 2171void play_sound_map (maptile *map, int x, int y, int sound_num)
2138 2172
2139int out_of_map (maptile *map, int x, int y) 2173int out_of_map (maptile *map, int x, int y)
2140 2174
2221 OUTPUT: RETVAL 2255 OUTPUT: RETVAL
2222 2256
2223void fix_walls (maptile *map, int x, int y) 2257void fix_walls (maptile *map, int x, int y)
2224 2258
2225void fix_walls_around (maptile *map, int x, int y) 2259void fix_walls_around (maptile *map, int x, int y)
2226
2227const char *
2228region_name (maptile *m)
2229 CODE:
2230 RETVAL = get_name_of_region_for_map (m);
2231 OUTPUT: RETVAL
2232 2260
2233# worst xs function of my life 2261# worst xs function of my life
2234bool 2262bool
2235_create_random_map (\ 2263_create_random_map (\
2236 maptile *self,\ 2264 maptile *self,\
2353 OUTPUT: RETVAL 2381 OUTPUT: RETVAL
2354 2382
2355region *find (char *name) 2383region *find (char *name)
2356 PROTOTYPE: $ 2384 PROTOTYPE: $
2357 CODE: 2385 CODE:
2358 RETVAL = get_region_by_name (name); 2386 RETVAL = region::find (name);
2359 OUTPUT: RETVAL 2387 OUTPUT: RETVAL
2360 2388
2361INCLUDE: $PERL genacc region ../include/map.h | 2389INCLUDE: $PERL genacc region ../include/map.h |
2362 2390
2363MODULE = cf PACKAGE = cf::living 2391MODULE = cf PACKAGE = cf::living

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines