{"id":84,"date":"2026-06-09T11:37:55","date_gmt":"2026-06-09T11:37:55","guid":{"rendered":"https:\/\/blogs.scummvm.org\/mohit\/?p=84"},"modified":"2026-06-09T12:39:23","modified_gmt":"2026-06-09T12:39:23","slug":"week-2-more-bug-fixes-in-the-dm-engine","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/mohit\/2026\/06\/09\/week-2-more-bug-fixes-in-the-dm-engine\/","title":{"rendered":"Week 2: More Bug Fixes in the DM Engine"},"content":{"rendered":"<p>Hi everyone! Following up on Week 1, most of this week was spent resolving PVS-Studio warnings in the DM engine. Many of these warnings were responsible for crashes or pointed to code paths that could lead to unstable behavior.<\/p>\n<p>By the end of the week, I was able to reduce the warning count from 103 to 13, with the remaining ones being false positives. With the static analysis issues largely addressed, I can now focus fully on gameplay-related bugs, fixing the remaining crashes, and implementing the remaining methods. <\/p>\n<p>One such crash was in <code>DisplayMan::drawDoorButton()<\/code>:<br \/>\n<code>doorButtonOrdinal = kDMDerivedBitmapFirstDoorButton + (doorButtonOrdinal * 2) + ((doorButton != kDMDoorButtonD3R) ? 0 : doorButton - 1) <\/code><br \/>\nThe existing logic worked for most door button values but failed when <code>doorButton = 0<\/code>, leading to an incorrect offset and eventually a crash. I corrected the expression to <code> ((!doorButton) ? 0 : doorButton - 1)<\/code>, fixing the crash and restoring the intended behavior. <\/p>\n<p>Another crash occurred while picking up a coin placed on a pressure plate. The game would immediately crash when processing the resulting door animation. After tracing the issue, I found that <code>processEventDoorAnimation()<\/code> unconditionally queried creature attributes before checking whether a creature group actually existed on that square. Reordering the checks fixed the heap buffer overflow and matched the behavior of the reversed source code.<\/p>\n<p>I also fixed several other crashes and memory safety issues in the DM engine, including an incorrect bitmask in <code>ProjExpl::projectileDelete()<\/code> and an out-of-bounds champion access in <code>drawPanelFoodWaterPoisoned()<\/code>.<\/p>\n<p>Towards the end of the week, I shifted my focus back to the GUI, where I fixed a bug in the launcher that caused the collapsed state of groups to be lost when switching between views.<br \/>\nThe fix prevents <code>LauncherSimple::updateListing()<\/code> from saving the collapsed group state during the initial build, avoiding an unnecessary overwrite of the already saved configuration and correctly preserving the collapsed groups when switching views.<\/p>\n<p>I also added support for stopping fluid scrolling animations with a click, allowing the first click to stop the ongoing animation and the next click to perform the intended selection in lists, grids, and scroll containers.<\/p>\n<p>Additionally, I added configuration support for fluid scrolling, allowing it to be toggled from the options menu, as the feature did not turn out to be a pleasant experience for everyone.<\/p>\n<p>That wraps up this week&#8217;s progress. Next week, I&#8217;ll continue working on the remaining gameplay issues and implementing the remaining methods. Thanks for reading, and see you in the next update!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone! Following up on Week 1, most of this week was spent resolving PVS-Studio warnings in the DM engine. Many of these warnings were responsible for crashes or pointed to code paths that could lead to unstable behavior. By the end of the week, I was able to reduce the warning count from 103 [&hellip;]<\/p>\n","protected":false},"author":30,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":23,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":107,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/posts\/84\/revisions\/107"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/mohit\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}