1
0
Fork 0

(svn r24229) [1.2] -Backport from trunk:

- Fix: If you consider a settings to potentially cause desyncs via NewGRFs and thus disallow changing it in network games, you should probably also sync it to clients (r24193, r24191)
- Fix: Use default value when reading an invalid setting value [FS#5153] (r24192, r24146)
- Fix: [Windows] When going to fullscreen and back, restore to the resolution you were, not to the fullscreen resolution (r24189)
- Fix: [Windows] When changing the basics of a window (fullscreen, 8bpp/32bpp), and a window already exists, it was forced out of maximize mode, and its resolution/position was reset, often causing unwanted side-effects [FS#5151] (r24188)
release/1.2
rubidium 2012-05-12 07:37:14 +00:00
parent 5ca16c21d3
commit fcaca9f7ee
3 changed files with 20 additions and 14 deletions

View File

@ -343,6 +343,12 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
case SDT_NUMX: {
char *end;
size_t val = strtoul(str, &end, 0);
if (end == str) {
SetDParamStr(0, str);
SetDParamStr(1, desc->name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL);
return desc->def;
}
if (*end != '\0') {
SetDParamStr(0, desc->name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_TRAILING_CHARACTERS, WL_CRITICAL);
@ -359,7 +365,7 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
SetDParamStr(0, str);
SetDParamStr(1, desc->name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL);
return 0;
return desc->def;
}
case SDT_MANYOFMANY: {
size_t r = LookupManyOfMany(desc->many, str);
@ -367,7 +373,7 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
SetDParamStr(0, str);
SetDParamStr(1, desc->name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL);
return NULL;
return desc->def;
}
case SDT_BOOLX:
if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0 || strcmp(str, "1") == 0) return (void*)true;
@ -376,7 +382,7 @@ static const void *StringToVal(const SettingDescBase *desc, const char *orig_str
SetDParamStr(0, str);
SetDParamStr(1, desc->name);
ShowErrorMessage(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE, WL_CRITICAL);
break;
return desc->def;
case SDT_STRING: return orig_str;
case SDT_INTLIST: return str;
@ -2137,7 +2143,7 @@ static void Load_PATS()
{
/* Copy over default setting since some might not get loaded in
* a networking environment. This ensures for example that the local
* signal_side stays when joining a network-server */
* currency setting stays when joining a network-server */
LoadSettings(_settings, &_settings_game);
}

View File

@ -456,7 +456,6 @@ to = 158
[SDT_BOOL]
base = GameSettings
var = construction.signal_side
flags = SLF_NO_NETWORK_SYNC
guiflags = SGF_NO_NETWORK
def = true
str = STR_CONFIG_SETTING_SIGNALSIDE

View File

@ -296,6 +296,9 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen)
} else if (_wnd.fullscreen) {
/* restore display? */
ChangeDisplaySettings(NULL, 0);
/* restore the resolution */
_wnd.width = _bck_resolution.width;
_wnd.height = _bck_resolution.height;
}
#endif
@ -319,15 +322,13 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen)
#if !defined(WINCE)
AdjustWindowRect(&r, style, FALSE);
#endif
w = r.right - r.left;
h = r.bottom - r.top;
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
if (_wnd.main_wnd) {
ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL); // remove maximize-flag
SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} else {
if (_wnd.main_wnd == NULL) {
w = r.right - r.left;
h = r.bottom - r.top;
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
TCHAR Windowtitle[50];
_sntprintf(Windowtitle, lengthof(Windowtitle), _T("OpenTTD %s"), MB_TO_WIDE(_openttd_revision));
@ -630,7 +631,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
/* Set maximized flag when we maximize (obviously), but also when we
* switched to fullscreen from a maximized state */
_window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen));
if (_window_maximize) _bck_resolution = _cur_resolution;
if (_window_maximize || _fullscreen) _bck_resolution = _cur_resolution;
ClientSizeChanged(LOWORD(lParam), HIWORD(lParam));
}
return 0;