--- deliantra/server/common/object.C 2007/01/19 18:06:51 1.119 +++ deliantra/server/common/object.C 2007/01/29 21:04:32 1.127 @@ -672,8 +672,7 @@ object::~object () { - if (index) - unlink (); + unlink (); free_key_values (this); } @@ -692,7 +691,9 @@ void object::unlink () { - assert (index);//D + if (!index) + return; + objects.erase (this); refcnt_dec (); } @@ -776,6 +777,7 @@ if (!drop_to_ground || !map || map->in_memory != MAP_IN_MEMORY + || map->nodrop || ms ().move_block == MOVE_ALL) { while (inv) @@ -819,7 +821,15 @@ remove_button_link (this); if (flag [FLAG_FRIENDLY]) - remove_friendly_object (this); + { + remove_friendly_object (this); + + if (type == GOLEM + && owner + && owner->type == PLAYER + && owner->contr->ranges[range_golem] == this) + owner->contr->ranges[range_golem] = 0; + } if (!flag [FLAG_REMOVED]) remove (); @@ -901,7 +911,6 @@ * object will have no environment. If the object previously had an * environment, the x and y coordinates will be updated to * the previous environment. - * Beware: This function is called from the editor as well! */ void object::remove_slow () @@ -1751,7 +1760,7 @@ { float - diff = tmp->move_slow_penalty * FABS (op->speed); + diff = tmp->move_slow_penalty * fabs (op->speed); if (op->type == PLAYER) if ((QUERY_FLAG (tmp, FLAG_IS_HILLY) && find_skill_by_number (op, SK_CLIMBING)) || @@ -1968,7 +1977,7 @@ if (!index) return -1; - return altern[RANDOM () % index]; + return altern [rndm (index)]; } /* @@ -1999,7 +2008,7 @@ end -= begin; while (--end) - swap (arr [end], arr [RANDOM () % (end + 1)]); + swap (arr [end], arr [rndm (end + 1)]); } /* new function to make monster searching more efficient, and effective! @@ -2571,7 +2580,7 @@ char info2[256 * 4]; char *p = info; - p += snprintf (p, 512, "{cnt:%d,uuid:<1,%" PRIx64 ">,name:\"%s\"%s%s,flags:[%s],type:%d}", + p += snprintf (p, 512, "{cnt:%d,uuid:<1.%" PRIx64 ">,name:\"%s\"%s%s,flags:[%s],type:%d}", count, uuid.seq, &name, title ? "\",title:\"" : "", @@ -2601,3 +2610,10 @@ return debug_desc (info); } +struct region * +object::region () const +{ + return map ? map->region (x, y) + : region::default_region (); +} +