self.timer1 = threading.Timer(1, self.restart4) self.timer1.start() def restart4(self): try: self.timer1.cancel() except: pass self.sendRestartMessage("O servidor ira reinicar em 4 segundos") self.timer1 = threading.Timer(1, self.restart3) self.timer1.start() def restart3(self): try: self.timer1.cancel() except: pass self.sendRestartMessage("O servidor ira reinicar em 3 segundos") self.timer1 = threading.Timer(1, self.restart2) self.timer1.start() def restart2(self): try: self.timer1.cancel() except: pass self.sendRestartMessage("O servidor ira reinicar em 2 segundos") for room in self.server.rooms.itervalues(): for player in room.clients.itervalues(): try:room.updatesqlserver() except: pass self.server.disconnectPlayer(player) def rested(self, time): self.restartTimer(time) def parseData(self, data): MDT_stuff = data[:4] data = data[4:] #print data values = data.split("\x01") #print repr(MDT_stuff), values #logging.warning("DATA: %s" % data) #logging.warning("DATAD: %s" % repr(MDT_stuff)) #logging.warning("DATAV: %s" % values) eventTokens = values.pop(0) eventToken1, eventToken2 = eventTokens if eventToken1 == "\x1A": if eventToken2 == "\x02": #awake timer unknownTime, = values unknownTime = int(unknownTime) elif eventToken2 == "\x03": #create account username, passwordHash = values username = username.replace("<","") if self.server.checkExistingUsers(username): self.sendData("\x1A" + "\x03", ) #Nickname Already Taken message else: passwordHash=hashlib.sha512(passwordHash).hexdigest() self.server.createAccount(username, passwordHash) self.login(username, passwordHash, "1") elif eventToken2 == "\x0E": #Sent Change Password if self.privilegeLevel!=0: utfLength=struct.unpack('!h', data[:2])[0] PassHash=data[2:utfLength+2] data=data[utfLength+2:] utfLength=struct.unpack('!h', data[:2])[0] ForumPassHash=data[2:utfLength+2] data=data[utfLength+2:] utfLength=struct.unpack('!h', data[:2])[0] ForumSalt=data[2:utfLength+2] if self.ValidatedPassChange: self.ValidatedPassChange=False passwordHash=hashlib.sha512(PassHash).hexdigest() dbcur.execute('UPDATE users SET password = ? WHERE name = ?', [passwordHash, self.username]) elif eventToken2 == "\x04": #login username, passwordHash, startRoom = values if passwordHash != "": passwordHash=hashlib.sha512(passwordHash).hexdigest() username = username.replace("<","") self.login(username, passwordHash, startRoom) else: logging.warning("Unimplemented %r" % eventTokens) #raise NotImplementedError, eventTokens elif eventToken1 == "\x04": if eventToken2 == "\x03": #print 'values: '+str(values) #world physics update #CodePartieEnCours = values.pop(0) #for objectData in values: # if objectData == 'x': # continue # objectType, x, y, dx, dy, rotation, angularVelocity, isSolid, valuea = objectData.split(',') if self.isSyncroniser: self.room.sendAllOthersAndSelf(self, eventTokens, values) #self.room.stateRecorder.setPhyscisState(eventTokens, values) elif eventToken2 == "\x04": #position update #isMovingRight, isMovingLeft, x, y, dx, dy, isJumping, jumpAnimation = values #self.room.sendAllOthers(self, eventTokens, values + [self.playerCode]) self.room.sendAll(eventTokens, values + [self.playerCode]) elif eventToken2 == "\x05": #player went out of bounds self.isDead = True #score #self.score = self.score-1 #if self.score < 0: # self.score = 0 #end self.score -= 1 if self.score < 0: self.score = 0 self.room.informAll(TransformiceClientHandler.sendPlayerDied, [self.playerCode, self.score]) self.room.checkShouldChangeWorld() elif eventToken2 == "\x06": # "Demande_Giclage" #objectCode, = values self.room.sendAll(eventTokens, values) elif eventToken2 == "\x08": #direction, = values #direction = int(direction) self.room.sendAllOthersAndSelf(self, eventTokens, [self.playerCode] + values) elif eventToken2 == "\n": #unknown, happens on first move on current map self.isAfk=False #pass elif eventToken2 == "\x0C": #unknown, happens on start conjuration self.isAfk=False #pass elif eventToken2 == "\r": #unknown, happens on end conjuration pass elif eventToken2 == "\x07": #unknown, happens on jumping. pass elif eventToken2 == "\x0E": #conjuration x, y = values self.DestroyConjurationTimer = threading.Timer(10, self.sendDestroyConjuration, args=[x, y]) self.DestroyConjurationTimer.start() #print values self.room.sendAllOthersAndSelf(self, eventTokens, values) elif eventToken2 == "\x10": #snowball if self.room.isSnowing==True: x, y, direction = values if direction == "1": self.room.sendAllOthers(self, "\x05" + "\x14", [self.playerCode, 34, x, y, 0, 10, -4, 1]) if direction == "0": self.room.sendAllOthers(self, "\x05" + "\x14", [self.playerCode, 34, x, y, 0, -10, -4, 1]) if self.room.isSnowing==False: self.room.informAll(TransformiceClientHandler.sendPlayerDisconnect, [self.playerCode]) self.room.removeClient(self) hmessage = "["+self.address[0]+" - "+self.username+"] Snowball when not snowing." self.sendAdminMessageChannel("Hack Detect", hmessage) self.close() elif eventToken2 == "\x09": #begin/end crouch crouching, = values crouching = bool(int(crouching)) if crouching: self.room.sendAllOthersAndSelf(self, eventTokens, [self.playerCode] + values) else: self.room.sendAllOthersAndSelf(self, eventTokens, [self.playerCode]) elif eventToken2 == "\x12": x, y = values