diff --git a/projects/openttd_vs90.vcproj.user b/projects/openttd_vs90.vcproj.user
new file mode 100644
index 0000000000..b49492a503
--- /dev/null
+++ b/projects/openttd_vs90.vcproj.user
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 09329b84f5..c6eb90ca97 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -315,7 +315,7 @@ FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath sp, Subd
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
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 2a454bf1a1..ccc268b30d 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1383,7 +1383,7 @@ static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type)
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 @@ static bool CheckIfFarEnoughFromIndustry(TileIndex tile, int type)
/* 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 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept
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 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept
}
/* 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 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
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. */
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index b1ce866011..dacef46ec8 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -410,7 +410,6 @@ void ScanNewGRFFiles()
* For that we first have to make an array, the qsort and
* then remake the linked list. */
GRFConfig **to_sort = MallocT(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 @@ void ScanNewGRFFiles()
}
to_sort[num - 1]->next = NULL;
_all_grfs = to_sort[0];
+
+ free(to_sort);
}
diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp
index 57ca37790f..210eb8d10e 100644
--- a/src/newgrf_spritegroup.cpp
+++ b/src/newgrf_spritegroup.cpp
@@ -204,6 +204,7 @@ static inline const SpriteGroup *ResolveVariable(const SpriteGroup *group, Resol
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;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 2587e53708..ae73e3779d 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -897,6 +897,9 @@ void SwitchMode(int new_mode)
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);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index d7be418ef7..56b00adc28 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -422,7 +422,7 @@ static const GameSettingData _game_setting_info[] = {
/*
* 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 GameSettingData _game_setting_info[] = {
*/
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)