1
0
Fork 0

(svn r13255) -Codechange: move _opt to _settings.

release/0.7
rubidium 2008-05-25 22:36:44 +00:00
parent 51ca426c4b
commit 8c9cc415e3
49 changed files with 344 additions and 360 deletions

View File

@ -184,8 +184,8 @@ void AI_RunGameLoop()
_ai.tick++; _ai.tick++;
/* Make sure the AI follows the difficulty rule.. */ /* Make sure the AI follows the difficulty rule.. */
assert(_opt.diff.competitor_speed <= 4); assert(_settings.difficulty.competitor_speed <= 4);
if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0) return; if ((_ai.tick & ((1 << (4 - _settings.difficulty.competitor_speed)) - 1)) != 0) return;
/* Check for AI-client (so joining a network with an AI) */ /* Check for AI-client (so joining a network with an AI) */
if (!_networking || _network_server) { if (!_networking || _network_server) {

View File

@ -2550,7 +2550,7 @@ handle_nocash:
bool is_pass = ( bool is_pass = (
_players_ai[p->index].cargo_type == CT_PASSENGERS || _players_ai[p->index].cargo_type == CT_PASSENGERS ||
_players_ai[p->index].cargo_type == CT_MAIL || _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; Order order;
@ -3285,7 +3285,7 @@ static void AiStateBuildRoadVehicles(Player *p)
bool is_pass = ( bool is_pass = (
_players_ai[p->index].cargo_type == CT_PASSENGERS || _players_ai[p->index].cargo_type == CT_PASSENGERS ||
_players_ai[p->index].cargo_type == CT_MAIL || _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; Order order;

View File

@ -1017,7 +1017,7 @@ static void AiNew_State_BuildPath(Player *p)
if (_players_ainew[p->index].temp == -1) { if (_players_ainew[p->index].temp == -1) {
DEBUG(ai, 1, "Starting to build new path"); DEBUG(ai, 1, "Starting to build new path");
// Init the counter // 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 ++) // Set the position to the startingplace (-1 because in a minute we do ++)
_players_ainew[p->index].path_info.position = -1; _players_ainew[p->index].path_info.position = -1;
// And don't do this again // 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.. // 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 :) // By let the counter count from AI_BUILDPATH_PAUSE to 0, we have a nice way :)
if (--_players_ainew[p->index].counter != 0) return; 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 // Increase the building position
_players_ainew[p->index].path_info.position++; _players_ainew[p->index].path_info.position++;

View File

@ -64,9 +64,9 @@ static int32 ClickChangeClimateCheat(int32 p1, int32 p2)
{ {
if (p1 == -1) p1 = 3; if (p1 == -1) p1 = 3;
if (p1 == 4) p1 = 0; if (p1 == 4) p1 = 0;
_opt.landscape = p1; _settings.game_creation.landscape = p1;
ReloadNewGRFData(); ReloadNewGRFData();
return _opt.landscape; return _settings.game_creation.landscape;
} }
extern void EnginesMonthlyLoop(); extern void EnginesMonthlyLoop();
@ -107,7 +107,7 @@ static const CheatEntry _cheats_ui[] = {
{SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.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_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_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_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 }, {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
}; };

View File

@ -218,7 +218,7 @@ static void TileLoop_Clear(TileIndex tile)
{ {
TileLoopClearHelper(tile); TileLoopClearHelper(tile);
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_TROPIC: TileLoopClearDesert(tile); break; case LT_TROPIC: TileLoopClearDesert(tile); break;
case LT_ARCTIC: TileLoopClearAlps(tile); break; case LT_ARCTIC: TileLoopClearAlps(tile); break;
} }
@ -346,7 +346,7 @@ static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID
void InitializeClearLand() 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) static CommandCost TerraformTile_Clear(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)

View File

@ -150,10 +150,10 @@ uint GetMaskOfAllowedCurrencies()
**/ **/
void CheckSwitchToEuro() void CheckSwitchToEuro()
{ {
if (_currency_specs[_opt.currency].to_euro != CF_NOEURO && if (_currency_specs[_settings.gui.currency].to_euro != CF_NOEURO &&
_currency_specs[_opt.currency].to_euro != CF_ISEURO && _currency_specs[_settings.gui.currency].to_euro != CF_ISEURO &&
_cur_year >= _currency_specs[_opt.currency].to_euro) { _cur_year >= _currency_specs[_settings.gui.currency].to_euro) {
_opt.currency = 2; // this is the index of euro above. _settings.gui.currency = 2; // this is the index of euro above.
AddNewsItem(STR_EURO_INTRODUCE, NS_ECONOMY, 0, 0); AddNewsItem(STR_EURO_INTRODUCE, NS_ECONOMY, 0, 0);
} }
} }

View File

@ -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 // XXX small hack, but makes the rest of the code a bit nicer to read
#define _custom_currency (_currency_specs[CUSTOM_CURRENCY_ID]) #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(); uint GetMaskOfAllowedCurrencies();
void CheckSwitchToEuro(); void CheckSwitchToEuro();

View File

@ -257,7 +257,7 @@ void IncreaseDate()
SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR); SaveOrLoad(name, SL_SAVE, AUTOSAVE_DIR);
DebugDumpCommands("ddc:save:%s\n", name); DebugDumpCommands("ddc:save:%s\n", name);
#endif /* DUMP_COMMANDS */ #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; _do_autosave = true;
RedrawAutosave(); RedrawAutosave();
} }

View File

@ -1050,7 +1050,7 @@ void DisasterDailyLoop()
ResetDisasterDelay(); ResetDisasterDelay();
if (_opt.diff.disasters != 0) DoDisaster(); if (_settings.difficulty.disasters != 0) DoDisaster();
} }
void StartupDisasters() void StartupDisasters()

View File

@ -704,7 +704,7 @@ static void PlayersPayInterest()
static void HandleEconomyFluctuations() static void HandleEconomyFluctuations()
{ {
if (_opt.diff.economy == 0) return; if (_settings.difficulty.economy == 0) return;
if (--_economy.fluct == 0) { if (--_economy.fluct == 0) {
_economy.fluct = -(int)GB(Random(), 0, 2); _economy.fluct = -(int)GB(Random(), 0, 2);
@ -813,7 +813,7 @@ void StartupEconomy()
for (i = 0; i != NUM_PRICES; i++) { for (i = 0; i != NUM_PRICES; i++) {
Money price = _price_base[i]; Money price = _price_base[i];
if (_price_category[i] != 0) { 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) { if (mod < 1) {
price = price * 3 >> 2; price = price * 3 >> 2;
} else if (mod > 1) { } else if (mod > 1) {
@ -829,10 +829,10 @@ void StartupEconomy()
_price_frac[i] = 0; _price_frac[i] = 0;
} }
_economy.interest_rate = _opt.diff.initial_interest; _economy.interest_rate = _settings.difficulty.initial_interest;
_economy.infl_amount = _opt.diff.initial_interest; _economy.infl_amount = _settings.difficulty.initial_interest;
_economy.infl_amount_pr = max(0, _opt.diff.initial_interest - 1); _economy.infl_amount_pr = max(0, _settings.difficulty.initial_interest - 1);
_economy.max_loan_unround = _economy.max_loan = _opt.diff.max_loan * 1000; _economy.max_loan_unround = _economy.max_loan = _settings.difficulty.max_loan * 1000;
_economy.fluct = GB(Random(), 0, 8) + 168; _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. */ /* 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; 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); SetDParam(0, _current_player);
AddNewsItem( AddNewsItem(
STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier, STR_2031_SERVICE_SUBSIDY_AWARDED + _settings.difficulty.subsidy_multiplier,
NS_SUBSIDIES, NS_SUBSIDIES,
pair.a, pair.b 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 */ /* Modify profit if a subsidy is in effect */
if (subsidised) { if (subsidised) {
switch (_opt.diff.subsidy_multiplier) { switch (_settings.difficulty.subsidy_multiplier) {
case 0: profit += profit >> 1; break; case 0: profit += profit >> 1; break;
case 1: profit *= 2; break; case 1: profit *= 2; break;
case 2: profit *= 3; break; case 2: profit *= 3; break;

View File

@ -296,7 +296,7 @@ void StartupEngines()
e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life; e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life;
/* prevent certain engines from ever appearing. */ /* 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->flags |= ENGINE_AVAILABLE;
e->player_avail = 0; e->player_avail = 0;
} }

View File

@ -48,7 +48,7 @@ extern void SwitchMode(int new_mode);
static inline void SetNewLandscapeType(byte landscape) static inline void SetNewLandscapeType(byte landscape)
{ {
_opt_newgame.landscape = landscape; _settings.game_creation.landscape = landscape;
InvalidateWindowClasses(WC_SELECT_GAME); InvalidateWindowClasses(WC_SELECT_GAME);
InvalidateWindowClasses(WC_GENERATE_LANDSCAPE); 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 */ /* Copy all XXX_newgame to XXX when coming from outside the editor */
UpdatePatches(); UpdatePatches();
_opt = _opt_newgame;
ResetGRFConfig(true); ResetGRFConfig(true);
SndPlayFx(SND_15_BEEP); SndPlayFx(SND_15_BEEP);
@ -254,7 +253,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : QueryStringBaseWindow(desc, number) 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); 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); 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); this->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0);
} }
/* Disable snowline if not hilly */ /* 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 */ /* Disable town, industry and trees in SE */
this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR); this->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN, _game_mode == GM_EDITOR);
this->SetWidgetDisabledState(GLAND_INDUSTRY_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_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_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_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 || _opt_newgame.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_TEMPERATE, _settings.game_creation.landscape == LT_TEMPERATE);
this->SetWidgetLoweredState(GLAND_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); this->SetWidgetLoweredState(GLAND_ARCTIC, _settings.game_creation.landscape == LT_ARCTIC);
this->SetWidgetLoweredState(GLAND_TROPICAL, _opt_newgame.landscape == LT_TROPIC); this->SetWidgetLoweredState(GLAND_TROPICAL, _settings.game_creation.landscape == LT_TROPIC);
this->SetWidgetLoweredState(GLAND_TOYLAND, _opt_newgame.landscape == LT_TOYLAND); this->SetWidgetLoweredState(GLAND_TOYLAND, _settings.game_creation.landscape == LT_TOYLAND);
if (_game_mode == GM_EDITOR) { if (_game_mode == GM_EDITOR) {
this->widget[GLAND_TOWN_PULLDOWN].data = STR_6836_OFF; this->widget[GLAND_TOWN_PULLDOWN].data = STR_6836_OFF;
this->widget[GLAND_INDUSTRY_PULLDOWN].data = STR_6836_OFF; this->widget[GLAND_INDUSTRY_PULLDOWN].data = STR_6836_OFF;
} else { } else {
this->widget[GLAND_TOWN_PULLDOWN].data = _num_towns[_opt_newgame.diff.number_towns]; this->widget[GLAND_TOWN_PULLDOWN].data = _num_towns[_settings_newgame.difficulty.number_towns];
this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_opt_newgame.diff.number_industries]; this->widget[GLAND_INDUSTRY_PULLDOWN].data = _num_inds[_settings_newgame.difficulty.number_industries];
} }
if (mode == GLWP_GENERATE) { if (mode == GLWP_GENERATE) {
this->widget[GLAND_LANDSCAPE_PULLDOWN].data = _landscape[_settings_newgame.game_creation.land_generator]; 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_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_TERRAIN_PULLDOWN].data = _elevations[_settings_newgame.difficulty.terrain_type];
this->widget[GLAND_WATER_PULLDOWN].data = _sea_lakes[_opt_newgame.diff.quantity_sea_lakes]; 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]; this->widget[GLAND_SMOOTHNESS_PULLDOWN].data = _smoothness[_settings_newgame.game_creation.tgen_smoothness];
} else { } else {
this->widget[GLAND_TREE_PULLDOWN].data = _tree_placer[_settings_newgame.game_creation.tree_placer]; 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_ARCTIC:
case GLAND_TROPICAL: case GLAND_TROPICAL:
case GLAND_TOYLAND: case GLAND_TOYLAND:
this->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE); this->RaiseWidget(_settings.game_creation.landscape + GLAND_TEMPERATE);
SetNewLandscapeType(widget - GLAND_TEMPERATE); SetNewLandscapeType(widget - GLAND_TEMPERATE);
break; break;
@ -359,11 +358,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break; break;
case GLAND_TOWN_PULLDOWN: // Number of towns 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; break;
case GLAND_INDUSTRY_PULLDOWN: // Number of industries 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; break;
case GLAND_RANDOM_BUTTON: // Random seed case GLAND_RANDOM_BUTTON: // Random seed
@ -451,11 +450,11 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break; break;
case GLAND_TERRAIN_PULLDOWN: // Terrain type 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; break;
case GLAND_WATER_PULLDOWN: // Water quantity 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; break;
case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness 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_SMOOTHNESS_PULLDOWN: _settings_newgame.game_creation.tgen_smoothness = index; break;
case GLAND_TOWN_PULLDOWN: case GLAND_TOWN_PULLDOWN:
_opt_newgame.diff.number_towns = index; _settings_newgame.difficulty.number_towns = index;
if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); if (_settings_newgame.difficulty.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); DoCommandP(0, 2, _settings_newgame.difficulty.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break; break;
case GLAND_INDUSTRY_PULLDOWN: case GLAND_INDUSTRY_PULLDOWN:
_opt_newgame.diff.number_industries = index; _settings_newgame.difficulty.number_industries = index;
if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); if (_settings_newgame.difficulty.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); DoCommandP(0, 3, _settings_newgame.difficulty.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break; break;
case GLAND_LANDSCAPE_PULLDOWN: case GLAND_LANDSCAPE_PULLDOWN:
@ -512,15 +511,15 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
break; break;
case GLAND_TERRAIN_PULLDOWN: case GLAND_TERRAIN_PULLDOWN:
_opt_newgame.diff.terrain_type = index; _settings_newgame.difficulty.terrain_type = index;
if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); if (_settings_newgame.difficulty.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); DoCommandP(0, 12, _settings_newgame.difficulty.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break; break;
case GLAND_WATER_PULLDOWN: case GLAND_WATER_PULLDOWN:
_opt_newgame.diff.quantity_sea_lakes = index; _settings_newgame.difficulty.quantity_sea_lakes = index;
if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); if (_settings_newgame.difficulty.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); DoCommandP(0, 13, _settings_newgame.difficulty.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
break; break;
} }
this->SetDirty(); this->SetDirty();
@ -643,7 +642,7 @@ struct CreateScenarioWindow : public Window
CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) 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); 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_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->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_TEMPERATE, _settings.game_creation.landscape == LT_TEMPERATE);
this->SetWidgetLoweredState(CSCEN_ARCTIC, _opt_newgame.landscape == LT_ARCTIC); this->SetWidgetLoweredState(CSCEN_ARCTIC, _settings.game_creation.landscape == LT_ARCTIC);
this->SetWidgetLoweredState(CSCEN_TROPICAL, _opt_newgame.landscape == LT_TROPIC); this->SetWidgetLoweredState(CSCEN_TROPICAL, _settings.game_creation.landscape == LT_TROPIC);
this->SetWidgetLoweredState(CSCEN_TOYLAND, _opt_newgame.landscape == LT_TOYLAND); this->SetWidgetLoweredState(CSCEN_TOYLAND, _settings.game_creation.landscape == LT_TOYLAND);
/* Set parameters for widget text that requires them */ /* Set parameters for widget text that requires them */
SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT 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_ARCTIC:
case CSCEN_TROPICAL: case CSCEN_TROPICAL:
case CSCEN_TOYLAND: case CSCEN_TOYLAND:
this->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); this->RaiseWidget(_settings.game_creation.landscape + CSCEN_TEMPERATE);
SetNewLandscapeType(widget - CSCEN_TEMPERATE); SetNewLandscapeType(widget - CSCEN_TEMPERATE);
break; break;

