{"id":80,"date":"2022-08-22T11:59:14","date_gmt":"2022-08-22T11:59:14","guid":{"rendered":"https:\/\/blogs.scummvm.org\/grisenti\/?p=80"},"modified":"2022-08-22T11:59:14","modified_gmt":"2022-08-22T11:59:14","slug":"looking-into-some-bugs-and-implementing-saves","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/grisenti\/2022\/08\/22\/looking-into-some-bugs-and-implementing-saves\/","title":{"rendered":"Looking into some bugs and implementing saves"},"content":{"rendered":"<p><span data-contrast=\"auto\">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 <code>isPlaying<\/code> method, which I replaced with a simple call to the mixer\u2019s\u00a0<code>isSoundChannelActive<\/code>.\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">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\u2019t turn up anything (the error is also visible in the original game\u2019s log and the code to load assets hasn\u2019t been changed, so this makes sense). <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><span data-contrast=\"auto\">Next, I tried looking in the physics library. Since, for the lamp, the engine instantiates the <code>PhysicsJointBallNewton<\/code>, I looked at the file <em>dgBallConstraint.cpp<\/em> of the physics library. Setting some breakpoints in the debugger, I found that only \u00a0<code>dgBallConstraint::JacobianDerivative<\/code> 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\u2019t 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 \u201ctranslates\u201d the assembly to C, which I found much more readable, but I still couldn\u2019t 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. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Next I worked on saves, which now work but are not integrated correctly in ScummVM. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">I also did some work to replace the config file used by the game to store the user\u2019s 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\u2019t think about how I would have <span class=\"TextRun SCXW125337836 BCX2\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"auto\"><span class=\"NormalTextRun SCXW125337836 BCX2\">dealt <\/span><\/span> 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.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Next week I\u2019ll keep working on removing the need for the config file and improving saves, but after that I haven\u2019t made any plans yet.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">Thanks for reading. \u00a0<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/comments?post=80"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/80\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/media?parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/categories?post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/tags?post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}