ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/utils.C
(Generate patch)

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.33 by root, Sun Dec 31 18:10:40 2006 UTC vs.
Revision 1.35 by root, Mon Jan 1 13:31:46 2007 UTC

199 199
200/* decay and destroy perishable items in a map */ 200/* decay and destroy perishable items in a map */
201void 201void
202maptile::decay_objects () 202maptile::decay_objects ()
203{ 203{
204 int x, y, destroy; 204 if (!spaces)
205 object *op, *otmp; 205 return;
206 206
207 for (x = 0; x < width; x++) 207 for (mapspace *ms = spaces + size (); ms-- > spaces; )
208 for (y = 0; y < height; y++) 208 for (object *above, *op = ms->bot; op; op = above)
209 for (op = at (x, y).bot; op; op = otmp)
210 { 209 {
210 above = op->above;
211
211 destroy = 0; 212 bool destroy = 0;
212 otmp = op->above;
213 213
214 // do not decay anything above unique floor tiles (yet :)
214 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) 215 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE))
215 break; 216 break;
216 217
217 if (QUERY_FLAG (op, FLAG_IS_FLOOR) 218 if (QUERY_FLAG (op, FLAG_IS_FLOOR)
218 || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) 219 || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL)
219 || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) 220 || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL)
220 || QUERY_FLAG (op, FLAG_UNIQUE) 221 || QUERY_FLAG (op, FLAG_UNIQUE)
221 || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) 222 || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR)
222 || QUERY_FLAG (op, FLAG_UNPAID) 223 || QUERY_FLAG (op, FLAG_UNPAID)
223 || op->is_alive ()) 224 || op->is_alive ())
224 continue; 225 ; // do not decay
225
226 /* otherwise, we decay and destroy */
227 if (op->is_weapon ()) 226 else if (op->is_weapon ())
228 { 227 {
229 op->stats.dam--; 228 op->stats.dam--;
230 if (op->stats.dam < 0) 229 if (op->stats.dam < 0)
231 destroy = 1; 230 destroy = 1;
232 } 231 }
233 else if (op->is_armor ()) 232 else if (op->is_armor ())
234 { 233 {
235 op->stats.ac--; 234 op->stats.ac--;
236 if (op->stats.ac < 0) 235 if (op->stats.ac < 0)
237 destroy = 1; 236 destroy = 1;
238 } 237 }
239 else if (op->type == FOOD) 238 else if (op->type == FOOD)
240 { 239 {
241 op->stats.food -= rndm (5, 20); 240 op->stats.food -= rndm (5, 20);
242 if (op->stats.food < 0) 241 if (op->stats.food < 0)
243 destroy = 1; 242 destroy = 1;
244 } 243 }
245 else 244 else
246 { 245 {
247 if (op->material & M_PAPER || op->material & M_LEATHER || 246 int mat = op->material;
248 op->material & M_WOOD || op->material & M_ORGANIC || op->material & M_CLOTH || op->material & M_LIQUID) 247
248 if (mat & M_PAPER
249 || mat & M_LEATHER
250 || mat & M_WOOD
251 || mat & M_ORGANIC
252 || mat & M_CLOTH
253 || mat & M_LIQUID
254 || (mat & M_IRON && rndm (1, 5) == 1)
255 || (mat & M_GLASS && rndm (1, 2) == 1)
256 || ((mat & M_STONE || mat & M_ADAMANT) && rndm (1, 10) == 1)
257 || ((mat & M_SOFT_METAL || mat & M_BONE) && rndm (1, 3) == 1)
258 || (mat & M_ICE && temp > 32))
249 destroy = 1; 259 destroy = 1;
250
251 if (op->material & M_IRON && rndm (1, 5) == 1)
252 destroy = 1;
253
254 if (op->material & M_GLASS && rndm (1, 2) == 1)
255 destroy = 1;
256
257 if ((op->material & M_STONE || op->material & M_ADAMANT) && rndm (1, 10) == 1)
258 destroy = 1;
259
260 if ((op->material & M_SOFT_METAL || op->material & M_BONE) && rndm (1, 3) == 1)
261 destroy = 1;
262
263 if (op->material & M_ICE && temp > 32)
264 destroy = 1;
265 } 260 }
266 261
267 /* adjust overall chance below */ 262 /* adjust overall chance below */
268 if (destroy && rndm (0, 1)) 263 if (destroy && rndm (0, 1))
269 op->destroy (); 264 op->destroy ();
270 } 265 }
271} 266}
272 267
273/* convert materialname to materialtype_t */ 268/* convert materialname to materialtype_t */
274 269
275materialtype_t * 270materialtype_t *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines