… | |
… | |
111 | |
111 | |
112 | unordered_vector<attachable *> attachable::mortals; |
112 | unordered_vector<attachable *> attachable::mortals; |
113 | |
113 | |
114 | attachable::~attachable () |
114 | attachable::~attachable () |
115 | { |
115 | { |
116 | flags |=0x3300;//D |
|
|
117 | assert (!self); |
116 | assert (!self); |
118 | assert (!cb); |
117 | assert (!cb); |
119 | } |
118 | } |
120 | |
119 | |
121 | int |
120 | int |
… | |
… | |
137 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
136 | sv_unmagic ((SV *)self, PERL_MAGIC_ext); |
138 | SvREFCNT_dec (self); |
137 | SvREFCNT_dec (self); |
139 | |
138 | |
140 | // self *must* be null now because thats sv_unmagic's job. |
139 | // self *must* be null now because thats sv_unmagic's job. |
141 | assert (!this->self); |
140 | assert (!this->self); |
142 | flags |= 0x80; // severed //D |
|
|
143 | } |
141 | } |
144 | } |
142 | } |
145 | |
143 | |
146 | void |
144 | void |
147 | attachable::optimise () |
145 | attachable::optimise () |
148 | { |
146 | { |
149 | if (self |
147 | if (self |
150 | && SvREFCNT (self) == 1 |
148 | && SvREFCNT (self) == 1 |
151 | && !HvTOTALKEYS (self)) |
149 | && !HvTOTALKEYS (self)) |
152 | flags |= 0x40,//D |
|
|
153 | sever_self (); |
150 | sever_self (); |
154 | } |
151 | } |
155 | |
152 | |
156 | // check wether the object really is dead |
153 | // check wether the object really is dead |
157 | void |
154 | void |
… | |
… | |
175 | } |
172 | } |
176 | |
173 | |
177 | if (self) |
174 | if (self) |
178 | sever_self (); |
175 | sever_self (); |
179 | |
176 | |
180 | flags |= 0x20; //D |
|
|
181 | mortals.push_back (this); |
177 | mortals.push_back (this); |
182 | } |
178 | } |
183 | |
179 | |
184 | void |
180 | void |
185 | attachable::destroy () |
181 | attachable::destroy () |
… | |
… | |
210 | |
206 | |
211 | attachable *obj = mortals [i]; |
207 | attachable *obj = mortals [i]; |
212 | |
208 | |
213 | obj->refcnt_chk (); // unborrow from perl, if necessary |
209 | obj->refcnt_chk (); // unborrow from perl, if necessary |
214 | |
210 | |
215 | //if (obj->refcnt > 0 || obj->self) |
|
|
216 | if (obj->refcnt || obj->self) |
211 | if (obj->refcnt || obj->self) |
217 | { |
212 | { |
218 | //printf ("%p rc %d\n", obj, obj->refcnt_cnt ());//D |
|
|
219 | ++i; // further delay freeing |
213 | ++i; // further delay freeing |
220 | |
214 | |
221 | if (!(i & 0x3ff)) |
215 | if (!(i & 0x3ff)) |
222 | break; |
216 | break; |
223 | } |
217 | } |
… | |
… | |
280 | |
274 | |
281 | if (!obj->self) |
275 | if (!obj->self) |
282 | { |
276 | { |
283 | obj->self = newHV (); |
277 | obj->self = newHV (); |
284 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
278 | sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); |
285 | obj->flags |= (obj->flags & 0xc0) << 8; |
|
|
286 | obj->flags &= ~0xc0;//D |
|
|
287 | obj->flags |= 0x10;//D |
|
|
288 | |
279 | |
289 | // now bless the object _once_ |
280 | // now bless the object _once_ |
290 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
281 | return sv_bless (newRV_inc ((SV *)obj->self), stash); |
291 | } |
282 | } |
292 | else |
283 | else |
… | |
… | |
1266 | |
1257 | |
1267 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1258 | const_iv (CS_QUERY_YESNO) const_iv (CS_QUERY_SINGLECHAR) const_iv (CS_QUERY_HIDEINPUT) |
1268 | |
1259 | |
1269 | const_iv (ST_DEAD) const_iv (ST_SETUP) const_iv (ST_PLAYING) const_iv (ST_CUSTOM) |
1260 | const_iv (ST_DEAD) const_iv (ST_SETUP) const_iv (ST_PLAYING) const_iv (ST_CUSTOM) |
1270 | |
1261 | |
1271 | const_iv (ST_CHANGE_CLASS) |
|
|
1272 | |
|
|
1273 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1262 | const_iv (IO_HEADER) const_iv (IO_OBJECTS) const_iv (IO_UNIQUES) |
1274 | |
1263 | |
1275 | // random map generator |
1264 | // random map generator |
1276 | const_iv (LAYOUT_NONE) const_iv (LAYOUT_ONION) const_iv (LAYOUT_MAZE) const_iv (LAYOUT_SPIRAL) |
1265 | const_iv (LAYOUT_NONE) const_iv (LAYOUT_ONION) const_iv (LAYOUT_MAZE) const_iv (LAYOUT_SPIRAL) |
1277 | const_iv (LAYOUT_ROGUELIKE) const_iv (LAYOUT_SNAKE) const_iv (LAYOUT_SQUARE_SPIRAL) |
1266 | const_iv (LAYOUT_ROGUELIKE) const_iv (LAYOUT_SNAKE) const_iv (LAYOUT_SQUARE_SPIRAL) |
… | |
… | |
1280 | const_iv (RMOPT_BOTTOM_C) const_iv (RMOPT_BOTTOM_R) const_iv (RMOPT_IRR_SPACE) |
1269 | const_iv (RMOPT_BOTTOM_C) const_iv (RMOPT_BOTTOM_R) const_iv (RMOPT_IRR_SPACE) |
1281 | const_iv (RMOPT_WALL_OFF) const_iv (RMOPT_WALLS_ONLY) const_iv (RMOPT_NO_DOORS) |
1270 | const_iv (RMOPT_WALL_OFF) const_iv (RMOPT_WALLS_ONLY) const_iv (RMOPT_NO_DOORS) |
1282 | |
1271 | |
1283 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1272 | const_iv (SYMMETRY_RANDOM) const_iv (SYMMETRY_NONE) const_iv (SYMMETRY_X) |
1284 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
1273 | const_iv (SYMMETRY_Y) const_iv (SYMMETRY_XY) |
|
|
1274 | |
|
|
1275 | const_iv (GT_ENVIRONMENT) const_iv (GT_INVISIBLE) const_iv (GT_STARTEQUIP) |
|
|
1276 | const_iv (GT_APPLY) const_iv (GT_ONLY_GOOD) const_iv (GT_UPDATE_INV) |
|
|
1277 | const_iv (GT_MINIMAL) |
1285 | }; |
1278 | }; |
1286 | |
1279 | |
1287 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1280 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1288 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1281 | newCONSTSUB (stash_cf, (char *)civ->name, newSViv (civ->iv)); |
1289 | |
1282 | |