(svn r13199) [0.6] -Backport from trunk (r12933, r12943, r12947, r12948, r12951, r12993, r12996): 0.6
authorrubidium
Tue, 20 May 2008 20:03:45 +0000
branch0.6
changeset 10655 b862a4add8b0
parent 10654 e511144c1b70
child 10656 8bea44dae56f
(svn r13199) [0.6] -Backport from trunk (r12933, r12943, r12947, r12948, r12951, r12993, r12996):
- Fix: Debugging was not possible with MSVC 2008 (r12996)
- Fix: List used for sorting GRFs was not freed (r12993)
- Fix: Default difficulty settings were different to TTD's original settings [FS#1977] (r12951)
- Fix: All vehicles would be available when an original scenario would be played [FS#1982] (r12948)
- Fix: Keep only first 15 bits for non failed callback results (r12947)
- Fix: Reading/modifying invalid data under some circumstances (r12943)
- Fix: Minor errors related to industries accepted/produced cargo (r12933)
projects/openttd_vs90.vcproj.user
src/fileio.cpp
src/industry_cmd.cpp
src/newgrf_config.cpp
src/newgrf_spritegroup.cpp
src/openttd.cpp
src/settings_gui.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/projects/openttd_vs90.vcproj.user	Tue May 20 20:03:45 2008 +0000
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="9.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				WorkingDirectory="..\bin"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				WorkingDirectory="..\bin"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			>
+			<DebugSettings
+				WorkingDirectory="..\bin"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			>
+			<DebugSettings
+				WorkingDirectory="..\bin"
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>
--- a/src/fileio.cpp	Tue May 20 19:57:22 2008 +0000
+++ b/src/fileio.cpp	Tue May 20 20:03:45 2008 +0000
@@ -315,7 +315,7 @@
 	f = fopen(buf, mode);
 #if !defined(WIN32)
 	if (f == NULL) {
-		strtolower(buf + strlen(_searchpaths[sp]) - 1);
+		strtolower(buf + ((subdir == NO_DIRECTORY) ? 0 : strlen(_searchpaths[sp]) - 1));
 		f = fopen(buf, mode);
 	}
 #endif
--- a/src/industry_cmd.cpp	Tue May 20 19:57:22 2008 +0000
+++ b/src/industry_cmd.cpp	Tue May 20 20:03:45 2008 +0000
@@ -1383,7 +1383,7 @@
 	const IndustrySpec *indspec = GetIndustrySpec(type);
 	const Industry *i;
 
-	if (_patches.same_industry_close && indspec->accepts_cargo[0] == CT_INVALID)
+	if (_patches.same_industry_close && indspec->IsRawIndustry())
 		/* Allow primary industries to be placed close to any other industry */
 		return true;
 
@@ -1393,7 +1393,7 @@
 
 		/* check if an industry that accepts the same goods is nearby */
 		if (in_low_distance &&
-				indspec->accepts_cargo[0] != CT_INVALID && // not a primary industry?
+				!indspec->IsRawIndustry() && // not a primary industry?
 				indspec->accepts_cargo[0] == i->accepts_cargo[0] && (
 				/* at least one of those options must be true */
 				_game_mode != GM_EDITOR || // editor must not be stopped
@@ -1896,7 +1896,8 @@
 	const IndustrySpec *indspec = GetIndustrySpec(ind->type);
 
 	/* Check for acceptance of cargo */
-	for (uint j = 0; j < lengthof(ind->accepts_cargo) && ind->accepts_cargo[j] != CT_INVALID; j++) {
+	for (byte j = 0; j < lengthof(ind->accepts_cargo); j++) {
+		if (ind->accepts_cargo[j] == CT_INVALID) continue;
 		if (cargo == ind->accepts_cargo[j]) {
 			if (HasBit(indspec->callback_flags, CBM_IND_REFUSE_CARGO)) {
 				uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO,
@@ -1910,7 +1911,8 @@
 	}
 
 	/* Check for produced cargo */
-	for (uint j = 0; j < lengthof(ind->produced_cargo) && ind->produced_cargo[j] != CT_INVALID; j++) {
+	for (byte j = 0; j < lengthof(ind->produced_cargo); j++) {
+		if (ind->produced_cargo[j] == CT_INVALID) continue;
 		if (cargo == ind->produced_cargo[j]) {
 			*c_produces = true;
 			break;
@@ -2072,7 +2074,8 @@
 
 		if (smooth_economy) {
 			closeit = true;
-			for (byte j = 0; j < 2 && i->produced_cargo[j] != CT_INVALID; j++){
+			for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
+				if (i->produced_cargo[j] == CT_INVALID) continue;
 				uint32 r = Random();
 				int old_prod, new_prod, percent;
 				/* If over 60% is transported, mult is 1, else mult is -1. */
--- a/src/newgrf_config.cpp	Tue May 20 19:57:22 2008 +0000
+++ b/src/newgrf_config.cpp	Tue May 20 20:03:45 2008 +0000
@@ -410,7 +410,6 @@
 	 * For that we first have to make an array, the qsort and
 	 * then remake the linked list. */
 	GRFConfig **to_sort = MallocT<GRFConfig*>(num);
-	if (to_sort == NULL) return; // No memory, then don't sort
 
 	uint i = 0;
 	for (GRFConfig *p = _all_grfs; p != NULL; p = p->next, i++) {
@@ -426,6 +425,8 @@
 	}
 	to_sort[num - 1]->next = NULL;
 	_all_grfs = to_sort[0];
+
+	free(to_sort);
 }
 
 
--- a/src/newgrf_spritegroup.cpp	Tue May 20 19:57:22 2008 +0000
+++ b/src/newgrf_spritegroup.cpp	Tue May 20 20:03:45 2008 +0000
@@ -204,6 +204,7 @@
 
 	if (group->g.determ.num_ranges == 0) {
 		/* nvar == 0 is a special case -- we turn our value into a callback result */
+		if (value != CALLBACK_FAILED) value = GB(value, 0, 15);
 		nvarzero.type = SGT_CALLBACK;
 		nvarzero.g.callback.result = value;
 		return &nvarzero;
--- a/src/openttd.cpp	Tue May 20 19:57:22 2008 +0000
+++ b/src/openttd.cpp	Tue May 20 20:03:45 2008 +0000
@@ -897,6 +897,9 @@
 			SetDParamStr(0, GetSaveLoadErrorString());
 			ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
 		} else {
+			if (_saveload_mode == SLD_LOAD_SCENARIO) {
+				StartupEngines();
+			}
 			/* Update the local player for a loaded game. It is either always
 			 * player #1 (eg 0) or in the case of a dedicated server a spectator */
 			SetLocalPlayer(_network_dedicated ? PLAYER_SPECTATOR : PLAYER_FIRST);
--- a/src/settings_gui.cpp	Tue May 20 19:57:22 2008 +0000
+++ b/src/settings_gui.cpp	Tue May 20 20:03:45 2008 +0000
@@ -422,7 +422,7 @@
 /*
  * A: competitors
  * B: start time in months / 3
- * C: town count (2 = high, 0 = very low)
+ * C: town count (3 = high, 0 = very low)
  * D: industry count (4 = high, 0 = none)
  * E: inital loan / 1000 (in GBP)
  * F: interest rate
@@ -441,9 +441,9 @@
  */
 static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
 	 A, B, C, D,   E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
-	{2, 2, 1, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy
-	{4, 1, 1, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium
-	{7, 0, 0, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard
+	{2, 2, 2, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy
+	{4, 1, 2, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium
+	{7, 0, 3, 3, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard
 };
 
 void SetDifficultyLevel(int mode, GameOptions *gm_opt)