Archive for the ‘Dev Humor’ Category

Code-fu

Wednesday, March 26th, 2008

I ran into some trouble testing a map today.  It would crash when I ran one of the events, and the routine that it crashed in was a system routine written in assembly language that did some odd things to memory, such as changing the program’s Call Stack, which my debugger needs to track the problem backwards from the crash to its source.

Very well.  My code-fu is strong.  Wise man say, “If cannot start from problem and work backwards, grasshopper, set breakpoint right before problem and work forwards.” (more…)

Potion of Death!

Monday, November 12th, 2007

It’s funny how bugs can interact with each other in unexpected ways. Case in point: The Potion of Death I accidentally created last night as I was coding item usage in the menu system.

The RPG Maker item data structure has a list of flags representing which conditions the item cures. But since most items don’t cure any condition, the program saves space in the file by simply skipping the entire list if the whole thing’s set to false. In my code to read the data structure, I accidentally had it set the entire set to true if the list was missing from the file. So an ordinary item, such as a potion, suddenly becomes a cure-all item.

But it gets worse. Characters can be afflicted with various conditions, as defined by the game writer, and one condition that’s hard-coded into the system: “dead”. If a character’s dead, it changes a bunch of the code for his behavior. (For example, he can’t be healed while dead.) In the code to set a character’s condition, I had a check for whether the condition being set was condition #1 (dead), and if it was, to set a couple other things in the hero’s data structure relating to being dead. Unfortunately, this check didn’t look to see whether the “dead” condition was being turned on or off.

You can probably see where this is going. I tested out a potion on a hero, and… he died?!? That confused the heck out of me, of course. Turns out the potion (with the “cure condition” attributes set to all true) had tried to cure the hero of being “dead”–for technical reasons, it’s more efficient to simply set the condition to false than to check whether it’s set and then only set it if it’s already true–and this set off the special code. So instead of getting healed by 50 HP, the hero died. Huzzah for Potions of Death!