Part 5 - Driven to Debugging


2 month(s), 0 day(s), 4 hour(s), 59 minute(s), 1 second(s) to deadline

Soon enough, the development of the new Capsule Monsters games began to draw to a close, but relief proved to be ever-fleeting. On an evening when the rain came down in torrents, and dark blue, wraith-like forms of Shuppet gathered under the eaves of the motel, Keita found himself once again wrapping up a session of typing into his text editor.


void add_listener(list, callback) {

int last = LENGTH(list);

list[last] = callback;

list[last+1] = NULL;

}


"Whew… Finally. No errors from compilation," he muttered. "I never expected that generalizing event handling would turn out to be such a chore."

Bracket and Paren were once again sidled against the programmer watching his progress, and the Corphish and Tropius turned looking quizzically at him. After all, it seemed as if their trainer had finished his work and ought to be free to play outside by the pool with them… and yet his attitude seemed to be every bit as stressed as when he'd started his current task.

"Yeah, I know, we're almost there. But first comes…" the man squinted and furrowed his brow as he braced himself for an oncoming trial, "Merging."

As the man fired up his terminal, he couldn't help but feel some dread for what was about to happen. The team had reached the point of their projects where he and all of the other programmers working on their portions of the games could no longer silo any parts of their work from the playable build, and would have to piece everything together.

It wasn't so much putting all of the code together that worried the programmer. Why it was just a matter of entering a few commands into the terminal and resolving any conflicting snippets of code with each other… except after resolving those conflicts, everything had to work.

"Here goes," the programmer said. "Once this thing gets all the conflicts sorted out, we should have a complete playable build… I hope."

Keita reluctantly pressed a button on his keyboard, and watched as a wave of messages flew by on the terminal's window. He braced himself after the text stopped outputting to his terminal and scrolled over the messages, where much to his astonishment, he saw none of the conflicts messages he was dreading to find.

"Huh? No conflicts at all? Must be my lucky day."

But as the green-haired man attempted to compile the patchwork of code, he realized that fate had not been nearly as kind to him as he had thought... an inscrutable message flashed onto the screen:

"'Bus Fault'?"

Keita grimaced at the message, which came when programs attempted to access locations in memory that just flatly didn't exist. A far more arduous task to isolate and sort out than merely reworking text in class files. A sinking realization crept onto the man's face, as his Pokemon began to notice that something was amiss.

"Maybe I should have kept my yap shut…"

And they all began to understand that Keita's ordeal was far from over, and that even at this late stage of the project, there would still be unpleasant surprises lurking in wait.


1 month(s), 19 day(s), 17 hour(s), 52 minute(s), 53 second(s) to deadline

The root cause of Keita's bus fault proved to be one of the dreaded logical conflicts, times when the different parts of the patchwork of code would manage to be close enough to each other in form to not yield any errors while merging, but have critical differences in their meaning. A variable here, a function there, each with two or more completely incongruous expectations foisted on it by different portions of the game's codebase.

After about a week of long and sleep-deprived nights, Keita and his compatriots were able to coax their codebase's different components into complying well enough. On the day the programmer was able to finally wrangle the game's code into a compiling state, Bracket and Paren were there playfully batting cardboard tubes at each other as he let out a triumphant cry from his workstation.

"Ah! It compiled! It finally compiled again!"

The Tropius and Corphish put their papery distractions aside and cheered for their trainer. After all, he was happy, meaning that surely his problems had come to a close? Right afterwards, the programmer loaded the compiling build onto a devkit, started it up, and immediately after his employer's logo flashed on the screen, promptly watched the game crash to a white screen along with the celebratory atmosphere in his portion of the hotel suite.

"You're kidding me."


0 month(s), 2 day(s), 0 hour(s), 2 minute(s), 34 second(s) to deadline

After getting the game's build to compile again, it was time for Keita to join in with his coworkers on the oft-dreaded but ever unavoidable task of every practitioner of his craft, debugging. A time when one unforeseen problem after another would be discovered from the codebase, and would then have to somehow have their culprits teased out and fixed.

It was a sisyphean process, with bugfixes that would expose other components to erratic behaviour, or "improvements" that would spawn completely new bugs, all in the 48-hour race to the finish. And one particular nemesis had been particularly stubborn and time-consuming to put down - a weird stack overflow error that kept creeping up while adding game events to their corresponding listeners.

