(svn r4782) - Newstations: fix issue with saving/loading games with newstations on big endian architectures.
authorpeter1138
Mon, 08 May 2006 13:35:25 +0000
changeset 3786 73784d02aa69
parent 3785 1becd6b333fe
child 3787 a71d1c53e679
(svn r4782) - Newstations: fix issue with saving/loading games with newstations on big endian architectures.
newgrf_station.c
station.h
--- a/newgrf_station.c	Mon May 08 10:01:34 2006 +0000
+++ b/newgrf_station.c	Mon May 08 13:35:25 2006 +0000
@@ -18,6 +18,10 @@
 
 static StationClass station_classes[STAT_CLASS_MAX];
 
+enum {
+	MAX_SPECLIST = 255,
+};
+
 /**
  * Reset station classes to their default state.
  * This includes initialising the Default and Waypoint classes with an empty
@@ -539,15 +543,15 @@
 	if (statspec == NULL) return 0;
 
 	/* Check if this spec has already been allocated */
-	for (i = 1; i < st->num_specs && i < 256; i++) {
+	for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) {
 		if (st->speclist[i].spec == statspec) return i;
 	}
 
-	for (i = 1; i < st->num_specs && i < 256; i++) {
+	for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) {
 		if (st->speclist[i].spec == NULL && st->speclist[i].grfid == 0) break;
 	}
 
-	if (i == 256) return -1;
+	if (i == MAX_SPECLIST) return -1;
 
 	if (exec) {
 		if (i >= st->num_specs) {
--- a/station.h	Mon May 08 10:01:34 2006 +0000
+++ b/station.h	Mon May 08 13:35:25 2006 +0000
@@ -72,7 +72,7 @@
 	byte trainst_w, trainst_h;
 
 	/** List of custom stations (StationSpecs) allocated to the station */
-	uint num_specs;
+	uint8 num_specs;
 	StationSpecList *speclist;
 
 	uint16 build_date;