ursina icon indicating copy to clipboard operation
ursina copied to clipboard

Fix race condition

Open BurntRanch opened this issue 7 months ago • 0 comments

There is a race condition before the variables are made where the update function runs before the rest of the code is initialized. First, yes, here is proof of the crash. image

Second, CustomFPC is not the reason, this is the code for CustomFPC, it calls super().__init__() which runs FirstPersonController's __init__ function and the rest is handled by FirstPersonController.

class customFPC(FirstPersonController):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
    def input(self, key):
        super().input(key)
        playerID = decodedGameToken[0]
        if playerID in gameState['PLAYERS'] and key == 'left mouse down':
            server.send(server.connections[0], b'FIRE\x00' + serverToken.encode('ascii'))

Last, if setting the self.enabled to False also works, its better to do that, I just couldn't replicate this race condition to test that.

BurntRanch avatar Nov 20 '23 12:11 BurntRanch