Changing AA lead to a crash

Alpha 5 has a bug that is responsible for almost half of its crashreports:

aa_crash

Stack trace of the crash

For reasons, Windows does not allow to change windows pixel format more than once (something about it being more complicated than destroy and recreate the window). These are rules of the game and this is fine. How does it affect Knights Province? Well, changing AA mode required to recreate OpenGL context, which in turn, required to reset the pixel format, which, when performed on the same window, caused an error. Unluckily, due to being non-modal, displaying that error dialog caused the underlying window to repaint itself, which triggered OpenGL context recreation once again (since it was missing) .. And now the code started to repeat itself, causing less-than-informative EInvalidPointer exception, since some things should not be used twice, especially in such manner.

The bug did not reveal itself before, because the only change that required recreation of OpenGL context was toggling the game fullscreen. Fullscreen toggle is special, because it recreates the window behind the scenes, thus always providing new “material” for which new pixel format could be set. AA is another such change added in Alpha 5.

I was able to recreate and fix a crash that was happening on changing AA (anti-aliasing) mode, if that change was made without toggling fullscreen mode. Hopefully that is the crash that was plaguing Alpha 5 for the players that have sent me their crashreports. Thank you guys for sending them in, they helped a lot!

Alpha 6 is around the corner, bugfix will be there. Hopefully without many more new bugs 😉

P.S. For now, workaround for this crash is – when you want to toggle AA, always toggle fullscreen mode alongside.

This entry was posted in How things work. Bookmark the permalink.

10 Responses to Changing AA lead to a crash

  1. thimo says:

    With most games if you switch AA mode you have to restart the game before it applies the setting IIRC.
    Maybe that’d be an option for KP as well?

    Or like full-screen, recreate the full window?

  2. marshal89 says:

    Cant wait for the next Update! 🙂

  3. Audio.82 says:

    I’m really excited for this game to be honest. Just wanna put this in front of the message!

    I’m having some trouble trying to install the alpha version. I know jack shit about programming etc but I would like to help by testing.

    • Krom says:

      Let’s try resolving this! What kind of trouble do you encounter?

      • Audio.82 says:

        Well when I open the download file and i wanna run the .Exe file. It says the following: Program can’t be started because libzplay.dll is missing on the pc.

        So I went looking for the libzplay.dll file and installed it.
        Afterwards I still get the same error.

        Hence not being able to install nor play.

        • Krom says:

          Please ensure that you have unpacked the game into new folder. There should be 4 folders, a few files, including KnightsProvince.exe and libzplay.dll is right next to it.

          • Audio.82 says:

            Alright so that was the problem :).

            However like in a RPG a new quest arrives.

            I all the files in a folder on my desktop. Now when i press the KnightsProvince.exe i immediatly get a warning that KnightsProvince.exe doesn’t work anymore.

            With no further explanation.

          • Krom says:

            Can you write me on Skype (kromster80) or email (kromster80 at gmail com), quote the error text and send me the game log (files in logs\ folder)

  4. Audio.82 says:

    Alright with the help of Krom fixed it.
    I just unpacked it wrong.

    First the libzplay.dll file was missing.

    And afterwards i just unpacked it wrong.

    Make sure to unpack the given file and then run the .exe file.

    Have fun all

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.