Keita looked over a list of problems while taking a Lava Cookie from a mostly-emptied box in the hopes that its alleged medicinal properties also worked on migraines. There were problems with attack animations causing the game to freeze, berries somehow giving monsters negative stats, the player character was apparently able to access illegal places on the map…

"There's no way that I'm going to get through all of these…"

The programmer sighed as he leafed through the still-massive list much as a doctor would perform triage, attempting to identify which of the problems were most important to prioritize next in the last two days. It was a crude and inelegant process, but there was only so much that could be done before the publisher's timetable ran out, not that Bracket and Paren seemed to have much of an awareness of the gravity of the situation as they helped themselves to the unattended Lava Cookie box.

"At least they're all mostly small bugs that QA should be able to catch and send back to us-"

Only for his heart to sink as he attempted to shove aside a boulder on the devkit. Much to his horror, the pixelated boulder not only failed to budge, but the game immediately stopped responding to any of his devkit's buttons.

"What?! Impossible!"

Keita reloaded the build. And then again. And again. Only to find that the same glitch reappeared in each case. He then went to his workstation, and looked over a debugging log:

"How?! I'm clearly sending the correct event flags, and there's no exceptions or errors! So why is-?!"

"Ahem…" a voice interrupted, which immediately caused the programmer to turn from his monitor. His Corphish and Tropius similarly turned from the box of Lava Cookies they were raiding, pieces of their snacks still dangling from their mouths… as the Director had walked up and was staring down with a stern frown.

"Oh… Hello, Director… er…"

"Not to interrupt your work," the blonde-haired man said. "But there's a bit of an urgent meeting that's going to start in about 5 minutes…"


0 month(s), 1 day(s), 23 hour(s), 43 minute(s), 38 second(s) to deadline

A short time later, Keita found himself watching the Director speaking before a small crowd of people in a familiar dingy room. The programmer looked about the room as his coworkers appeared visibly agitated, and others disheveled and visibly short of sleep much as he had been for most of the past week.

"So… As you all know, it's presently 48 hours until we have to deliver a build for final QA to the office… and… Well."

Keita noted that Bracket and Paren seemed uneasy about the atmosphere in the room. They apparently also felt the thick tension clogging the air as the Director attempted to tease out a way to break some less-than-pleasant news to his audience.

"Last I was aware, we had at least a dozen known bugs that render the game unplayable."

Some murmurs began to go about the room, as varying voices began to complain of the current state of affairs.

"Well, looks like we can kiss those bonuses goodbye," a man towards the back said.

"Grr… This is all the fault of those new programmers!" one of the veteran programmers fumed. "If it was just a team of four like last time, we wouldn't be in this mess!"

"Our fault?" a man with a Chimecho demanded. "We aren't the ones throwing in GOTOs every other function!"

"It's a perfectly acceptable practice when it's properly documented!"

The murmuring quickly evolved into heated bickering as the Director pinched his brow and attempted to rein in the project team with a sharp reprimand from his podium:

"Quiet! Quiet!"

The arguments began to die down as the Director took a sharp breath and started addressing the room.

"Look, it's a challenge, yes," he reminded them. "But we as a firm have made it through tougher obstacles, and this one is no different."

The Director looked about his audience and, much to his dismay, found his reassurance had failed to lift his subordinates' spirits. The man let out a quiet sigh and shook his head before continuing on in a quiet, resigned voice.

"All I ask is that until the deadline passes," the man pleaded, "you try your hardest. If we succeed, we succeed. And if not, well…"

There was an uncomfortable silence around the room, which the Director himself finally broke:

"We'll get there when we get there."


0 month(s), 0 day(s), 0 hour(s), 29 minute(s), 57 second(s) to deadline

Just a little over 47 hours later, Keita found himself at his workstation again. He had not slept a wink since the emergency debriefing. And by some stroke of luck all of the game-breaking glitches had managed to be caught and patched…

"Argh! WHY?!"

With one solitary, stubborn exception. The very same glitch he'd discovered with the boulder two days ago, which had eluded all remedy since then.

"I don't believe this!" he fumed. "30 minutes left, and my bonus is going to be withheld over this stupid boulder glitch!"

The programmer set down the devkit and slumped his head against his desk. This was how he was going to spend these last 30 minutes, just sitting and letting the inevitable pass. If there was a Duskull passing by outside which for some reason wanted to cart off the project's spirit to the underworld, the man would not have resisted. It was then as he rested his head against his workstation that he felt a presence brushing at his arm.

