Social Media
Follow us, or not!

As per usual, anything said during the show is subject to change by CIG and may not always be accurate at the time of posting. Also any mistakes you see that I may have missed, please let me know so I can correct them. Enjoy the show!

TL;DR (Too Long; Didn't Read)

Bug is when you sometimes get into a map you can’t move

You have two systems working together, the flight controller and the thruster manager and the thruster manager is responsible for letting the flight control system know how much thrust is able to be done by the whole ship

The thrust manager needs to know such things as mass of an object to determine acceleration but the physics status that the manager sees is all zeroed out, causing it to see the object as static because it doesn’t have mass

There are two updates: physics update and main update

Physics update happens in the physics system so it can do it’s physical calculations

Main update is game code specific on how it should provide stuff for physics

Physics update has correct information, main update has invalid information

The flight controller has a variable animation mode and because it’s true they’re never updating physics status so thrusters can never figure out valid acceleration

Problem occurs in C++if you never give it initial value, it’ll be random, it was never set to Boolean true, it was set to true by random data in a memory block

To fix this have to start off false and to validate that go into memory and start it false, then it’ll calculate correct information

Full Transcript

Mark Abent: Hey everyone, welcome to Bugsmashers. I’m your host Mark Abent and I’m here to take you behind the scenes on those shenanigans called bugs.

Hey everyone, we are here and got blinking lights… I’m going to disable lights to not distract me. Now we look like a PS2 game, excellent. So we are in a fun real production map, this is Dying Star and I disabled lighting because I don’t like blinking. We have a bug here where sometimes when I get into a map I can’t move and this is the case of the non movable ships. So, let’s step into John Pritchett’s fun IFCS code and figured out what’s going on, weee.

The best part is sometimes when I respawn it works and sometimes it doesn’t. All right, so here we are, we have two adjunct systems… we have the flight controller which is his actual IFCS, this dictates how the spaceship should move. Then we have this thruster manager which tells the IFCS, ‘hey I have all these thrusters all over, this is how they move, this is the acceleration velocity and this could change dynamically in case it gets detached or if they get damaged’. So you have these two systems working in a pair, so this thruster manager is basically responsible for letting the flight control system know how much thrust it is able to be done by the whole ship. If I put a breakpoint on this fun little bad boy, this tells what the maximum thrust of the whole system is and unfortunately we have this thing called a physics state which John uses to determine the overall physic object.

So, we have this rigid body which has mass, it has speed, it has acceleration and it has a bunch of thrusters on it and what this guy does is this thruster manager says, ‘hey I have all these thrusters here and they can move this way, this way, this way’ so the IFCS can move this guy a certain way based on input and move and fire off the thrusters. So the thrust manager needs to know a few bits such as the mass of this thing to figure it’s acceleration and unfortunately this physics status that the thruster manager sees is all basically zeroed out. So according to the thruster manager this thing has no mass, so it’s going to say that all the thrusters are basically not going to be able to use any acceleration or provide any acceleration on a zero mass object, cause from a standpoint of the game zero mass means static and it’s just going to stay.

You can’t have zero mass on a thing, so this lovely thing is going to basically return, let’s step back… let’s put a breakpoint actually right here and as you can see our acceleration for the whole system is going to be zero so I can never ever move. The joys, so let’s find out when this m-status is set. So, it’s set… this is some debug thing and it’s never going to get hit obviously because we never hit the breakpoint. That’s end tuning, so here’s something where the thrust manager when it updates it’s going to capture the physics state of the flight controller so put up a breakpoint there. We’ll put up a breakpoint here and let’s continue, so we get it on the begin update and we have actual information. Key point here we have two updates, we have the physics update and then we have the main update. The physics updates happens in the physics system so that it can do it’s physical calculations and we have the main update which is game code specific on how it should provide stuff to the physics.

So in this specific area, this is the physics update and as you can see, we’re getting our physics information correctly, cool. Let’s disable that, continue… now we get to the main update and as you can see we have invalid information. So where does this happen in the flight controller, so the flight controller, let’s go back. This is m-status... so we have the physics status and we have the physics status for main, this guy works, this guy’s broken. So, let’s find out when this gets updated...this gets updated and this very specific code for track view so it won’t get hit in here. This gets called on tuning debug feature, won’t get called and this gets… oh, here we go. Here’s our update main and before way down here we actually update the thrusters to figure out the new acceleration, it’s supposed to set the main physics information.

However I bet you, debug all things, aha… so what this tells us is the flight controller has this variable animation mode and because it’s true we’re never updating this physics status so the thrusters can never figure out their valid acceleration. This is fun because this is supposed to be trackview that was that value we saw way up up top which doesn’t get hit. This should never be true so, let’s find out, this should only get to true when we enter trackview information. This is not going to hit cause we’re not in a cinematic sequence and that’s the only spot.

All right, let’s find out in the code where all this gets set. So, nowhere does it ever set it except when you’re in trackview and in here, aha… so what’s happening is C++ if you never give this guy initial value it will be random, it will be whatever the memories in there. As you can tell from this breakpoint, it says true followed by a 4, what that means is we didn’t actually set this to Boolean true, we set this to true because it had some random data in this memory block. So what we have to do for this fix is make sure that we start off false and to validate that we’re going to in memory start it false, now from then on it’ll calculate the correct information. If we continue… we’re now getting correct acceleration and I should be able to fly. Shizam!

So all it was was a simple uninitialized variable causing havoc on the system globally. Ah the joys of C++, you have to be very very careful, one variable can cause destruction in the whole wide system. So just adding this will fix it and we will no longer will get that random, this guy works on this machine, doesn’t work on this machine. There you go, hope you guys enjoyed.

So, as you guys saw we had one awesome uninitialized variable where sometimes it was true, sometimes it was false… it was pure random and that caused havoc because on my machine it might work, on someone else’s machine it wouldn’t work. Just disrupted the flow of John’s IFCS system, just making sure it was predefined fixed all the issues so when you hop into a multiplayer it worked, hopped into single player it worked and in that fun trackview it worked as intended. Hope you guys enjoyed, til next time.

Moonlighting as a writer in her spare time StormyWinters combines her passion for the written word and love of science fiction resulting in innumerable works of fiction. As the Director of Fiction, she works with a fantastic team of writers to bring you amazing stories that transport you to new places week after week.