I worked at Codemasters for over three years. I did well there. I learned a lot and became a the programmer I am today. If it wasn’t for them I would never have become a network programmer.
When I decided to move to London they didn’t want me to go. Unfortunately my love for the job was overwhelmed by my desire for adventure, so I moved on. But I’ll always have fond memories of the studio.
Of course, none of this means I was perfect. Like any normal programmer, I would write bad code on occasion, and sometimes make mistakes. There was one mistake I made that, despite being peer-reviewed, managed to bypass all of our tests and broke the game completely. It’s probably the dumbest things I did while I was there.
One day I would go into the office and find that the game couldn’t connect to any online services. Parties, achievements, multiplayer games, any feature that relied on an internet connection didn’t work at all. This meant a lot of people in the office couldn’t do any work. Naturally it fell on the network team to figure out what was wrong.
Although I was on the network team when working on the last game, for this game I had shifted over to the UI team so I didn’t worry about it too much. It wouldn’t have anything to do with my code.
At least that’s what I thought until the Lead Network Programmer called me to his desk. He pulled up a change I had made the day before. It was some tidying up of the UI flow to make sure that everything was initialised properly before certain parts of the game loaded. He highlighted a line of code he thought might be the issue. It was a check to see if the player was logged in. He believed that check was failing, and blocking all the network systems in the game from initialising.
I looked at the line and knew straight away he was wrong. I explained how this would only block the network if someone wasn’t logged into their console, and it was unlikely the whole dev team had decided to log out of their Xboxes that morning. He looked at it again and he realised I was right. He thanked me for taking a look at it, and I went back to my desk.
I sat down and started to work again when something scratched the back of my mind. “Shit!“, I thought, as the realisation hit me. I went straight back to the Network Lead’s desk and asked him, “Was that check an equals condition or a not equals condition?” He pulled up the line of code again. It was checking for the opposite condition. It would only start the network systems if the player wasn’t connected to the internet.
The title suggest this story is about a single line of code. But it was actually worse than that. It was one character1. With that single character I had managed to break the entire game. We changed that character and checked it into the build. I also suggested to that we should add some online services to our UI flow tests so we would have a better chance of spotting something like this earlier.
Thankfully the fallout wasn’t terrible. Some of the team couldn’t work for a few hours while we figured it out, but since it was an easy fix we were quickly back on track. But it still amazes me to this day that software can be so fragile that a single character could break absolutely everything.
1/ Basically “==” instead of “!=”.
Header image by Peggychoucair from Pixabay.