--- a/src/openttd.cpp Mon May 26 20:45:25 2008 +0000
+++ b/src/openttd.cpp Tue May 27 00:50:55 2008 +0000
@@ -41,7 +41,7 @@
#include "fios.h"
#include "airport.h"
#include "aircraft.h"
-#include "console.h"
+#include "console_func.h"
#include "screenshot.h"
#include "network/network.h"
#include "signs_base.h"
@@ -100,7 +100,7 @@
void ProcessAsyncSaveFinish();
void CallWindowTickEvent();
-extern void SetDifficultyLevel(int mode, GameOptions *gm_opt);
+extern void SetDifficultyLevel(int mode, DifficultySettings *gm_opt);
extern Player* DoStartupNewPlayer(bool is_ai);
extern void ShowOSErrorBox(const char *buf);
extern void InitializeRailGUI();
@@ -284,7 +284,6 @@
{
/* Dynamic stuff needs to be initialized somewhere... */
_town_sort = NULL;
- _industry_sort = NULL;
_industry_mngr.ResetMapping();
_industile_mngr.ResetMapping();
}
@@ -318,7 +317,6 @@
_Engine_pool.CleanPool();
free((void*)_town_sort);
- free((void*)_industry_sort);
free(_config_file);
@@ -330,7 +328,6 @@
{
_game_mode = GM_MENU;
- _opt_ptr = &_opt_newgame;
ResetGRFConfig(false);
/* Setup main window */
@@ -486,8 +483,8 @@
if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
- if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
- if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
+ if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
+ if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
/* The width and height must be at least 1 pixel, this
* way all internal drawing routines work correctly. */
@@ -581,17 +578,13 @@
ScanNewGRFFiles();
- _opt_ptr = &_opt_newgame;
ResetGRFConfig(false);
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */
- if (_opt_newgame.diff_level == 9) SetDifficultyLevel(0, &_opt_newgame);
+ if (_settings_newgame.difficulty.diff_level == 9) SetDifficultyLevel(0, &_settings_newgame.difficulty);
- /* Make sure _patches is filled with _patches_newgame if we switch to a game directly */
- if (_switch_mode != SM_NONE) {
- _opt = _opt_newgame;
- UpdatePatches();
- }
+ /* Make sure _settings is filled with _settings_newgame if we switch to a game directly */
+ if (_switch_mode != SM_NONE) _settings = _settings_newgame;
/* initialize the ingame console */
IConsoleInit();
@@ -651,7 +644,7 @@
{
if (_game_mode == GM_MENU) { // do not ask to quit on the main screen
_exit_game = true;
- } else if (_patches.autosave_on_exit) {
+ } else if (_settings.gui.autosave_on_exit) {
DoExitSave();
_exit_game = true;
} else {
@@ -683,9 +676,9 @@
SetLocalPlayer(PLAYER_FIRST);
_current_player = _local_player;
- DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
- SettingsDisableElrail(_patches.disable_elrails);
+ SettingsDisableElrail(_settings.vehicle.disable_elrails);
InitializeRailGUI();
#ifdef ENABLE_NETWORK
@@ -710,7 +703,7 @@
_industry_mngr.ResetMapping();
GenerateWorldSetCallback(&MakeNewGameDone);
- GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
}
static void MakeNewEditorWorldDone()
@@ -727,7 +720,7 @@
ResetGRFConfig(true);
GenerateWorldSetCallback(&MakeNewEditorWorldDone);
- GenerateWorld(GW_EMPTY, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(GW_EMPTY, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
}
void StartupPlayers();
@@ -766,9 +759,7 @@
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
}
- _opt_ptr = &_opt;
- _opt_ptr->diff = _opt_newgame.diff;
- _opt.diff_level = _opt_newgame.diff_level;
+ _settings.difficulty = _settings_newgame.difficulty;
/* Inititalize data */
StartupEconomy();
@@ -778,7 +769,7 @@
SetLocalPlayer(PLAYER_FIRST);
_current_player = _local_player;
- DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
+ DoCommandP(0, (_settings.gui.autorenew << 15 ) | (_settings.gui.autorenew_months << 16) | 4, _settings.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
MarkWholeScreenDirty();
}
@@ -837,8 +828,7 @@
/* check if we should reload the config */
if (_network_reload_cfg) {
LoadFromConfig();
- _patches = _patches_newgame;
- _opt = _opt_newgame;
+ _settings = _settings_newgame;
ResetGRFConfig(false);
}
NetworkServerStart();
@@ -874,7 +864,6 @@
break;
case SM_LOAD: { /* Load game, Play Scenario */
- _opt_ptr = &_opt;
ResetGRFConfig(true);
ResetWindowSystem();
@@ -912,16 +901,14 @@
case SM_LOAD_HEIGHTMAP: /* Load heightmap from scenario editor */
SetLocalPlayer(OWNER_NONE);
- GenerateWorld(GW_HEIGHTMAP, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(GW_HEIGHTMAP, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
MarkWholeScreenDirty();
break;
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR, NO_DIRECTORY)) {
- _opt_ptr = &_opt;
-
SetLocalPlayer(OWNER_NONE);
- _patches_newgame.starting_year = _cur_year;
+ _settings_newgame.game_creation.starting_year = _cur_year;
} else {
SetDParamStr(0, GetSaveLoadErrorString());
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
@@ -947,7 +934,7 @@
case SM_GENRANDLAND: /* Generate random land within scenario editor */
SetLocalPlayer(OWNER_NONE);
- GenerateWorld(GW_RANDOM, 1 << _patches.map_x, 1 << _patches.map_y);
+ GenerateWorld(GW_RANDOM, 1 << _settings.game_creation.map_x, 1 << _settings.game_creation.map_y);
/* XXX: set date */
MarkWholeScreenDirty();
break;
@@ -1063,16 +1050,16 @@
if (_networking) return;
#endif /* PSP */
- if (_patches.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
+ if (_settings.gui.keep_all_autosave && _local_player != PLAYER_SPECTATOR) {
SetDParam(0, _local_player);
SetDParam(1, _date);
GetString(buf, STR_4004, lastof(buf));
ttd_strlcat(buf, ".sav", lengthof(buf));
} else {
- /* generate a savegame name and number according to _patches.max_num_autosaves */
+ /* generate a savegame name and number according to _settings.gui.max_num_autosaves */
snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr);
- if (++_autosave_ctr >= _patches.max_num_autosaves) _autosave_ctr = 0;
+ if (++_autosave_ctr >= _settings.gui.max_num_autosaves) _autosave_ctr = 0;
}
DEBUG(sl, 2, "Autosaving to '%s'", buf);
@@ -1262,7 +1249,7 @@
/* since savegame version 4.2 the currencies are arranged differently */
static void UpdateCurrencies()
{
- _opt.currency = convert_currency[_opt.currency];
+ _settings.gui.currency = convert_currency[_settings.gui.currency];
}
/* Up to revision 1413 the invisible tiles at the southern border have not been
@@ -1370,6 +1357,11 @@
SetCachedEngineCounts();
+ /* Towns have a noise controlled number of airports system
+ * So each airport's noise value must be added to the town->noise_reached value
+ * Reset each town's noise_reached value to '0' before. */
+ UpdateAirportsNoise();
+
return true;
}
@@ -1420,7 +1412,7 @@
Town *t;
FOR_ALL_TOWNS(t) {
t->name = CopyFromOldName(t->townnametype);
- if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name;
+ if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
}
Waypoint *wp;
@@ -1434,7 +1426,7 @@
ResetOldNames();
/* convert road side to my format. */
- if (_opt.road_side) _opt.road_side = 1;
+ if (_settings.vehicle.road_side) _settings.vehicle.road_side = 1;
/* Check if all NewGRFs are present, we are very strict in MP mode */
GRFListCompatibility gcf_res = IsGoodGRFConfigList();
@@ -1454,7 +1446,7 @@
SetDate(_date);
/* Force dynamic engines off when loading older savegames */
- if (CheckSavegameVersion(95)) _patches.dynamic_engines = 0;
+ if (CheckSavegameVersion(95)) _settings.vehicle.dynamic_engines = 0;
/* Load the sprites */
GfxLoadSprites();
@@ -1687,9 +1679,9 @@
*/
if (!_network_dedicated && IsValidPlayer(PLAYER_FIRST)) {
p = GetPlayer(PLAYER_FIRST);
- p->engine_renew = _patches.autorenew;
- p->engine_renew_months = _patches.autorenew_months;
- p->engine_renew_money = _patches.autorenew_money;
+ p->engine_renew = _settings.gui.autorenew;
+ p->engine_renew_months = _settings.gui.autorenew_months;
+ p->engine_renew_money = _settings.gui.autorenew_money;
}
}
@@ -1971,8 +1963,6 @@
}
}
- if (CheckSavegameVersion(22)) UpdatePatches();
-
if (CheckSavegameVersion(25)) {
Vehicle *v;
FOR_ALL_VEHICLES(v) {
@@ -2074,9 +2064,9 @@
/* from version 38 we have optional elrails, since we cannot know the
* preference of a user, let elrails enabled; it can be disabled manually */
- if (CheckSavegameVersion(38)) _patches.disable_elrails = false;
+ if (CheckSavegameVersion(38)) _settings.vehicle.disable_elrails = false;
/* do the same as when elrails were enabled/disabled manually just now */
- SettingsDisableElrail(_patches.disable_elrails);
+ SettingsDisableElrail(_settings.vehicle.disable_elrails);
InitializeRailGUI();
/* From version 53, the map array was changed for house tiles to allow
@@ -2241,7 +2231,7 @@
Town *t;
FOR_ALL_TOWNS(t) {
- if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) {
+ if (_settings.economy.larger_towns != 0 && (t->index % _settings.economy.larger_towns) == 0) {
t->larger_town = true;
}
}
@@ -2278,12 +2268,12 @@
if (CheckSavegameVersion(58)) {
/* patch difficulty number_industries other then zero get bumped to +1
* since a new option (very low at position1) has been added */
- if (_opt.diff.number_industries > 0) {
- _opt.diff.number_industries++;
+ if (_settings.difficulty.number_industries > 0) {
+ _settings.difficulty.number_industries++;
}
/* Same goes for number of towns, although no test is needed, just an increment */
- _opt.diff.number_towns++;
+ _settings.difficulty.number_towns++;
}
if (CheckSavegameVersion(64)) {
@@ -2516,22 +2506,22 @@
}
/* Convert old PF settings to new */
- if (_patches.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
- _patches.pathfinder_for_trains = VPF_YAPF;
+ if (_settings.pf.yapf.rail_use_yapf || CheckSavegameVersion(28)) {
+ _settings.pf.pathfinder_for_trains = VPF_YAPF;
} else {
- _patches.pathfinder_for_trains = (_patches.new_pathfinding_all ? VPF_NPF : VPF_NTP);
+ _settings.pf.pathfinder_for_trains = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_NTP);
}
- if (_patches.yapf.road_use_yapf || CheckSavegameVersion(28)) {
- _patches.pathfinder_for_roadvehs = VPF_YAPF;
+ if (_settings.pf.yapf.road_use_yapf || CheckSavegameVersion(28)) {
+ _settings.pf.pathfinder_for_roadvehs = VPF_YAPF;
} else {
- _patches.pathfinder_for_roadvehs = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
+ _settings.pf.pathfinder_for_roadvehs = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
}
- if (_patches.yapf.ship_use_yapf) {
- _patches.pathfinder_for_ships = VPF_YAPF;
+ if (_settings.pf.yapf.ship_use_yapf) {
+ _settings.pf.pathfinder_for_ships = VPF_YAPF;
} else {
- _patches.pathfinder_for_ships = (_patches.new_pathfinding_all ? VPF_NPF : VPF_OPF);
+ _settings.pf.pathfinder_for_ships = (_settings.pf.new_pathfinding_all ? VPF_NPF : VPF_OPF);
}
}