diff src/saveload/afterload.cpp @ 16120:9c19ce78d8ec draft

(svn r20816) -Codechange [FS#3835]: make waypoint default names work like depots, stations and vehicles (Krille)
author rubidium <rubidium@openttd.org>
date Thu, 16 Sep 2010 16:31:57 +0000
parents 6b3718ff071d
children 9994b0118198
line wrap: on
line diff
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2295,6 +2295,19 @@
 				SetWaterClass(t, WATER_CLASS_INVALID);
 			}
 		}
+
+		/* Waypoints with custom name may have a non-unique town_cn,
+		 * renumber those. First set all affected waypoints to the
+		 * highest possible number to get them numbered in the
+		 * order they have in the pool. */
+		Waypoint *wp;
+		FOR_ALL_WAYPOINTS(wp) {
+			if (wp->name != NULL) wp->town_cn = UINT16_MAX;
+		}
+
+		FOR_ALL_WAYPOINTS(wp) {
+			if (wp->name != NULL) MakeDefaultName(wp);
+		}
 	}
 
 	/* Road stops is 'only' updating some caches */