Mark Abent is back to Smash more bugs on BugSmashers! Check it out!
Mark Abent: Hey everyone, welcome back to Bugsmashers: whole new year, same old bugs, well, new bugs. Ah, we’re actually still in the good old new office, and can hear some construction, don’t mind it, the show must go on, let’s get started.
Hey everyone, welcome back to Bugsmashers: whole new year, same old bugs, well, new bugs. Ah, we’re actually still in the good old new office, and can hear some construction, don’t mind it, the show must go on, let’s get started *thumbs up*.
Hey everyone, welcome to our lovely lovely test level as you can hear we have good ol’ construction noise going, so bare with us, oh it stopped, and we had a little bug in 2.1.
Whereas you can see I can shoot no problem, cool, but when I go over to my dedicated server, I detach a few things as you can see all my guns are gone, cool. Now, I’m going to simulate repair so I’m going to repair all of my guns, now I get ‘em back woo, oh no I can’t fire, nooo.
So, you get your wings blown off, your guns shot up, you go to land on a repair bay, get your guns back and now you can’t shoot ‘em: why?! So let’s take a look to see what was happening. Well, here in our lovely item code we have this thing called shared item manager. This guy’s job is to basically select a port on the weapon, so in this case my Hornet and this is my item port for the gun, this authority basically says if whether or not the pilot or the copilot or the guy in the back, should be able to use this item. And let’s go over to, here we are, this is our function that gets called when our items get attached. So let’s detach all of our guns and simulate a repair again, oh no the breakpoint didn’t get hit- ah good old- let’s try this again. What’s happening. Why..? What is happening… Oh… I broke the vehicle.
Alright, coming back from that … I put in some debug code and forgot to reset it. Alright, so we’re back here with our weapons, can’t make it shoot, we detach it, woo goodbye. Now, we’re going to repair everything and when we get called on this shared item manager: ah-ha! We hit our breakpoint. So now we’re adding that item back onto the item port because we repaired it. Let’s see what happens, so we have an authority, the authority is basically going to be some logic that indicates if and who should be using this thing, in this case it’s the pilot. So let’s step into there in our current authority we have an authority we are using, so we just added this thing, we’ve been given the ok that the pilot should be able to start using this item.
So now that we have used it, we’re gonna go say, “what should we do Mr. Authority Manager?” Since we are the server we are going to check to see if our authority has changed and oh no our authority is exactly the same, and because our authority is exactly the same it won’t refresh the state of the item, so the item for all intents and purposes will never get used, because the item manager thinks it’s already in the valid state.
So, and that’s going to happen to all of our lovely items, just going to kill the ship, and we’re going to go back.
So what we need to do here is under some condition we need to re-grant the authority, or refresh the item state, and the authority will basically call start-use. Start-use is, “Hey item, I’m using you, I’m the pilot.” and then things like from the weapon will be like “oh, you’re using me, so when I press this button, listen to my attack, and start shooting, cool.”
So we’re going to refresh it, by indicating that we lost it and then gained it again.
So, we’ll lose it and then gain it, and we need to do this only if we have a valid authority, if we are using, and we have to have an item on this port. So we have an authority, we have item- oh, give me my item! And, that item has to point to an actual entity, the p-item here is just information about the actual entity item, it’s like an extra bit of memory for our authority and we need to make sure that our item is not used.
So when we hit this block of the code and we have an actual authority piece and we have an actual item, and the item use state is not equal to the authority use state is then we need to refresh that logic so that we can actually start-use on that item. Now this is good for the server, but we also need to do this same bit of information on the client and that’s where this bit of code happens. So the server will do that information, it will tell the network to flush and send all that information to the client. Now the client will come here and they’re going to have the same problem because for all intents and purposes nothing has changed, however we got a new item on there so we need to refresh everything.
So we are going to, “should refresh base on item.” So we’re going to say that our authority has changed, even though it hasn’t, so that way we can get the same code setup where it loses its authority and gains it again, so that way we could refresh our state. There we go, so if we have an authority and have an item, and it’s not equal to our current use state, we are going to refresh.
Alright, so let’s give that guy a recode, oh I love recode. Sippin’ mah’ coffee’, and if this works out I’ll get my seven quarterly portions.[Tom Hennessy badgering him about his food portions in the background]
I get- do you see this sticky? It says seven- it says seven. Seven. I get seven quarter portions.
Alright, so we spawn, we can shoot, and we’ll detatch everything. Oh no, our guns are gone! Now we’ll simulate repair. Wam. Now I can shoot again, haha! So now, when you get your wing blown off, your gun blown off, and be able to repair, you can expect that gun to work again just as it is. This will actually fix another fun issue where if for some reason we have to detach and reattach during item sterilization. So when you spawn in we have to do a lot of weird stuff, um sometimes in your standard playing where you initially spawn, you can’t shoot or use your actual guns or items, this was the cause of that. So this sucker fixed two things, one when you repair and add everything back you can shoot again, and during the initial spawn sometimes you guns wouldn’t work. So two for one, I think that’s worth seven shekels or quarterly portions. Seven! Alright.
(DiscoLando creeping behind the monitor while they joke around regarding the noise levels.)
Alright, so hope you guys enjoyed this bug. It was a little fun thing with our item authority, you know when you detach and reattach it was just like, “hey! you’re in the same state! I’m not going to reset you, everything’s good,” but in reality it didn’t call start-use, so you couldn’t actually use the guns, couldn’t use the items. So we fixed that bad boy up, and it fixes your weapons when you repair and when you initially spawn in, so everything’s good to go. Hope you guys enjoy and I hope you guys destroy things, repair, and get your quarterly portions. It’s worth seven.