http://bugs.winehq.org/show_bug.cgi?id=27674
Summary: Majesty 2: fog of war broken Product: Wine Version: 1.3.23 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: directx-d3d AssignedTo: wine-bugs@winehq.org ReportedBy: pp@siedziba.pl
Fog of war in Majesty 2 is not updated properly. Explored objects stay visible, but explored terrain goes back to unexplored state once it's out of unit's visibility range, so the player sees rocks and buildings and other things floating in the dark void.
Regression testing points to this patch:
599d09b08ca88a9270c56053317ba922c6c4228a is the first bad commit commit 599d09b08ca88a9270c56053317ba922c6c4228a Author: Alexandre Julliard julliard@winehq.org Date: Mon May 16 20:18:33 2011 +0200
wined3d: Always create the software cursor.
:040000 040000 a9467b72ce58ded7655884c707f1c99c66d12bea 9a5de16cb0cebdc0f29777df8f4f211ab594e790 M dlls
Reverting the patch on top of current git makes the game work properly again (reverse patching dlls/wined3d/device.c fails and needs to be done manually).
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #1 from Piotr Pawlow pp@siedziba.pl 2011-07-02 16:50:12 CDT --- Created an attachment (id=35405) --> (http://bugs.winehq.org/attachment.cgi?id=35405) Screenshot from the tutorial level
http://bugs.winehq.org/show_bug.cgi?id=27674
Piotr Pawlow pp@siedziba.pl changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression CC| |julliard@winehq.org
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #2 from Piotr Pawlow pp@siedziba.pl 2011-07-03 17:15:48 CDT --- Poking the code for several hours leads to the following results:
I can leave the code creating the cursor in device.c intact, I can leave the code blitting the cursor in swapchain.c intact, and the game still works properly, provided that I delete / comment out the following line in device.c/5200, wined3d_device_set_cursor_properties():
glDeleteTextures(1, &device->cursorTexture);
Of course it makes Wine leak cursor textures.
So, is it deleting wrong texture because cursorTexture is uninitialized or invalid at some point? It seems not, I put tracing before glDeleteTextures and after glGenTextures. It starts by generating texture number 5, then deleting 5, and it keeps generating / deleting, always number 5.
Does the glDeleteTextures call have some unexpected side effect? It doesn't seem so. I can leave glDeleteTextures untoched but duplicate the line in device.c/5275:
glGenTextures(1, &device->cursorTexture);
Of course we leak textures, but glDeleteTextures() gets called and it doesn't break the game.
Even more surprising is that I can do this instead - add in device.c/5202:
else glGenTextures(1, &device->cursorTexture);
Leave the rest of the code untouched, just one line so that if the device->cursorTexture is uninitialized we create one extra (which will leak). It causes the game to use texture number *6* for the cursor instead of 5, and somehow makes it work!
And one more funny thing: saving cursorTexture to a temporary variable, and deleting it AFTER glGenTextures, makes the terrain all explored by default.
All of this doesn't make sense to me, and I have no idea what's going on.
I'm testing on Gefore 9600 GT with NVidia proprietary driver version 270.41.06.
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #3 from Henri Verbeet hverbeet@gmail.com 2011-07-03 17:36:55 CDT --- I suppose you could check if there's anything else that tries to use that texture name. The main functions you'd care about are wined3d_texture_bind() and surface_bind(). Something else you may want to check is if there are any calls to wined3d_device_reset() after the cursor texture is created. The cursor texture should probably be deleted in delete_opengl_contexts(). (I.e., I suspect something along the lines of the GL context going away but cursorTexture not being updated, and then later deleting a different texture that happened to end up with the old cursorTexture name.) The software cursor drawing code is pretty hacky though, I'm not all that surprised it has bugs.
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #4 from Piotr Pawlow pp@siedziba.pl 2011-07-04 03:38:48 CDT --- Created an attachment (id=35423) --> (http://bugs.winehq.org/attachment.cgi?id=35423) Delete cursor on device reset.
Oh, indeed, looks like wined3d_device_reset() wasn't deleting the cursor.
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #5 from Henri Verbeet hverbeet@gmail.com 2011-07-05 08:43:58 CDT --- Looks good to me, if that fixes the bug.
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #6 from Piotr Pawlow pp@siedziba.pl 2011-07-05 12:44:06 CDT --- Yes, it fixes the bug. Patch sent: http://www.winehq.org/pipermail/wine-patches/2011-July/103967.html
http://bugs.winehq.org/show_bug.cgi?id=27674
--- Comment #7 from Henri Verbeet hverbeet@gmail.com 2011-07-05 13:06:18 CDT --- Should be fixed by f6600263c1b35fb8576ec064b2fabdf1e097b82e.
http://bugs.winehq.org/show_bug.cgi?id=27674
Piotr Pawlow pp@siedziba.pl changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED
--- Comment #8 from Piotr Pawlow pp@siedziba.pl 2011-07-05 15:00:36 CDT --- Thank you, marking fixed.
http://bugs.winehq.org/show_bug.cgi?id=27674
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Alexandre Julliard julliard@winehq.org 2011-07-08 13:46:49 CDT --- Closing bugs fixed in 1.3.24.