View File

@ -807,7 +807,7 @@ void DoPaletteAnimations()
memcpy(old_val, d, c * sizeof(*old_val)); memcpy(old_val, d, c * sizeof(*old_val));
/* Dark blue water */ /* 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); j = EXTR(320, 5);
for (i = 0; i != 5; i++) { for (i = 0; i != 5; i++) {
*d++ = s[j]; *d++ = s[j];
@ -816,7 +816,7 @@ void DoPaletteAnimations()
} }
/* Glittery water */ /* 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); j = EXTR(128, 15);
for (i = 0; i != 5; i++) { for (i = 0; i != 5; i++) {
*d++ = s[j]; *d++ = s[j];
@ -876,7 +876,7 @@ void DoPaletteAnimations()
/* Animate water for old DOS graphics */ /* Animate water for old DOS graphics */
if (_use_dos_palette) { if (_use_dos_palette) {
/* Dark blue water DOS */ /* 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); j = EXTR(320, 5);
for (i = 0; i != 5; i++) { for (i = 0; i != 5; i++) {
*d++ = s[j]; *d++ = s[j];
@ -885,7 +885,7 @@ void DoPaletteAnimations()
} }
/* Glittery water DOS */ /* 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); j = EXTR(128, 15);
for (i = 0; i != 5; i++) { for (i = 0; i != 5; i++) {
*d++ = s[j]; *d++ = s[j];

View File

@ -214,10 +214,10 @@ static void LoadSpriteTables()
* This overwrites some of the temperate sprites, such as foundations * This overwrites some of the temperate sprites, such as foundations
* and the ground sprites. * and the ground sprites.
*/ */
if (_opt.landscape != LT_TEMPERATE) { if (_settings.game_creation.landscape != LT_TEMPERATE) {
LoadGrfIndexed( LoadGrfIndexed(
files->landscape[_opt.landscape - 1].filename, files->landscape[_settings.game_creation.landscape - 1].filename,
_landscape_spriteindexes[_opt.landscape - 1], _landscape_spriteindexes[_settings.game_creation.landscape - 1],
i++ i++
); );
} }
@ -248,7 +248,7 @@ static void LoadSpriteTables()
void GfxLoadSprites() void GfxLoadSprites()
{ {
DEBUG(sprite, 2, "Loading sprite set %d", _opt.landscape); DEBUG(sprite, 2, "Loading sprite set %d", _settings.game_creation.landscape);
GfxInitSpriteMem(); GfxInitSpriteMem();
LoadSpriteTables(); LoadSpriteTables();

View File

@ -70,7 +70,7 @@ void ResetIndustries()
/* once performed, enable only the current climate industries */ /* once performed, enable only the current climate industries */
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) { for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
_industry_specs[i].enabled = i < NEW_INDUSTRYOFFSET && _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)); memset(&_industry_tile_specs, 0, sizeof(_industry_tile_specs));
@ -84,7 +84,7 @@ void ResetIndustries()
void ResetIndustryCreationProbility(IndustryType type) void ResetIndustryCreationProbility(IndustryType type)
{ {
assert(type < INVALID_INDUSTRYTYPE); 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) DEFINE_OLD_POOL_GENERIC(Industry, Industry)
@ -888,14 +888,14 @@ static void PlantFarmField(TileIndex tile, IndustryID industry)
uint field_type; uint field_type;
int type; int type;
if (_opt.landscape == LT_ARCTIC) { if (_settings.game_creation.landscape == LT_ARCTIC) {
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine()) if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine())
return; return;
} }
/* determine field size */ /* determine field size */
r = (Random() & 0x303) + 0x404; 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_x = GB(r, 0, 8);
size_y = GB(r, 8, 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) END_TILE_LOOP(cur_tile, size_x, size_y, tile)
type = 3; 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]; type = _plantfarmfield_type[Random() & 0xF];
} }
@ -1063,7 +1063,7 @@ static bool CheckNewIndustry_NULL(TileIndex tile)
static bool CheckNewIndustry_Forest(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) { if (GetTileZ(tile) < HighestSnowLine() + TILE_HEIGHT * 2U) {
_error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED; _error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED;
return false; return false;
@ -1095,7 +1095,7 @@ static bool CheckNewIndustry_OilRig(TileIndex tile)
static bool CheckNewIndustry_Farm(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()) { if (GetTileZ(tile) + TILE_HEIGHT * 2 >= HighestSnowLine()) {
_error_message = STR_0239_SITE_UNSUITABLE; _error_message = STR_0239_SITE_UNSUITABLE;
return false; 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 /* 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 */ * _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); const IndustrySpec *ind_spc = GetIndustrySpec(type);
/* These are always placed next to the coastline, so we scale by the perimeter instead. */ /* 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); 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; PlayerID old_player = _current_player;
_current_player = OWNER_NONE; _current_player = OWNER_NONE;
assert(num > 0); assert(num > 0);
@ -1735,7 +1735,7 @@ void GenerateIndustries()
const IndustrySpec *ind_spc; const IndustrySpec *ind_spc;
/* Find the total amount of industries */ /* 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++) { for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
ind_spc = GetIndustrySpec(it); ind_spc = GetIndustrySpec(it);
@ -1744,12 +1744,12 @@ void GenerateIndustries()
ResetIndustryCreationProbility(it); ResetIndustryCreationProbility(it);
} }
chance = ind_spc->appear_creation[_opt.landscape]; chance = ind_spc->appear_creation[_settings.game_creation.landscape];
if (ind_spc->enabled && chance > 0) { if (ind_spc->enabled && chance > 0) {
/* once the chance of appearance is determind, it have to be scaled by /* 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 difficulty level. The "chance" in question is more an index into
* the _numof_industry_table,in fact */ * 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. */ /* 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); 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); SetGeneratingWorldProgress(GWP_INDUSTRY, i);
if (_opt.diff.number_industries > 0) { if (_settings.difficulty.number_industries > 0) {
for (it = 0; it < NUM_INDUSTRYTYPES; it++) { for (it = 0; it < NUM_INDUSTRYTYPES; it++) {
/* Once the number of industries has been determined, let's really create them. /* 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 * 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. */ * processed that scaling above? No, don't think so. Will find a way. */
ind_spc = GetIndustrySpec(it); ind_spc = GetIndustrySpec(it);
if (ind_spc->enabled) { 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); 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. */ /* Generate a list of all possible industries that can be built. */
for (j = 0; j < NUM_INDUSTRYTYPES; j++) { for (j = 0; j < NUM_INDUSTRYTYPES; j++) {
ind_spc = GetIndustrySpec(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; if (!ind_spc->enabled || chance == 0) continue;
@ -1881,7 +1881,7 @@ static bool CheckIndustryCloseDownProtection(IndustryType type)
const IndustrySpec *indspec = GetIndustrySpec(type); const IndustrySpec *indspec = GetIndustrySpec(type);
/* oil wells (or the industries with that flag set) are always allowed to closedown */ /* 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; 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) { if (standard && (indspec->life_type & (INDUSTRYLIFE_ORGANIC | INDUSTRYLIFE_EXTRACTIVE)) != 0) {
/* decrease or increase */ /* 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) { if (smooth_economy) {
closeit = true; closeit = true;

View File

@ -195,7 +195,7 @@ public:
* In Editor, you just build, while ingame, or you fund or you prospect */ * In Editor, you just build, while ingame, or you fund or you prospect */
if (_game_mode == GM_EDITOR) { if (_game_mode == GM_EDITOR) {
/* We've chosen many random industries but no industries have been specified */ /* 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; this->widget[DPIW_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
} else { } else {
this->widget[DPIW_FUND_WIDGET].data = (_settings.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY; this->widget[DPIW_FUND_WIDGET].data = (_settings.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;

View File

@ -49,7 +49,7 @@ static const Widget _select_game_widgets[] = {
static inline void SetNewLandscapeType(byte landscape) static inline void SetNewLandscapeType(byte landscape)
{ {
_opt_newgame.landscape = landscape; _settings_newgame.game_creation.landscape = landscape;
InvalidateWindowClasses(WC_SELECT_GAME); InvalidateWindowClasses(WC_SELECT_GAME);
} }
@ -76,17 +76,17 @@ private:
public: public:
SelectGameWindow(const WindowDesc *desc) : Window(desc) 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); this->FindWindowPlacementAndResize(desc);
} }
virtual void OnPaint() virtual void OnPaint()
{ {
this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _opt_newgame.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _opt_newgame.landscape == LT_ARCTIC); this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC);
this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _opt_newgame.landscape == LT_TROPIC); this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC);
this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _opt_newgame.landscape == LT_TOYLAND); this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND);
SetDParam(0, STR_6801_EASY + _opt_newgame.diff_level); SetDParam(0, STR_6801_EASY + _settings_newgame.difficulty.diff_level);
this->DrawWidgets(); this->DrawWidgets();
} }
@ -115,7 +115,7 @@ public:
case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE: case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_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); SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE);
break; break;

View File

@ -526,7 +526,7 @@ void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS])
*/ */
byte GetSnowLine(void) byte GetSnowLine(void)
{ {
if (_snow_line == NULL) return _opt.snow_line; if (_snow_line == NULL) return _settings.game_creation.snow_line;
YearMonthDay ymd; YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd); ConvertDateToYMD(_date, &ymd);
@ -539,7 +539,7 @@ byte GetSnowLine(void)
*/ */
byte HighestSnowLine(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; static const int gwp_desert_amount = 4 + 8;
if (mode == GW_HEIGHTMAP) { 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); LoadHeightmap(_file_to_saveload.name);
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
} else if (_settings.game_creation.land_generator == LG_TERRAGENESIS) { } 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(); GenerateTerrainPerlin();
} else { } else {
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_ARCTIC: { case LT_ARCTIC: {
SetGeneratingWorldProgress(GWP_LANDSCAPE, 2); SetGeneratingWorldProgress(GWP_LANDSCAPE, 2);
@ -872,9 +872,9 @@ void GenerateLandscape(byte mode)
uint32 r = Random(); 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) { for (; i != 0; --i) {
GenerateTerrain(_opt.diff.terrain_type, 0); GenerateTerrain(_settings.difficulty.terrain_type, 0);
} }
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE); IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
} break; } break;
@ -883,7 +883,7 @@ void GenerateLandscape(byte mode)
ConvertGroundTilesIntoWaterTiles(); ConvertGroundTilesIntoWaterTiles();
if (_opt.landscape == LT_TROPIC) CreateDesertOrRainForest(); if (_settings.game_creation.landscape == LT_TROPIC) CreateDesertOrRainForest();
} }
void OnTick_Town(); void OnTick_Town();

View File

@ -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; 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 (flags & DC_EXEC) {
if (p1 != (uint32)-1L) { if (p1 != (uint32)-1L) {
((GDType*)&opt_ptr->diff)[p1] = p2; ((GDType*)opt_ptr)[p1] = p2;
opt_ptr->diff_level = 3; // custom difficulty level opt_ptr->diff_level = 3; // custom difficulty level
} else { } else {
opt_ptr->diff_level = p2; opt_ptr->diff_level = p2;

View File

@ -1012,7 +1012,7 @@ static void NetworkInitGameInfo()
_network_game_info.start_date = ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1); _network_game_info.start_date = ConvertYMDToDate(_settings.game_creation.starting_year, 0, 1);
_network_game_info.map_width = MapSizeX(); _network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY(); _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'); _network_game_info.use_password = (_network_server_password[0] != '\0');

View File

@ -77,7 +77,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
_network_game_info.game_date = _date; _network_game_info.game_date = _date;
_network_game_info.map_width = MapSizeX(); _network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY(); _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.companies_on = ActivePlayerCount();
_network_game_info.spectators_on = NetworkSpectatorCount(); _network_game_info.spectators_on = NetworkSpectatorCount();
_network_game_info.grfconfig = _grfconfig; _network_game_info.grfconfig = _grfconfig;

View File

@ -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. /* 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 */ * 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) : CargoID cid = (goods >= 0) ? ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
((_opt.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD); ((_settings.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
/* Make sure the cargo type is valid in this climate. */ /* Make sure the cargo type is valid in this climate. */
if (!GetCargo(cid)->IsValid()) goods = 0; if (!GetCargo(cid)->IsValid()) goods = 0;
@ -2167,11 +2167,11 @@ static bool IndustriesChangeInfo(uint indid, int numinfo, int prop, byte **bufp,
break; break;
case 0x17: // Probability in random game 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; break;
case 0x18: // Probability during gameplay 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; break;
case 0x19: // Map color case 0x19: // Map color
@ -3557,11 +3557,11 @@ bool GetGlobalVariable(byte param, uint32 *value)
return true; return true;
case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland case 0x03: // current climate, 0=temp, 1=arctic, 2=trop, 3=toyland
*value = _opt.landscape; *value = _settings.game_creation.landscape;
return true; return true;
case 0x06: // road traffic side, bit 4 clear=left, set=right case 0x06: // road traffic side, bit 4 clear=left, set=right
*value = _opt.road_side << 4; *value = _settings.vehicle.road_side << 4;
return true; return true;
case 0x09: // date fraction case 0x09: // date fraction
@ -3635,7 +3635,7 @@ bool GetGlobalVariable(byte param, uint32 *value)
/* case 0x1F: // locale dependent settings not implemented */ /* case 0x1F: // locale dependent settings not implemented */
case 0x20: // snow line height case 0x20: // snow line height
*value = _opt.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF; *value = _settings.game_creation.landscape == LT_ARCTIC ? GetSnowLine() : 0xFF;
return true; return true;
case 0x21: // OpenTTD version case 0x21: // OpenTTD version
@ -3643,7 +3643,7 @@ bool GetGlobalVariable(byte param, uint32 *value)
return true; return true;
case 0x22: // difficulty level case 0x22: // difficulty level
*value = _opt.diff_level; *value = _settings.difficulty.diff_level;
return true; return true;
default: return false; default: return false;
@ -5352,7 +5352,7 @@ static void ResetNewGRFData()
ResetNewGRFErrors(); ResetNewGRFErrors();
/* Set up the default cargo types */ /* Set up the default cargo types */
SetupCargoForClimate(_opt.landscape); SetupCargoForClimate(_settings.game_creation.landscape);
/* Reset misc GRF features and train list display variables */ /* Reset misc GRF features and train list display variables */
_misc_grf_features = 0; _misc_grf_features = 0;

View File

@ -278,7 +278,7 @@ void IndustryTileOverrideManager::SetEntitySpec(const IndustryTileSpec *its)
* Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */ * Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */
uint32 GetTerrainType(TileIndex tile) uint32 GetTerrainType(TileIndex tile)
{ {
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_TROPIC: return GetTropicZone(tile); case LT_TROPIC: return GetTropicZone(tile);
case LT_ARCTIC: return GetTileZ(tile) > GetSnowLine() ? 4 : 0; case LT_ARCTIC: return GetTileZ(tile) > GetSnowLine() ? 4 : 0;
default: return 0; default: return 0;

View File

@ -319,8 +319,8 @@ static void FixOldTowns()
/* Convert town-names if needed */ /* Convert town-names if needed */
FOR_ALL_TOWNS(town) { FOR_ALL_TOWNS(town) {
if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) { if (IsInsideMM(town->townnametype, 0x20C1, 0x20C3)) {
town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _opt.town_name; town->townnametype = SPECSTR_TOWNNAME_ENGLISH + _settings.game_creation.town_name;
town->townnameparts = GetOldTownName(town->townnameparts, _opt.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[] = { static const OldChunks game_difficulty_chunk[] = {
OCL_SVAR( OC_UINT16, GameDifficulty, max_no_competitors ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, max_no_competitors ),
OCL_SVAR( OC_UINT16, GameDifficulty, competitor_start_time ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_start_time ),
OCL_SVAR( OC_UINT16, GameDifficulty, number_towns ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, number_towns ),
OCL_SVAR( OC_UINT16, GameDifficulty, number_industries ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, number_industries ),
OCL_SVAR( OC_UINT16, GameDifficulty, max_loan ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U16, DifficultySettings, max_loan ),
OCL_SVAR( OC_UINT16, GameDifficulty, initial_interest ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, initial_interest ),
OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_costs ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, vehicle_costs ),
OCL_SVAR( OC_UINT16, GameDifficulty, competitor_speed ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_speed ),
OCL_SVAR( OC_UINT16, GameDifficulty, competitor_intelligence ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, competitor_intelligence ),
OCL_SVAR( OC_UINT16, GameDifficulty, vehicle_breakdowns ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, vehicle_breakdowns ),
OCL_SVAR( OC_UINT16, GameDifficulty, subsidy_multiplier ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, subsidy_multiplier ),
OCL_SVAR( OC_UINT16, GameDifficulty, construction_cost ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, construction_cost ),
OCL_SVAR( OC_UINT16, GameDifficulty, terrain_type ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, terrain_type ),
OCL_SVAR( OC_UINT16, GameDifficulty, quantity_sea_lakes ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, quantity_sea_lakes ),
OCL_SVAR( OC_UINT16, GameDifficulty, economy ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, economy ),
OCL_SVAR( OC_UINT16, GameDifficulty, line_reverse_mode ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, line_reverse_mode ),
OCL_SVAR( OC_UINT16, GameDifficulty, disasters ), OCL_SVAR( OC_FILE_U16 | OC_VAR_U8, DifficultySettings, disasters ),
OCL_END() OCL_END()
}; };
static inline bool LoadOldGameDifficulty(LoadgameState *ls, int num) 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_FILE_U8 | OC_VAR_U16, 1, &_station_tick_ctr ),
OCL_VAR ( OC_UINT8, 1, &_opt.currency ), OCL_VAR ( OC_UINT8, 1, &_settings.gui.currency ),
OCL_VAR ( OC_UINT8, 1, &_opt.units ), OCL_VAR ( OC_UINT8, 1, &_settings.gui.units ),
OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_player_tick_index ), OCL_VAR ( OC_FILE_U8 | OC_VAR_U32, 1, &_cur_player_tick_index ),
OCL_NULL( 2 ), ///< Date stuff, calculated automatically 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.infl_amount_pr ),
OCL_VAR ( OC_UINT8, 1, &_economy.interest_rate ), OCL_VAR ( OC_UINT8, 1, &_economy.interest_rate ),
OCL_NULL( 1 ), // available airports OCL_NULL( 1 ), // available airports
OCL_VAR ( OC_UINT8, 1, &_opt.road_side ), OCL_VAR ( OC_UINT8, 1, &_settings.vehicle.road_side ),
OCL_VAR ( OC_UINT8, 1, &_opt.town_name ), OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.town_name ),
OCL_CHUNK( 1, LoadOldGameDifficulty ), OCL_CHUNK( 1, LoadOldGameDifficulty ),
OCL_ASSERT( 0x77130 ), OCL_ASSERT( 0x77130 ),
OCL_VAR ( OC_UINT8, 1, &_opt.diff_level ), OCL_VAR ( OC_UINT8, 1, &_settings.difficulty.diff_level ),
OCL_VAR ( OC_UINT8, 1, &_opt.landscape ), OCL_VAR ( OC_UINT8, 1, &_settings.game_creation.landscape ),
OCL_VAR ( OC_UINT8, 1, &_trees_tick_ctr ), OCL_VAR ( OC_UINT8, 1, &_trees_tick_ctr ),
OCL_NULL( 1 ), ///< Custom vehicle types yes/no, no longer used 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( 32 ), ///< new_industry_randtable, no longer used (because of new design)
OCL_NULL( 36 ), ///< cargo-stuff, calculated in InitializeLandscapeVariables OCL_NULL( 36 ), ///< cargo-stuff, calculated in InitializeLandscapeVariables
@ -1628,7 +1628,7 @@ static bool LoadOldMain(LoadgameState *ls)
DEBUG(oldloader, 3, "Done, converting game data..."); DEBUG(oldloader, 3, "Done, converting game data...");
/* Fix some general stuff */ /* Fix some general stuff */
_opt.landscape = _opt.landscape & 0xF; _settings.game_creation.landscape = _settings.game_creation.landscape & 0xF;
/* Remap some pointers */ /* Remap some pointers */
_cur_town_ctr = REMAP_TOWN_IDX(_old_cur_town_ctr); _cur_town_ctr = REMAP_TOWN_IDX(_old_cur_town_ctr);
@ -1690,7 +1690,7 @@ static bool LoadOldMain(LoadgameState *ls)
FixOldVehicles(); FixOldVehicles();
/* We have a new difficulty setting */ /* 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, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted"); DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");

View File

@ -99,7 +99,7 @@ void ResetOldNames();
void ProcessAsyncSaveFinish(); void ProcessAsyncSaveFinish();
void CallWindowTickEvent(); 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 Player* DoStartupNewPlayer(bool is_ai);
extern void ShowOSErrorBox(const char *buf); extern void ShowOSErrorBox(const char *buf);
extern void InitializeRailGUI(); extern void InitializeRailGUI();
@ -586,11 +586,10 @@ int ttd_main(int argc, char *argv[])
ResetGRFConfig(false); ResetGRFConfig(false);
/* XXX - ugly hack, if diff_level is 9, it means we got no setting from the config file */ /* 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 */ /* Make sure _patches is filled with _patches_newgame if we switch to a game directly */
if (_switch_mode != SM_NONE) { if (_switch_mode != SM_NONE) {
_opt = _opt_newgame;
UpdatePatches(); UpdatePatches();
} }
@ -767,8 +766,7 @@ static void StartScenario()
ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0); ShowErrorMessage(INVALID_STRING_ID, STR_012D, 0, 0);
} }
_opt.diff = _opt_newgame.diff; _settings.difficulty = _settings_newgame.difficulty;
_opt.diff_level = _opt_newgame.diff_level;
/* Inititalize data */ /* Inititalize data */
StartupEconomy(); StartupEconomy();
@ -838,7 +836,6 @@ void SwitchMode(int new_mode)
if (_network_reload_cfg) { if (_network_reload_cfg) {
LoadFromConfig(); LoadFromConfig();
_settings = _settings_newgame; _settings = _settings_newgame;
_opt = _opt_newgame;
ResetGRFConfig(false); ResetGRFConfig(false);
} }
NetworkServerStart(); NetworkServerStart();
@ -1259,7 +1256,7 @@ static const byte convert_currency[] = {
/* since savegame version 4.2 the currencies are arranged differently */ /* since savegame version 4.2 the currencies are arranged differently */
static void UpdateCurrencies() 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 /* Up to revision 1413 the invisible tiles at the southern border have not been
@ -1394,7 +1391,7 @@ bool AfterLoadGame()
Town *t; Town *t;
FOR_ALL_TOWNS(t) { FOR_ALL_TOWNS(t) {
t->name = CopyFromOldName(t->townnametype); 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; Waypoint *wp;
@ -1408,7 +1405,7 @@ bool AfterLoadGame()
ResetOldNames(); ResetOldNames();
/* convert road side to my format. */ /* 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 */ /* Check if all NewGRFs are present, we are very strict in MP mode */
GRFListCompatibility gcf_res = IsGoodGRFConfigList(); GRFListCompatibility gcf_res = IsGoodGRFConfigList();
@ -2226,12 +2223,12 @@ bool AfterLoadGame()
if (CheckSavegameVersion(58)) { if (CheckSavegameVersion(58)) {
/* patch difficulty number_industries other then zero get bumped to +1 /* patch difficulty number_industries other then zero get bumped to +1
* since a new option (very low at position1) has been added */ * since a new option (very low at position1) has been added */
if (_opt.diff.number_industries > 0) { if (_settings.difficulty.number_industries > 0) {
_opt.diff.number_industries++; _settings.difficulty.number_industries++;
} }
/* Same goes for number of towns, although no test is needed, just an increment */ /* 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)) { if (CheckSavegameVersion(64)) {

View File

@ -1477,7 +1477,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
} else { } else {
/* in single player _local player is always valid */ /* in single player _local player is always valid */
const Player *p = GetPlayer(_local_player); const Player *p = GetPlayer(_local_player);
this->window_number = _opt.diff_level; this->window_number = _settings.difficulty.diff_level;
this->rank = SaveHighScoreValue(p); this->rank = SaveHighScoreValue(p);
} }

View File

@ -563,7 +563,7 @@ Player *DoStartupNewPlayer(bool is_ai)
void StartupPlayers() void StartupPlayers()
{ {
/* The AI starts like in the setting with +2 month max */ /* 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() 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 */ /* 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 ? n < (_network_server ?
InteractiveRandomRange(_opt.diff.max_no_competitors + 2) : InteractiveRandomRange(_settings.difficulty.max_no_competitors + 2) :
RandomRange(_opt.diff.max_no_competitors + 2) RandomRange(_settings.difficulty.max_no_competitors + 2)
)) { )) {
/* Send a command to all clients to start up a new AI. /* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */ * 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 */ /* 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); _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 */ /** Save the highscore for the player */
int8 SaveHighScoreValue(const Player *p) int8 SaveHighScoreValue(const Player *p)
{ {
HighScore *hs = _highscore_table[_opt.diff_level]; HighScore *hs = _highscore_table[_settings.difficulty.diff_level];
uint i; uint i;
uint16 score = p->old_economy[0].performance_history; uint16 score = p->old_economy[0].performance_history;

View File

@ -207,7 +207,7 @@ RailTypes GetPlayerRailtypes(PlayerID p)
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
const EngineInfo *ei = &e->info; 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)) { (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
const RailVehicleInfo *rvi = &e->u.rail; const RailVehicleInfo *rvi = &e->u.rail;

View File

@ -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) 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] = { static const Point SignalPositions[2][12] = {
{ /* Signals on the left side */ { /* Signals on the left side */
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */ /* LEFT LEFT RIGHT RIGHT UPPER UPPER */
@ -1789,7 +1789,7 @@ static void DrawTile_Track(TileInfo *ti)
/* adjust ground tile for desert /* adjust ground tile for desert
* don't adjust for snow, because snow in depots looks weird */ * 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) { if (image != SPR_FLAT_GRASS_TILE) {
image += rti->snow_offset; // tile with tracks image += rti->snow_offset; // tile with tracks
} else { } else {
@ -1953,7 +1953,7 @@ static void TileLoop_Track(TileIndex tile)
return; return;
} }
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_ARCTIC: { case LT_ARCTIC: {
uint z; uint z;
Slope slope = GetTileSlope(tile, &z); Slope slope = GetTileSlope(tile, &z);

View File

@ -103,7 +103,7 @@ RoadTypes GetPlayerRoadtypes(PlayerID p)
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) { FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
const EngineInfo *ei = &e->info; 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)) { (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD); SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
} }

View File

@ -69,9 +69,9 @@ CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (_game_mode == GM_MENU) { if (_game_mode == GM_MENU) {
_opt_newgame.road_side = p1; _settings.vehicle.road_side = p1;
} else { } else {
_opt.road_side = p1; _settings.vehicle.road_side = p1;
} }
InvalidateWindow(WC_GAME_OPTIONS, 0); InvalidateWindow(WC_GAME_OPTIONS, 0);
} }
@ -1000,7 +1000,7 @@ const byte _road_sloped_sprites[14] = {
static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside) static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
{ {
return (IsOnSnow(tile) && 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)); 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) static void TileLoop_Road(TileIndex tile)
{ {
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_ARCTIC: case LT_ARCTIC:
if (IsOnSnow(tile) != (GetTileZ(tile) > GetSnowLine())) { if (IsOnSnow(tile) != (GetTileZ(tile) > GetSnowLine())) {
ToggleSnow(tile); 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) */ /* 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); Roadside cur_rs = GetRoadside(tile);
/* We have our desired type, do nothing */ /* We have our desired type, do nothing */

View File

@ -702,7 +702,7 @@ static void HandleBrokenRoadVeh(Vehicle *v)
InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { 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); SND_0F_VEHICLE_BREAKDOWN : SND_35_COMEDY_BREAKDOWN, v);
} }
@ -1273,7 +1273,7 @@ static bool RoadVehLeaveDepot(Vehicle *v, bool first)
v->direction = DiagDirToDir(dir); v->direction = DiagDirToDir(dir);
Trackdir tdir = _roadveh_depot_exit_trackdir[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 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); 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. */ * In this case v->u.road.state is masked to give the road stop entry direction. */
rd = _road_drive_data[v->u.road.roadtype][( 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) + (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) { if (rd.x & RDE_NEXT_TILE) {
TileIndex tile = v->tile + TileOffsByDiagDir((DiagDirection)(rd.x & 3)); TileIndex tile = v->tile + TileOffsByDiagDir((DiagDirection)(rd.x & 3));
@ -1529,7 +1529,7 @@ again:
} }
/* Get position data for first frame on the new tile */ /* 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; x = TileX(tile) * TILE_SIZE + rdp[start_frame].x;
y = TileY(tile) * TILE_SIZE + rdp[start_frame].y; y = TileY(tile) * TILE_SIZE + rdp[start_frame].y;
@ -1632,7 +1632,7 @@ again:
return false; 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; x = TileX(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].x;
y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y; 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 * (the station test and stop type test ensure that other vehicles, using the road stop as
* a through route, do not stop) */ * a through route, do not stop) */
if (IsRoadVehFront(v) && ((IsInsideMM(v->u.road.state, RVSB_IN_ROAD_STOP, RVSB_IN_ROAD_STOP_END) && 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) && (IsInsideMM(v->u.road.state, RVSB_IN_DT_ROAD_STOP, RVSB_IN_DT_ROAD_STOP_END) &&
v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) && GetRoadStopType(v->tile) == (IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? ROADSTOP_BUS : ROADSTOP_TRUCK) &&

View File

@ -63,8 +63,6 @@
#include "table/strings.h" #include "table/strings.h"
GameOptions _opt;
GameOptions _opt_newgame;
Settings _settings; Settings _settings;
Settings _settings_newgame; Settings _settings_newgame;
@ -1429,18 +1427,18 @@ static const SettingDesc _gameopt_settings[] = {
* and why not byte for example? * and why not byte for example?
* 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack * '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 */ * 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_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, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION), 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(GameOptions, diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL), SDT_VAR(Settings, difficulty.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(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(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", 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. */ /* 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(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(GameOptions, landscape, SLE_UINT8, 0, 0, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape), SDT_OMANY(Settings, game_creation.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_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(GameOptions,autosave, SLE_UINT8, 0, 22, N, 0, 0, 0, "", STR_NULL, NULL, NULL), SDT_CONDOMANY(Settings,gui.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_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(GameOptions, road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL), SDT_OMANY(Settings, vehicle.road_side, SLE_UINT8, 0, 0, 1, 1, "left|right", STR_NULL, NULL, NULL),
SDT_END() SDT_END()
}; };
@ -1838,7 +1836,7 @@ static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescP
proc(ini, (const SettingDesc*)_win32_settings, "win32", NULL); proc(ini, (const SettingDesc*)_win32_settings, "win32", NULL);
#endif /* WIN32 */ #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, _patch_settings, "patches", &_settings_newgame);
proc(ini, _currency_settings,"currency", &_custom_currency); 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 /* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local * a networking environment. This ensures for example that the local
* autosave-frequency stays when joining a network-server */ * autosave-frequency stays when joining a network-server */
_opt = _opt_newgame; LoadSettings(_gameopt_settings, &_settings);
LoadSettings(_gameopt_settings, &_opt);
} }
static void Save_OPTS() static void Save_OPTS()
{ {
SaveSettings(_gameopt_settings, &_opt); SaveSettings(_gameopt_settings, &_settings);
} }
static void Load_PATS() static void Load_PATS()
@ -2100,7 +2097,6 @@ static void Load_PATS()
/* Copy over default setting since some might not get loaded in /* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local * a networking environment. This ensures for example that the local
* signal_side stays when joining a network-server */ * signal_side stays when joining a network-server */
_settings = _settings_newgame;
LoadSettings(_patch_settings, &_settings); LoadSettings(_patch_settings, &_settings);
} }

View File

@ -142,11 +142,11 @@ static void ShowTownnameDropdown(Window *w, int sel)
static void ShowCustCurrency(); static void ShowCustCurrency();
struct GameOptionsWindow : Window { struct GameOptionsWindow : Window {
GameOptions *opt; Settings *opt;
GameOptionsWindow(const WindowDesc *desc) : Window(desc) 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); this->FindWindowPlacementAndResize(desc);
} }
@ -162,11 +162,11 @@ struct GameOptionsWindow : Window {
this->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1)); this->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1));
if (!this->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM; if (!this->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM;
SetDParam(0, str); SetDParam(0, str);
SetDParam(1, _currency_specs[this->opt->currency].name); SetDParam(1, _currency_specs[this->opt->gui.currency].name);
SetDParam(2, STR_UNITS_IMPERIAL + this->opt->units); SetDParam(2, STR_UNITS_IMPERIAL + this->opt->gui.units);
SetDParam(3, STR_02E9_DRIVE_ON_LEFT + this->opt->road_side); SetDParam(3, STR_02E9_DRIVE_ON_LEFT + this->opt->vehicle.road_side);
SetDParam(4, TownName(this->opt->town_name)); SetDParam(4, TownName(this->opt->game_creation.town_name));
SetDParam(5, _autosave_dropdown[this->opt->autosave]); SetDParam(5, _autosave_dropdown[this->opt->gui.autosave]);
SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr); SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
int i = GetCurRes(); int i = GetCurRes();
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
@ -181,11 +181,11 @@ struct GameOptionsWindow : Window {
{ {
switch (widget) { switch (widget) {
case GAMEOPT_CURRENCY_BTN: // Setup currencies dropdown 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; break;
case GAMEOPT_DISTANCE_BTN: // Setup distance unit dropdown 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; break;
case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown 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 /* 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 */ * no vehicles present. In a networking game only the server can change it */
if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) { 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; } break;
case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown
ShowTownnameDropdown(this, this->opt->town_name); ShowTownnameDropdown(this, this->opt->game_creation.town_name);
break; break;
case GAMEOPT_AUTOSAVE_BTN: // Setup autosave dropdown 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; break;
case GAMEOPT_VEHICLENAME_BTN: // Setup customized vehicle-names dropdown case GAMEOPT_VEHICLENAME_BTN: // Setup customized vehicle-names dropdown
@ -265,17 +265,17 @@ struct GameOptionsWindow : Window {
case GAMEOPT_CURRENCY_BTN: /* Currency */ case GAMEOPT_CURRENCY_BTN: /* Currency */
if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
this->opt->currency = index; this->opt->gui.currency = index;
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;
case GAMEOPT_DISTANCE_BTN: // Measuring units case GAMEOPT_DISTANCE_BTN: // Measuring units
this->opt->units = index; this->opt->gui.units = index;
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;
case GAMEOPT_ROADSIDE_BTN: // Road side 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)); DoCommandP(0, index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
@ -283,13 +283,13 @@ struct GameOptionsWindow : Window {
case GAMEOPT_TOWNNAME_BTN: // Town names case GAMEOPT_TOWNNAME_BTN: // Town names
if (_game_mode == GM_MENU) { if (_game_mode == GM_MENU) {
this->opt->town_name = index; this->opt->game_creation.town_name = index;
InvalidateWindow(WC_GAME_OPTIONS, 0); InvalidateWindow(WC_GAME_OPTIONS, 0);
} }
break; break;
case GAMEOPT_AUTOSAVE_BTN: // Autosave options case GAMEOPT_AUTOSAVE_BTN: // Autosave options
_opt.autosave = _opt_newgame.autosave = index; _settings.gui.autosave = _settings.gui.autosave = index;
this->SetDirty(); this->SetDirty();
break; 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 {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; int i;
assert(mode <= 3); assert(mode <= 3);
@ -424,7 +424,7 @@ void SetDifficultyLevel(int mode, GameOptions *gm_opt)
gm_opt->diff_level = mode; gm_opt->diff_level = mode;
if (mode != 3) { // not custom if (mode != 3) { // not custom
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) 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() void CheckDifficultyLevels()
{ {
if (_opt_newgame.diff_level != 3) { if (_settings_newgame.difficulty.diff_level != 3) {
SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame); SetDifficultyLevel(_settings_newgame.difficulty.diff_level, &_settings_newgame.difficulty);
} else { } else {
for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) { 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 = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
*diff -= *diff % _game_setting_info[i].step; *diff -= *diff % _game_setting_info[i].step;
} }
@ -479,7 +479,7 @@ private:
uint8 timeout; uint8 timeout;
/* Temporary holding place of values in the difficulty window until 'Save' is clicked */ /* Temporary holding place of values in the difficulty window until 'Save' is clicked */
GameOptions opt_mod_temp; DifficultySettings opt_mod_temp;
enum { enum {
GAMEDIFF_WND_TOP_OFFSET = 45, GAMEDIFF_WND_TOP_OFFSET = 45,
@ -510,7 +510,7 @@ public:
{ {
/* Copy current settings (ingame or in intro) to temporary holding place /* Copy current settings (ingame or in intro) to temporary holding place
* change that when setting stuff, copy back on clicking 'OK' */ * 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_increase = false;
this->clicked_button = NO_SETTINGS_BUTTON; this->clicked_button = NO_SETTINGS_BUTTON;
this->timeout = 0; this->timeout = 0;
@ -549,7 +549,7 @@ public:
int y = GAMEDIFF_WND_TOP_OFFSET; int y = GAMEDIFF_WND_TOP_OFFSET;
for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) { for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) {
const GameSettingData *gsd = &_game_setting_info[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, DrawArrowButtons(5, y, 3,
(this->clicked_button == i) ? 1 + !!this->clicked_increase : 0, (this->clicked_button == i) ? 1 + !!this->clicked_increase : 0,
@ -587,7 +587,7 @@ public:
this->timeout = 5; 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 const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting
if (x >= 10) { if (x >= 10) {
@ -603,7 +603,7 @@ public:
this->clicked_button = btn; this->clicked_button = btn;
/* save value in temporary variable */ /* 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); this->RaiseWidget(GDW_LVL_EASY + this->opt_mod_temp.diff_level);
SetDifficultyLevel(3, &this->opt_mod_temp); // set difficulty level to custom SetDifficultyLevel(3, &this->opt_mod_temp); // set difficulty level to custom
this->LowerWidget(GDW_LVL_CUSTOM); this->LowerWidget(GDW_LVL_CUSTOM);
@ -627,11 +627,11 @@ public:
case GDW_ACCEPT: { // Save button - save changes case GDW_ACCEPT: { // Save button - save changes
GDType btn, val; 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++) { 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 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); DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
} }
} }

View File

@ -33,46 +33,29 @@ enum {
/** Specific type for Game Difficulty to ease changing the type */ /** Specific type for Game Difficulty to ease changing the type */
typedef uint16 GDType; typedef uint16 GDType;
struct GameDifficulty { /** Settings related to the difficulty of the game */
GDType max_no_competitors; struct DifficultySettings {
GDType competitor_start_time; GDType max_no_competitors; ///< the number of competitors (AIs)
GDType number_towns; GDType competitor_start_time; ///< how long to wait for the first competitors (AIs)
GDType number_industries; GDType number_towns; ///< the amount of towns
GDType max_loan; GDType number_industries; ///< the amount of industries
GDType initial_interest; GDType max_loan; ///< the maximum initial loan
GDType vehicle_costs; GDType initial_interest; ///< amount of interest (to pay over the loan)
GDType competitor_speed; GDType vehicle_costs; ///< amount of money spent on vehicle running cost
GDType competitor_intelligence; ///< no longer in use GDType competitor_speed; ///< the speed at which the AI builds
GDType vehicle_breakdowns; GDType competitor_intelligence; ///< the competior's (AI) intelligence
GDType subsidy_multiplier; GDType vehicle_breakdowns; ///< likelihood of vehicles breaking down
GDType construction_cost; GDType subsidy_multiplier; ///< amount of subsidy
GDType terrain_type; GDType construction_cost; ///< how expensive is building
GDType quantity_sea_lakes; GDType terrain_type; ///< the mountainousness of the landscape
GDType economy; GDType quantity_sea_lakes; ///< the amount of seas/lakes
GDType line_reverse_mode; GDType economy; ///< how volatile is the economy
GDType disasters; 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 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. */ /** Settings related to the GUI and other stuff that is not saved in the savegame. */
struct GUISettings { struct GUISettings {
bool vehicle_speed; ///< show vehicle speed 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 toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right
uint8 window_snap_radius; ///< windows snap at each other if closer than this 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 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 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?" 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) 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? 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? 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? 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. */ /** Settings related to the creation of games. */
@ -132,6 +118,9 @@ struct GameCreationSettings {
byte tree_placer; ///< the tree placer algorithm byte tree_placer; ///< the tree placer algorithm
byte heightmap_rotation; ///< rotation director for the heightmap byte heightmap_rotation; ///< rotation director for the heightmap
byte se_flat_world_height; ///< land height a flat world gets in SE 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 */ /** Settings related to construction in-game */
@ -266,6 +255,7 @@ struct VehicleSettings {
bool dynamic_engines; ///< enable dynamic allocation of engine data bool dynamic_engines; ///< enable dynamic allocation of engine data
bool never_expire_vehicles; ///< never expire vehicles bool never_expire_vehicles; ///< never expire vehicles
byte extend_vehicle_life; ///< extend vehicle life by this many years 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. */ /** Settings related to the economy. */
@ -300,6 +290,7 @@ struct StationSettings {
/** All settings together. */ /** All settings together. */
struct Settings { struct Settings {
DifficultySettings difficulty; ///< settings related to the difficulty
GUISettings gui; ///< settings related to the GUI GUISettings gui; ///< settings related to the GUI
GameCreationSettings game_creation; ///< settings used during the creation of a game (map) GameCreationSettings game_creation; ///< settings used during the creation of a game (map)
ConstructionSettings construction; ///< construction of things in-game ConstructionSettings construction; ///< construction of things in-game
@ -311,9 +302,10 @@ struct Settings {
StationSettings station; ///< settings related to station management StationSettings station; ///< settings related to station management
}; };
/** The current settings. */
extern Settings _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; extern Settings _settings_newgame;
#endif /* SETTINGS_TYPE_H */ #endif /* SETTINGS_TYPE_H */

View File

@ -196,7 +196,7 @@ static void HandleBrokenShip(Vehicle *v)
InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { 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); SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
} }

View File

@ -459,7 +459,7 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
case MP_TREES: case MP_TREES:
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) { 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 { } else {
bits = MKCOLOR(0x54575754); bits = MKCOLOR(0x54575754);
} }

View File

@ -296,7 +296,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
CountMapSquareAround(tile, CMSATree) >= 8 || CountMapSquareAround(tile, CMSATree) >= 8 ||
CountMapSquareAround(tile, CMSAForest) >= 2) 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 */ /* 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. * 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 * Basically, it says that the less tolerant a town is, the bigger the distance before
* an actual decrease can be granted */ * 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 */ /* The airport is in the "inner" distance where there is no noise reduction */
if (distance < town_tolerance_distance) return afc->noise_level; if (distance < town_tolerance_distance) return afc->noise_level;

View File

@ -546,7 +546,7 @@ static const Units units[] = {
*/ */
uint ConvertSpeedToDisplaySpeed(uint speed) 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) 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) 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} case SCC_VELOCITY: {// {VELOCITY}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv)); 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; modifier = 0;
break; break;
} }
@ -625,18 +625,18 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
switch (cargo_str) { switch (cargo_str) {
case STR_TONS: { case STR_TONS: {
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].w_m >> units[_opt.units].w_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].l_weight), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_weight), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
case STR_LITERS: { case STR_LITERS: {
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].v_m >> units[_opt.units].v_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].l_volume), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_volume), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
@ -718,9 +718,9 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
case SCC_VOLUME: { // {VOLUME} case SCC_VOLUME: { // {VOLUME}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].v_m >> units[_opt.units].v_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].l_volume), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_volume), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
@ -763,45 +763,45 @@ static char* FormatString(char* buff, const char* str, const int64* argv, uint c
case SCC_POWER: { // {POWER} case SCC_POWER: { // {POWER}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].p_m >> units[_opt.units].p_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].p_m >> units[_settings.gui.units].p_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].power), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].power), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
case SCC_VOLUME_SHORT: { // {VOLUME_S} case SCC_VOLUME_SHORT: { // {VOLUME_S}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].v_m >> units[_opt.units].v_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].v_m >> units[_settings.gui.units].v_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].s_volume), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].s_volume), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
case SCC_WEIGHT: { // {WEIGHT} case SCC_WEIGHT: { // {WEIGHT}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].w_m >> units[_opt.units].w_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].l_weight), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].l_weight), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
case SCC_WEIGHT_SHORT: { // {WEIGHT_S} case SCC_WEIGHT_SHORT: { // {WEIGHT_S}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].w_m >> units[_opt.units].w_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].w_m >> units[_settings.gui.units].w_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].s_weight), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].s_weight), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
case SCC_FORCE: { // {FORCE} case SCC_FORCE: { // {FORCE}
int64 args[1]; int64 args[1];
assert(_opt.units < lengthof(units)); assert(_settings.gui.units < lengthof(units));
args[0] = GetInt32(&argv) * units[_opt.units].f_m >> units[_opt.units].f_s; args[0] = GetInt32(&argv) * units[_settings.gui.units].f_m >> units[_settings.gui.units].f_s;
buff = FormatString(buff, GetStringPtr(units[_opt.units].force), args, modifier >> 24, last); buff = FormatString(buff, GetStringPtr(units[_settings.gui.units].force), args, modifier >> 24, last);
modifier = 0; modifier = 0;
break; break;
} }
@ -1137,7 +1137,7 @@ static char *GenAndCoName(char *buff, uint32 arg, const char* last)
const char* const* base; const char* const* base;
uint num; uint num;
if (_opt.landscape == LT_TOYLAND) { if (_settings.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list; base = _silly_surname_list;
num = lengthof(_silly_surname_list); num = lengthof(_silly_surname_list);
} else { } else {
@ -1167,7 +1167,7 @@ static char *GenPresidentName(char *buff, uint32 x, const char* last)
buff = strecpy(buff, initial, last); buff = strecpy(buff, initial, last);
} }
if (_opt.landscape == LT_TOYLAND) { if (_settings.game_creation.landscape == LT_TOYLAND) {
base = _silly_surname_list; base = _silly_surname_list;
num = lengthof(_silly_surname_list); num = lengthof(_silly_surname_list);
} else { } else {

View File

@ -550,7 +550,7 @@ static void EditorTerraformClick_RockyArea(Window *w)
static void EditorTerraformClick_DesertLightHouse(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) static void EditorTerraformClick_Transmitter(Window *w)
@ -615,7 +615,7 @@ static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
struct ScenarioEditorLandscapeGenerationWindow : Window { struct ScenarioEditorLandscapeGenerationWindow : Window {
ScenarioEditorLandscapeGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) 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); this->FindWindowPlacementAndResize(desc);
} }

View File

@ -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}, {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}; 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] = { static const int8 _max_height[4] = {
6, ///< Very flat 6, ///< Very flat
9, ///< Flat 9, ///< Flat
@ -402,7 +402,7 @@ static void HeightMapSineTransform(height_t h_min, height_t h_max)
/* Transform height into 0..1 space */ /* Transform height into 0..1 space */
fheight = (double)(*h - h_min) / (double)(h_max - h_min); fheight = (double)(*h - h_min) / (double)(h_max - h_min);
/* Apply sine transform depending on landscape type */ /* Apply sine transform depending on landscape type */
switch(_opt.landscape) { switch(_settings.game_creation.landscape) {
case LT_TOYLAND: case LT_TOYLAND:
case LT_TEMPERATE: case LT_TEMPERATE:
/* Move and scale 0..1 into -1..+1 */ /* 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 */ * - height histogram redistribution by sine wave transform */
static void HeightMapNormalize() static void HeightMapNormalize()
{ {
const amplitude_t water_percent = _water_percent[_opt.diff.quantity_sea_lakes]; const amplitude_t water_percent = _water_percent[_settings.difficulty.quantity_sea_lakes];
const height_t h_max_new = I2H(_max_height[_opt.diff.terrain_type]); const height_t h_max_new = I2H(_max_height[_settings.difficulty.terrain_type]);
const height_t roughness = 7 + 3 * _settings.game_creation.tgen_smoothness; const height_t roughness = 7 + 3 * _settings.game_creation.tgen_smoothness;
HeightMapAdjustWaterLevel(water_percent, h_max_new); HeightMapAdjustWaterLevel(water_percent, h_max_new);

View File

@ -197,7 +197,7 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
inline uint16 MaxTownNoise() const { inline uint16 MaxTownNoise() const {
if (this->population == 0) return 0; // no population? no noise 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);
} }
}; };

View File

@ -596,7 +596,7 @@ static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
if (callback != CALLBACK_FAILED) { if (callback != CALLBACK_FAILED) {
if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4); 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 (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 */ /* The 'S' bit indicates food instead of goods */
ac[CT_FOOD] = GB(callback, 8, 4); ac[CT_FOOD] = GB(callback, 8, 4);
} else { } else {
@ -1367,9 +1367,9 @@ static bool CreateTownName(uint32 *townnameparts)
* the other towns may take considerable amount of time (10000 is * the other towns may take considerable amount of time (10000 is
* too much). */ * too much). */
int tries = 1000; int tries = 1000;
bool grf = (_opt.town_name >= _nb_orig_names); bool grf = (_settings.game_creation.town_name >= _nb_orig_names);
uint32 grfid = grf ? GetGRFTownNameId(_opt.town_name - _nb_orig_names) : 0; uint32 grfid = grf ? GetGRFTownNameId(_settings.game_creation.town_name - _nb_orig_names) : 0;
uint16 townnametype = grf ? GetGRFTownNameType(_opt.town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + _opt.town_name; uint16 townnametype = grf ? GetGRFTownNameType(_settings.game_creation.town_name - _nb_orig_names) : SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
assert(townnameparts != NULL); assert(townnameparts != NULL);
@ -1453,14 +1453,14 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
t->exclusive_counter = 0; t->exclusive_counter = 0;
t->statues = 0; t->statues = 0;
if (_opt.town_name < _nb_orig_names) { if (_settings.game_creation.town_name < _nb_orig_names) {
/* Original town name */ /* Original town name */
t->townnamegrfid = 0; t->townnamegrfid = 0;
t->townnametype = SPECSTR_TOWNNAME_START + _opt.town_name; t->townnametype = SPECSTR_TOWNNAME_START + _settings.game_creation.town_name;
} else { } else {
/* Newgrf town name */ /* Newgrf town name */
t->townnamegrfid = GetGRFTownNameId(_opt.town_name - _nb_orig_names); t->townnamegrfid = GetGRFTownNameId(_settings.game_creation.town_name - _nb_orig_names);
t->townnametype = GetGRFTownNameType(_opt.town_name - _nb_orig_names); t->townnametype = GetGRFTownNameType(_settings.game_creation.town_name - _nb_orig_names);
} }
t->townnameparts = townnameparts; t->townnameparts = townnameparts;
@ -1585,7 +1585,7 @@ static const byte _num_initial_towns[4] = {5, 11, 23, 46}; // very low, low, no
bool GenerateTowns() bool GenerateTowns()
{ {
uint num = 0; 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; uint num_cities = _settings.economy.larger_towns == 0 ? 0 : n / _settings.economy.larger_towns;
SetGeneratingWorldProgress(GWP_TOWN, n); SetGeneratingWorldProgress(GWP_TOWN, n);
@ -1879,8 +1879,8 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
HouseZonesBits rad = GetTownRadiusGroup(t, tile); HouseZonesBits rad = GetTownRadiusGroup(t, tile);
/* Above snow? */ /* Above snow? */
int land = _opt.landscape; int land = _settings.game_creation.landscape;
if (land == LT_ARCTIC && z >= _opt.snow_line) land = -1; if (land == LT_ARCTIC && z >= _settings.game_creation.snow_line) land = -1;
uint bitmask = (1 << rad) + (1 << (land + 12)); uint bitmask = (1 << rad) + (1 << (land + 12));
@ -2352,10 +2352,10 @@ static void UpdateTownGrowRate(Town *t)
if (n == 0 && !Chance16(1, 12)) return; 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) if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90)
return; 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) if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food == 0 || t->act_water == 0) && t->population > 60)
return; 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 * owned by a town no removal if rating is lower than ... depends now on
* difficulty setting. Minimum town rating selected by difficulty level * 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)) { if (GetRating(t) < 16 + modemod && !(flags & DC_NO_TOWN_RATING)) {
SetDParam(0, t->index); SetDParam(0, t->index);

View File

@ -2474,7 +2474,7 @@ static Track ChooseTrainTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir
static bool CheckReverseTrain(Vehicle *v) 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->u.rail.track == TRACK_BIT_DEPOT || v->u.rail.track == TRACK_BIT_WORMHOLE ||
!(v->direction & 1)) { !(v->direction & 1)) {
return false; return false;
@ -3246,7 +3246,7 @@ static void HandleBrokenTrain(Vehicle *v)
InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (!PlayVehicleSound(v, VSE_BREAKDOWN)) { 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); SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
} }

View File

@ -112,7 +112,7 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint
*/ */
static TreeType GetRandomTreeType(TileIndex tile, uint seed) static TreeType GetRandomTreeType(TileIndex tile, uint seed)
{ {
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_TEMPERATE: case LT_TEMPERATE:
return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE); return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
@ -259,7 +259,7 @@ void PlaceTreesRandomly()
j = GetTileZ(tile) / TILE_HEIGHT * 2; j = GetTileZ(tile) / TILE_HEIGHT * 2;
while (j--) { while (j--) {
/* Above snowline more trees! */ /* 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);
PlaceTreeAtSameHeight(tile, ht); PlaceTreeAtSameHeight(tile, ht);
}; };
@ -270,7 +270,7 @@ void PlaceTreesRandomly()
} while (--i); } while (--i);
/* place extra trees at rainforest area */ /* place extra trees at rainforest area */
if (_opt.landscape == LT_TROPIC) { if (_settings.game_creation.landscape == LT_TROPIC) {
i = ScaleByMapSize(15000); i = ScaleByMapSize(15000);
do { do {
@ -298,16 +298,16 @@ void GenerateTrees()
if (_settings.game_creation.tree_placer == TP_NONE) return; 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) { switch (_settings.game_creation.tree_placer) {
case TP_ORIGINAL: i = _opt.landscape == LT_ARCTIC ? 15 : 6; break; case TP_ORIGINAL: i = _settings.game_creation.landscape == LT_ARCTIC ? 15 : 6; break;
case TP_IMPROVED: i = _opt.landscape == LT_ARCTIC ? 4 : 2; break; case TP_IMPROVED: i = _settings.game_creation.landscape == LT_ARCTIC ? 4 : 2; break;
default: NOT_REACHED(); return; default: NOT_REACHED(); return;
} }
total = ScaleByMapSize(1000); total = ScaleByMapSize(1000);
if (_opt.landscape == LT_TROPIC) total += ScaleByMapSize(15000); if (_settings.game_creation.landscape == LT_TROPIC) total += ScaleByMapSize(15000);
total *= i; total *= i;
SetGeneratingWorldProgress(GWP_TREE, total); SetGeneratingWorldProgress(GWP_TREE, total);
@ -332,7 +332,7 @@ CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (p2 >= MapSize()) return CMD_ERROR; if (p2 >= MapSize()) return CMD_ERROR;
/* Check the tree type. It can be random or some valid value within the current climate */ /* 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 // make sure sx,sy are smaller than ex,ey
ex = TileX(tile); ex = TileX(tile);
@ -626,7 +626,7 @@ static void TileLoop_Trees(TileIndex tile)
if (GetTreeGround(tile) == TREE_GROUND_SHORE) { if (GetTreeGround(tile) == TREE_GROUND_SHORE) {
TileLoop_Water(tile); TileLoop_Water(tile);
} else { } else {
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_TROPIC: TileLoopTreesDesert(tile); break; case LT_TROPIC: TileLoopTreesDesert(tile); break;
case LT_ARCTIC: TileLoopTreesAlps(tile); break; case LT_ARCTIC: TileLoopTreesAlps(tile); break;
} }
@ -652,7 +652,7 @@ static void TileLoop_Trees(TileIndex tile)
switch (GetTreeGrowth(tile)) { switch (GetTreeGrowth(tile)) {
case 3: /* regular sized tree */ case 3: /* regular sized tree */
if (_opt.landscape == LT_TROPIC && if (_settings.game_creation.landscape == LT_TROPIC &&
GetTreeType(tile) != TREE_CACTUS && GetTreeType(tile) != TREE_CACTUS &&
GetTropicZone(tile) == TROPICZONE_DESERT) { GetTropicZone(tile) == TROPICZONE_DESERT) {
AddTreeGrowth(tile, 1); 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_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break;
case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break; case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
default: // snow or desert 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; break;
} }
} }
@ -725,7 +725,7 @@ void OnTick_Trees()
TreeType tree; TreeType tree;
/* place a tree at a random rainforest spot */ /* 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) && (r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
CanPlantTreesOnTile(tile, false) && CanPlantTreesOnTile(tile, false) &&
(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) { (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {

View File

@ -74,8 +74,8 @@ public:
this->DrawWidgets(); this->DrawWidgets();
int i = this->base = _tree_base_by_landscape[_opt.landscape]; int i = this->base = _tree_base_by_landscape[_settings.game_creation.landscape];
int count = this->count = _tree_count_by_landscape[_opt.landscape]; int count = this->count = _tree_count_by_landscape[_settings.game_creation.landscape];
int x = 18; int x = 18;
int y = 54; int y = 54;

View File

@ -1200,7 +1200,7 @@ static void AnimateTile_TunnelBridge(TileIndex tile)
static void TileLoop_TunnelBridge(TileIndex tile) static void TileLoop_TunnelBridge(TileIndex tile)
{ {
bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile); bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile);
switch (_opt.landscape) { switch (_settings.game_creation.landscape) {
case LT_ARCTIC: case LT_ARCTIC:
if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) { if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert); SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);

View File

@ -375,11 +375,11 @@ static bool IsRadioTowerNearby(TileIndex tile)
void GenerateUnmovables() void GenerateUnmovables()
{ {
if (_opt.landscape == LT_TOYLAND) return; if (_settings.game_creation.landscape == LT_TOYLAND) return;
/* add radio tower */ /* add radio tower */
int radiotowser_to_build = ScaleByMapSize(15); // maximum number of radio towers on the map 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); SetGeneratingWorldProgress(GWP_UNMOVABLE, radiotowser_to_build + lighthouses_to_build);
for (uint i = ScaleByMapSize(1000); i != 0; i--) { 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 */ /* add lighthouses */
uint maxx = MapMaxX(); uint maxx = MapMaxX();

View File

@ -127,7 +127,7 @@ bool Vehicle::NeedsServicing() const
{ {
if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false; 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. /* 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. */ * Note: If servicing is enabled, we postpone replacement till next service. */
return EngineHasReplacementForPlayer(GetPlayer(this->owner), this->engine_type, this->group_id); 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 ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED || 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) { v->cur_speed < 5 || _game_mode == GM_MENU) {
return; return;
} }
@ -930,7 +930,7 @@ void CheckVehicleBreakdown(Vehicle *v)
if (v->type == VEH_SHIP) rel += 0x6666; if (v->type == VEH_SHIP) rel += 0x6666;
/* reduced breakdowns? */ /* reduced breakdowns? */
if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666; if (_settings.difficulty.vehicle_breakdowns == 1) rel += 0x6666;
/* check if to break down */ /* check if to break down */
if (_breakdown_chance[(uint)min(rel, 0xffff) >> 10] <= v->breakdown_chance) { if (_breakdown_chance[(uint)min(rel, 0xffff) >> 10] <= v->breakdown_chance) {