--- deliantra/server/common/friend.C 2006/09/10 16:00:23 1.5 +++ deliantra/server/common/friend.C 2007/01/06 14:42:28 1.8 @@ -1,12 +1,7 @@ - -/* - * static char *rcsid_friend_c = - * "$Id: friend.C,v 1.5 2006/09/10 16:00:23 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows + Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team Copyright (C) 2002 Mark Wedel & Crossfire Development Team Copyright (C) 1992 Frank Tore Johansen @@ -24,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at */ #include @@ -56,7 +51,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; } @@ -83,7 +77,7 @@ { obj = first_friendly_object; first_friendly_object = obj->next; - free (obj); + delete obj; } else { @@ -95,18 +89,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; } } } @@ -134,26 +121,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); }