The case of the immortality hack.


Wanted to share a short story on how strange game development can be sometimes.

For a while now the game has been suffering from a strange immortality bug. Sometimes, seemingly random, the game puts players into “godmode”, unable to receive damage. Big oops!

When i develop for LBZ, i use cppcheck, valgrind, and internal debugger, and GDB as tools to help me identify and fix problems. Usually i am helped by the fact that i have been working on this game for 15 years, so usually know what is happening pretty quickly. But not this weird immortality bug, my tools were telling me nothing, and my instincts completely failed me. Sometimes the solution just comes from a weird place… In this case it began with a hacked skype account:

LSDuck was receiving strange URL’s from one of his contacts and got in touch with him…

XXXXXXX: but u probably know about it?
XXXXXXX: block 0hp left?
Loozzer S. Duck: wait.. you know how to provoke it?
Loozzer S. Duck: it happens when you get killed while blocking?
XXXXXXX: it’s blocking while someone teleports to u

Great scott! I had been searching (for weeks) for a way to “trigger” the bug, and this guy just takes 5 minutes out of his day and gives us the answer! great!

So…. now we know how to make it happen: block on one character, then let another character teleport to him.
So i dive back into my tools, and start debugging. Several HOURS later i am convinced that it has something to do with setting the player variable “player_IsBlocking” to 1…. if i dont set it, it does not happen, and when i do set it… well… bug!
So i am working hard on debugging the engine, and then LSDuck starts searching in the moves…. A whole lot of confusion later, LSDuck says to me “I’ve found the problem, the teleport move has no damage configured. When i configure damage the bug is gone…”
Suddenly a light switches on in my mind, but i have to cook for my wife, so i can’t test my idea…. So i ask LSDuck to test which part of the damage configuration causes the troubles.
I cook, i eat, i do dishes, and i return to coding. LSDuck found out that the damage class setting triggers the bug. He can even make kiballs, that make whomever they hit immortal! (hmmm might be a feature here!)

So…. what made the players immortal? When you block a move, the damage given to you is divided by the damage class… when the damage class was not configured it stays zero… so your damage gets divided by zero. This produces infinity. Boom! Player with infinite health…

Lesson learned: “Always have sensible defaults for when things are not configured!”

As LSDuck said: “here’s a quote: the ways of the universe are weird…”