Looking into some bugs and implementing saves

I started this week by fixing an audio bug that was playing some sounds on loop if they had been triggered once and the player got far enough away. Initially I thought this might be a physics issue, but the problem turned out to be that the pause member variable for the sound channel class was not set to false in the stop method. After this, another issue was that some sounds did not play to completion, this was caused by my implementation of the isPlaying method, which I replaced with a simple call to the mixer’s isSoundChannelActive

Next, I looked into the physics issue with the lamp in the first level. The problem is that swinging left to right does not work correctly, with the lamp often getting stuck halfway. Some of this is also present in the base game, where the left to right swing is often not correct but its less apparent. First, I tried looking into an error generated while loading the object but this didn’t turn up anything (the error is also visible in the original game’s log and the code to load assets hasn’t been changed, so this makes sense).  Next, I tried looking in the physics library. Since, for the lamp, the engine instantiates the PhysicsJointBallNewton, I looked at the file dgBallConstraint.cpp of the physics library. Setting some breakpoints in the debugger, I found that only  dgBallConstraint::JacobianDerivative is getting called while the game is running, and looking at more recent versions of the library, I found that some changes had been made to it, but implementing them didn’t make the behavior much better. I then tried to disassemble the binary for the version of the library that the game originally used (when I tried liking it with the ScummVM version of the game, it did fix the problem), but having no experience in this kind of stuff, I struggled a bit. I used a tool that “translates” the assembly to C, which I found much more readable, but I still couldn’t really make out anything. The code looks similar to the sources we have now, but there are some differences that I had no success in porting.  

Next I worked on saves, which now work but are not integrated correctly in ScummVM.  

I also did some work to replace the config file used by the game to store the user’s preferences, like keymaps, graphics settings and sound settings. For keymaps, I tried to replace the current system that deals directly with keys with the custom events provided by ScummVM, since I thought that implementing support for the controller would have been easier in the future. After implementing everything and getting into the game though, I realized that I didn’t think about how I would have dealt with key press and release, so I decided to scrap everything, since fixing it would have made the system more complex than it needed to be. 

Next week I’ll keep working on removing the need for the config file and improving saves, but after that I haven’t made any plans yet. 

Thanks for reading.   

Leave a Reply

Your email address will not be published. Required fields are marked *