… | |
… | |
164 | } |
164 | } |
165 | |
165 | |
166 | void |
166 | void |
167 | attachable::check_mortals () |
167 | attachable::check_mortals () |
168 | { |
168 | { |
169 | for (int i = 0; i < mortals.size (); ) |
169 | static int i = 0; |
|
|
170 | |
|
|
171 | for (;;) |
170 | { |
172 | { |
|
|
173 | if (i >= mortals.size ()) |
|
|
174 | { |
|
|
175 | i = 0; |
|
|
176 | |
|
|
177 | if (mortals.size () > 1000) |
|
|
178 | fprintf (stderr, "mortal queue size (%d) exceeds 1000.\n", mortals.size ()); |
|
|
179 | |
|
|
180 | break; |
|
|
181 | } |
|
|
182 | |
171 | attachable *obj = mortals [i]; |
183 | attachable *obj = mortals [i]; |
172 | |
184 | |
173 | obj->refcnt_chk (); // unborrow from perl, if necessary |
185 | obj->refcnt_chk (); // unborrow from perl, if necessary |
174 | |
186 | |
175 | if (obj->refcnt || obj->self) |
187 | if (obj->refcnt > 0 || obj->self) |
176 | { |
188 | { |
177 | #if 0 |
189 | //printf ("%p rc %d\n", obj, obj->refcnt_cnt ());//D |
178 | if (mortals.size() > 5)fprintf (stderr, "%d delaying %d:%p:%s %d (self %p:%d)\n", time(0),i, obj, typeid (*obj).name (), |
|
|
179 | obj->refcnt, obj->self, obj->self ? SvREFCNT(obj->self): - 1);//D |
|
|
180 | #endif |
|
|
181 | |
|
|
182 | ++i; // further delay freeing |
190 | ++i; // further delay freeing |
|
|
191 | |
|
|
192 | if (!(i & 0x3ff)) |
|
|
193 | break; |
183 | }//D |
194 | } |
184 | else |
195 | else |
185 | { |
196 | { |
186 | //Dfprintf (stderr, "deleteing %d:%p:%s\n", i, obj,typeid (*obj).name ());//D |
|
|
187 | mortals.erase (i); |
197 | mortals.erase (i); |
188 | delete obj; |
198 | delete obj; |
189 | } |
199 | } |
190 | } |
200 | } |
191 | } |
201 | } |
… | |
… | |
313 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
323 | inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } |
314 | |
324 | |
315 | inline SV *to_sv (object & v) { return to_sv (&v); } |
325 | inline SV *to_sv (object & v) { return to_sv (&v); } |
316 | inline SV *to_sv (living & v) { return to_sv (&v); } |
326 | inline SV *to_sv (living & v) { return to_sv (&v); } |
317 | |
327 | |
318 | inline SV *to_sv (New_Face * v) { return to_sv (v->name); } |
328 | inline SV *to_sv (facetile * v) { return to_sv (v->name); } |
319 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
329 | inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } |
320 | |
330 | |
321 | inline SV *to_sv (UUID v) |
331 | inline SV *to_sv (UUID v) |
322 | { |
332 | { |
323 | char buf[128]; |
333 | char buf[128]; |
… | |
… | |
348 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
358 | inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
349 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
359 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
350 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
360 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
351 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
361 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
352 | |
362 | |
353 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } |
363 | inline void sv_to (SV *sv, facetile * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } |
354 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } |
364 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } |
355 | |
365 | |
356 | template<class T> |
366 | template<class T> |
357 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
367 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
358 | |
368 | |
… | |
… | |
895 | void |
905 | void |
896 | iw::alloc () |
906 | iw::alloc () |
897 | { |
907 | { |
898 | pe = GEventAPI->new_idle (0, 0); |
908 | pe = GEventAPI->new_idle (0, 0); |
899 | |
909 | |
|
|
910 | WaREENTRANT_off (pe); |
900 | pe->base.callback = (void *)iw_dispatch; |
911 | pe->base.callback = (void *)iw_dispatch; |
901 | pe->base.ext_data = (void *)this; |
912 | pe->base.ext_data = (void *)this; |
902 | } |
913 | } |
903 | |
914 | |
904 | static void iow_dispatch (pe_event *ev) |
915 | static void iow_dispatch (pe_event *ev) |
… | |
… | |
910 | void |
921 | void |
911 | iow::alloc () |
922 | iow::alloc () |
912 | { |
923 | { |
913 | pe = GEventAPI->new_io (0, 0); |
924 | pe = GEventAPI->new_io (0, 0); |
914 | |
925 | |
|
|
926 | WaREENTRANT_off (pe); |
915 | pe->base.callback = (void *)iow_dispatch; |
927 | pe->base.callback = (void *)iow_dispatch; |
916 | pe->base.ext_data = (void *)this; |
928 | pe->base.ext_data = (void *)this; |
917 | |
929 | |
918 | pe->fd = -1; |
930 | pe->fd = -1; |
919 | pe->poll = 0; |
931 | pe->poll = 0; |
… | |
… | |
1248 | const_iv (FLAG_IS_WATER) |
1260 | const_iv (FLAG_IS_WATER) |
1249 | const_iv (FLAG_CONTENT_ON_GEN) |
1261 | const_iv (FLAG_CONTENT_ON_GEN) |
1250 | const_iv (FLAG_IS_A_TEMPLATE) |
1262 | const_iv (FLAG_IS_A_TEMPLATE) |
1251 | const_iv (FLAG_IS_BUILDABLE) |
1263 | const_iv (FLAG_IS_BUILDABLE) |
1252 | const_iv (FLAG_DESTROY_ON_DEATH) |
1264 | const_iv (FLAG_DESTROY_ON_DEATH) |
1253 | const_iv (FLAG_NO_SAVE) |
1265 | const_iv (FLAG_NO_MAP_SAVE) |
1254 | |
1266 | |
1255 | const_iv (NDI_BLACK) |
1267 | const_iv (NDI_BLACK) |
1256 | const_iv (NDI_WHITE) |
1268 | const_iv (NDI_WHITE) |
1257 | const_iv (NDI_NAVY) |
1269 | const_iv (NDI_NAVY) |
1258 | const_iv (NDI_RED) |
1270 | const_iv (NDI_RED) |
… | |
… | |
1443 | const_iv (ATNR_BLIND) |
1455 | const_iv (ATNR_BLIND) |
1444 | const_iv (ATNR_INTERNAL) |
1456 | const_iv (ATNR_INTERNAL) |
1445 | const_iv (ATNR_LIFE_STEALING) |
1457 | const_iv (ATNR_LIFE_STEALING) |
1446 | const_iv (ATNR_DISEASE) |
1458 | const_iv (ATNR_DISEASE) |
1447 | |
1459 | |
1448 | const_iv (MAP_FLUSH) |
|
|
1449 | const_iv (MAP_PLAYER_UNIQUE) |
|
|
1450 | const_iv (MAP_BLOCK) |
|
|
1451 | const_iv (MAP_STYLE) |
|
|
1452 | const_iv (MAP_OVERLAY) |
|
|
1453 | |
|
|
1454 | const_iv (MAP_IN_MEMORY) |
1460 | const_iv (MAP_IN_MEMORY) |
1455 | const_iv (MAP_SWAPPED) |
1461 | const_iv (MAP_SWAPPED) |
1456 | const_iv (MAP_LOADING) |
1462 | const_iv (MAP_LOADING) |
1457 | const_iv (MAP_SAVING) |
1463 | const_iv (MAP_SAVING) |
1458 | |
1464 | |
… | |
… | |
1624 | void fork_abort (char *cause = "cf::fork_abort") |
1630 | void fork_abort (char *cause = "cf::fork_abort") |
1625 | |
1631 | |
1626 | void cleanup (const char *cause, bool make_core = false) |
1632 | void cleanup (const char *cause, bool make_core = false) |
1627 | |
1633 | |
1628 | void emergency_save () |
1634 | void emergency_save () |
|
|
1635 | |
|
|
1636 | UV sv_2watcher (SV *w) |
|
|
1637 | CODE: |
|
|
1638 | RETVAL = (UV)GEventAPI->sv_2watcher (w); |
|
|
1639 | OUTPUT: |
|
|
1640 | RETVAL |
1629 | |
1641 | |
1630 | void _exit (int status = 0) |
1642 | void _exit (int status = 0) |
1631 | |
1643 | |
1632 | #if _POSIX_MEMLOCK |
1644 | #if _POSIX_MEMLOCK |
1633 | |
1645 | |
… | |
… | |
2221 | char *origin_map,\ |
2233 | char *origin_map,\ |
2222 | char *final_map,\ |
2234 | char *final_map,\ |
2223 | char *exitstyle,\ |
2235 | char *exitstyle,\ |
2224 | char *this_map,\ |
2236 | char *this_map,\ |
2225 | char *exit_on_final_map,\ |
2237 | char *exit_on_final_map,\ |
2226 | int Xsize,\ |
2238 | int xsize,\ |
2227 | int Ysize,\ |
2239 | int ysize,\ |
2228 | int expand2x,\ |
2240 | int expand2x,\ |
2229 | int layoutoptions1,\ |
2241 | int layoutoptions1,\ |
2230 | int layoutoptions2,\ |
2242 | int layoutoptions2,\ |
2231 | int layoutoptions3,\ |
2243 | int layoutoptions3,\ |
2232 | int symmetry,\ |
2244 | int symmetry,\ |
… | |
… | |
2237 | int dungeon_depth,\ |
2249 | int dungeon_depth,\ |
2238 | int decoroptions,\ |
2250 | int decoroptions,\ |
2239 | int orientation,\ |
2251 | int orientation,\ |
2240 | int origin_y,\ |
2252 | int origin_y,\ |
2241 | int origin_x,\ |
2253 | int origin_x,\ |
2242 | int random_seed,\ |
2254 | U32 random_seed,\ |
2243 | val64 total_map_hp,\ |
2255 | val64 total_map_hp,\ |
2244 | int map_layout_style,\ |
2256 | int map_layout_style,\ |
2245 | int treasureoptions,\ |
2257 | int treasureoptions,\ |
2246 | int symmetry_used,\ |
2258 | int symmetry_used,\ |
2247 | region *region,\ |
2259 | region *region,\ |
… | |
… | |
2263 | assign (rmp.exit_on_final_map, exit_on_final_map); |
2275 | assign (rmp.exit_on_final_map, exit_on_final_map); |
2264 | |
2276 | |
2265 | rmp.origin_map = origin_map; |
2277 | rmp.origin_map = origin_map; |
2266 | rmp.final_map = final_map; |
2278 | rmp.final_map = final_map; |
2267 | rmp.this_map = this_map; |
2279 | rmp.this_map = this_map; |
2268 | rmp.Xsize = Xsize; |
2280 | rmp.xsize = xsize; |
2269 | rmp.Ysize = Ysize; |
2281 | rmp.ysize = ysize; |
2270 | rmp.expand2x = expand2x; |
2282 | rmp.expand2x = expand2x; |
2271 | rmp.layoutoptions1 = layoutoptions1; |
2283 | rmp.layoutoptions1 = layoutoptions1; |
2272 | rmp.layoutoptions2 = layoutoptions2; |
2284 | rmp.layoutoptions2 = layoutoptions2; |
2273 | rmp.layoutoptions3 = layoutoptions3; |
2285 | rmp.layoutoptions3 = layoutoptions3; |
2274 | rmp.symmetry = symmetry; |
2286 | rmp.symmetry = symmetry; |