Bubb13 / EEex

An executable extender for Beamdog's Enhanced Edition of the Infinity Engine
50 stars 7 forks source link

Slow quick saves when using EEex in Icewind Dale EE v2.6.6.0 #45

Closed tomasz1986 closed 2 years ago

tomasz1986 commented 2 years ago

Please forgive me if this is a known problem, but I'm experiencing an issue with slow quick saves when using EEex in Icewind Dale EE v2.6.6.0. Basically, normally when you hit the quick save hotkey, the game is saved instantaneously. However, with EEex installed, there is a 1-2 second delay after pressing the hotkey. In other words, the game freezes until the save has completed. It kind of makes it similar to the original game, where you had wait a few seconds for the save to happen too. The only difference is that there's no special screen displayed when that happens :wink:.

For the record, I'm having this problem using a clean installation of Icewind Dale EE v2.6.6.0 from GOG paired with EEex v0.9.7-alpha. It makes no differences whether the two optional modules are installed or not.

// Log of Currently Installed WeiDU Mods
// The top of the file is the 'oldest' mod
// ~TP2_File~ #language_number #component_number // [Subcomponent Name -> ] Component Name [ : Version]
~EEEX/EEEX.TP2~ #0 #0 // EEex: 0.9.7

Have you got any idea what the problem could be about? I used to play before using EEex in Baldur's Gate EE v2.5 and I don't remember such quick save delays there. I'd also suspect that the problem isn't about quick save per se, but rather all saves, but to tell the truth, it doesn't really matter whether it takes a few seconds when doing an explicit save. It's only when quick saving that any delays like that make a real difference, especially if you're used to quick save almost all the time as I am 🙁.

Just in case, here are two videos that show the issue at hand.

  1. Slow quick save with EEex - https://youtu.be/9obGGKdJBBA
  2. Instant quick save without EEex - https://youtu.be/B8BajrSTddA
Bubb13 commented 2 years ago

This has something to do with how InfinityLoader binds to the console. When you save the engine logs a bunch of a debug output to the console, and when the game is started by InfinityLoader this output takes significantly longer to finish.

I've swapped which function the engine uses to log, (now WriteConsoleW, was fprintf). There is still a slight hiccup when quicksaving but it should be faster now.

tomasz1986 commented 2 years ago

Thank you for a very quick fix 🙂. As you said, there's still a slight slowdown, but it seems to take much less time than before.

Bubb13 commented 2 years ago

97cc7a77060e99c24e39ebe1e8ecf80157598de8 broke redirecting console IO; for example:

InfinityLoader.exe > log.txt 2>&1

Reverting the commit fixes this.

tomasz1986 commented 2 years ago

Is there no other way? :pensive:

The difference in save speed between before and after this commit is drastic.