--- deliantra/server/common/friend.C 2006/09/14 22:33:58 1.6 +++ deliantra/server/common/friend.C 2006/10/15 02:16:34 1.7 @@ -50,7 +50,6 @@ ol = first_friendly_object; first_friendly_object = get_objectlink (); first_friendly_object->ob = op; - first_friendly_object->id = op->count; first_friendly_object->next = ol; } @@ -77,7 +76,7 @@ { obj = first_friendly_object; first_friendly_object = obj->next; - free (obj); + delete obj; } else { @@ -89,18 +88,11 @@ break; prev = obj; } + if (obj) { - /* This should not happen. But if it does, presumably the - * call to remove it is still valid. - */ - if (obj->id != op->count) - { - LOG (llevError, "remove_friendly_object, tags do no match, %s, %d != %d\n", - op->name ? (const char *) op->name : "none", op->count, obj->id); - } prev->next = obj->next; - free (obj); + delete obj; } } } @@ -128,26 +120,24 @@ objectlink *obj, *prev = NULL, *next; int count = 0; - for (obj = first_friendly_object; obj != NULL; obj = next) + for (obj = first_friendly_object; obj; obj = next) { next = obj->next; - if (QUERY_FLAG (obj->ob, FLAG_FREED) || !QUERY_FLAG (obj->ob, FLAG_FRIENDLY) || (obj->id != obj->ob->count)) + if (QUERY_FLAG (obj->ob, FLAG_FREED) || !QUERY_FLAG (obj->ob, FLAG_FRIENDLY)) { if (prev) - { - prev->next = obj->next; - } + prev->next = obj->next; else - { - first_friendly_object = obj->next; - } + first_friendly_object = obj->next; + count++; - free (obj); + delete obj; } - /* If we removed the object, then prev is still valid. */ else + /* If we removed the object, then prev is still valid. */ prev = obj; } + if (count) LOG (llevDebug, "clean_friendly_list: Removed %d bogus links\n", count); }