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.34 by root, Mon Jan 1 12:28:46 2007 UTC vs.
Revision 1.36 by pippijn, Sat Jan 6 14:42:29 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
199 200
200/* decay and destroy perishable items in a map */ 201/* decay and destroy perishable items in a map */
201void 202void
202maptile::decay_objects () 203maptile::decay_objects ()
203{ 204{
204 for (int x = 0; x < width; x++) 205 if (!spaces)
205 for (int y = 0; y < height; y++) 206 return;
207
208 for (mapspace *ms = spaces + size (); ms-- > spaces; )
206 for (object *above = 0, *op = at (x, y).bot; op; op = above) 209 for (object *above, *op = ms->bot; op; op = above)
207 { 210 {
208 bool destroy = 0;
209
210 above = op->above; 211 above = op->above;
211 212
213 bool destroy = 0;
214
212 // do not decay anything above unique floor tiles (yet :) 215 // do not decay anything above unique floor tiles (yet :)
213 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) 216 if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE))
214 break; 217 break;
215 218
216 if (QUERY_FLAG (op, FLAG_IS_FLOOR) 219 if (QUERY_FLAG (op, FLAG_IS_FLOOR)
217 || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) 220 || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL)
218 || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) 221 || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL)
219 || QUERY_FLAG (op, FLAG_UNIQUE) 222 || QUERY_FLAG (op, FLAG_UNIQUE)
220 || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) 223 || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR)
221 || QUERY_FLAG (op, FLAG_UNPAID) 224 || QUERY_FLAG (op, FLAG_UNPAID)
222 || op->is_alive ()) 225 || op->is_alive ())
223 ; // do not decay 226 ; // do not decay
224 else if (op->is_weapon ()) 227 else if (op->is_weapon ())
225 { 228 {
226 op->stats.dam--; 229 op->stats.dam--;
227 if (op->stats.dam < 0) 230 if (op->stats.dam < 0)
228 destroy = 1; 231 destroy = 1;
229 } 232 }
230 else if (op->is_armor ()) 233 else if (op->is_armor ())
231 { 234 {
232 op->stats.ac--; 235 op->stats.ac--;
233 if (op->stats.ac < 0) 236 if (op->stats.ac < 0)
234 destroy = 1; 237 destroy = 1;
235 } 238 }
236 else if (op->type == FOOD) 239 else if (op->type == FOOD)
237 { 240 {
238 op->stats.food -= rndm (5, 20); 241 op->stats.food -= rndm (5, 20);
239 if (op->stats.food < 0) 242 if (op->stats.food < 0)
240 destroy = 1; 243 destroy = 1;
241 } 244 }
242 else 245 else
243 { 246 {
244 int mat = op->material; 247 int mat = op->material;
245 248
246 if (mat & M_PAPER 249 if (mat & M_PAPER
247 || mat & M_LEATHER 250 || mat & M_LEATHER
248 || mat & M_WOOD 251 || mat & M_WOOD
249 || mat & M_ORGANIC 252 || mat & M_ORGANIC
250 || mat & M_CLOTH 253 || mat & M_CLOTH
251 || mat & M_LIQUID 254 || mat & M_LIQUID
252 || (mat & M_IRON && rndm (1, 5) == 1) 255 || (mat & M_IRON && rndm (1, 5) == 1)
253 || (mat & M_GLASS && rndm (1, 2) == 1) 256 || (mat & M_GLASS && rndm (1, 2) == 1)
254 || ((mat & M_STONE || mat & M_ADAMANT) && rndm (1, 10) == 1) 257 || ((mat & M_STONE || mat & M_ADAMANT) && rndm (1, 10) == 1)
255 || ((mat & M_SOFT_METAL || mat & M_BONE) && rndm (1, 3) == 1) 258 || ((mat & M_SOFT_METAL || mat & M_BONE) && rndm (1, 3) == 1)
256 || (mat & M_ICE && temp > 32)) 259 || (mat & M_ICE && temp > 32))
257 destroy = 1; 260 destroy = 1;
258 } 261 }
259 262
260 /* adjust overall chance below */ 263 /* adjust overall chance below */
261 if (destroy && rndm (0, 1)) 264 if (destroy && rndm (0, 1))
262 op->destroy (); 265 op->destroy ();
263 } 266 }
264} 267}
265 268
266/* convert materialname to materialtype_t */ 269/* convert materialname to materialtype_t */
267 270
268materialtype_t * 271materialtype_t *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines