self.rooms.itervalues(): for player in room.clients.itervalues(): #room.informAll(TransformiceClientHandler.sendPlayerDiscnnect, [player.playerCode]) room.updatesqlserver() os.system("stop.bat") def checkAlreadyExistingGuest(self, nusername): count = 0 for room in self.rooms.itervalues(): for player in room.clients.itervalues(): playername = player.username count = count+1 if player.username == nusername: nusername = nusername+"_"+str(count) return nusername def checkAlreadyConnectedAccount(self, username): found = False for room in self.rooms.itervalues(): for player in room.clients.itervalues(): if player.username == username: found = True return found def findUser(self, username): found = False for player in room.clients.intervalues(): if player.username == username: found = self.room return found def addClientToRoom(self, client, roomName): roomName = str(roomName) if self.rooms.has_key(roomName): self.rooms[roomName].addClient(client) else: self.rooms[roomName] = TransformiceRoomHandler(self, roomName) self.rooms[roomName].addClient(client) #return self.rooms[roomName] def closeRoom(self, room): if self.rooms.has_key(room.name): room.close() del self.rooms[room.name] def getConnectedPlayerCount(self): count = 0 for room in self.rooms.itervalues(): for player in room.clients.itervalues(): count = count+1 return count #return 1 def findPlayer(self, username): found = "Offline" for room in self.rooms.itervalues(): for player in room.clients.itervalues(): if player.username == username: found = room.name return found def setShaman(self, roomz, usernamez): found = False for room in self.rooms.itervalues(): if room.name == roomz: for player in room.clients.itervalues(): if player.username == usernamez: found = player.playerCode return found def getConnectedRooms(self): rooms = "" for room in self.rooms.itervalues(): old = rooms new = "%s\n%s" % (old, room.name) rooms = new roomz = new return roomz def getConnectedPlayers(self): players = "" for room in self.rooms.itervalues(): for player in room.clients.itervalues(): #self.room.sendData("\x1A" + "\x04", ["[Serveur] %s -> %s" % (player.username, room.name)]) #playerfound = "%s -> %s" % (player.username, room.name) old = players new = "%s\n%s -> %s" % (old, player.username, room.name) players = new playerfound = new return playerfound def generatePlayerCode(self): return random.randrange(1, 10000000) def recommendRoom(self): return 1 #return min(self.rooms.itervalues(), key=lambda room: abs(len(room.clients) - 20)).nameclass TransformiceStateRecorder(object): def __init__(self, room): self.room = room self.reset() def reset(self): self.sateLog = [] self.lastPhysicsStateEvent = None self.anchors = [] def log(self, eventTokens, values): self.sateLog.append((eventTokens, values)) def logMessage(self, messageFunction, args): self.sateLog.append((messageFunction, args)) def setPhyscisState(self, eventTokens, values): self.lastPhysicsStateEvent = (eventTokens, values) def addAnchor(self, values): self.anchors.extend(values) def sendToClient(self, client): if self.lastPhysicsStateEvent: eventTokens, value = self.lastPhysicsStateEvent client.sendData(eventTokens, value) for sendThing, value in self.sateLog: if type(sendThing) == types.FunctionType: sendThing(client, *value) else: client.sendData(sendThing, value) if len(self.anchors) > 0: client.sendSetAnchors(self.anchors)class TransformiceRoomHandler(object): def __init__(self, server, name): self.server = server self.name = name.strip() self.clients = {} #self.stateRecorder = TransformiceStateRecorder(self) self.currentShamanCode = None self.currentSyncroniserCode = None self.isSandbox = False self.isCustom = False self.customMap = None self.isEditeur = False self.editeurMap = "" self.isTesting = False self.customShaman = None self.isCustomsh = False self.isPlay = False self.racing = False self.isBootcamp = False self.specificMap = False self.isSnowing = False self.properNoShamanMaps = True self.isCatchTheCheeseMap = False self.currentTime = 0 self.alreadySet = False self.currentlyDrawing = False self.currentDrawer = None # Code[0], Name[1], XML[2], YesVotes[3], NoVotes[4], Perma[5], Deleted[6] self.ISCMdata = [0, "Invalid", "", 0, 0, 0, 0] self.ISCM = 0 self.ISCMstatus = 0 # Code[0], Name[1], XML[2], YesVotes[3], NoVotes[4], Perma[5], Deleted[6], Validated[7] self.ISCMVdata =[0, "Invalid", "null", 0, 0, 0, 0, 0] self.ISCMV = 0 self.ISCMVloaded = 0 self.snowStormStartTimer = threading.Timer(random.randrange(900, 1500), self.startSnowStorm) self.snowStormStartTimer.start() #self.currentWorld = random.choice(LEVEL_LIST) runthismap = random.choice(LEVEL_LIST) self.currentWorld = runthismap if self.name == "repeat": self.specificMap = True self.isPlay = True self.currentWorld = "0" if self.name == "sandbox": self.specificMap = True self.isSandbox = True self.currentWorld = "444" if