(svn r9351) [0.5] -Backport from trunk (r9147, r9205, r9251, r9298): 0.5
authorrubidium
Mon, 19 Mar 2007 20:38:26 +0000
branch0.5
changeset 5468 10836820b2bc
parent 5467 24a2a4d58223
child 5469 e0b2d7d37916
(svn r9351) [0.5] -Backport from trunk (r9147, r9205, r9251, r9298):
- Fix: when loadin games, enroute_from was updated in the wrong place, causing issues with TTD savegames/scenarios (r9147)
- Fix: when you started openttd with '-g' you got the same map every run (r9205)
- Fix: use a less CPU-intensive algorithm to find a random industry for the AI to prevent it slowing down the game (r9251)
- Fix: A34-1000, Z-Shuttle, and Kelling K1 are now listed as small aircraft (r9298)
ai/default/default.c
openttd.c
station_cmd.c
table/engines.h
--- a/ai/default/default.c	Mon Mar 19 20:23:27 2007 +0000
+++ b/ai/default/default.c	Mon Mar 19 20:38:26 2007 +0000
@@ -459,7 +459,10 @@
 
 static Industry *AiFindRandomIndustry(void)
 {
-	return GetRandomIndustry();
+	int num = RandomRange(GetMaxIndustryIndex());
+	if (IsValidIndustry(GetIndustry(num))) return GetIndustry(num);
+
+	return NULL;
 }
 
 static void AiFindSubsidyIndustryRoute(FoundRoute *fr)
--- a/openttd.c	Mon Mar 19 20:23:27 2007 +0000
+++ b/openttd.c	Mon Mar 19 20:38:26 2007 +0000
@@ -385,6 +385,8 @@
 				_switch_mode = SM_LOAD;
 			} else {
 				_switch_mode = SM_NEWGAME;
+				/* Give a random map */
+				generation_seed = InteractiveRandom();
 			}
 			break;
 		case 'G': generation_seed = atoi(mgo.opt); break;
@@ -1594,6 +1596,21 @@
 		}
 	}
 
+	if (CheckSavegameVersion(7)) {
+		Station *st;
+		FOR_ALL_STATIONS(st) {
+			CargoID c;
+			for (c = 0; c < NUM_CARGO; c++) {
+				GoodsEntry *ge = &st->goods[c];
+
+				/* In old versions, enroute_from used 0xFF as INVALID_STATION */
+				if (ge->enroute_from == 0xFF) {
+					ge->enroute_from = INVALID_STATION;
+				}
+			}
+		}
+	}
+
 	return true;
 }
 
--- a/station_cmd.c	Mon Mar 19 20:23:27 2007 +0000
+++ b/station_cmd.c	Mon Mar 19 20:38:26 2007 +0000
@@ -3064,11 +3064,6 @@
 	SlObject(st, _station_desc);
 	for (i = 0; i != NUM_CARGO; i++) {
 		SlObject(&st->goods[i], _goods_desc);
-
-		/* In older versions, enroute_from had 0xFF as INVALID_STATION, is now 0xFFFF */
-		if (CheckSavegameVersion(7) && st->goods[i].enroute_from == 0xFF) {
-			st->goods[i].enroute_from = INVALID_STATION;
-		}
 	}
 
 	if (st->num_specs != 0) {
--- a/table/engines.h	Mon Mar 19 20:23:27 2007 +0000
+++ b/table/engines.h	Mon Mar 19 20:38:26 2007 +0000
@@ -555,9 +555,9 @@
 	AVI(  4, 26, 210, J, SND_09_JET,                     40,  74, 20, 220 ), /* 21 */
 	AVI(  6, 16, 125, P, SND_09_JET,                     50,  74, 10,  80 ), /* 22 */
 	AVI(  2, 17, 145, P, SND_09_JET,                     40,  74, 10,  85 ), /* 23 */
-	AVI( 11, 16, 130, J, SND_09_JET,                     40,  74, 10,  75 ), /* 24 */
-	AVI( 10, 16, 149, J, SND_09_JET,                     40,  74, 10,  85 ), /* 25 */
-	AVI( 15, 17, 170, J, SND_09_JET,                     40,  74, 18,  65 ), /* 26 */
+	AVI( 11, 16, 130, P, SND_09_JET,                     40,  74, 10,  75 ), /* 24 */
+	AVI( 10, 16, 149, P, SND_09_JET,                     40,  74, 10,  85 ), /* 25 */
+	AVI( 15, 17, 170, P, SND_09_JET,                     40,  74, 18,  65 ), /* 26 */
 	AVI( 12, 18, 210, J, SND_09_JET,                     40,  74, 25, 110 ), /* 27 */
 	AVI( 13, 20, 230, J, SND_09_JET,                     40,  74, 60, 180 ), /* 28 */
 	AVI( 14, 21, 220, J, SND_09_JET,                     40,  74, 65, 150 ), /* 29 */