Bad fix for changing video depth resetting all settings to zero

This commit is contained in:
pelya
2017-04-05 21:50:24 +03:00
committed by Sergii Pylypenko
parent 65a601c1e1
commit 4f81c56d8f
4 changed files with 30 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ Point _right_button_down_pos; ///< Pos of right mouse button click, for drag and
DrawPixelInfo _screen;
bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
bool _exit_game;
bool _restart_game;
GameMode _game_mode;
SwitchMode _switch_mode; ///< The next mainloop command.
PauseModeByte _pause_mode;

View File

@@ -491,6 +491,20 @@ struct AfterNewGRFScan : NewGRFScanCallback {
}
#endif /* ENABLE_NETWORK */
// TODO: remove this hack in one year
// Check if OpenTTD config is broken by blitter changing code
static bool checked = false;
DEBUG(misc, 0, "========= Limits for vehicles: %d %d %d %d", _settings_newgame.vehicle.max_trains, _settings_newgame.vehicle.max_roadveh, _settings_newgame.vehicle.max_aircraft, _settings_newgame.vehicle.max_ships);
if (!checked &&
_settings_newgame.vehicle.max_trains == 0 && _settings_newgame.vehicle.max_roadveh == 0 &&
_settings_newgame.vehicle.max_aircraft == 0 && _settings_newgame.vehicle.max_ships == 0) {
unlink("libsdl-DownloadFinished-1.flag");
//_exit_game = true;
//_restart_game = true;
abort(); // Kill myself with contempt, user will restart the app, because otherwise we enter infinite restart loop
}
checked = true;
/* After the scan we're not used anymore. */
delete this;
}
@@ -925,6 +939,13 @@ exit_normal:
}
#endif /* ENABLE_NETWORK */
if (_restart_game) {
#ifdef __ANDROID__
// This makes OpenTTD reset all it's settings for some reason. Just abort and pretend we crashed
//SDL_ANDROID_RestartMyself("restart-settings");
#endif
}
return ret;
}

View File

@@ -52,6 +52,7 @@ enum DisplayOptions {
extern GameMode _game_mode;
extern SwitchMode _switch_mode;
extern bool _exit_game;
extern bool _restart_game;
/** Modes of pausing we've got */
enum PauseMode {

View File

@@ -187,7 +187,7 @@ struct GameOptionsWindow : Window {
{
DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
if (this->reload) _switch_mode = SM_MENU;
SaveToConfig(); // save all settins immediately on Android, because users tend to kill the app instead of pressing 'Quit' button
if (!_exit_game) SaveToConfig(); // Save all settings immediately on Android, because users tend to kill the app instead of pressing 'Quit' button
}
/**
@@ -494,10 +494,10 @@ struct GameOptionsWindow : Window {
if (this->IsWidgetLowered(WID_GO_8BPP_BUTTON)) break;
free(_ini_blitter);
_ini_blitter = stredup("8bpp-optimized");
SaveToConfig();
_exit_game = true;
_restart_game = true;
#ifdef __ANDROID__
SDL_ANDROID_SetConfigOption(SDL_ANDROID_CONFIG_VIDEO_DEPTH_BPP, 16);
SDL_ANDROID_RestartMyself("restart-settings"); // We terminate here, no need to update widget state
#endif
break;
@@ -505,10 +505,10 @@ struct GameOptionsWindow : Window {
if (this->IsWidgetLowered(WID_GO_16BPP_BUTTON)) break;
free(_ini_blitter);
_ini_blitter = stredup("16bpp-simple");
SaveToConfig();
_exit_game = true;
_restart_game = true;
#ifdef __ANDROID__
SDL_ANDROID_SetConfigOption(SDL_ANDROID_CONFIG_VIDEO_DEPTH_BPP, 16);
SDL_ANDROID_RestartMyself("restart-settings"); // We terminate here, no need to update widget state
#endif
break;
@@ -516,10 +516,10 @@ struct GameOptionsWindow : Window {
if (this->IsWidgetLowered(WID_GO_32BPP_BUTTON)) break;
free(_ini_blitter);
_ini_blitter = stredup("32bpp-anim");
SaveToConfig();
_exit_game = true;
_restart_game = true;
#ifdef __ANDROID__
SDL_ANDROID_SetConfigOption(SDL_ANDROID_CONFIG_VIDEO_DEPTH_BPP, 24);
SDL_ANDROID_RestartMyself("restart-settings"); // We terminate here, no need to update widget state
#endif
break;