--- deliantra/server/common/friend.C 2006/08/13 17:16:00 1.1 +++ deliantra/server/common/friend.C 2006/08/29 08:01:35 1.2 @@ -1,6 +1,6 @@ /* * static char *rcsid_friend_c = - * "$Id: friend.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; + * "$Id: friend.C,v 1.2 2006/08/29 08:01:35 root Exp $"; */ /* @@ -42,11 +42,11 @@ * the debugger here and see where the problem is happening. */ for (ol=first_friendly_object; ol!=NULL; ol=ol->next) { - if (ol->ob == op) { - LOG(llevError, "add_friendly_object: Trying to add object already on list (%s)\n", - op->name); - return; - } + if (ol->ob == op) { + LOG(llevError, "add_friendly_object: Trying to add object already on list (%s)\n", + op->name); + return; + } } ol=first_friendly_object; @@ -66,34 +66,34 @@ CLEAR_FLAG(op,FLAG_FRIENDLY); if (!first_friendly_object) { - LOG(llevError,"remove_friendly_object called with empty friendly list, remove ob=%s\n", op->name); - return; + LOG(llevError,"remove_friendly_object called with empty friendly list, remove ob=%s\n", op->name); + return; } /* if the first object happens to be the one, processing is pretty * easy. */ if(first_friendly_object->ob==op) { - obj=first_friendly_object; - first_friendly_object=obj->next; - free(obj); + obj=first_friendly_object; + first_friendly_object=obj->next; + free(obj); } else { - objectlink *prev=first_friendly_object; + objectlink *prev=first_friendly_object; - for (obj=first_friendly_object->next; obj!=NULL; obj=obj->next) { - if (obj->ob == op) 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?op->name:"none", op->count, obj->id); - } - prev->next = obj->next; - free(obj); - } + for (obj=first_friendly_object->next; obj!=NULL; obj=obj->next) { + if (obj->ob == op) 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?op->name:"none", op->count, obj->id); + } + prev->next = obj->next; + free(obj); + } } } @@ -105,7 +105,7 @@ objectlink *ol; for(ol=first_friendly_object;ol!=NULL;ol=ol->next) - LOG(llevError, "%s (%d)\n",ol->ob->name,ol->ob->count); + LOG(llevError, "%s (%d)\n",ol->ob->name,ol->ob->count); } /* New function, MSW 2000-1-14 @@ -117,24 +117,24 @@ int count=0; for (obj=first_friendly_object; obj!=NULL; obj=next) { - next=obj->next; - if (QUERY_FLAG(obj->ob, FLAG_FREED) || - !QUERY_FLAG(obj->ob, FLAG_FRIENDLY) || - (obj->id != obj->ob->count)) { - if (prev) { - prev->next = obj->next; - } - else { - first_friendly_object = obj->next; - } - count++; - free(obj); - } - /* If we removed the object, then prev is still valid. */ - else prev=obj; + next=obj->next; + if (QUERY_FLAG(obj->ob, FLAG_FREED) || + !QUERY_FLAG(obj->ob, FLAG_FRIENDLY) || + (obj->id != obj->ob->count)) { + if (prev) { + prev->next = obj->next; + } + else { + first_friendly_object = obj->next; + } + count++; + free(obj); + } + /* If we removed the object, then prev is still valid. */ + else prev=obj; } if (count) - LOG(llevDebug,"clean_friendly_list: Removed %d bogus links\n", count); + LOG(llevDebug,"clean_friendly_list: Removed %d bogus links\n", count); } /* Checks if the given object is already in the friendly list or not