This Week in SpyParty, Week 2: A Bug In Plain Sight

This week there was a recent bug discovery that caught my attention. With any game, especially one in beta, there are going to be bugs regardless of how hard you try to prevent them. The nature of the beast is if you have a game then you have bugs in your code. Some bugs are minor and some are absolutely game-breaking. This one in particular seems like it should have been found ages ago.

What is This Bug?

The bug that was discovered allows your laser to pass through certain sections of certain characters. This makes it seem like you miss some of your shots even though you really shouldn’t. This bug is easy to reproduce as well. All you have to do is aim at these imaginary holes and that’s it. For example, you can aim your laser at the stomach region of Alphonse “Snaps” Mcgee, or at his hat: 


Since there was a good repro, checker was able to find and fix it pretty quickly. I asked him if he could give us a more technical side to this bug and he agreed. Here is his response:

Okay, so the characters are made out of triangles. For the old characters, there are about 1.5k tris, and for the new ones there are about 11k tris.  It’s slow to do a raycast against all these triangles, so you do check on the overall bounding box of the character first, since that’s much faster.  If your bounding box is conservative, then that means all the triangles are inside it, so if the ray doesn’t hit the bounding box, you don’t have to test all the triangles.  But, since that test assumes all the triangles are inside the bounding box (hence the word “bounding”), if that’s not actually true, you won’t test the triangles at all. 

This is what the bounding box looked like before the fix:



This is what it looks like after the fix:


I looked into this bug so I could gain my own understanding of it. I noticed the holes seemed to disappear during animations and while holding a drink. I asked checker if he could give some insight into what’s happening. Here is what he had to say:

With animated characters, you really don’t want to build the bounding box from the triangles as they move around because that’s slow, and you often don’t have access to the posed triangles because that happens on the video card, so you build the bounding box from the bones themselves, and then expand it a bit (20% in this case) to get all the triangles. Well, with the old skeleton, it’s almost flat on the xz plane in the rest pose, so the expansion doesn’t do much.  When you’re holding a drink, your arm is forward, and that makes the bounding box actually bound the whole body! 

These are images with the old bounding box built from the bones:

snaps-busted-bones snaps-busted-bones-drink

So what was the fix?

I looked at the code, and with the current (read: slow) animation code I decided it wouldn’t actually be any slower if I just computed the triangle-accurate bounding box.  Once I optimize the animation code, I’ll have to come up with a better solution, potentially having bounding boxes for each bone authored in Maya, or something smarter, I’m not sure yet.

How was it Discovered?

krazycaley took on challenger virifaux in Spy on the Hill week 7. It was during one of these games the Sniper appeared to shoot through one of the characters to both the stream viewers and to himself.  Interestingly enough, he did!

You can hear  krazycaley exclaim “Noooo! Miss!” right after the shot. He knew who virifaux was and virifaux knew he was dead to rights. Yet somehow he was still alive. This was enough to pique the interest of virifaux and he chose to pursue it more deeply a day later. Once he discovered a reliable way to reproduce the bug, he made a quick video showcasing it in action, marking the beginning of the end for this bug.

Streaming was a big help in squashing this bug.  SpyParty doesn’t support replays yet, which makes bug hunting difficult sometimes. Streaming is probably the next best thing. If pictures are worth a thousand words then videos are probably worth a couple million. In this case, the video gave clues to virifaux for where to start looking. He knew exactly what it looked like when the bug occured. He could watch it over and over until he formulated his hypothesis. Then he could go into practice mode and test it out. 

Streaming and videos give us great insight into reproducing pesky bugs. Streaming may not always be the main tool in bug hunting, but streams and videos are almost always helpful for gathering more evidence and figuring out a clean repro.   This was the case with another bug’s story. I don’t think streaming was the main reason this bug was caught and squashed but it certainly played a role. 

Why is This Interesting?

I find it very interesting the bug was discovered only now. When first looking over the new bug report, checker made a post stating he remembers this happened a long time ago and that it was super rare, so we know this bug has been in the game for quite some time.

I am going to throw some numbers your way to help give an idea of the scope of this thing. There are currently over 11,000 people who have registered with the beta. The top 100 players have a combined total of 185,520 games played. It’s safe to say there have been a lot of games played across the entire community. This isn’t even counting the number of people who have played at conventions. In all of the games that have been played, this bug is just now being talked about and reproduced.

That’s not the only thing about this particular bug that makes it so interesting to me. Not only have there been tons of games in which it could have been discovered, the steps needed to reproduce the bug are really simple. When you combine these two characteristics together, it’s crazy how long this bug has lasted! However, thinking about it more deeply, maybe it’s not so crazy after all…

There are a few things that need to align correctly in order for this to be spotted. The main thing is looking at the character from the side. Next the character can’t be doing the vast majority of animations nor can he or she have a drink in their hands. Finally, the sniper has to aim in the correct spots. Perhaps you also need to be streaming for Spy on the Hill week 7.

Whatever the case, the bug is nearing the end of its lifetime since it’s fixed on checker’s local copy, but until the patch goes live you might be able to utilize this bug in a game mode. As beta tester virifaux said, “Now that we have a reliable reproduction, we’ll have skill shots where we shoot through McGee to hit the spy.” Bugs can be fun to play with so get in your skill shots before it’s too late!


  1. BL00DW0LF says:

    Great info, my favorite part about indie games is getting insight into dev stuff like this.  I occasionally read through the Fixed Bugs forum to remember everything we’ve gone through, it’s always surprising when something new comes to light.

  2. Korey says:

    Great post, was a fun read.  I especially enjoyed the “behind the scenes” images and explanations from checker and your own analysis for why it’s interesting.  Can’t wait for next week’s post!

  3. KrazyCaley says:

    Wow, great post!  Thanks to Zero for writing it up and Checker for laying bare the entrails.

  4. james1221 says:

    Very cool and interesting write-up.
    I’m really liking these ZeroTKA posts!

  5. r7 says:

    This post was excellent – a great mix of some info from checker (hopefully low enough effort that this sort of thing can be considered for many future posts) and some perceptive commentary from zero. I don’t think it can be overstated enough how important video is for these rare bugs. I was vaguely aware of this one for many months, but never realized there was one consistent bug underlying lots of ‘edge cases’ I had found.

    • checker says:

      Yeah, it was a good mix!  I love bugs like this, which seem completely random, but then you get a good repro, figure it out, and then draw the bounding box, and like, duh, it’s crystal clear.  It’s always interesting how such a clear a simple issue can manifest seemingly mysteriously.

Leave a Reply