From fef0f6da52cc55177bfdc76bf1149ad5e5bb4627 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Fri, 2 Aug 2002 18:20:14 +0000
Subject: [PATCH] Fixed warning and perhaps code, nice programming alternative
 added.

---
 src/pathfinder/hierarchical.cpp  |  2 +-
 src/pathfinder/region_groups.cpp | 50 +++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/src/pathfinder/hierarchical.cpp b/src/pathfinder/hierarchical.cpp
index 738a63462..718303c13 100644
--- a/src/pathfinder/hierarchical.cpp
+++ b/src/pathfinder/hierarchical.cpp
@@ -52,7 +52,7 @@ int PfHierShowGroupIds = 1;
 local void AreaDestroyRegions (int , int );
 local int AreasInitialize (void);
 local void AreasDestroy (void);
-local void AreasFillRegionLists (void);
+// local void AreasFillRegionLists (void);
 local int PfHierGetPrecomputed (Unit * , int * , int * );
 local int ResolveDeadlock (Unit * , Unit * , int * , int * );
 local int GetGroupIds (int , int , int , int , unsigned short ** );
diff --git a/src/pathfinder/region_groups.cpp b/src/pathfinder/region_groups.cpp
index 1ab4dfc7e..f7e1c9dae 100644
--- a/src/pathfinder/region_groups.cpp
+++ b/src/pathfinder/region_groups.cpp
@@ -608,25 +608,47 @@ local void MovementTypeAddSuperGroup (int type, SuperGroup *s)
 	}
 }
 
-local void MovementTypeDeleteSuperGroup (int type, SuperGroup *sg)
+local void MovementTypeDeleteSuperGroup(int type, SuperGroup * sg)
 {
-	SuperGroup *s, *p;
+#if 1
+    SuperGroup *s;
+    SuperGroup *p;
 
-	if (MovementTypes[type].SuperGroups == NULL)
-		return;
+    if (MovementTypes[type].SuperGroups == NULL) {
+	return;
+    }
 
-	if (MovementTypes[type].SuperGroups == sg) {
-		MovementTypes[type].SuperGroups = MovementTypes[type].SuperGroups->Next;
-		sg->Next = NULL;
-		return;
+    if (MovementTypes[type].SuperGroups == sg) {
+	MovementTypes[type].SuperGroups =
+	    MovementTypes[type].SuperGroups->Next;
+	sg->Next = NULL;
+	return;
+    }
+
+    DebugLevel0Fn("FIXME: s unintialized, please control my fix!\n");
+    for (p = MovementTypes[type].SuperGroups, s = p->Next;
+		s; p = s, s = s->Next) {
+	if (s == sg) {
+	    p->Next = s->Next;
+	    s->Next = NULL;
+	    return;
 	}
+    }
+#else
+    // JOHNS: should do the same as the above part :)
+    SuperGroup **p;
+    SuperGroup *s;
 
-	for (p = MovementTypes[type].SuperGroups, s; s; p=s, s=s->Next)
-		if (s == sg) {
-			p->Next = s->Next;
-			s->Next = NULL;
-			return;
-		}
+    p = &MovementTypes[type].SuperGroups;
+    while ((s=*p)) {
+	if (s == sg) {
+	    *p = s->Next;
+	    s->Next = NULL;
+	    return;
+	}
+	p = &s->Next;
+    }
+#endif
 }
 
 local int MovementTypeCheckPassability (int type, unsigned short flags)