{"id":91,"date":"2022-09-05T19:15:10","date_gmt":"2022-09-05T19:15:10","guid":{"rendered":"https:\/\/blogs.scummvm.org\/grisenti\/?p=91"},"modified":"2022-09-05T19:15:10","modified_gmt":"2022-09-05T19:15:10","slug":"solving-more-game-bugs","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/grisenti\/2022\/09\/05\/solving-more-game-bugs\/","title":{"rendered":"Solving more game bugs"},"content":{"rendered":"<p><span data-contrast=\"auto\">This week I played more of the game and solved the bugs I encountered.\u00a0<\/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\">First, I worked on the sound issues I talked about at the end of the last blog. To expand the brief description I gave: at the end of the first major level, some rocks are spawned by the level script and pushed in various directions, the problem was that after the rocks hit the ground, the scraping sound would play on repeat until the player left the level. After a while I discovered that it was a specific rock that caused the issue. More debugging also revealed that the problem was caused only if the player went some distance away from the spawning rocks. At one point, before knowing that distance mattered, I had a couple of sessions where, after setting breakpoints and resuming the game, the issue would disappear, which was very confusing. Now I\u2019m confident that the problem is caused by two operations that are supposed to be done in a different order. One of these is fading out the sound, which is done by physics callback presumably when the item stops rolling, while the second stops the sound if it&#8217;s too far from the player. If the first is done before the second, the sound is stopped twice, but not removed from the update list that starts it again as soon as the player is again in range. In the opposite order, when the call to fade out the sound is made, seeing that the sound was already stopped, it\u2019s immediately removed from the update list. To fix the problem, I added removed\u00a0the sound from the update list after checking that it&#8217;s too far for the player to hear and that the sound is already fading.<\/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\">Going further in the game, I noticed that an important interaction did not work. I tracked it down to physics&#8217;\u00a0ray-casting system, for which I think the problem is that the version of the physics library the game used originally returned negative distances if the player was inside an interactable object, while now they are clamped to 0. Adding the check for equality with 0 fixed it.\u00a0<\/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 found a problem in the level where the player controls a crane, with the issue being that the crane didn\u2019t move when it should have. The way the movement is implemented is by moving the minimum and maximum limits of the joints that control the crane arm, and looking into the code, I found that the problem is with the physics callback, that was not getting called and consequently, the updated values were not getting used. I think the reason is that if the body doesn\u2019t move, the callback is not called. To solve this, I added some code to move the crate attached to the crane in the <code>SetMaxDistance<\/code> method of the <code>PhysicsJointSliderNewton<\/code> class.\u00a0<\/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\">After that, I investigated a door that was not getting created, with something still blocking the room\u2019s entrance. I tracked the problem down to an optimization option in the creation of the wall collider, that removed the door hole and caused the door to go missing. To fix it I removed the optimization code, since it\u2019s the solution that was also used in HPL2. <\/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\u2019ve ended the week working on a door that fails to open when it should. Since the script is calling an animation function, that\u2019s where I\u2019ll start debugging next week. I am at about more that two thirds of the way through the game and hopefully I will be able to get to the end, so I can start working on removing the STL containers.\u00a0<\/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.<\/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>This week I played more of the game and solved the bugs I encountered.\u00a0\u00a0 First, I worked on the sound issues I talked about at the end of the last blog. To expand the brief description I gave: at the end of the first major level, some rocks are spawned by the level script and [&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-91","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/91","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=91"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":92,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/posts\/91\/revisions\/92"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/grisenti\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}