FS#998 - Chosen resolution is not used on re-open of OTTD
Attached to Project:
OpenTTD
Opened by SirkoZ (SirkoZ) - Sunday, 08 July 2007, 12:54 GMT
Last edited by Patric Stout (TrueBrain) - Monday, 06 August 2007, 20:32 GMT
Opened by SirkoZ (SirkoZ) - Sunday, 08 July 2007, 12:54 GMT
Last edited by Patric Stout (TrueBrain) - Monday, 06 August 2007, 20:32 GMT
|
DetailsRevision: 0.5.3 RC2
Desc.: I play OpenTTD in 640x480 (like TTD's default res.), but my desktop is at 1024x768. When I close down the OTTD and re-run it - the screen resolution of the game is re-set to 1024x768. Quite annoying. |
This task depends upon
Closed by Loïc GUILLOUX (glx)
Thursday, 09 August 2007, 21:02 GMT
Reason for closing: Fixed
Additional comments about closing: in r10399
Thursday, 09 August 2007, 21:02 GMT
Reason for closing: Fixed
Additional comments about closing: in r10399
If set at 640x480, in 0.5.2 and all the releases (apart from 0.4.0 I think) the resolution stayed at 640x480 or any other for that matter.
Interesting - upon actually opening the .cfg and editing "resolution" to 640, 480 - openTTD started in 640x480 - I then closed it and when I re-ran it, it was again in 1024x768 - 1024, 768 was also written in .cfg. That is in both - trunk and RC2 0-5-3.
Here's the .cfg of my 0.5.3-RC2 and also trunk's.
That move of shutdown commands to after the config is saved helped a heap! :-)
Now the set resolution, fullscreen or not, stays. Thank you.
Only one more thing though - perhaps should I open a new bug report?
When switching from full screen, with resolution other than desktop's, to window mode, the window doesn't retain its fullscreen size but is stretched to the desktop resolution and it says "other" in resolution box (again - Win2k). The other way around works ok.
If however I go _from_ full screen (640x480) to 1024x768 (my desktop res) the window doesn't retain its 640x480 size - it's stretched across the whole 1024x768. The other way around works OK.
And the reason I do not commit my patch is because it just hides the real issue; the resolution should not change when going from/to full screen. UNLESS the window was maximized.
About your not applying your patch:
Of course the default code can't work - you DO NOT save the config information before shut-down of the OpenTTD window only after - whatever logic that follows. At any rate - the patch works and I don't know bout that second issue why it would pop-up. But it does.
And without a way to reproduce it, it is impossible to fix :( Not to mention that my knowledge of windows is virtually nil.
I'd say - for the time being - with inclusion of your fs998.diff patch - you'd greatly improve the current state of affairs at least
till you or some other developer or even player come up with a better solution. ;-)
As long as I use the window mode, the selected resolution is remembered for the next start. The windows will always be the same size. (openttd.cfg always contains e.g. "resolution = 800,600")
When I check fullscreen in the options (from a non-maximised game window), the resolution of the monitor is immediatly changed accordingly. But after closing the game, openttd.cfg always contains the current desktop resolution (e.g. "resolution = 1280,1024") instead of the previously selected one, which is then used at the next start of the game (the fullscreen option is correctly remembered). If I manually change the resolution in the config file before starting the game, this resolution is correctly used.
(I never maximised the window in the process.)
I hope this get's things moving. Or perhaps this patch is too radical for non-0.6.0?
There must be some common ground for the environments that have this issue, but so far there is no knowledge about that. Without making it reproducable for the developers or someone with a little programming knowledge looking where things go wrong, it is just a very big gamble to fix the bug.
Just apply the patch till you get a better understanding of the problem - I mean - I already described to you exactly it lacks in behaviour if applied so it's no gamble at all - well - at least not if nothings is broken under other OS-es than Windoze which you can simply ask someone on IRC to test it... Work-around or not - tis good enough for now - for Windoze.
Oh by the way - tell to one of the developers who actually has a Windoze machine to test it in exact way as I and Sansei (Lupin III) have described.
- make sure openttd.cfg is writable
- start OpenTTD non-maximised non-fullscreen
- open the "Game Options"
- select 800x600
- click on fullscreen
- close the "Game Options" menu
- close OpenTTD
- restart OpenTTD
== now OpenTTD is started in full screen ==
According to you the resolution is 1024x768. In my version the resolution is 800x600.
Ergo, I cannot reproduce it on Windows. And I've gotten the exact same report from glx, peter1138 and KUDr (the developers that actually use Windows).
It is not only not broken on non-Windowses, it is even not broken on some Windowses. Even though we use the exact same procedure to reproduce it.
So, could you please explain me how to reproduce it on my machine (or glx's, peter1138's or KUDr's machine)?
I mean you did all the steps. Please - do 1 more try - with the OTTD resolution of 640x480 (native) in full screen.
In any case - the whole thing is that OTTD doesn't write the chosen res. in the CFG...
0.5.2 works as expected (as it does on a "real" Windows), 0.5.3-RC2 has the same problem even in the virtual machine. I did not configure any patches, just used the zips from the downloadpage, copied the few required files into the data folder and repeated the steps. 0.5.2 works as expected, 0.5.3-RC2 does not.
As far as I am aware the patch itself is a valid one, but I think BuildOTTD expects the patch to be in a different format, but then again I've got not idea only hunches.
Btw I managed to compile OTTD within a cygwin environment (but without png and freetype support). Even when I start the game from there the same problem exists. It's really astonishing how others can't reproduce this bug while I can observe it on WinXP, WinXP in vmware and in a cygwin environment.
And what does it show if you run it with the attached patch?
In one I started in 1024 windowed mode, selected fullscreen from the options (1024 fullscreen), quit the game.
In the other I started 1280 fullscreen, selected 1024 as resolution, quit the game.
Both files have an "csc 1280" at the end, which I shouldn't be there in my opinion.
If you need another sequence, tell me what to try.
Again like above:
1) start windowed in desired resolution, switch to fullscreen, quit
2) start fullscreen (desktop res), switch to desired resolution, quit
Is there any way you can provide the image to us?
But I tried other things by adding some printfs to win32_v.cpp and openttd.cpp. I post the log right here since it's easier to explain. I changed win32_v.cpp (which also still contains the patch from above) and openttd.cpp. The latter mostly to track where the change of resolution occurs before saving the config. The numbers are the contents of "_cur_resolution[0]" and "_cur_resolution[1]" at the given time. Again the game is started in 1280 fullscreen, then changed to 1024 fullscreen and finally closed.
"win32_v # WndProcGdi # case WM_....." are printfs at the beginning and end of the matching case of the switch statement in the WndProcGdi function. I did this because there the value of _cur_resolution is copied to/from _bck_resolution. But this didn't seem to be a problem the problem as it is only used when maximizing the window, not for fullscreen.
More important is the part in "VideoDriver_Win32::Stop". After "DestroyWindow" is called the resolution has changed (see from line "VideoDriver_Win32::Stop # 3" and "... # 4"). I couldn't split it up any further at this point, because I could find a "DestroyWindow"-function in the source (is this a Windows function?).
win32_v # WndProcGdi # case WM_SIZE: 1280x1024
win32_v # WndProcGdi # case WM_SIZE: 1280x1024
active 1, minimize 0, fullscreen 1
active 0, minimize 0, fullscreen 1
win32_v # WndProcGdi # case WM_DESTROY: 1280x1024
win32_v # WndProcGdi # case WM_DESTROY: 1280x1024
win32_v # WndProcGdi # case WM_SIZE: 1280x1024
win32_v # WndProcGdi # case WM_SIZE: 1280x1024
active 1, minimize 0, fullscreen 1
openttd # before _video_driver->Stop(): 1024x768
win32_v # VideoDriver_Win32::Stop # 1: 1024x768
win32_v # VideoDriver_Win32::Stop # 2: 1024x768
win32_v # VideoDriver_Win32::Stop # 3: 1024x768
active 0, minimize 0, fullscreen 1
win32_v # WndProcGdi # case WM_SIZE: 1024x768
win32_v # WndProcGdi # case WM_SIZE: 1024x768
win32_v # WndProcGdi # case WM_DESTROY: 1280x1024
win32_v # WndProcGdi # case WM_DESTROY: 1280x1024
win32_v # VideoDriver_Win32::Stop # 4: 1280x1024
win32_v # VideoDriver_Win32::Stop # 5: 1280x1024
win32_v # VideoDriver_Win32::Stop # r: 1280x1024
openttd # after _video_driver->Stop(): 1280x1024
opentdd # if (save_config): Saving CFG...
I never created a patch file (always applied them), so I hope this is working.
Could you check how your Windows reacts on the attached patch?
Other resolitions are saved with this patch, but the behaviour is a little complicated to describe now. If I start the game in 1280f and switch to 1024f the resolution changes, but the size of the game window doesn't. It is still 1280 although you can't see parts of it because they are off screen (and the starting menu is off center for example). The same goes the other way round from 1024f to 1280f, the resolution changes to 1280 but the game stays 1024. The windows desktop can be seen below and right of the game. The game still is in fullscreen mode, there are no window controls.
Second: If I start the game 1280f, switch to 1024f and quit, the config will still contain 1280. The same the other way round again. Starting 1024f, switching to 1280f, quitting, gives 1024 in the cfg. So the game size, which stays the same with this method as described above, is saved.
To actually get the right resolution saved, you have to changed to windowed mode, change the resolution, then switch to fullscreen again. But with this method you can't set a resolution bigger than the desktop resolution, actually not even the desktopn resolution itself. Windows doesn't allow a window that's larger than the desktop minus the window title bar. So if I select 1280x1024 in window mode the, the resolution in OTTD switches to "other" and actually gets set to 1280x1009 and saved. At this point the game will always start in window mode, because this is an invalied fullscreen resolution.
Btw. Thanks for all this effort for such a little bug. I hope there aren't any other serious things held back!