Keita turned, and saw that it was Paren, the same Tropius that had spent most of the last year with him through his ordeal. Its highs, its lows, and now she was here to witness the deadline's expiration without a finished product.

"Hey girl, did I wake you up?" he sighed.

The Tropius curled her neck around Keita's shoulder and nuzzled her audibly troubled trainer, letting out a low, worried whine.

"Yeah… I know," the programmer sighed. "I thought we were going to be done too…"

Much to Keita's surprise, Paren nosed at the monitor. It crossed the programmer's mind that Paren probably wanted to be amused by the images and text from the screen again... only to realize that at an unholy hour like this, she must be trying to egg him on to keep working, thinking a cheer would resolve his down mood.

"Don't worry about it," Keita murmured. "It's not as if anything can be done about it right now."

The Tropius was not satisfied and proceeded to nip and drag one of her trainer's arms over to the keyboard before looking up at him. Keita shook his arm after Paren let go and looked back at the glow of his monitor, realizing that she must've wanted him to explain his work to her again. As foolish and pointless as it probably was after two days of failing to find his bug's origin, surely there would be no harm in humoring her.

"Eh… Fine, I suppose that one last step through can't hurt…"

The man pushed the devkit aside and opened up his text editor, beginning to go through various files one by one.

"Uh… I guess I'll start from the top."


struct player player_data;


"This is the player struct, which handles all the information the game needs to keep tabs on about the player character," Keita said, before moving his fingers along his mouse's wheel as he scrolled down with an audible whir.


player_data_controls = TRUE;

player_data_event_listeners = game_state -⟩ strength_listeners;


"And this is the part where we actually track the event listeners for the player," he continued. "It's really a list from the global state, but it's still important to do some bookkeeping like this."


add_listener(player_data -⟩ event_listeners, player_strength_callback);


"And here is where we add the Strength callback to the event listeners," Keita explained, before moving his mouse's pointer on the screen opening another file.


if (case == STR):

strength_player_event = dispatch_event(player -⟩ event_listeners[index(STR)], &data );


"And this where the events are dispatched, it checks if the case is equal to the enum for Strength," he explained. "The save state I left off on on my devkit has me walking back and forth in-game. Each step that I make sends out an event that the player's listeners respond to.

"Everything works. Except for this."

The man quickly loaded up a save state onto the devkit, right before his accursed nemesis for the past two days.

"When I try to move a boulder, I can move the rock just fine."

And indeed the pixelated boulder did move, only for the devkit to become unresponsive.

"But then it paralyzes my character and I have to reset everything just to get it to work again!" Keita exclaimed. "And I for the life of me I just don't know why this is happening!"

It was then that his Tropius companion nosed at a line on the screen with a terminal cursor blinking beside it.

"Huh? Paren? What's it that you see?"


void player_strength_callback(hm_evt *event) {

if(event-⟩active = TRUE) {

lock_all_controls();

} else {

unlock_all_controls();

}

}


Keita looked for a moment, then realized which line the sauropod was attempting to point out. He did not know whether or not it was a lucky guess, or perhaps Paren genuinely understood the problem, but there was indeed a critical error with the portion of the callback on the screen…

The code didn't say "event-active == TRUE", which would have checked for equality, but rather "event-active = TRUE". It wasn't checking to see if the event was active, it was always making it so!

"Uh… yeah. That… would be a problem."

Keita hastily edited the typo in the code, compiled it, and after what seemed like an eternity, saw that no errors had arisen during compilation. He then sent the build to the devkit, and with bated breath, he pushed the pixelated boulder again.

And then he moved forward. And then backward. And then he accessed the menu. And quickly discovered that all of the buttons and their bindings were properly working.

"Yes!"

Keita threw his arms around Paren, gratefully hugging and patting the Tropius for her help. The Grass-type squirmed initially from Keita's surprise intimacy, before easing and nuzzling her trainer back with a small smile.

"It's official, you're allowed to pig out on berries until you get sick!"

The programmer quickly stopped himself, realizing that it had been over 50 hours since he last slept and that his body and mind were harshly protesting any further deprivation.

"Er… could we put a pin in this until tomorrow?" he asked with a sheepish smile.

Paren obliged with a small nod, and Keita turned his attention to hastily uploading the fixed build. The upload terminated mere minutes before the deadline rolled over, with the young Tropius leading her trainer to a triumphant and well-deserved rest on his hotel bed, the Grass-type curling beside him as fatigue quickly claimed him.