Categories
Coding Experience Fun Nerdy Talk Opinion Technical

The Butterfly Effect of Fixing Bugs!

Hello! It’s nice to see you again XD Welcome to another blog article demonstrating my progress for this week! How was your week? I hope it was good, for me It was amazing as I was quite productive -> (Read More)

So Let’s start!

Justice for Texts, Granted

In my previous blog post I mentioned this text problem where some texts were getting jumped up while others were overflowing! Well, the great detective (err.. developer) HSK, successfully investigated the problem to be linked with fonts!

What was happening in the original behavior is that, while calculating line height (because look, for rendering all those texts, we need to know the exact dimensions they occupy) with custom fonts, the heights were just a very small magnitude different from what It should be (I mean, for some texts, adding 1 to all line heights fixed the problem, but broke all other fonts)

The Solution?

Was very simple. In the original implementation, they only used the font’s height but didn’t make use of another parameter, that is called “Leading”

The vertical space between lines of type is called leading.

After simply making a change, from

virtual int getFontHeight() const { return_data._fRectHeight }
to
virtual int getFontHeight() const { return_data._fRectHeight + getFontLeading(); }
Everything was fixed, WOOHOO!
Obviously, the warlock-100 (game for which bug was discovered), became very happy, as text alignment now properly works! (Screenshot below)
fixed alignment of “The Blaster” text, now matching with it’s play button!
Merged PR link -> #5100

Game Save loading Error – Total Distortion

This is yet another bug which was discovered while playing through total distortion, where sometimes there is corruption in game properties which, when saved and loaded again, completely crash the game!

This is an interesting bug because It made me unable to progress further (and was quite annoying)

Details for this -> https://trello.com/c/TllLPBYZ/626-game-save-loading-lingo-parse-error-totaldistortion

Oh, by the way, there is a public Trello board for tracking bugs and issues. You can always look there to know the current state of the engine!

So again, after lot of digging through I finally found the rootcause of the problem! That was a simple comparison check:

In certain parts of games, two similar but different types were being compared (for example, you can compare Integer 4 and string “4” and expect them to be true). Similarly, it was happening that two datatypes of Director Engine Symbol and String were being checked for equality, now being similar but also different, ScummVM didn’t take them into account and just returned false even for similar ones and thus, this small issue was giving big troubles! The Fix was very simple, that is to tell scummvm to treat Symbol and String comparison by “String” way!

Just for reference, a symbol in Director looks like #mysymbol, while a string is “mysymbol” like if you also have doubts that WHY? aren’t they same?? Well they are not.. let’s see what books say about this!

A Universal “Name Constant”
Symbols are something special to Lingo. They’re sort
of a “name constant,” giving you the portability of
string names minus the computational and data
overhead.

Lingo! (Tab Juilius)

Well, Let’s not go deep into the technical aspect of this, just know that they are similar but distinct!

And finally, here’s the fix: #5107

Butterfly Effect of Fixing Bugs

Bonus section! So I remember my mentor said this when I was starting to submit a proposal in GSoC! He told me:

and look, we are not testing GAMES, we are testing Director, so, there is a beautiful side effect they break because some feature we implemented is not correct or absent 
How is this relevant to my previous bug fix? Well, those words were precisely correct, they couldn’t be any more truth to what I do every day! The more I get into finding and fixing bugs, the more I realize that they are fixing many other things that I have no idea of!
This was very much visible in my last bugfix of symbols comparison, where once I fixed it and was testing game again, I observed that many big and small bugs were also fixed, and the game suddenly got a lot-lot better… Just like that!
That’s why putting emphasis on the butterfly effect of fixing bugs, you fix one bug, It fixes another, and that.. fixes another as well! (The converse is also true, make one bug, destroy the whole program)!

Listing out things that were successfully working in total distortion:

shops and calling feature working!
video sequencer now opening without crash!

Finishing what I started – Meet Mediaband’s UnDo Me

Now comes the last and most nostalgic part! One of the first things I worked on after being introduced to ScummVM is Quicktime Video playback!

Yes, I cannot remember exactly if this was my 2nd or 3rd task, but what I can remember is this was one of the things that gave me an, even more, deeper understanding of the codebase and made me familiar with how things work when you play video!

Anyways, so in the month of March-April, I was given the task to implement custom playback rate and reverse playback for Quicktime Videos, you can just think of it as how your video player can be set to play at twice the speed skipping boring university lectures (Yes, I have done it too, personal experience), but here It was no movie player, here it was ScummVM, and we needed this functionality for this game meet-mediaband where one of the movies were using a miniature sort of video-player with different playback speed and this was all a part of UnDo Me.

A little bit about “UnDo Me”

well, it is a very simple game where you can choose between four romances for our lady and have two controls, “Ice” and “Fire” for going passive or aggressive to different situations and scenarios that will be played throughout the movie, while there are two buttons “Un” and “Do” for reversing/resetting story and for quickly going forward)! This clever game was implemented by seeking different parts of our QuickTime movie! You can even watch this youtube video of gameplay

Continuing on,

In the months of March-April, I implemented this custom playback but didn’t implement/integrate this with UnDo Me (the very game for which it was made), fast forward to 2 months, and suddenly we got a fully explained video of mechanics, and how it looks like, sev (my mentor) asked me to look into it and I knew, This is destiny… (Well I was supposed to finish it either way :P)

Fast forward to another sleepless night and voila! We have our UnDo Me working with all the controls working and a smooth experience! YAY!

Also, special thanks to fracturehill and their PR #4965 that made this integration possible (because setting custom rate audio was not implemented when I first started looking into video playback)! Not only that I must thank him for finding a bug that I mistakenly thought was due to their work(In the end, it was me who didn’t debug it thoroughly)! And being so helpful!

undome in scummvm!

Link to PR – #5118

Ending Notes

As usual, thanks a lot for reading all the way up to here! Apologies for any grammatical, or writing mistakes (My Grammarly is screaming right now), and with this see you next week!

2 replies on “The Butterfly Effect of Fixing Bugs!”

It’s so awesome to see this progress in the Director engine. I follow the ScummVM project since, I don’t know maybe like 20 years now. Back in the days Director was a big no-go, and it was always said it will never be supported. But now you and some other students make so much progress on it. It’s really great to see this finally happening.

There are so many great games using this as their engine.

And mentioning Total Distortion is so awesome too. I remember playing this game. Well or trying to, as I could understand only the most basic stuff in english and I didn’t know what the game wanted me to do. But I loved the artstyle and the sounds. And it always felt like I was the only person to still remember this game.

I can’t wait for the day when we can play this, and all the other great director games, like it’s nothing in ScummVM.

I’m in awe of your and everyone else’s talent who is and was working on ScummVM. All of you are truly awesome!

Thank you!

Nice stuff! Though in my experience I usually have a different effect during development – fix one bug and create 3 more 😀
Would you be open to also looking into the Cosmology of Kyoto game? I believe it uses Director 4 in the US version.

Leave a Reply

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