--- deliantra/server/common/utils.C 2006/12/16 21:40:26 1.24 +++ deliantra/server/common/utils.C 2006/12/25 14:54:44 1.31 @@ -208,27 +208,31 @@ 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 < m->width; x++) + for (y = 0; y < m->height; y++) + for (op = GET_MAP_OB (m, x, y); 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) || - QUERY_FLAG (op, FLAG_UNIQUE) || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) || QUERY_FLAG (op, FLAG_UNPAID) || IS_LIVE (op)) + if (QUERY_FLAG (op, FLAG_IS_FLOOR) + || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) + || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) + || QUERY_FLAG (op, FLAG_UNIQUE) + || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) + || QUERY_FLAG (op, FLAG_UNPAID) + || op->is_alive ()) continue; + /* otherwise, we decay and destroy */ - if (IS_WEAPON (op)) + if (op->is_weapon ()) { op->stats.dam--; if (op->stats.dam < 0) destroy = 1; } - else if (IS_ARMOR (op)) + else if (op->is_armor ()) { op->stats.ac--; if (op->stats.ac < 0) @@ -253,7 +257,7 @@ 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 && m->temp > 32) destroy = 1; } /* adjust overall chance below */ @@ -297,7 +301,7 @@ if (change->materialname != NULL && strcmp (op->materialname, change->materialname)) return; - if (!IS_ARMOR (op)) + if (!op->is_armor ()) return; mt = name_to_material (op->materialname); @@ -353,7 +357,7 @@ difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0)) { lmt = mt; - if (!(IS_WEAPON (op) || IS_ARMOR (op))) + if (!(op->is_weapon () || op->is_armor ())) break; } } @@ -371,7 +375,7 @@ return; #else - if (op->stats.dam && IS_WEAPON (op)) + if (op->stats.dam && op->is_weapon ()) { op->stats.dam += lmt->damage; if (op->stats.dam < 1) @@ -379,9 +383,9 @@ } if (op->stats.sp && op->type == BOW) op->stats.sp += lmt->sp; - if (op->stats.wc && IS_WEAPON (op)) + if (op->stats.wc && op->is_weapon ()) op->stats.wc += lmt->wc; - if (IS_ARMOR (op)) + if (op->is_armor ()) { if (op->stats.ac) op->stats.ac += lmt->ac; @@ -397,7 +401,7 @@ } op->materialname = add_string (lmt->name); /* dont make it unstackable if it doesn't need to be */ - if (IS_WEAPON (op) || IS_ARMOR (op)) + if (op->is_weapon () || op->is_armor ()) { op->weight = (op->weight * lmt->weight) / 100; op->value = (op->value * lmt->value) / 100; @@ -542,26 +546,9 @@ ///////////////////////////////////////////////////////////////////////////// -#if 0 -refcounted *refcounted::rc_first; - -refcounted::refcounted () -{ - refcnt = 0; - rc_next = rc_first; - rc_first = this; -} - -refcounted::~refcounted () -{ - assert (!rc_next); - assert (!refcnt); -} -#endif - -void *salloc (int size) throw (std::bad_alloc) +void *salloc_ (int n) throw (std::bad_alloc) { - void *ptr = g_slice_alloc (size); + void *ptr = g_slice_alloc (n); if (!ptr) throw std::bad_alloc (); @@ -569,14 +556,14 @@ return ptr; } -void *salloc (int size, void *src) throw (std::bad_alloc) +void *salloc_ (int n, void *src) throw (std::bad_alloc) { - void *ptr = salloc (size); + void *ptr = salloc_ (n); if (src) - memcpy (ptr, src, size); + memcpy (ptr, src, n); else - memset (ptr, 0, size); + memset (ptr, 0, n); return ptr; }