Ejemplo n.º 1
0
 def processPacket(self, msgID, remotePacketCount, ack, acks, hashID, serialized, address):
     #If not in our protocol range then we just reject
     if msgID < 0 or msgID > 200:
         return
     data = protocol.readProto(msgID, serialized)
     if msgID == protocol.CONFIRM_STATIONS:
         sandbox.send('shipUpdate', [data, True])
         sandbox.send('setShipID', [data])
         sandbox.send('makeStationUI', [data])
     elif msgID == protocol.PLAYER_SHIPS:
         sandbox.send('shipUpdates', [data])
         sandbox.send('shipSelectScreen', [data])
     elif msgID == protocol.POS_PHYS_UPDATE:
         sandbox.send('shipUpdates', [data])
     elif msgID == protocol.SHIP_CLASSES:
         sandbox.send('shipClassList', [data])
Ejemplo n.º 2
0
    def processPacket(self, msgID, remotePacketCount, ack, acks, hashID,
                      serialized, address):
        #If not in our protocol range then we just reject
        if msgID < 0 or msgID > 200:
            return
        data = protocol.readProto(msgID, serialized)
        if data is None and msgID != protocol.LOGIN:
            log.warning("Package reading error: " + str(msgID) + " " +
                        serialized)
            return

        #Order of these will need to be optimized later
        if msgID == protocol.LOGIN:
            #TODO, if connection previously existed, reconnect
            #TODO: send current mission status.
            #TODO: Move ship select to separate function
            ackDatagram = protocol.shipClasses(shipSystem.shipClasses)
            self.sendData(ackDatagram, address)
            ackDatagram = protocol.playerShipStations()
            self.sendData(ackDatagram, address)
            entity = sandbox.createEntity()
            component = AccountComponent()
            component.address = address
            entity.addComponent(component)
            self.activeConnections[component.address] = component
        elif msgID == protocol.REQUEST_CREATE_SHIP:
            sandbox.send('spawnShip', [data.name, data.className, True])
        elif msgID == protocol.REQUEST_STATIONS:
            entity = sandbox.entities[data.ship[0].id]
            #info = entity.getComponent(shipComponents.InfoComponent)
            player = entity.getComponent(shipComponents.PlayerComponent)
            stations = data.ship[0].stations
            for stationName in universals.playerStations:
                if getattr(player, stationName) != 0:
                    print "Resend ship select window"
            sandbox.send('setPlayerStations',
                         [address, data.ship[0].id, stations])
        elif msgID == protocol.SET_THROTTLE:
            sandbox.send('setThrottle', [self.playerMap[address], data])
        elif msgID == protocol.SET_TARGET:
            sandbox.send('setTarget', [self.playerMap[address], data])
        '''if username not in accountEntities:
Ejemplo n.º 3
0
    def processPacket(
        self, msgID, remotePacketCount,
        ack, acks, hashID, serialized, address
    ):
        #If not in our protocol range then we just reject
        if msgID < 0 or msgID > 200:
            return
        data = protocol.readProto(msgID, serialized)
        if data is None and msgID != protocol.LOGIN:
            log.warning("Package reading error: " + str(msgID) + " " + serialized)
            return

        #Order of these will need to be optimized later
        if msgID == protocol.LOGIN:
            #TODO, if connection previously existed, reconnect
            #TODO: send current mission status.
            #TODO: Move ship select to separate function
            ackDatagram = protocol.shipClasses(shipSystem.shipClasses)
            self.sendData(ackDatagram, address)
            ackDatagram = protocol.playerShipStations()
            self.sendData(ackDatagram, address)
            entity = sandbox.createEntity()
            component = AccountComponent()
            component.address = address
            entity.addComponent(component)
            self.activeConnections[component.address] = component
        elif msgID == protocol.REQUEST_CREATE_SHIP:
            sandbox.send('spawnShip', [data.name, data.className, True])
        elif msgID == protocol.REQUEST_STATIONS:
            entity = sandbox.entities[data.ship[0].id]
            #info = entity.getComponent(shipComponents.InfoComponent)
            player = entity.getComponent(shipComponents.PlayerComponent)
            stations = data.ship[0].stations
            for stationName in universals.playerStations:
                if getattr(player, stationName) != 0:
                    print "Resend ship select window"
            sandbox.send('setPlayerStations', [address, data.ship[0].id, stations])
        elif msgID == protocol.SET_THROTTLE:
            sandbox.send('setThrottle', [self.playerMap[address], data])
        elif msgID == protocol.SET_TARGET:
            sandbox.send('setTarget', [self.playerMap[address], data])
        '''if username not in accountEntities: