--- deliantra/server/common/utils.C 2006/12/23 16:05:19 1.28 +++ deliantra/server/common/utils.C 2006/12/31 18:10:40 1.33 @@ -197,25 +197,23 @@ return (RANDOM () % diff + min); } -/* decay and destroy persihable items in a map */ - +/* decay and destroy perishable items in a map */ void -decay_objects (maptile *m) +maptile::decay_objects () { int x, y, destroy; object *op, *otmp; - if (m->unique) - return; - - for (x = 0; x < MAP_WIDTH (m); x++) - for (y = 0; y < MAP_HEIGHT (m); y++) - for (op = GET_MAP_OB (m, x, y); op; op = otmp) + for (x = 0; x < width; x++) + for (y = 0; y < height; y++) + for (op = at (x, y).bot; op; op = otmp) { destroy = 0; otmp = op->above; + if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) break; + if (QUERY_FLAG (op, FLAG_IS_FLOOR) || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) @@ -249,17 +247,23 @@ if (op->material & M_PAPER || op->material & M_LEATHER || op->material & M_WOOD || op->material & M_ORGANIC || op->material & M_CLOTH || op->material & M_LIQUID) destroy = 1; + if (op->material & M_IRON && rndm (1, 5) == 1) destroy = 1; + if (op->material & M_GLASS && rndm (1, 2) == 1) destroy = 1; + if ((op->material & M_STONE || op->material & M_ADAMANT) && rndm (1, 10) == 1) destroy = 1; + if ((op->material & M_SOFT_METAL || op->material & M_BONE) && rndm (1, 3) == 1) destroy = 1; - if (op->material & M_ICE && MAP_TEMP (m) > 32) + + if (op->material & M_ICE && temp > 32) destroy = 1; } + /* adjust overall chance below */ if (destroy && rndm (0, 1)) op->destroy (); @@ -546,25 +550,6 @@ ///////////////////////////////////////////////////////////////////////////// -#if 0 -refcounted *refcounted::rc_first; - -refcounted::refcounted () -{ - refcnt = 0; - rc_next = rc_first; - rc_first = this; -} -#endif - -refcounted::~refcounted () -{ -#if 0 - assert (!rc_next); - assert (!refcnt); -#endif -} - void *salloc_ (int n) throw (std::bad_alloc) { void *ptr = g_slice_alloc (n); @@ -619,3 +604,13 @@ return tstamp (tv.tv_sec) + tstamp (tv.tv_usec) * tstamp (1e-6); } +int +similar_direction (int a, int b) +{ + if (!a || !b) + return 0; + + int diff = (b - a) & 7; + return diff <= 1 || diff >= 7; +} +