Recent discussion about the perils of doors in gamedev reminded me of a bug caused by a door in a game you may have heard of called “Half Life 2”. Are you sitting comfortably? Then I shall begin.
![]()
…
What is meant to happen is a guard (spoiler alert – it’s actually Barney in disguise) bangs on a door, the door opens, he says “get in”, and then the game waits for you to enter the room before the script proceeds.
But in this case the door sort of rattled, but didn’t open, and then locked shut again. So you can’t get in the room, and the gate closed behind you, so you can’t go do anything else. The guard waits forever, pointing at the locked door, and you’re stuck.
…
If you watch the video, when the door unlocks and then opens, there’s a second guard standing inside the room to the left of the opening door. That guard is actually standing very slightly too close – the very corner of his bounding box intersects the door’s path as it opens. So what’s happening is the door starts to open, slightly nudges into the guard’s toe, bounces back, closes, and then automatically locks. And because there’s no script to deal with this and re-open the door, you’re stuck.
…
So this kicked off an even longer bug-hunt. The answer was (as with so many of my stories) good old floating point. Half Life 2 was originally shipped in 2004, and although the SSE instruction set existed, it wasn’t yet ubiquitous, so most of HL2 was compiled to use the older 8087 or x87 maths instruction set. That has a wacky grab-bag of precisions – some things are 32-bit, some are 64-bit, some are 80-bit, and exactly which precision you get in which bits of code is somewhat arcane.
…
Amazing thread from Tom Forsyth, reflecting on his time working at Valve. The tl;dr is that after their compiler was upgraded (to support the SSE instruction sets that had now become common in processors), subsequent builds of Half-Life 2 became unwinnable. The reason was knock-on effects from a series of precision roundings, which meant that a Combine security guard’s toe was in a slightly wrong place and the physics engine would bounce a door off him.
A proper 500-mile-email grade story, in terms of unusual bugs.
0 comments