Hello Citizens! Two weeks have flown by which means BugSmashers with Mark Abent and a new bug! Check it out.
Mark Abent: Hey everyone! Welcome back to an all new exciting BugSmashers. We’re going to do things a little bit differently. We’re going to do things in 3D… Allright..
Randy: No mark, that’s not how 3D works..
Mark Abent: Dammit Randy! [Sighs]. Alright, back to 1D
Mark Abent: Hey everyone, we’re here in a fun little test level. Actually this is going to be the next, what do you call it… SC 2.0, a fun map that you guys will get to play. We have a fun bug where the thrusters stop working after you get in the ship, fly for a bit and then get out of the seat and go back into the seat so we are going to try and replicate that bad boy right now.
We are in a local multiplayer server, so as I get into my seat you can see my fun dedicated server, I’ll hide it off to the side… Grabs his little joystick.. Wait for all the little sequences… So much cooler in 3D.. [whispers] Randy was wrong. Alright we’re going to fly up a bit and move forward; as you can see I can move all the way around. Alright let’s hop out of the seat and see what happens. We need like a super hyper state animation for that. Oh crap pirates are coming we got to get into the seat fast! One day… Oh no I’m getting shot I gotta turn on all this stuff first and…. grab my joystick.
So now as you can see when I try to move around, oh no my ship doesn’t work! Nooooooooo. So if I actually turn on the mystical pipe system, it makes it a little more readable. You’ll notice that all these green things in the power, there’s a bunch of items turned on but none of them are in my thrusters; so what’s happening is when I get into the seat the first time, I’m able to use the thrusters and It’ll actually show up in this thing, and then when I get out of the seat and back into the seat, I no longer am able to use the item and as such you don’t see them in the power request. So if I turn off.. Eh I’ll leave that on and we’ll go into what we call the shared item manager.
This bad boy is in charge of saying: “Hey, if you sit down in this sit, you’re going to get access to this item, this item, this item, and this item. It’s all controlled by the server so if a sneaky clients like:” I should get this?” and the server is like: “Nope”. So when we get a packet from the server we’ll run through this bit of logic and this is the information we get from the server which are authority do we have authority, were were denied, were we given it, was it cancelled? And the mystical is selected.
The selection is basically. Alright I have the authority now I can actually use the item so if I have ownership of the thruster, I use the thruster and now the thruster is on and you can toggle the thruster on and off by using it or selections. So I can turn off the thruster, turn on the thruster. So the selection is basically on and off. When we get or change our authority or if we change our selection it will deselect it, change the authority and reselect the item if it needs be.
So what’s happening is when we get out of the seat, we’ll get a packet saying: “Hey, we’re no longer selected and we were selected so we’re going to do our deselection, Cool” and it changes the authority getting lost and we don’t select it again because well we lost it. When we finally get out of the seat the authority now goes back to no longer the actor, it goes back to being the default thing and what happens is; this selection gets stuck, it gets set to turn on by default and because it was off and now it’s on, it gets turned off.
But then since I left, it’s still set as turned on so the selection is still stuck so when I sit back in and this is set to true I never get my selection the client is effectively stuck, when the selection is set to true. So what we have to do is instead of serialising the selection cause yes it may have changed on the server but the client; we don’t want to change it until we have done our selection process, so i’m going to say hey we’re going to store off the server instead of writing directly into the variable we are going to store it for now and that way we can say “hey we were selected” and if the server changes it we’re not going to change our client state until after we have done the thing. So that way if the server changes it then we can call the thing correctly so we get changed the client can replicate the thing.
So if we don’t have an authority, so this would mean like if we have a turret and we’re connecting and for some reason we got our lasers for our turret and it’s not in yet we have to put it in a pending list. That’s what this guy is and fortunately for us the pending stuff will directly call the selection or not based on this variable so we can just assign it to whatever the server has told us. Basically what it says is what it’s been doing with the floor. Now if we’re going to do a de-selection we want to check what the server is telling us instead of our own state and if we have changed, now we change our client state.
Bam! We have de-selected and now we have to do the same thing for the server. And we’ll change this to our fancy dancy level, for our variable. Bam! So now when the client gets the server information it won’t directly write into that variable instead we will check to see what the client has done assuming we actually have basically an authority. The authority, is the actual the player sitting down in the seat, sit here, you get this, this and this. So now that we have the selection and we’re making sure that we only set the selection to when we have an authority. We are going to compile and see what happens.
So as you can see in our green little output that we have here we have no thrusters, and when I get off the seat it removed all the pipes because we’re not using the thing anymore. Cool. He’ll get up from the seat, and then we’ll sit down again. Once he has seated down we should get all the fun stuff. Bam! I have gotten all the things… And now I can fly… Let my ship figure itself out, there we go. Actually funnily enough. We only have..oh we have quite a few thrusters as you can see here popping in and out, as you use the thrusters they’ll make heat in this case i’m looking at the heatpipe, but you can see i’m actually flying and everything is connected. So we are good to go!
Alright and to recap. We had a little problem with our item system authority where the client would get locked into a state of “Hey you used this item” and it would never change it. So when a new guy popped in it wouldn’t give you access to your thrusters, because it was still in a ‘selected state’. What I had to do was clean that up a bit so when you get out of the seat and make sure to set the selection to false and then you get back into the seat it actually now populates it as true and allows you to do the selection/de-selection.
Unfortunately this has never popped up until we got into these bigger maps and we’re starting to see some fun little things because we’re networking a lot of stuff in these huge maps so we’re getting all these fun little issues that have been around, but they’re more dominant in these big maps which is kind of cool, cause we get to actually fix these things, rather than them being these minute instances that one guy gets but no one else gets. It’s pretty cool a little frustrating but we’re getting there. Hope you guys enjoyed. ‘Til next time.