titlelist = titlelist.replace("\"","") titlelist = titlelist.replace(" ","") return titlelist return found def sendPrivMsg(self, fromUsername, toUsername, message): found = False for room in self.rooms.itervalues(): for player in room.clients.itervalues(): if player.username.lower() == toUsername.lower(): player.sendRecievePrivMsg(fromUsername, message) found = True return found def disconnectPlayer(self, username): found = False for room in self.rooms.itervalues(): for player in room.clients.itervalues(): if player.username == username: room.informAll(TransformiceClientHandler.sendPlayerDisconnect, [player.playerCode]) room.removeClient(player) player.close() found = True print '%s disconnected' % (player.username) break return found def banPlayer(self, username, time, reason, modname): found = False time = int(time) for room in self.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.username == username: client.sendPlayerBan(time, reason) if time >= 25: clientaddr = client.address[0] dbcur.execute("insert into ippermaban (ip, bannedby, reason) values (?, ?, ?)", (clientaddr, modname, reason)) dbcur.execute("insert into userpermaban (name, bannedby, reason) values (?, ?, ?)", (username, modname, reason)) #player.close() found = True break return found def getIPaddress(self, username): found = False for room in self.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.username == username: found = client.address[0] break return found def restartServer(self): logging.info("Restarting") found = False for room in self.rooms.itervalues(): for player in room.clients.itervalues(): #room.informAll(TransformiceClientHandler.sendPlayerDiscnnect, [player.playerCode]) room.updatesqlserver() #os.system("restart.bat") def updateit(self): room.updatesqlserver() def stopServer(self): logging.info("Stopping") found = False for room in 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)).name class 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: