summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-25 22:36:44 +0000
committerrubidium <rubidium@openttd.org>2008-05-25 22:36:44 +0000
commit8c9cc415e3eac6a7709f6a8978f213311416312e (patch)
tree1460114c8e9243ecb6e428c7db15dfa7abc391ed
parent51ca426c4bdb85137be82b0cc2436fc5ac0c442f (diff)
downloadopenttd-8c9cc415e3eac6a7709f6a8978f213311416312e.tar.xz
(svn r13255) -Codechange: move _opt to _settings.
-rw-r--r--src/ai/ai.cpp4
-rw-r--r--src/ai/default/default.cpp4
-rw-r--r--src/ai/trolly/trolly.cpp4
-rw-r--r--src/cheat_gui.cpp22
-rw-r--r--src/clear_cmd.cpp4
-rw-r--r--src/currency.cpp8
-rw-r--r--src/currency.h2
-rw-r--r--src/date.cpp2
-rw-r--r--src/disaster_cmd.cpp2
-rw-r--r--src/economy.cpp18
-rw-r--r--src/engine.cpp2
-rw-r--r--src/genworld_gui.cpp73
-rw-r--r--src/gfx.cpp8
-rw-r--r--src/gfxinit.cpp8
-rw-r--r--src/industry_cmd.cpp34
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/intro_gui.cpp16
-rw-r--r--src/landscape.cpp16
-rw-r--r--src/misc_cmd.cpp4
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_udp.cpp2
-rw-r--r--src/newgrf.cpp18
-rw-r--r--src/newgrf_commons.cpp2
-rw-r--r--src/oldloader.cpp58
-rw-r--r--src/openttd.cpp21
-rw-r--r--src/player_gui.cpp2
-rw-r--r--src/players.cpp12
-rw-r--r--src/rail.cpp2
-rw-r--r--src/rail_cmd.cpp6
-rw-r--r--src/road.cpp2
-rw-r--r--src/road_cmd.cpp10
-rw-r--r--src/roadveh_cmd.cpp12
-rw-r--r--src/settings.cpp32
-rw-r--r--src/settings_gui.cpp62
-rw-r--r--src/settings_type.h70
-rw-r--r--src/ship_cmd.cpp2
-rw-r--r--src/smallmap_gui.cpp2
-rw-r--r--src/station_cmd.cpp4
-rw-r--r--src/strings.cpp60
-rw-r--r--src/terraform_gui.cpp4
-rw-r--r--src/tgp.cpp10
-rw-r--r--src/town.h2
-rw-r--r--src/town_cmd.cpp28
-rw-r--r--src/train_cmd.cpp4
-rw-r--r--src/tree_cmd.cpp24
-rw-r--r--src/tree_gui.cpp4
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp6
-rw-r--r--src/vehicle.cpp6
49 files changed, 344 insertions, 360 deletions
diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp
index e48c8ef00..b72efc921 100644
--- a/src/ai/ai.cpp
+++ b/src/ai/ai.cpp
@@ -184,8 +184,8 @@ void AI_RunGameLoop()
_ai.tick++;
/* Make sure the AI follows the difficulty rule.. */
- assert(_opt.diff.competitor_speed <= 4);
- if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return;
+ assert(_settings.difficulty.competitor_speed <= 4);
+ if ((_ai.tick & ((1 << (4 - _settings.difficulty.competitor_speed)) - 1)) != 0) return;
/* Check for AI-client (so joining a network with an AI) */
if (!_networking || _network_server) {
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 70aaf2c04..14fc43392 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -2550,7 +2550,7 @@ handle_nocash:
bool is_pass = (
_players_ai[p->index].cargo_type == CT_PASSENGERS ||
_players_ai[p->index].cargo_type == CT_MAIL ||
- (_opt.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES)
+ (_settings.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES)
);
Order order;
@@ -3285,7 +3285,7 @@ static void AiStateBuildRoadVehicles(Player *p)
bool is_pass = (
_players_ai[p->index].cargo_type == CT_PASSENGERS ||
_players_ai[p->index].cargo_type == CT_MAIL ||
- (_opt.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES)
+ (_settings.game_creation.landscape == LT_TEMPERATE && _players_ai[p->index].cargo_type == CT_VALUABLES)
);
Order order;
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index 4be9819ca..cb572e486 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -1017,7 +1017,7 @@ static void AiNew_State_BuildPath(Player *p)
if (_players_ainew[p->index].temp == -1) {
DEBUG(ai, 1, "Starting to build new path");
// Init the counter
- _players_ainew[p->index].counter = (4 - _opt.diff.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
+ _players_ainew[p->index].counter = (4 - _settings.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
// Set the position to the startingplace (-1 because in a minute we do ++)
_players_ainew[p->index].path_info.position = -1;
// And don't do this again
@@ -1026,7 +1026,7 @@ static void AiNew_State_BuildPath(Player *p)
// Building goes very fast on normal rate, so we are going to slow it down..
// By let the counter count from AI_BUILDPATH_PAUSE to 0, we have a nice way :)
if (--_players_ainew[p->index].counter != 0) return;
- _players_ainew[p->index].counter = (4 - _opt.diff.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
+ _players_ainew[p->index].counter = (4 - _settings.difficulty.competitor_speed) * AI_BUILDPATH_PAUSE + 1;
// Increase the building position
_players_ainew[p->index].path_info.position++;
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index 42b8ca470..681f973c7 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -64,9 +64,9 @@ static int32 ClickChangeClimateCheat(int32 p1, int32 p2)
{
if (p1 == -1) p1 = 3;
if (p1 == 4) p1 = 0;
- _opt.landscape = p1;
+ _settings.game_creation.landscape = p1;
ReloadNewGRFData();
- return _opt.landscape;
+ return _settings.game_creation.landscape;
}
extern void EnginesMonthlyLoop();
@@ -100,15 +100,15 @@ struct CheatEntry {
};
static const CheatEntry _cheats_ui[] = {
- {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
- {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
- {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
- {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
- {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
+ {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
+ {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
+ {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
+ {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_settings.game_creation.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
+ {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
};
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 46bd31f6e..977ebb301 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -218,7 +218,7 @@ static void TileLoop_Clear(TileIndex tile)
{
TileLoopClearHelper(tile);
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TROPIC: TileLoopClearDesert(tile); break;
case LT_ARCTIC: TileLoopClearAlps(tile); break;
}
@@ -346,7 +346,7 @@ static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID
void InitializeClearLand()
{
- _opt.snow_line = _settings.game_creation.snow_line_height * TILE_HEIGHT;
+ _settings.game_creation.snow_line = _settings.game_creation.snow_line_height * TILE_HEIGHT;
}
static CommandCost TerraformTile_Clear(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
diff --git a/src/currency.cpp b/src/currency.cpp
index b26de04bb..7f21b7c50 100644
--- a/src/currency.cpp
+++ b/src/currency.cpp
@@ -150,10 +150,10 @@ uint GetMaskOfAllowedCurrencies()
**/
void CheckSwitchToEuro()
{
- if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
- _currency_specs[_opt.currency].to_euro != CF_ISEURO &&
- _cur_year >= _currency_specs[_opt.currency].to_euro) {
- _opt.currency = 2; // this is the index of euro above.
+ if (_currency_specs[_settings.gui.currency].to_euro != CF_NOEURO &&
+ _currency_specs[_settings.gui.currency].to_euro != CF_ISEURO &&
+ _cur_year >= _currency_specs[_settings.gui.currency].to_euro) {
+ _settings.gui.currency = 2; // this is the index of euro above.
AddNewsItem(STR_EURO_INTRODUCE, NS_ECONOMY, 0, 0);
}
}
diff --git a/src/currency.h b/src/currency.h
index f2ff11650..e7cac77c2 100644
--- a/src/currency.h
+++ b/src/currency.h
@@ -39,7 +39,7 @@ extern CurrencySpec _currency_specs[NUM_CURRENCY];
// XXX small hack, but makes the rest of the code a bit nicer to read
#define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID])
-#define _currency ((const CurrencySpec*)&_currency_specs[(_game_mode == GM_MENU) ? _opt_newgame.currency : _opt.currency])
+#define _currency ((const CurrencySpec*)&_currency_specs[(_game_mode == GM_MENU) ? _settings_newgame.gui.currency : _settings.gui.currency])
uint GetMaskOfAllowedCurrencies();
void CheckSwitchToEuro();
diff --git a/src/date.cpp b/src/date.cpp
index 7ee769c64..359433572 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -257,7 +257,7 @@ void IncreaseDate()
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
DebugDumpCommands("ddc:save:%s\n", name);
#endif /* DUMP_COMMANDS */
- if (_opt.autosave != 0 && (_cur_month % _autosave_months[_opt.autosave]) == 0) {
+ if (_settings.gui.autosave != 0 && (_cur_month % _autosave_months[_settings.gui.autosave]) == 0) {
_do_autosave = true;
RedrawAutosave();
}
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index 848f97144..d4c0b722f 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -1050,7 +1050,7 @@ void DisasterDailyLoop()
ResetDisasterDelay();
- if (_opt.diff.disasters != 0) DoDisaster();
+ if (_settings.difficulty.disasters != 0) DoDisaster();
}
void StartupDisasters()
diff --git a/src/economy.cpp b/src/economy.cpp
index 436f278d2..c11125e94 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -704,7 +704,7 @@ static void PlayersPayInterest()
static void HandleEconomyFluctuations()
{
- if (_opt.diff.economy == 0) return;
+ if (_settings.difficulty.economy == 0) return;
if (--_economy.fluct == 0) {
_economy.fluct = -(int)GB(Random(), 0, 2);
@@ -813,7 +813,7 @@ void StartupEconomy()
for (i = 0; i != NUM_PRICES; i++) {
Money price = _price_base[i];
if (_price_category[i] != 0) {
- uint mod = _price_category[i] == 1 ? _opt.diff.vehicle_costs : _opt.diff.construction_cost;
+ uint mod = _price_category[i] == 1 ? _settings.difficulty.vehicle_costs : _settings.difficulty.construction_cost;
if (mod < 1) {
price = price * 3 >> 2;
} else if (mod > 1) {
@@ -829,10 +829,10 @@ void StartupEconomy()
_price_frac[i] = 0;
}
- _economy.interest_rate = _opt.diff.initial_interest;
- _economy.infl_amount = _opt.diff.initial_interest;
- _economy.infl_amount_pr = max(0, _opt.diff.initial_interest - 1);
- _economy.max_loan_unround = _economy.max_loan = _opt.diff.max_loan * 1000;
+ _economy.interest_rate = _settings.difficulty.initial_interest;
+ _economy.infl_amount = _settings.difficulty.initial_interest;
+ _economy.infl_amount_pr = max(0, _settings.difficulty.initial_interest - 1);
+ _economy.max_loan_unround = _economy.max_loan = _settings.difficulty.max_loan * 1000;
_economy.fluct = GB(Random(), 0, 8) + 168;
}
@@ -1162,7 +1162,7 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, C
}
/* zero the distance (thus income) if it's the bank and very short transport. */
- if (_opt.landscape == LT_TEMPERATE && cs->label == 'VALU' && dist < 10) return 0;
+ if (_settings.game_creation.landscape == LT_TEMPERATE && cs->label == 'VALU' && dist < 10) return 0;
static const int MIN_TIME_FACTOR = 31;
@@ -1313,7 +1313,7 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
SetDParam(0, _current_player);
AddNewsItem(
- STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
+ STR_2031_SERVICE_SUBSIDY_AWARDED + _settings.difficulty.subsidy_multiplier,
NS_SUBSIDIES,
pair.a, pair.b
);
@@ -1360,7 +1360,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source,
/* Modify profit if a subsidy is in effect */
if (subsidised) {
- switch (_opt.diff.subsidy_multiplier) {
+ switch (_settings.difficulty.subsidy_multiplier) {
case 0: profit += profit >> 1; break;
case 1: profit *= 2; break;
case 2: profit *= 3; break;
diff --git a/src/engine.cpp b/src/engine.cpp
index 37bedbf06..558fcd8e0 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -296,7 +296,7 @@ void StartupEngines()
e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life;
/* prevent certain engines from ever appearing. */
- if (!HasBit(ei->climates, _opt.landscape)) {
+ if (!HasBit(ei->climates, _settings.game_creation.landscape)) {
e->flags |= ENGINE_AVAILABLE;
e->player_avail = 0;
}
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index da2115e24..63ba75b83 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -48,7 +48,7 @@ extern void SwitchMode(int new_mode);
static inline void SetNewLandscapeType(byte landscape)
{
- _opt_newgame.landscape = landscape;
+ _settings.game_creation.landscape = landscape;
InvalidateWindowClasses(WC_SELECT_GAME);
InvalidateWindowClasses(WC_GENERATE_LANDSCAPE);
}
@@ -206,7 +206,6 @@ void StartGeneratingLandscape(glwp_modes mode)
/* Copy all XXX_newgame to XXX when coming from outside the editor */
UpdatePatches();
- _opt = _opt_newgame;
ResetGRFConfig(true);
SndPlayFx(SND_15_BEEP);
@@ -254,7 +253,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : QueryStringBaseWindow(desc, number)
{
- this->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
+ this->LowerWidget(_settings.game_creation.landscape + GLAND_TEMPERATE);
snprintf(this->edit_str_buf, sizeof(this->edit_str_buf), "%u", _settings_newgame.game_creation.generation_seed);
InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 120);
@@ -273,7 +272,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0);
}
/* Disable snowline if not hilly */
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _settings.game_creation.landscape != LT_ARCTIC);
/* Disable town, industry and trees in SE */
this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
this->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
@@ -281,27 +280,27 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
this->SetWidgetDisabledState(GLAND_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
- this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= 2 || _settings.game_creation.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _settings.game_creation.landscape != LT_ARCTIC);
- this->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
- this->SetWidgetLoweredState(GLAND_ARCTIC, _opt_newgame.landscape == LT_ARCTIC);
- this->SetWidgetLoweredState(GLAND_TROPICAL, _opt_newgame.landscape == LT_TROPIC);
- this->SetWidgetLoweredState(GLAND_TOYLAND, _opt_newgame.landscape == LT_TOYLAND);
+ this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings.game_creation.landscape == LT_TEMPERATE);
+ this->SetWidgetLoweredState(GLAND_ARCTIC, _settings.game_creation.landscape == LT_ARCTIC);
+ this->SetWidgetLoweredState(GLAND_TROPICAL, _settings.game_creation.landscape == LT_TROPIC);
+ this->SetWidgetLoweredState(GLAND_TOYLAND, _settings.game_creation.landscape == LT_TOYLAND);
if (_game_mode == GM_EDITOR) {
this->widget[GLAND_TOWN_PULLDOWN].data = STR_6836_OFF;
this->widget[GLAND_INDUSTRY_PULLDOWN].data = STR_6836_OFF;
} else {
- this->widget[GLAND_TOWN_PULLDOWN].data = _num_towns[_opt_newgame.diff.number_towns];
- this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_opt_newgame.diff.number_industries];
+ this->widget[GLAND_TOWN_PULLDOWN].data = _num_towns[_settings_newgame.difficulty.number_towns];
+ this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_settings_newgame.difficulty.number_industries];
}
if (mode == GLWP_GENERATE) {
this->widget[GLAND_LANDSCAPE_PULLDOWN].data = _landscape[_settings_newgame.game_creation.land_generator];
this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_settings_newgame.game_creation.tree_placer];
- this->widget[GLAND_TERRAIN_PULLDOWN].data = _elevations[_opt_newgame.diff.terrain_type];
- this->widget[GLAND_WATER_PULLDOWN].data = _sea_lakes[_opt_newgame.diff.quantity_sea_lakes];
+ this->widget[GLAND_TERRAIN_PULLDOWN].data = _elevations[_settings_newgame.difficulty.terrain_type];
+ this->widget[GLAND_WATER_PULLDOWN].data = _sea_lakes[_settings_newgame.difficulty.quantity_sea_lakes];
this->widget[GLAND_SMOOTHNESS_PULLDOWN].data = _smoothness[_settings_newgame.game_creation.tgen_smoothness];
} else {
this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_settings_newgame.game_creation.tree_placer];
@@ -346,7 +345,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_ARCTIC:
case GLAND_TROPICAL:
case GLAND_TOYLAND:
- this->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
+ this->RaiseWidget(_settings.game_creation.landscape + GLAND_TEMPERATE);
SetNewLandscapeType(widget - GLAND_TEMPERATE);
break;
@@ -359,11 +358,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break;
case GLAND_TOWN_PULLDOWN: // Number of towns
- ShowDropDownMenu(this, _num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _num_towns, _settings_newgame.difficulty.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
break;
case GLAND_INDUSTRY_PULLDOWN: // Number of industries
- ShowDropDownMenu(this, _num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _num_inds, _settings_newgame.difficulty.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
break;
case GLAND_RANDOM_BUTTON: // Random seed
@@ -451,11 +450,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break;
case GLAND_TERRAIN_PULLDOWN: // Terrain type
- ShowDropDownMenu(this, _elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
break;
case GLAND_WATER_PULLDOWN: // Water quantity
- ShowDropDownMenu(this, _sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
+ ShowDropDownMenu(this, _sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
break;
case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
@@ -491,15 +490,15 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
case GLAND_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break;
case GLAND_TOWN_PULLDOWN:
- _opt_newgame.diff.number_towns = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.number_towns = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ DoCommandP(0, 2, _settings_newgame.difficulty.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break;
case GLAND_INDUSTRY_PULLDOWN:
- _opt_newgame.diff.number_industries = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.number_industries = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ DoCommandP(0, 3, _settings_newgame.difficulty.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break;
case GLAND_LANDSCAPE_PULLDOWN:
@@ -512,15 +511,15 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break;
case GLAND_TERRAIN_PULLDOWN:
- _opt_newgame.diff.terrain_type = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.terrain_type = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ DoCommandP(0, 12, _settings_newgame.difficulty.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break;
case GLAND_WATER_PULLDOWN:
- _opt_newgame.diff.quantity_sea_lakes = index;
- if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
- DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
+ _settings_newgame.difficulty.quantity_sea_lakes = index;
+ if (_settings_newgame.difficulty.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
+ DoCommandP(0, 13, _settings_newgame.difficulty.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break;
}
this->SetDirty();
@@ -643,7 +642,7 @@ struct CreateScenarioWindow : public Window
CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- this->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
+ this->LowerWidget(_settings.game_creation.landscape + CSCEN_TEMPERATE);
this->FindWindowPlacementAndResize(desc);
}
@@ -654,10 +653,10 @@ struct CreateScenarioWindow : public Window
this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _settings_newgame.game_creation.se_flat_world_height <= 0);
this->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP, _settings_newgame.game_creation.se_flat_world_height >= MAX_TILE_HEIGHT);
- this->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
- this->SetWidgetLoweredState(CSCEN_ARCTIC, _opt_newgame.landscape == LT_ARCTIC);
- this->SetWidgetLoweredState(CSCEN_TROPICAL, _opt_newgame.landscape == LT_TROPIC);
- this->SetWidgetLoweredState(CSCEN_TOYLAND, _opt_newgame.landscape == LT_TOYLAND);
+ this->SetWidgetLoweredState(CSCEN_TEMPERATE, _settings.game_creation.landscape == LT_TEMPERATE);
+ this->SetWidgetLoweredState(CSCEN_ARCTIC, _settings.game_creation.landscape == LT_ARCTIC);
+ this->SetWidgetLoweredState(CSCEN_TROPICAL, _settings.game_creation.landscape == LT_TROPIC);
+ this->SetWidgetLoweredState(CSCEN_TOYLAND, _settings.game_creation.landscape == LT_TOYLAND);
/* Set parameters for widget text that requires them */
SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT
@@ -675,7 +674,7 @@ struct CreateScenarioWindow : public Window
case CSCEN_ARCTIC:
case CSCEN_TROPICAL:
case CSCEN_TOYLAND:
- this->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
+ this->RaiseWidget(_settings.game_creation.landscape + CSCEN_TEMPERATE);
SetNewLandscapeType(widget - CSCEN_TEMPERATE);
break;
diff --git a/src/gfx.cpp b/src/gfx.cpp
index e85caaab8..0ee113fb0 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -807,7 +807,7 @@ void DoPaletteAnimations()
memcpy(old_val, d, c * sizeof(*old_val));
/* Dark blue water */
- s = (_opt.landscape == LT_TOYLAND) ? ev->ac : ev->a;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->ac : ev->a;
j = EXTR(320, 5);
for (i = 0; i != 5; i++) {
*d++ = s[j];
@@ -816,7 +816,7 @@ void DoPaletteAnimations()
}
/* Glittery water */
- s = (_opt.landscape == LT_TOYLAND) ? ev->bc : ev->b;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->bc : ev->b;
j = EXTR(128, 15);
for (i = 0; i != 5; i++) {
*d++ = s[j];
@@ -876,7 +876,7 @@ void DoPaletteAnimations()
/* Animate water for old DOS graphics */
if (_use_dos_palette) {
/* Dark blue water DOS */
- s = (_opt.landscape == LT_TOYLAND) ? ev->ac : ev->a;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->ac : ev->a;
j = EXTR(320, 5);
for (i = 0; i != 5; i++) {
*d++ = s[j];
@@ -885,7 +885,7 @@ void DoPaletteAnimations()
}
/* Glittery water DOS */
- s = (_opt.landscape == LT_TOYLAND) ? ev->bc : ev->b;
+ s = (_settings.game_creation.landscape == LT_TOYLAND) ? ev->bc : ev->b;
j = EXTR(128, 15);
for (i = 0; i != 5; i++) {
*d++ = s[j];
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index c0350185d..390f69e73 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -214,10 +214,10 @@ static void LoadSpriteTables()
* This overwrites some of the temperate sprites, such as foundations
* and the ground sprites.
*/
- if (_opt.landscape != LT_TEMPERATE) {
+ if (_settings.game_creation.landscape != LT_TEMPERATE) {
LoadGrfIndexed(
- files->landscape[_opt.landscape - 1].filename,
- _landscape_spriteindexes[_opt.landscape - 1],
+ files->landscape[_settings.game_creation.landscape - 1].filename,
+ _landscape_spriteindexes[_settings.game_creation.landscape - 1],
i++
);
}
@@ -248,7 +248,7 @@ static void LoadSpriteTables()
void GfxLoadSprites()
{
- DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape);
+ DEBUG(sprite, 2, "Loading sprite set %d", _settings.game_creation.landscape);
GfxInitSpriteMem();
LoadSpriteTables();
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 3a0613aaa..d98bf3b83 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -70,7 +70,7 @@ void ResetIndustries()
/* once performed, enable only the current climate industries */
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
_industry_specs[i].enabled = i < NEW_INDUSTRYOFFSET &&
- HasBit(_origin_industry_specs[i].climate_availability, _opt.landscape);
+ HasBit(_origin_industry_specs[i].climate_availability, _settings.game_creation.landscape);
}
memset(&_industry_tile_specs, 0, sizeof(_industry_tile_specs));
@@ -84,7 +84,7 @@ void ResetIndustries()
void ResetIndustryCreationProbility(IndustryType type)
{
assert(type < INVALID_INDUSTRYTYPE);
- _industry_specs[type].appear_creation[_opt.landscape] = 0;
+ _industry_specs[type].appear_creation[_settings.game_creation.landscape] = 0;
}
DEFINE_OLD_POOL_GENERIC(Industry, Industry)
@@ -888,14 +888,14 @@ static void PlantFarmField(TileIndex tile, IndustryID industry)
uint field_type;
int type;
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine())
return;
}
/* determine field size */
r = (Random() & 0x303) + 0x404;
- if (_opt.landscape == LT_ARCTIC) r += 0x404;
+ if (_settings.game_creation.landscape == LT_ARCTIC) r += 0x404;
size_x = GB(r, 0, 8);
size_y = GB(r, 8, 8);
@@ -926,7 +926,7 @@ static void PlantFarmField(TileIndex tile, IndustryID industry)
END_TILE_LOOP(cur_tile, size_x, size_y, tile)
type = 3;
- if (_opt.landscape != LT_ARCTIC && _opt.landscape != LT_TROPIC) {
+ if (_settings.game_creation.landscape != LT_ARCTIC && _settings.game_creation.landscape != LT_TROPIC) {
type = _plantfarmfield_type[Random() & 0xF];
}
@@ -1063,7 +1063,7 @@ static bool CheckNewIndustry_NULL(TileIndex tile)
static bool CheckNewIndustry_Forest(TileIndex tile)
{
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) < HighestSnowLine() + TILE_HEIGHT * 2U) {
_error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED;
return false;
@@ -1095,7 +1095,7 @@ static bool CheckNewIndustry_OilRig(TileIndex tile)
static bool CheckNewIndustry_Farm(TileIndex tile)
{
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= HighestSnowLine()) {
_error_message = STR_0239_SITE_UNSUITABLE;
return false;
@@ -1700,13 +1700,13 @@ static void PlaceInitialIndustry(IndustryType type, int amount)
{
/* We need to bypass the amount given in parameter if it exceeds the maximum dimension of the
* _numof_industry_table. newgrf can specify a big amount */
- int num = (amount > NB_NUMOFINDUSTRY) ? amount : _numof_industry_table[_opt.diff.number_industries][amount];
+ int num = (amount > NB_NUMOFINDUSTRY) ? amount : _numof_industry_table[_settings.difficulty.number_industries][amount];
const IndustrySpec *ind_spc = GetIndustrySpec(type);
/* These are always placed next to the coastline, so we scale by the perimeter instead. */
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
- if (_opt.diff.number_industries != 0) {
+ if (_settings.difficulty.number_industries != 0) {
PlayerID old_player = _current_player;
_current_player = OWNER_NONE;
assert(num > 0);
@@ -1735,7 +1735,7 @@ void GenerateIndustries()
const IndustrySpec *ind_spc;
/* Find the total amount of industries */
- if (_opt.diff.number_industries > 0) {
+ if (_settings.difficulty.number_industries > 0) {
for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
ind_spc = GetIndustrySpec(it);
@@ -1744,12 +1744,12 @@ void GenerateIndustries()
ResetIndustryCreationProbility(it);
}
- chance = ind_spc->appear_creation[_opt.landscape];
+ chance = ind_spc->appear_creation[_settings.game_creation.landscape];
if (ind_spc->enabled && chance > 0) {
/* once the chance of appearance is determind, it have to be scaled by
* the difficulty level. The "chance" in question is more an index into
* the _numof_industry_table,in fact */
- int num = (chance > NB_NUMOFINDUSTRY) ? chance : _numof_industry_table[_opt.diff.number_industries][chance];
+ int num = (chance > NB_NUMOFINDUSTRY) ? chance : _numof_industry_table[_settings.difficulty.number_industries][chance];
/* These are always placed next to the coastline, so we scale by the perimeter instead. */
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
@@ -1760,7 +1760,7 @@ void GenerateIndustries()
SetGeneratingWorldProgress(GWP_INDUSTRY, i);
- if (_opt.diff.number_industries > 0) {
+ if (_settings.difficulty.number_industries > 0) {
for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
/* Once the number of industries has been determined, let's really create them.
* The test for chance allows us to try create industries that are available only
@@ -1769,7 +1769,7 @@ void GenerateIndustries()
* processed that scaling above? No, don't think so. Will find a way. */
ind_spc = GetIndustrySpec(it);
if (ind_spc->enabled) {
- chance = ind_spc->appear_creation[_opt.landscape];
+ chance = ind_spc->appear_creation[_settings.game_creation.landscape];
if (chance > 0) PlaceInitialIndustry(it, chance);
}
}
@@ -1823,7 +1823,7 @@ static void MaybeNewIndustry(void)
/* Generate a list of all possible industries that can be built. */
for (j = 0; j < NUM_INDUSTRYTYPES; j++) {
ind_spc = GetIndustrySpec(j);
- byte chance = ind_spc->appear_ingame[_opt.landscape];
+ byte chance = ind_spc->appear_ingame[_settings.game_creation.landscape];
if (!ind_spc->enabled || chance == 0) continue;
@@ -1881,7 +1881,7 @@ static bool CheckIndustryCloseDownProtection(IndustryType type)
const IndustrySpec *indspec = GetIndustrySpec(type);
/* oil wells (or the industries with that flag set) are always allowed to closedown */
- if (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD && _opt.landscape == LT_TEMPERATE) return false;
+ if (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD && _settings.game_creation.landscape == LT_TEMPERATE) return false;
return (indspec->behaviour & INDUSTRYBEH_CANCLOSE_LASTINSTANCE) == 0 && GetIndustryTypeCount(type) <= 1;
}
@@ -2072,7 +2072,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
if (standard && (indspec->life_type & (INDUSTRYLIFE_ORGANIC | INDUSTRYLIFE_EXTRACTIVE)) != 0) {
/* decrease or increase */
- bool only_decrease = (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _opt.landscape == LT_TEMPERATE;
+ bool only_decrease = (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _settings.game_creation.landscape == LT_TEMPERATE;
if (smooth_economy) {
closeit = true;
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index f52fec3cc..57c7b9b51 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -195,7 +195,7 @@ public:
* In Editor, you just build, while ingame, or you fund or you prospect */
if (_game_mode == GM_EDITOR) {
/* We've chosen many random industries but no industries have been specified */
- if (indsp == NULL) this->enabled[this->selected_index] = _opt.diff.number_industries != 0;
+ if (indsp == NULL) this->enabled[this->selected_index] = _settings.difficulty.number_industries != 0;
this->widget[DPIW_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
} else {
this->widget[DPIW_FUND_WIDGET].data = (_settings.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index 8ff4d46df..c4cca9ab2 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -49,7 +49,7 @@ static const Widget _select_game_widgets[] = {
static inline void SetNewLandscapeType(byte landscape)
{
- _opt_newgame.landscape = landscape;
+ _settings_newgame.game_creation.landscape = landscape;
InvalidateWindowClasses(WC_SELECT_GAME);
}
@@ -76,17 +76,17 @@ private:
public:
SelectGameWindow(const WindowDesc *desc) : Window(desc)
{
- this->LowerWidget(_opt_newgame.landscape + SGI_TEMPERATE_LANDSCAPE);
+ this->LowerWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
- this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _opt_newgame.landscape == LT_TEMPERATE);
- this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _opt_newgame.landscape == LT_ARCTIC);
- this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _opt_newgame.landscape == LT_TROPIC);
- this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _opt_newgame.landscape == LT_TOYLAND);
- SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level);
+ this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
+ this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC);
+ this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC);
+ this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND);
+ SetDParam(0, STR_6801_EASY + _settings_newgame.difficulty.diff_level);
this->DrawWidgets();
}
@@ -115,7 +115,7 @@ public:
case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
- this->RaiseWidget(_opt_newgame.landscape + SGI_TEMPERATE_LANDSCAPE);
+ this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE);
SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
break;
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 8a6f0e7b4..7ed652885 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -526,7 +526,7 @@ void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
*/
byte GetSnowLine(void)
{
- if (_snow_line == NULL) return _opt.snow_line;
+ if (_snow_line == NULL) return _settings.game_creation.snow_line;
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);
@@ -539,7 +539,7 @@ byte GetSnowLine(void)
*/
byte HighestSnowLine(void)
{
- return _snow_line == NULL ? _opt.snow_line : _snow_line->highest_value;
+ return _snow_line == NULL ? _settings.game_creation.snow_line : _snow_line->highest_value;
}
/**
@@ -818,14 +818,14 @@ void GenerateLandscape(byte mode)
static const int gwp_desert_amount = 4 + 8;
if (mode == GW_HEIGHTMAP) {
- SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1);
+ SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings.game_creation.landscape == LT_TROPIC) ? 1 + gwp_desert_amount : 1);
LoadHeightmap(_file_to_saveload.name);
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
} else if (_settings.game_creation.land_generator == LG_TERRAGENESIS) {
- SetGeneratingWorldProgress(GWP_LANDSCAPE, (_opt.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3);
+ SetGeneratingWorldProgress(GWP_LANDSCAPE, (_settings.game_creation.landscape == LT_TROPIC) ? 3 + gwp_desert_amount : 3);
GenerateTerrainPerlin();
} else {
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC: {
SetGeneratingWorldProgress(GWP_LANDSCAPE, 2);
@@ -872,9 +872,9 @@ void GenerateLandscape(byte mode)
uint32 r = Random();
- uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _opt.diff.quantity_sea_lakes) * 256 + 100);
+ uint i = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings.difficulty.quantity_sea_lakes) * 256 + 100);
for (; i != 0; --i) {
- GenerateTerrain(_opt.diff.terrain_type, 0);
+ GenerateTerrain(_settings.difficulty.terrain_type, 0);
}
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
} break;
@@ -883,7 +883,7 @@ void GenerateLandscape(byte mode)
ConvertGroundTilesIntoWaterTiles();
- if (_opt.landscape == LT_TROPIC) CreateDesertOrRainForest();
+ if (_settings.game_creation.landscape == LT_TROPIC) CreateDesertOrRainForest();
}
void OnTick_Town();
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index 62ec5bcc7..49e3eafdb 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -395,11 +395,11 @@ CommandCost CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, ui
{
if (p1 != (uint32)-1L && ((int32)p1 >= GAME_DIFFICULTY_NUM || (int32)p1 < 0)) return CMD_ERROR;
- GameOptions *opt_ptr = (_game_mode == GM_MENU) ? &_opt_newgame : &_opt;
+ DifficultySettings *opt_ptr = (_game_mode == GM_MENU) ? &_settings_newgame.difficulty : &_settings.difficulty;
if (flags & DC_EXEC) {
if (p1 != (uint32)-1L) {
- ((GDType*)&opt_ptr->diff)[p1] = p2;
+ ((GDType*)opt_ptr)[p1] = p2;
opt_ptr->diff_level = 3; // custom difficulty level
} else {
opt_ptr->diff_level = p2;
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 20f6852da..47c3545da 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -1012,7 +1012,7 @@ static void NetworkInitGameInfo()
_network_game_info.start_date = ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1);
_network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY();
- _network_game_info.map_set = _opt.landscape;
+ _network_game_info.map_set = _settings.game_creation.landscape;
_network_game_info.use_password = (_network_server_password[0] != '\0');
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 636bf67fb..8744875d9 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -77,7 +77,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
_network_game_info.game_date = _date;
_network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY();
- _network_game_info.map_set = _opt.landscape;
+ _network_game_info.map_set = _settings.game_creation.landscape;
_network_game_info.companies_on = ActivePlayerCount();
_network_game_info.spectators_on = NetworkSpectatorCount();
_network_game_info.grfconfig = _grfconfig;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index a9ada136c..83b1ef79a 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1437,8 +1437,8 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in
/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance.
* Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */
- CargoID cid = (goods >= 0) ? ((_opt.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
- ((_opt.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
+ CargoID cid = (goods >= 0) ? ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
+ ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
/* Make sure the cargo type is valid in this climate. */
if (!GetCargo(cid)->IsValid()) goods = 0;
@@ -2167,11 +2167,11 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
break;
case 0x17: // Probability in random game
- indsp->appear_creation[_opt.landscape] = grf_load_byte(&buf);
+ indsp->appear_creation[_settings.game_creation.landscape] = grf_load_byte(&buf);
break;
case 0x18: // Probability during gameplay
- indsp->appear_ingame[_opt.landscape] = grf_load_byte(&buf);
+ indsp->appear_ingame[_settings.game_creation.landscape] = grf_load_byte(&buf);
break;
case 0x19: // Map color
@@ -3557,11 +3557,11 @@ bool GetGlobalVariable(byte param, uint32 *value)
return true;
case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland
- *value = _opt.landscape;
+ *value = _settings.game_creation.landscape;
return true;
case 0x06: // road traffic side, bit 4 clear=left, set=right
- *value = _opt.road_side << 4;
+ *value = _settings.vehicle.road_side << 4;
return true;
case 0x09: // date fraction
@@ -3635,7 +3635,7 @@ bool GetGlobalVariable(byte param, uint32 *value)
/* case 0x1F: // locale dependent settings not implemented */
case 0x20: // snow line height
- *value = _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
+ *value = _settings.game_creation.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
return true;
case 0x21: // OpenTTD version
@@ -3643,7 +3643,7 @@ bool GetGlobalVariable(byte param, uint32 *value)
return true;
case 0x22: // difficulty level
- *value = _opt.diff_level;
+ *value = _settings.difficulty.diff_level;
return true;
default: return false;
@@ -5352,7 +5352,7 @@ static void ResetNewGRFData()
ResetNewGRFErrors();
/* Set up the default cargo types */
- SetupCargoForClimate(_opt.landscape);
+ SetupCargoForClimate(_settings.game_creation.landscape);
/* Reset misc GRF features and train list display variables */
_misc_grf_features = 0;
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp
index 6bb2612d9..485ffbd40 100644
--- a/src/newgrf_commons.cpp
+++ b/src/newgrf_commons.cpp
@@ -278,7 +278,7 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its)
* Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */
uint32 GetTerrainType(TileIndex tile)
{
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TROPIC: return GetTropicZone(tile);
case LT_ARCTIC: return GetTileZ(tile) > GetSnowLine() ? 4 : 0;
default: return 0;
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 32dcd3b76..8bc9c7be4 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -319,8 +319,8 @@ static void FixOldTowns()
/* Convert town-names if needed */
FOR_ALL_TOWNS(town) {
if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
- town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name;
- town->townnameparts = GetOldTownName(town->townnameparts, _opt.town_name);
+ town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings.game_creation.town_name;
+ town->townnameparts = GetOldTownName(town->townnameparts, _settings.game_creation.town_name);
}
}
}
@@ -1370,29 +1370,29 @@ static inline bool LoadOldSubsidy(LoadgameState *ls, int num)
}
static const OldChunks game_difficulty_chunk[] = {
- OCL_SVAR( OC_UINT16, GameDifficulty, max_no_competitors ),
- OCL_SVAR( OC_UINT16, GameDifficulty, competitor_start_time ),
- OCL_SVAR( OC_UINT16, GameDifficulty, number_towns ),
- OCL_SVAR( OC_UINT16, GameDifficulty, number_industries ),
- OCL_SVAR( OC_UINT16, GameDifficulty, max_loan ),
- OCL_SVAR( OC_UINT16, GameDifficulty, initial_interest ),
- OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_costs ),
- OCL_SVAR( OC_UINT16, GameDifficulty, competitor_speed ),
- OCL_SVAR( OC_UINT16, GameDifficulty, competitor_intelligence ),
- OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_breakdowns ),
- OCL_SVAR( OC_UINT16, GameDifficulty, subsidy_multiplier ),
- OCL_SVAR( OC_UINT16, GameDifficulty, construction_cost ),
- OCL_SVAR( OC_UINT16, GameDifficulty, terrain_type ),
- OCL_SVAR( OC_UINT16, GameDifficulty, quantity_sea_lakes ),
- OCL_SVAR( OC_UINT16, GameDifficulty, economy ),
- OCL_SVAR( OC_UINT16, GameDifficulty, line_reverse_mode ),
- OCL_SVAR( OC_UINT16, GameDifficulty, disasters ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, max_no_competitors ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_start_time ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, number_towns ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, number_industries ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U16, DifficultySettings, max_loan ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, initial_interest ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, vehicle_costs ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_speed ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_intelligence ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, vehicle_breakdowns ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, subsidy_multiplier ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, construction_cost ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, terrain_type ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, quantity_sea_lakes ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, economy ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, line_reverse_mode ),
+ OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, disasters ),
OCL_END()
};
static inline bool LoadOldGameDifficulty(LoadgameState *ls, int num)
{
- return LoadChunk(ls, &_opt.diff, game_difficulty_chunk);
+ return LoadChunk(ls, &_settings.difficulty, game_difficulty_chunk);
}
@@ -1570,8 +1570,8 @@ static const OldChunks main_chunk[] = {
OCL_VAR ( OC_FILE_U8 | OC_VAR_U16, 1, &_station_tick_ctr ),
- OCL_VAR ( OC_UINT8, 1, &_opt.currency ),
- OCL_VAR ( OC_UINT8, 1, &_opt.units ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.gui.currency ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.gui.units ),
OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_player_tick_index ),
OCL_NULL( 2 ), ///< Date stuff, calculated automatically
@@ -1581,19 +1581,19 @@ static const OldChunks main_chunk[] = {
OCL_VAR ( OC_UINT8, 1, &_economy.infl_amount_pr ),
OCL_VAR ( OC_UINT8, 1, &_economy.interest_rate ),
OCL_NULL( 1 ), // available airports
- OCL_VAR ( OC_UINT8, 1, &_opt.road_side ),
- OCL_VAR ( OC_UINT8, 1, &_opt.town_name ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.vehicle.road_side ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.town_name ),
OCL_CHUNK( 1, LoadOldGameDifficulty ),
OCL_ASSERT( 0x77130 ),
- OCL_VAR ( OC_UINT8, 1, &_opt.diff_level ),
- OCL_VAR ( OC_UINT8, 1, &_opt.landscape ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.difficulty.diff_level ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.landscape ),
OCL_VAR ( OC_UINT8, 1, &_trees_tick_ctr ),
OCL_NULL( 1 ), ///< Custom vehicle types yes/no, no longer used
- OCL_VAR ( OC_UINT8, 1, &_opt.snow_line ),
+ OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.snow_line ),
OCL_NULL( 32 ), ///< new_industry_randtable, no longer used (because of new design)
OCL_NULL( 36 ), ///< cargo-stuff, calculated in InitializeLandscapeVariables
@@ -1628,7 +1628,7 @@ static bool LoadOldMain(LoadgameState *ls)
DEBUG(oldloader, 3, "Done, converting game data...");
/* Fix some general stuff */
- _opt.landscape = _opt.landscape & 0xF;
+ _settings.game_creation.landscape = _settings.game_creation.landscape & 0xF;
/* Remap some pointers */
_cur_town_ctr = REMAP_TOWN_IDX(_old_cur_town_ctr);
@@ -1690,7 +1690,7 @@ static bool LoadOldMain(LoadgameState *ls)
FixOldVehicles();
/* We have a new difficulty setting */
- _opt.diff.town_council_tolerance = Clamp(_opt.diff_level, 0, 2);
+ _settings.difficulty.town_council_tolerance = Clamp(_settings.difficulty.diff_level, 0, 2);
DEBUG(oldloader, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
diff --git a/src/openttd.cpp b/src/openttd.cpp
index efdab795c..f15c0b8d7 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -99,7 +99,7 @@ void ResetOldNames();
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();
@@ -586,11 +586,10 @@ int ttd_main(int argc, char *argv[])
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();
}
@@ -767,8 +766,7 @@ static void StartScenario()
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
}
- _opt.diff = _opt_newgame.diff;
- _opt.diff_level = _opt_newgame.diff_level;
+ _settings.difficulty = _settings_newgame.difficulty;
/* Inititalize data */
StartupEconomy();
@@ -838,7 +836,6 @@ void SwitchMode(int new_mode)
if (_network_reload_cfg) {
LoadFromConfig();
_settings = _settings_newgame;
- _opt = _opt_newgame;
ResetGRFConfig(false);
}
NetworkServerStart();
@@ -1259,7 +1256,7 @@ static const byte convert_currency[] = {
/* 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
@@ -1394,7 +1391,7 @@ bool AfterLoadGame()
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;
@@ -1408,7 +1405,7 @@ bool AfterLoadGame()
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();
@@ -2226,12 +2223,12 @@ bool AfterLoadGame()
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)) {
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index b883affdf..57b4e3c8a 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -1477,7 +1477,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
} else {
/* in single player _local player is always valid */
const Player *p = GetPlayer(_local_player);
- this->window_number = _opt.diff_level;
+ this->window_number = _settings.difficulty.diff_level;
this->rank = SaveHighScoreValue(p);
}
diff --git a/src/players.cpp b/src/players.cpp
index 169456b52..030e9a787 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -563,7 +563,7 @@ Player *DoStartupNewPlayer(bool is_ai)
void StartupPlayers()
{
/* The AI starts like in the setting with +2 month max */
- _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
+ _next_competitor_start = _settings.difficulty.competitor_start_time * 90 * DAY_TICKS + RandomRange(60 * DAY_TICKS) + 1;
}
static void MaybeStartNewPlayer()
@@ -578,10 +578,10 @@ static void MaybeStartNewPlayer()
}
/* when there's a lot of computers in game, the probability that a new one starts is lower */
- if (n < (uint)_opt.diff.max_no_competitors &&
+ if (n < (uint)_settings.difficulty.max_no_competitors &&
n < (_network_server ?
- InteractiveRandomRange(_opt.diff.max_no_competitors + 2) :
- RandomRange(_opt.diff.max_no_competitors + 2)
+ InteractiveRandomRange(_settings.difficulty.max_no_competitors + 2) :
+ RandomRange(_settings.difficulty.max_no_competitors + 2)
)) {
/* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */
@@ -589,7 +589,7 @@ static void MaybeStartNewPlayer()
}
/* The next AI starts like the difficulty setting said, with +2 month max */
- _next_competitor_start = _opt.diff.competitor_start_time * 90 * DAY_TICKS + 1;
+ _next_competitor_start = _settings.difficulty.competitor_start_time * 90 * DAY_TICKS + 1;
_next_competitor_start += _network_server ? InteractiveRandomRange(60 * DAY_TICKS) : RandomRange(60 * DAY_TICKS);
}
@@ -994,7 +994,7 @@ StringID EndGameGetPerformanceTitleFromValue(uint value)
/** Save the highscore for the player */
int8 SaveHighScoreValue(const Player *p)
{
- HighScore *hs = _highscore_table[_opt.diff_level];
+ HighScore *hs = _highscore_table[_settings.difficulty.diff_level];
uint i;
uint16 score = p->old_economy[0].performance_history;
diff --git a/src/rail.cpp b/src/rail.cpp
index fc21f5dfe..00e9d91d2 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -207,7 +207,7 @@ RailTypes GetPlayerRailtypes(PlayerID p)
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
const EngineInfo *ei = &e->info;
- if (HasBit(ei->climates, _opt.landscape) &&
+ if (HasBit(ei->climates, _settings.game_creation.landscape) &&
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
const RailVehicleInfo *rvi = &e->u.rail;
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 9e13017d2..6b8f6e4aa 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1420,7 +1420,7 @@ static uint GetSaveSlopeZ(uint x, uint y, Track track)
static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos)
{
- bool side = (_opt.road_side != 0) && _settings.construction.signal_side;
+ bool side = (_settings.vehicle.road_side != 0) && _settings.construction.signal_side;
static const Point SignalPositions[2][12] = {
{ /* Signals on the left side */
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */
@@ -1789,7 +1789,7 @@ static void DrawTile_Track(TileInfo *ti)
/* adjust ground tile for desert
* don't adjust for snow, because snow in depots looks weird */
- if (IsSnowRailGround(ti->tile) && _opt.landscape == LT_TROPIC) {
+ if (IsSnowRailGround(ti->tile) && _settings.game_creation.landscape == LT_TROPIC) {
if (image != SPR_FLAT_GRASS_TILE) {
image += rti->snow_offset; // tile with tracks
} else {
@@ -1953,7 +1953,7 @@ static void TileLoop_Track(TileIndex tile)
return;
}
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC: {
uint z;
Slope slope = GetTileSlope(tile, &z);
diff --git a/src/road.cpp b/src/road.cpp
index 3e99f656f..d25ca7a1b 100644
--- a/src/road.cpp
+++ b/src/road.cpp
@@ -103,7 +103,7 @@ RoadTypes GetPlayerRoadtypes(PlayerID p)
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
const EngineInfo *ei = &e->info;
- if (HasBit(ei->climates, _opt.landscape) &&
+ if (HasBit(ei->climates, _settings.game_creation.landscape) &&
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 7e13d69b0..0910f3b95 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -69,9 +69,9 @@ CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32
if (flags & DC_EXEC) {
if (_game_mode == GM_MENU) {
- _opt_newgame.road_side = p1;
+ _settings.vehicle.road_side = p1;
} else {
- _opt.road_side = p1;
+ _settings.vehicle.road_side = p1;
}
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
@@ -1000,7 +1000,7 @@ const byte _road_sloped_sprites[14] = {
static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
{
return (IsOnSnow(tile) &&
- !(_opt.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
+ !(_settings.game_creation.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS));
}
@@ -1291,7 +1291,7 @@ static const Roadside _town_road_types_2[][2] = {
static void TileLoop_Road(TileIndex tile)
{
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC:
if (IsOnSnow(tile) != (GetTileZ(tile) > GetSnowLine())) {
ToggleSnow(tile);
@@ -1337,7 +1337,7 @@ static void TileLoop_Road(TileIndex tile)
{
/* Adjust road ground type depending on 'grp' (grp is the distance to the center) */
- const Roadside* new_rs = (_opt.landscape == LT_TOYLAND) ? _town_road_types_2[grp] : _town_road_types[grp];
+ const Roadside* new_rs = (_settings.game_creation.landscape == LT_TOYLAND) ? _town_road_types_2[grp] : _town_road_types[grp];
Roadside cur_rs = GetRoadside(tile);
/* We have our desired type, do nothing */
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 3f75123f1..c8ad073d8 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -702,7 +702,7 @@ static void HandleBrokenRoadVeh(Vehicle *v)
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
- SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
+ SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ?
SND_0F_VEHICLE_BREAKDOWN : SND_35_COMEDY_BREAKDOWN, v);
}
@@ -1273,7 +1273,7 @@ static bool RoadVehLeaveDepot(Vehicle *v, bool first)
v->direction = DiagDirToDir(dir);
Trackdir tdir = _roadveh_depot_exit_trackdir[dir];
- const RoadDriveEntry *rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + tdir];
+ const RoadDriveEntry *rdp = _road_drive_data[v->u.road.roadtype][(_settings.vehicle.road_side << RVS_DRIVE_SIDE) + tdir];
int x = TileX(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].x & 0xF);
int y = TileY(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].y & 0xF);
@@ -1451,7 +1451,7 @@ static bool IndividualRoadVehicleController(Vehicle *v, const Vehicle *prev)
* In this case v->u.road.state is masked to give the road stop entry direction. */
rd = _road_drive_data[v->u.road.roadtype][(
(HasBit(v->u.road.state, RVS_IN_DT_ROAD_STOP) ? v->u.road.state & RVSB_ROAD_STOP_TRACKDIR_MASK : v->u.road.state) +
- (_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking][v->u.road.frame + 1];
+ (_settings.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking][v->u.road.frame + 1];
if (rd.x & RDE_NEXT_TILE) {
TileIndex tile = v->tile + TileOffsByDiagDir((DiagDirection)(rd.x & 3));
@@ -1529,7 +1529,7 @@ again:
}
/* Get position data for first frame on the new tile */
- rdp = _road_drive_data[v->u.road.roadtype][(dir + (_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking];
+ rdp = _road_drive_data[v->u.road.roadtype][(dir + (_settings.vehicle.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking];
x = TileX(tile) * TILE_SIZE + rdp[start_frame].x;
y = TileY(tile) * TILE_SIZE + rdp[start_frame].y;
@@ -1632,7 +1632,7 @@ again:
return false;
}
- rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + dir];
+ rdp = _road_drive_data[v->u.road.roadtype][(_settings.vehicle.road_side << RVS_DRIVE_SIDE) + dir];
x = TileX(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].x;
y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;
@@ -1711,7 +1711,7 @@ again:
* (the station test and stop type test ensure that other vehicles, using the road stop as
* a through route, do not stop) */
if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) &&
- _road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_opt.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
+ _road_veh_data_1[v->u.road.state - RVSB_IN_ROAD_STOP + (_settings.vehicle.road_side << RVS_DRIVE_SIDE)] == v->u.road.frame) ||
(IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&
diff --git a/src/settings.cpp b/src/settings.cpp
index 840ab9747..b03bff602 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -63,8 +63,6 @@
#include "table/strings.h"
-GameOptions _opt;
-GameOptions _opt_newgame;
Settings _settings;
Settings _settings_newgame;
@@ -1429,18 +1427,18 @@ static const SettingDesc _gameopt_settings[] = {
* and why not byte for example?
* 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
* for savegames version 0 - though it is an array, it has to go through the byteswap process */
- SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_FILE_I16 | SLE_VAR_U16, 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 0, 3),
- SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16, 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION),
- SDT_VAR(GameOptions, diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
- SDT_OMANY(GameOptions, currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
- SDT_OMANY(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
+ SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_FILE_I16 | SLE_VAR_U16, 0, 0, Settings, difficulty, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 0, 3),
+ SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, SLE_UINT16, 0, 0, Settings, difficulty, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION),
+ SDT_VAR(Settings, difficulty.diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
+ SDT_OMANY(Settings, gui.currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, gui.units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
/* There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. */
- SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
- SDT_OMANY(GameOptions, landscape, SLE_UINT8, 0, 0, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
- SDT_VAR(GameOptions, snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
- SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8, 0, 22, N, 0, 0, 0, "", STR_NULL, NULL, NULL),
- SDT_CONDOMANY(GameOptions,autosave, SLE_UINT8,23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL, NULL),
- SDT_OMANY(GameOptions, road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, game_creation.town_name, SLE_UINT8, 0, 0, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, game_creation.landscape, SLE_UINT8, 0, 0, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
+ SDT_VAR(Settings, game_creation.snow_line, SLE_UINT8, 0, 0, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
+ SDT_CONDOMANY(Settings,gui.autosave, SLE_UINT8, 0, 22, N, 0, 0, 0, "", STR_NULL, NULL, NULL),
+ SDT_CONDOMANY(Settings,gui.autosave, SLE_UINT8,23, SL_MAX_VERSION, S, 0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL, NULL, NULL),
+ SDT_OMANY(Settings, vehicle.road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL),
SDT_END()
};
@@ -1838,7 +1836,7 @@ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescP
proc(ini, (const SettingDesc*)_win32_settings, "win32", NULL);
#endif /* WIN32 */
- proc(ini, _gameopt_settings, "gameopt", &_opt_newgame);
+ proc(ini, _gameopt_settings, "gameopt", &_settings_newgame);
proc(ini, _patch_settings, "patches", &_settings_newgame);
proc(ini, _currency_settings,"currency", &_custom_currency);
@@ -2086,13 +2084,12 @@ static void Load_OPTS()
/* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local
* autosave-frequency stays when joining a network-server */
- _opt = _opt_newgame;
- LoadSettings(_gameopt_settings, &_opt);
+ LoadSettings(_gameopt_settings, &_settings);
}
static void Save_OPTS()
{
- SaveSettings(_gameopt_settings, &_opt);
+ SaveSettings(_gameopt_settings, &_settings);
}
static void Load_PATS()
@@ -2100,7 +2097,6 @@ static void Load_PATS()
/* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local
* signal_side stays when joining a network-server */
- _settings = _settings_newgame;
LoadSettings(_patch_settings, &_settings);
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 63173d811..7b2fbdaef 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -142,11 +142,11 @@ static void ShowTownnameDropdown(Window *w, int sel)
static void ShowCustCurrency();
struct GameOptionsWindow : Window {
- GameOptions *opt;
+ Settings *opt;
GameOptionsWindow(const WindowDesc *desc) : Window(desc)
{
- this->opt = (_game_mode == GM_MENU) ? &_opt_newgame : &_opt;
+ this->opt = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
this->FindWindowPlacementAndResize(desc);
}
@@ -162,11 +162,11 @@ struct GameOptionsWindow : Window {
this->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1));
if (!this->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM;
SetDParam(0, str);
- SetDParam(1, _currency_specs[this->opt->currency].name);
- SetDParam(2, STR_UNITS_IMPERIAL + this->opt->units);
- SetDParam(3, STR_02E9_DRIVE_ON_LEFT + this->opt->road_side);
- SetDParam(4, TownName(this->opt->town_name));
- SetDParam(5, _autosave_dropdown[this->opt->autosave]);
+ SetDParam(1, _currency_specs[this->opt->gui.currency].name);
+ SetDParam(2, STR_UNITS_IMPERIAL + this->opt->gui.units);
+ SetDParam(3, STR_02E9_DRIVE_ON_LEFT + this->opt->vehicle.road_side);
+ SetDParam(4, TownName(this->opt->game_creation.town_name));
+ SetDParam(5, _autosave_dropdown[this->opt->gui.autosave]);
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
int i = GetCurRes();
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
@@ -181,11 +181,11 @@ struct GameOptionsWindow : Window {
{
switch (widget) {
case GAMEOPT_CURRENCY_BTN: // Setup currencies dropdown
- ShowDropDownMenu(this, BuildCurrencyDropdown(), this->opt->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
+ ShowDropDownMenu(this, BuildCurrencyDropdown(), this->opt->gui.currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
break;
case GAMEOPT_DISTANCE_BTN: // Setup distance unit dropdown
- ShowDropDownMenu(this, _units_dropdown, this->opt->units, GAMEOPT_DISTANCE_BTN, 0, 0);
+ ShowDropDownMenu(this, _units_dropdown, this->opt->gui.units, GAMEOPT_DISTANCE_BTN, 0, 0);
break;
case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown
@@ -195,18 +195,18 @@ struct GameOptionsWindow : Window {
/* You can only change the drive side if you are in the menu or ingame with
* no vehicles present. In a networking game only the server can change it */
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) {
- i = (-1) ^ (1 << this->opt->road_side); // disable the other value
+ i = (-1) ^ (1 << this->opt->vehicle.road_side); // disable the other value
}
- ShowDropDownMenu(this, _driveside_dropdown, this->opt->road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
+ ShowDropDownMenu(this, _driveside_dropdown, this->opt->vehicle.road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
} break;
case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown
- ShowTownnameDropdown(this, this->opt->town_name);
+ ShowTownnameDropdown(this, this->opt->game_creation.town_name);
break;
case GAMEOPT_AUTOSAVE_BTN: // Setup autosave dropdown
- ShowDropDownMenu(this, _autosave_dropdown, this->opt->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
+ ShowDropDownMenu(this, _autosave_dropdown, this->opt->gui.autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
break;
case GAMEOPT_VEHICLENAME_BTN: // Setup customized vehicle-names dropdown
@@ -265,17 +265,17 @@ struct GameOptionsWindow : Window {
case GAMEOPT_CURRENCY_BTN: /* Currency */
if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
- this->opt->currency = index;
+ this->opt->gui.currency = index;
MarkWholeScreenDirty();
break;
case GAMEOPT_DISTANCE_BTN: // Measuring units
- this->opt->units = index;
+ this->opt->gui.units = index;
MarkWholeScreenDirty();
break;
case GAMEOPT_ROADSIDE_BTN: // Road side
- if (this->opt->road_side != index) { // only change if setting changed
+ if (this->opt->vehicle.road_side != index) { // only change if setting changed
DoCommandP(0, index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
MarkWholeScreenDirty();
}
@@ -283,13 +283,13 @@ struct GameOptionsWindow : Window {
case GAMEOPT_TOWNNAME_BTN: // Town names
if (_game_mode == GM_MENU) {
- this->opt->town_name = index;
+ this->opt->game_creation.town_name = index;
InvalidateWindow(WC_GAME_OPTIONS, 0);
}
break;
case GAMEOPT_AUTOSAVE_BTN: // Autosave options
- _opt.autosave = _opt_newgame.autosave = index;
+ _settings.gui.autosave = _settings.gui.autosave = index;
this->SetDirty();
break;
@@ -416,7 +416,7 @@ static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
{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)
+void SetDifficultyLevel(int mode, DifficultySettings *gm_opt)
{
int i;
assert(mode <= 3);
@@ -424,7 +424,7 @@ void SetDifficultyLevel(int mode, GameOptions *gm_opt)
gm_opt->diff_level = mode;
if (mode != 3) { // not custom
for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
- ((GDType*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
+ ((GDType*)gm_opt)[i] = _default_game_diff[mode][i];
}
}
@@ -434,11 +434,11 @@ void SetDifficultyLevel(int mode, GameOptions *gm_opt)
*/
void CheckDifficultyLevels()
{
- if (_opt_newgame.diff_level != 3) {
- SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
+ if (_settings_newgame.difficulty.diff_level != 3) {
+ SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
} else {
for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
- GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
+ GDType *diff = ((GDType*)&_settings_newgame.difficulty) + i;
*diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
*diff -= *diff % _game_setting_info[i].step;
}
@@ -479,7 +479,7 @@ private:
uint8 timeout;
/* Temporary holding place of values in the difficulty window until 'Save' is clicked */
- GameOptions opt_mod_temp;
+ DifficultySettings opt_mod_temp;
enum {
GAMEDIFF_WND_TOP_OFFSET = 45,
@@ -510,7 +510,7 @@ public:
{
/* Copy current settings (ingame or in intro) to temporary holding place
* change that when setting stuff, copy back on clicking 'OK' */
- this->opt_mod_temp = (_game_mode == GM_MENU) ? _opt_newgame : _opt;
+ this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame.difficulty : _settings.difficulty;
this->clicked_increase = false;
this->clicked_button = NO_SETTINGS_BUTTON;
this->timeout = 0;
@@ -549,7 +549,7 @@ public:
int y = GAMEDIFF_WND_TOP_OFFSET;
for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) {
const GameSettingData *gsd = &_game_setting_info[i];
- value = ((GDType*)&this->opt_mod_temp.diff)[i];
+ value = ((GDType*)&this->opt_mod_temp)[i];
DrawArrowButtons(5, y, 3,
(this->clicked_button == i) ? 1 + !!this->clicked_increase : 0,
@@ -587,7 +587,7 @@ public:
this->timeout = 5;
- int16 val = ((GDType*)&this->opt_mod_temp.diff)[btn];
+ int16 val = ((GDType*)&this->opt_mod_temp)[btn];
const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting
if (x >= 10) {
@@ -603,7 +603,7 @@ public:
this->clicked_button = btn;
/* save value in temporary variable */
- ((GDType*)&this->opt_mod_temp.diff)[btn] = val;
+ ((GDType*)&this->opt_mod_temp)[btn] = val;
this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level);
SetDifficultyLevel(3, &this->opt_mod_temp); // set difficulty level to custom
this->LowerWidget(GDW_LVL_CUSTOM);
@@ -627,11 +627,11 @@ public:
case GDW_ACCEPT: { // Save button - save changes
GDType btn, val;
- GameOptions *opt_ptr = (_game_mode == GM_MENU) ? &_opt_newgame : &_opt;
+ Settings *opt_ptr = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings;
for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
- val = ((GDType*)&this->opt_mod_temp.diff)[btn];
+ val = ((GDType*)&this->opt_mod_temp)[btn];
/* if setting has changed, change it */
- if (val != ((GDType*)&opt_ptr->diff)[btn]) {
+ if (val != ((GDType*)&opt_ptr->difficulty)[btn]) {
DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
}
}
diff --git a/src/settings_type.h b/src/settings_type.h
index a60b2b208..6cd8d326f 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -33,46 +33,29 @@ enum {
/** Specific type for Game Difficulty to ease changing the type */
typedef uint16 GDType;
-struct GameDifficulty {
- GDType max_no_competitors;
- GDType competitor_start_time;
- GDType number_towns;
- GDType number_industries;
- GDType max_loan;
- GDType initial_interest;
- GDType vehicle_costs;
- GDType competitor_speed;
- GDType competitor_intelligence; ///< no longer in use
- GDType vehicle_breakdowns;
- GDType subsidy_multiplier;
- GDType construction_cost;
- GDType terrain_type;
- GDType quantity_sea_lakes;
- GDType economy;
- GDType line_reverse_mode;
- GDType disasters;
- GDType town_council_tolerance; ///< minimum required town ratings to be allowed to demolish stuff
+/** Settings related to the difficulty of the game */
+struct DifficultySettings {
+ GDType max_no_competitors; ///< the number of competitors (AIs)
+ GDType competitor_start_time; ///< how long to wait for the first competitors (AIs)
+ GDType number_towns; ///< the amount of towns
+ GDType number_industries; ///< the amount of industries
+ GDType max_loan; ///< the maximum initial loan
+ GDType initial_interest; ///< amount of interest (to pay over the loan)
+ GDType vehicle_costs; ///< amount of money spent on vehicle running cost
+ GDType competitor_speed; ///< the speed at which the AI builds
+ GDType competitor_intelligence; ///< the competior's (AI) intelligence
+ GDType vehicle_breakdowns; ///< likelihood of vehicles breaking down
+ GDType subsidy_multiplier; ///< amount of subsidy
+ GDType construction_cost; ///< how expensive is building
+ GDType terrain_type; ///< the mountainousness of the landscape
+ GDType quantity_sea_lakes; ///< the amount of seas/lakes
+ GDType economy; ///< how volatile is the economy
+ GDType line_reverse_mode; ///< reversing at stations or not
+ GDType disasters; ///< are disasters enabled
+ GDType town_council_tolerance; ///< minimum required town ratings to be allowed to demolish stuff
+ GDType diff_level; ///< the difficulty level
};
-struct GameOptions {
- GameDifficulty diff;
- byte diff_level;
- byte currency;
- byte units;
- byte town_name;
- byte landscape;
- byte snow_line;
- byte autosave;
- byte road_side;
-};
-
-/* These are the options for the current game
- * either ingame, or loaded. Also used for networking games */
-extern GameOptions _opt;
-
-/* These are the default options for a new game */
-extern GameOptions _opt_newgame;
-
/** Settings related to the GUI and other stuff that is not saved in the savegame. */
struct GUISettings {
bool vehicle_speed; ///< show vehicle speed
@@ -98,6 +81,7 @@ struct GUISettings {
uint8 toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right
uint8 window_snap_radius; ///< windows snap at each other if closer than this
bool always_build_infrastructure; ///< always allow building of infrastructure, even when you do not have the vehicles for it
+ byte autosave; ///< how often should we do autosaves?
bool keep_all_autosave; ///< name the autosave in a different way
bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
byte max_num_autosaves; ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
@@ -117,6 +101,8 @@ struct GUISettings {
bool autorenew; ///< should autorenew be enabled for new companies?
int16 autorenew_months; ///< how many months from EOL of vehicles should autorenew trigger for new companies?
int32 autorenew_money; ///< how much money before autorenewing for new companies?
+ byte currency; ///< currency we currently use
+ byte units; ///< unit system we show everything
};
/** Settings related to the creation of games. */
@@ -132,6 +118,9 @@ struct GameCreationSettings {
byte tree_placer; ///< the tree placer algorithm
byte heightmap_rotation; ///< rotation director for the heightmap
byte se_flat_world_height; ///< land height a flat world gets in SE
+ byte town_name; ///< the town name generator used for town names
+ byte landscape; ///< the landscape we're currently in
+ byte snow_line; ///< the snowline level in this game
};
/** Settings related to construction in-game */
@@ -266,6 +255,7 @@ struct VehicleSettings {
bool dynamic_engines; ///< enable dynamic allocation of engine data
bool never_expire_vehicles; ///< never expire vehicles
byte extend_vehicle_life; ///< extend vehicle life by this many years
+ byte road_side; ///< the side of the road vehicles drive on
};
/** Settings related to the economy. */
@@ -300,6 +290,7 @@ struct StationSettings {
/** All settings together. */
struct Settings {
+ DifficultySettings difficulty; ///< settings related to the difficulty
GUISettings gui; ///< settings related to the GUI
GameCreationSettings game_creation; ///< settings used during the creation of a game (map)
ConstructionSettings construction; ///< construction of things in-game
@@ -311,9 +302,10 @@ struct Settings {
StationSettings station; ///< settings related to station management
};
+/** The current settings. */
extern Settings _settings;
-/** The patch values that are used for new games and/or modified in config file */
+/** The settings values that are used for new games and/or modified in config file */
extern Settings _settings_newgame;
#endif /* SETTINGS_TYPE_H */
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 10fd85df2..4b458bdeb 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -196,7 +196,7 @@ static void HandleBrokenShip(Vehicle *v)
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
- SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
+ SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ?
SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
}
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index b6ba2037a..5f0f039fb 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -459,7 +459,7 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
case MP_TREES:
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
- bits = (_opt.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
+ bits = (_settings.game_creation.landscape == LT_ARCTIC) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2);
} else {
bits = MKCOLOR(0x54575754);
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 6432782a6..479d05e3f 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -296,7 +296,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
CountMapSquareAround(tile, CMSATree) >= 8 ||
CountMapSquareAround(tile, CMSAForest) >= 2)
) {
- return _opt.landscape == LT_TROPIC ? STR_SV_STNAME_FOREST : STR_SV_STNAME_WOODS;
+ return _settings.game_creation.landscape == LT_TROPIC ? STR_SV_STNAME_FOREST : STR_SV_STNAME_WOODS;
}
/* check elevation compared to town */
@@ -1681,7 +1681,7 @@ uint8 GetAirportNoiseLevelForTown(const AirportFTAClass *afc, TileIndex town_til
* adding the town_council_tolerance 4 times, as a way to graduate, depending of the tolerance.
* Basically, it says that the less tolerant a town is, the bigger the distance before
* an actual decrease can be granted */
- uint8 town_tolerance_distance = 8 + (_opt.diff.town_council_tolerance * 4);
+ uint8 town_tolerance_distance = 8 + (_settings.difficulty.town_council_tolerance * 4);
/* The airport is in the "inner" distance where there is no noise reduction */
if (distance < town_tolerance_distance) return afc->noise_level;
diff --git a/src/strings.cpp b/src/strings.cpp
index 6deec5263..112e4c42b 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -546,7 +546,7 @@ static const Units units[] = {
*/
uint ConvertSpeedToDisplaySpeed(uint speed)
{
- return (speed * units[_opt.units].s_m) >> units[_opt.units].s_s;
+ return (speed * units[_settings.gui.units].s_m) >> units[_settings.gui.units].s_s;
}
/**
@@ -556,7 +556,7 @@ uint ConvertSpeedToDisplaySpeed(uint speed)
*/
uint ConvertDisplaySpeedToSpeed(uint speed)
{
- return ((speed << units[_opt.units].s_s) + units[_opt.units].s_m / 2) / units[_opt.units].s_m;
+ return ((speed << units[_settings.gui.units].s_s) + units[_settings.gui.units].s_m / 2) / units[_settings.gui.units].s_m;
}
static char* FormatString(char* buff, const char* str, const int64* argv, uint casei, const char* last)
@@ -602,9 +602,9 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
case SCC_VELOCITY: {// {VELOCITY}
int64 args[1];
- assert(_opt.units < lengthof(units));
+ assert(_settings.gui.units < lengthof(units));
args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv));
- buff = FormatString(buff, GetStringPtr(units[_opt.units].velocity), args, modifier >> 24, last);
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].velocity), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -625,18 +625,18 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
switch (cargo_str) {
case STR_TONS: {
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].w_m >> units[_opt.units].w_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].l_weight), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_weight), args, modifier >> 24, last);
modifier = 0;
break;
}
case STR_LITERS: {
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].v_m >> units[_opt.units].v_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].l_volume), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_volume), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -718,9 +718,9 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
case SCC_VOLUME: { // {VOLUME}
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].v_m >> units[_opt.units].v_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].l_volume), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_volume), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -763,45 +763,45 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
case SCC_POWER: { // {POWER}
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].p_m >> units[_opt.units].p_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].power), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].p_m >> units[_settings.gui.units].p_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].power), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_VOLUME_SHORT: { // {VOLUME_S}
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].v_m >> units[_opt.units].v_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].s_volume), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].s_volume), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_WEIGHT: { // {WEIGHT}
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].w_m >> units[_opt.units].w_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].l_weight), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_weight), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_WEIGHT_SHORT: { // {WEIGHT_S}
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].w_m >> units[_opt.units].w_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].s_weight), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].s_weight), args, modifier >> 24, last);
modifier = 0;
break;
}
case SCC_FORCE: { // {FORCE}
int64 args[1];
- assert(_opt.units < lengthof(units));
- args[0] = GetInt32(&argv) * units[_opt.units].f_m >> units[_opt.units].f_s;
- buff = FormatString(buff, GetStringPtr(units[_opt.units].force), args, modifier >> 24, last);
+ assert(_settings.gui.units < lengthof(units));
+ args[0] = GetInt32(&argv) * units[_settings.gui.units].f_m >> units[_settings.gui.units].f_s;
+ buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].force), args, modifier >> 24, last);
modifier = 0;
break;
}
@@ -1137,7 +1137,7 @@ static char *GenAndCoName(char *buff, uint32 arg, const char* last)
const char* const* base;
uint num;
- if (_opt.landscape == LT_TOYLAND) {
+ if (_settings.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list;
num = lengthof(_silly_surname_list);
} else {
@@ -1167,7 +1167,7 @@ static char *GenPresidentName(char *buff, uint32 x, const char* last)
buff = strecpy(buff, initial, last);
}
- if (_opt.landscape == LT_TOYLAND) {
+ if (_settings.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list;
num = lengthof(_silly_surname_list);
} else {
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index f0dae8a97..4e8e82251 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -550,7 +550,7 @@ static void EditorTerraformClick_RockyArea(Window *w)
static void EditorTerraformClick_DesertLightHouse(Window *w)
{
- HandlePlacePushButton(w, ETTW_PLACE_DESERT_LIGHTHOUSE, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_opt.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
+ HandlePlacePushButton(w, ETTW_PLACE_DESERT_LIGHTHOUSE, SPR_CURSOR_LIGHTHOUSE, VHM_RECT, (_settings.game_creation.landscape == LT_TROPIC) ? PlaceProc_DesertArea : PlaceProc_LightHouse);
}
static void EditorTerraformClick_Transmitter(Window *w)
@@ -615,7 +615,7 @@ static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
struct ScenarioEditorLandscapeGenerationWindow : Window {
ScenarioEditorLandscapeGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
- this->widget[ETTW_PLACE_DESERT_LIGHTHOUSE].tooltips = (_opt.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
+ this->widget[ETTW_PLACE_DESERT_LIGHTHOUSE].tooltips = (_settings.game_creation.landscape == LT_TROPIC) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
this->FindWindowPlacementAndResize(desc);
}
diff --git a/src/tgp.cpp b/src/tgp.cpp
index 5b0db2943..f27c51b5d 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -211,10 +211,10 @@ static const amplitude_t _amplitudes_by_smoothness_and_frequency[4][12] = {
{1500, 1000, 1200, 1000, 500, 32, 20, 0, 0, 0, 0, 0},
};
-/** Desired water percentage (100% == 1024) - indexed by _opt.diff.quantity_sea_lakes */
+/** Desired water percentage (100% == 1024) - indexed by _settings.difficulty.quantity_sea_lakes */
static const amplitude_t _water_percent[4] = {20, 80, 250, 400};
-/** Desired maximum height - indexed by _opt.diff.terrain_type */
+/** Desired maximum height - indexed by _settings.difficulty.terrain_type */
static const int8 _max_height[4] = {
6, ///< Very flat
9, ///< Flat
@@ -402,7 +402,7 @@ static void HeightMapSineTransform(height_t h_min, height_t h_max)
/* Transform height into 0..1 space */
fheight = (double)(*h - h_min) / (double)(h_max - h_min);
/* Apply sine transform depending on landscape type */
- switch(_opt.landscape) {
+ switch(_settings.game_creation.landscape) {
case LT_TOYLAND:
case LT_TEMPERATE:
/* Move and scale 0..1 into -1..+1 */
@@ -661,8 +661,8 @@ static void HeightMapSmoothSlopes(height_t dh_max)
* - height histogram redistribution by sine wave transform */
static void HeightMapNormalize()
{
- const amplitude_t water_percent = _water_percent[_opt.diff.quantity_sea_lakes];
- const height_t h_max_new = I2H(_max_height[_opt.diff.terrain_type]);
+ const amplitude_t water_percent = _water_percent[_settings.difficulty.quantity_sea_lakes];
+ const height_t h_max_new = I2H(_max_height[_settings.difficulty.terrain_type]);
const height_t roughness = 7 + 3 * _settings.game_creation.tgen_smoothness;
HeightMapAdjustWaterLevel(water_percent, h_max_new);
diff --git a/src/town.h b/src/town.h
index 3e5da5546..d19a6b387 100644
--- a/src/town.h
+++ b/src/town.h
@@ -197,7 +197,7 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
inline uint16 MaxTownNoise() const {
if (this->population == 0) return 0; // no population? no noise
- return ((this->population / _settings.economy.town_noise_population[_opt.diff.town_council_tolerance]) + 3);
+ return ((this->population / _settings.economy.town_noise_population[_settings.difficulty.town_council_tolerance]) + 3);
}
};
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 60bd389a4..7359ef952 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -596,7 +596,7 @@ static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
if (callback != CALLBACK_FAILED) {
if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4);
if (accepts[1] != CT_INVALID) ac[accepts[1]] = GB(callback, 4, 4);
- if (_opt.landscape != LT_TEMPERATE && HasBit(callback, 12)) {
+ if (_settings.game_creation.landscape != LT_TEMPERATE && HasBit(callback, 12)) {
/* The 'S' bit indicates food instead of goods */
ac[CT_FOOD] = GB(callback, 8, 4);
} else {
@@ -1367,9 +1367,9 @@ static bool CreateTownName(uint32 *townnameparts)
* the other towns may take considerable amount of time (10000 is
* too much). */
int tries = 1000;
- bool grf = (_opt.town_name >= _nb_orig_names);
- uint32 grfid = grf ? GetGRFTownNameId(_opt.town_name - _nb_orig_names) : 0;
- uint16 townnametype = grf ? GetGRFTownNameType(_opt.town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + _opt.town_name;
+ bool grf = (_settings.game_creation.town_name >= _nb_orig_names);
+ uint32 grfid = grf ? GetGRFTownNameId(_settings.game_creation.town_name - _nb_orig_names) : 0;
+ uint16 townnametype = grf ? GetGRFTownNameType(_settings.game_creation.town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
assert(townnameparts != NULL);
@@ -1453,14 +1453,14 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
t->exclusive_counter = 0;
t->statues = 0;
- if (_opt.town_name < _nb_orig_names) {
+ if (_settings.game_creation.town_name < _nb_orig_names) {
/* Original town name */
t->townnamegrfid = 0;
- t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name;
+ t->townnametype = SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
} else {
/* Newgrf town name */
- t->townnamegrfid = GetGRFTownNameId(_opt.town_name - _nb_orig_names);
- t->townnametype = GetGRFTownNameType(_opt.town_name - _nb_orig_names);
+ t->townnamegrfid = GetGRFTownNameId(_settings.game_creation.town_name - _nb_orig_names);
+ t->townnametype = GetGRFTownNameType(_settings.game_creation.town_name - _nb_orig_names);
}
t->townnameparts = townnameparts;
@@ -1585,7 +1585,7 @@ static const byte _num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, no
bool GenerateTowns()
{
uint num = 0;
- uint n = ScaleByMapSize(_num_initial_towns[_opt.diff.number_towns] + (Random() & 7));
+ uint n = ScaleByMapSize(_num_initial_towns[_settings.difficulty.number_towns] + (Random() & 7));
uint num_cities = _settings.economy.larger_towns == 0 ? 0 : n / _settings.economy.larger_towns;
SetGeneratingWorldProgress(GWP_TOWN, n);
@@ -1879,8 +1879,8 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
HouseZonesBits rad = GetTownRadiusGroup(t, tile);
/* Above snow? */
- int land = _opt.landscape;
- if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1;
+ int land = _settings.game_creation.landscape;
+ if (land == LT_ARCTIC && z >= _settings.game_creation.snow_line) land = -1;
uint bitmask = (1 << rad) + (1 << (land + 12));
@@ -2352,10 +2352,10 @@ static void UpdateTownGrowRate(Town *t)
if (n == 0 && !Chance16(1, 12)) return;
}
- if (_opt.landscape == LT_ARCTIC) {
+ if (_settings.game_creation.landscape == LT_ARCTIC) {
if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90)
return;
- } else if (_opt.landscape == LT_TROPIC) {
+ } else if (_settings.game_creation.landscape == LT_TROPIC) {
if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food == 0 || t->act_water == 0) && t->population > 60)
return;
}
@@ -2524,7 +2524,7 @@ bool CheckforTownRating(uint32 flags, Town *t, byte type)
* owned by a town no removal if rating is lower than ... depends now on
* difficulty setting. Minimum town rating selected by difficulty level
*/
- int modemod = _default_rating_settings[_opt.diff.town_council_tolerance][type];
+ int modemod = _default_rating_settings[_settings.difficulty.town_council_tolerance][type];
if (GetRating(t) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
SetDParam(0, t->index);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 00ff10cc1..c1201398c 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2474,7 +2474,7 @@ static Track ChooseTrainTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir
static bool CheckReverseTrain(Vehicle *v)
{
- if (_opt.diff.line_reverse_mode != 0 ||
+ if (_settings.difficulty.line_reverse_mode != 0 ||
v->u.rail.track == TRACK_BIT_DEPOT || v->u.rail.track == TRACK_BIT_WORMHOLE ||
!(v->direction & 1)) {
return false;
@@ -3246,7 +3246,7 @@ static void HandleBrokenTrain(Vehicle *v)
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
- SndPlayVehicleFx((_opt.landscape != LT_TOYLAND) ?
+ SndPlayVehicleFx((_settings.game_creation.landscape != LT_TOYLAND) ?
SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
}
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 2ff5ba9a3..1dd5c0983 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -112,7 +112,7 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint
*/
static TreeType GetRandomTreeType(TileIndex tile, uint seed)
{
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TEMPERATE:
return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
@@ -259,7 +259,7 @@ void PlaceTreesRandomly()
j = GetTileZ(tile) / TILE_HEIGHT * 2;
while (j--) {
/* Above snowline more trees! */
- if (_opt.landscape == LT_ARCTIC && ht > GetSnowLine()) {
+ if (_settings.game_creation.landscape == LT_ARCTIC && ht > GetSnowLine()) {
PlaceTreeAtSameHeight(tile, ht);
PlaceTreeAtSameHeight(tile, ht);
};
@@ -270,7 +270,7 @@ void PlaceTreesRandomly()
} while (--i);
/* place extra trees at rainforest area */
- if (_opt.landscape == LT_TROPIC) {
+ if (_settings.game_creation.landscape == LT_TROPIC) {
i = ScaleByMapSize(15000);
do {
@@ -298,16 +298,16 @@ void GenerateTrees()
if (_settings.game_creation.tree_placer == TP_NONE) return;
- if (_opt.landscape != LT_TOYLAND) PlaceMoreTrees();
+ if (_settings.game_creation.landscape != LT_TOYLAND) PlaceMoreTrees();
switch (_settings.game_creation.tree_placer) {
- case TP_ORIGINAL: i = _opt.landscape == LT_ARCTIC ? 15 : 6; break;
- case TP_IMPROVED: i = _opt.landscape == LT_ARCTIC ? 4 : 2; break;
+ case TP_ORIGINAL: i = _settings.game_creation.landscape == LT_ARCTIC ? 15 : 6; break;
+ case TP_IMPROVED: i = _settings.game_creation.landscape == LT_ARCTIC ? 4 : 2; break;
default: NOT_REACHED(); return;
}
total = ScaleByMapSize(1000);
- if (_opt.landscape == LT_TROPIC) total += ScaleByMapSize(15000);
+ if (_settings.game_creation.landscape == LT_TROPIC) total += ScaleByMapSize(15000);
total *= i;
SetGeneratingWorldProgress(GWP_TREE, total);
@@ -332,7 +332,7 @@ CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (p2 >= MapSize()) return CMD_ERROR;
/* Check the tree type. It can be random or some valid value within the current climate */
- if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_opt.landscape] >= _tree_count_by_landscape[_opt.landscape]) return CMD_ERROR;
+ if (p1 != (uint)-1 && p1 - _tree_base_by_landscape[_settings.game_creation.landscape] >= _tree_count_by_landscape[_settings.game_creation.landscape]) return CMD_ERROR;
// make sure sx,sy are smaller than ex,ey
ex = TileX(tile);
@@ -626,7 +626,7 @@ static void TileLoop_Trees(TileIndex tile)
if (GetTreeGround(tile) == TREE_GROUND_SHORE) {
TileLoop_Water(tile);
} else {
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_TROPIC: TileLoopTreesDesert(tile); break;
case LT_ARCTIC: TileLoopTreesAlps(tile); break;
}
@@ -652,7 +652,7 @@ static void TileLoop_Trees(TileIndex tile)
switch (GetTreeGrowth(tile)) {
case 3: /* regular sized tree */
- if (_opt.landscape == LT_TROPIC &&
+ if (_settings.game_creation.landscape == LT_TROPIC &&
GetTreeType(tile) != TREE_CACTUS &&
GetTropicZone(tile) == TROPICZONE_DESERT) {
AddTreeGrowth(tile, 1);
@@ -704,7 +704,7 @@ static void TileLoop_Trees(TileIndex tile)
case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break;
case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
default: // snow or desert
- MakeClear(tile, _opt.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW, GetTreeDensity(tile));
+ MakeClear(tile, _settings.game_creation.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW, GetTreeDensity(tile));
break;
}
}
@@ -725,7 +725,7 @@ void OnTick_Trees()
TreeType tree;
/* place a tree at a random rainforest spot */
- if (_opt.landscape == LT_TROPIC &&
+ if (_settings.game_creation.landscape == LT_TROPIC &&
(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
CanPlantTreesOnTile(tile, false) &&
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp
index 410d4724d..0e84466cc 100644
--- a/src/tree_gui.cpp
+++ b/src/tree_gui.cpp
@@ -74,8 +74,8 @@ public:
this->DrawWidgets();
- int i = this->base = _tree_base_by_landscape[_opt.landscape];
- int count = this->count = _tree_count_by_landscape[_opt.landscape];
+ int i = this->base = _tree_base_by_landscape[_settings.game_creation.landscape];
+ int count = this->count = _tree_count_by_landscape[_settings.game_creation.landscape];
int x = 18;
int y = 54;
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index d1f1b3c87..d0ec9f283 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1200,7 +1200,7 @@ static void AnimateTile_TunnelBridge(TileIndex tile)
static void TileLoop_TunnelBridge(TileIndex tile)
{
bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
- switch (_opt.landscape) {
+ switch (_settings.game_creation.landscape) {
case LT_ARCTIC:
if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 61ab5fe9b..f84a4d8e7 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -375,11 +375,11 @@ static bool IsRadioTowerNearby(TileIndex tile)
void GenerateUnmovables()
{
- if (_opt.landscape == LT_TOYLAND) return;
+ if (_settings.game_creation.landscape == LT_TOYLAND) return;
/* add radio tower */
int radiotowser_to_build = ScaleByMapSize(15); // maximum number of radio towers on the map
- int lighthouses_to_build = _opt.landscape == LT_TROPIC ? 0 : ScaleByMapSize1D((Random() & 3) + 7);
+ int lighthouses_to_build = _settings.game_creation.landscape == LT_TROPIC ? 0 : ScaleByMapSize1D((Random() & 3) + 7);
SetGeneratingWorldProgress(GWP_UNMOVABLE, radiotowser_to_build + lighthouses_to_build);
for (uint i = ScaleByMapSize(1000); i != 0; i--) {
@@ -395,7 +395,7 @@ void GenerateUnmovables()
}
}
- if (_opt.landscape == LT_TROPIC) return;
+ if (_settings.game_creation.landscape == LT_TROPIC) return;
/* add lighthouses */
uint maxx = MapMaxX();
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index bdfef2aa4..f5bb940f7 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -127,7 +127,7 @@ bool Vehicle::NeedsServicing() const
{
if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false;
- if (_settings.order.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0) {
+ if (_settings.order.no_servicing_if_no_breakdowns && _settings.difficulty.vehicle_breakdowns == 0) {
/* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off.
* Note: If servicing is enabled, we postpone replacement till next service. */
return EngineHasReplacementForPlayer(GetPlayer(this->owner), this->engine_type, this->group_id);
@@ -913,7 +913,7 @@ void CheckVehicleBreakdown(Vehicle *v)
if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
- _opt.diff.vehicle_breakdowns < 1 ||
+ _settings.difficulty.vehicle_breakdowns < 1 ||
v->cur_speed < 5 || _game_mode == GM_MENU) {
return;
}
@@ -930,7 +930,7 @@ void CheckVehicleBreakdown(Vehicle *v)
if (v->type == VEH_SHIP) rel += 0x6666;
/* reduced breakdowns? */
- if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666;
+ if (_settings.difficulty.vehicle_breakdowns == 1) rel += 0x6666;
/* check if to break down */
if (_breakdown_chance[(uint)min(rel, 0xffff) >> 10] <= v->breakdown_chance) {