mirror of https://github.com/OpenTTD/OpenTTD
(svn r1076) Feature: Patch setting to autosave the game on exit
If you set autosave_on_exit = true in openttd.cfg, your game will be saved as exit.sav in the autosave folder and you won't be asked if you want to quit the game any more.release/0.4.5
parent
2b13b2d239
commit
77e882c3bd
|
@ -1146,6 +1146,14 @@ bool EmergencySave()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoExitSave()
|
||||||
|
{
|
||||||
|
char buf[200];
|
||||||
|
sprintf(buf, "%s%sexit.sav", _path.autosave_dir, PATHSEP);
|
||||||
|
debug(buf);
|
||||||
|
SaveOrLoad(buf, SL_SAVE);
|
||||||
|
}
|
||||||
|
|
||||||
// not used right now, but could be used if extensions of savegames are garbled
|
// not used right now, but could be used if extensions of savegames are garbled
|
||||||
/*int GetSavegameType(char *file)
|
/*int GetSavegameType(char *file)
|
||||||
{
|
{
|
||||||
|
|
12
sdl.c
12
sdl.c
|
@ -434,6 +434,8 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
|
||||||
return (key << 16) + sym->unicode;
|
return (key << 16) + sym->unicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoExitSave();
|
||||||
|
|
||||||
static int PollEvent(void)
|
static int PollEvent(void)
|
||||||
{
|
{
|
||||||
SDL_Event ev;
|
SDL_Event ev;
|
||||||
|
@ -500,9 +502,13 @@ static int PollEvent(void)
|
||||||
|
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
// do not ask to quit on the main screen
|
// do not ask to quit on the main screen
|
||||||
if (_game_mode != GM_MENU)
|
if (_game_mode != GM_MENU) {
|
||||||
AskExitGame();
|
if(_patches.autosave_on_exit) {
|
||||||
else
|
DoExitSave();
|
||||||
|
return ML_QUIT;
|
||||||
|
} else
|
||||||
|
AskExitGame();
|
||||||
|
} else
|
||||||
return ML_QUIT;
|
return ML_QUIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -779,6 +779,7 @@ static const SettingDesc patch_player_settings[] = {
|
||||||
{"errmsg_duration", SDT_UINT8, (void*)5, &_patches.errmsg_duration, NULL},
|
{"errmsg_duration", SDT_UINT8, (void*)5, &_patches.errmsg_duration, NULL},
|
||||||
{"toolbar_pos", SDT_UINT8, (void*)0, &_patches.toolbar_pos, NULL},
|
{"toolbar_pos", SDT_UINT8, (void*)0, &_patches.toolbar_pos, NULL},
|
||||||
{"keep_all_autosave", SDT_BOOL, (void*)false, &_patches.keep_all_autosave, NULL},
|
{"keep_all_autosave", SDT_BOOL, (void*)false, &_patches.keep_all_autosave, NULL},
|
||||||
|
{"autosave_on_exit", SDT_BOOL, (void*)false, &_patches.autosave_on_exit, NULL},
|
||||||
|
|
||||||
{"bridge_pillars", SDT_BOOL, (void*)true, &_patches.bridge_pillars, NULL},
|
{"bridge_pillars", SDT_BOOL, (void*)true, &_patches.bridge_pillars, NULL},
|
||||||
{"invisible_trees", SDT_BOOL, (void*)false, &_patches.invisible_trees, NULL},
|
{"invisible_trees", SDT_BOOL, (void*)false, &_patches.invisible_trees, NULL},
|
||||||
|
|
|
@ -148,6 +148,7 @@ typedef struct Patches {
|
||||||
uint32 colored_news_date; // when does newspaper become colored?
|
uint32 colored_news_date; // when does newspaper become colored?
|
||||||
|
|
||||||
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 extra_dynamite; // extra dynamite
|
bool extra_dynamite; // extra dynamite
|
||||||
|
|
||||||
bool never_expire_vehicles; // never expire vehicles
|
bool never_expire_vehicles; // never expire vehicles
|
||||||
|
|
12
win32.c
12
win32.c
|
@ -181,6 +181,8 @@ static void ClientSizeChanged(int w, int h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoExitSave();
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch(msg) {
|
switch(msg) {
|
||||||
|
@ -224,7 +226,15 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
AskExitGame();
|
// do not ask to quit on the main screen
|
||||||
|
if (_game_mode != GM_MENU) {
|
||||||
|
if(_patches.autosave_on_exit) {
|
||||||
|
DoExitSave();
|
||||||
|
_exit_game = true;
|
||||||
|
} else
|
||||||
|
AskExitGame();
|
||||||
|
} else
|
||||||
|
return ML_QUIT;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
|
Loading…
Reference in New Issue