From 0767cf31e3c2d7156fea270330fd3e75cb515e1c Mon Sep 17 00:00:00 2001 From: cidoku Date: Thu, 13 Feb 2025 18:36:10 -0300 Subject: [PATCH] player list kick + ban + unicode --- gameview.py | 46 ++++++++++++++++++++++------------------------ mainmenu.py | 1 - 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/gameview.py b/gameview.py index 128658f..ee01449 100644 --- a/gameview.py +++ b/gameview.py @@ -1413,7 +1413,7 @@ class gui(QtGui.QWidget): def onEditEvidence(self): if not self.evidence: - return QtGui.QMessageBox.information(self, 'edit what?', "there's no evidence on the court record...") + return QtGui.QMessageBox.information(self, 'No evidence', "There's no evidence on the court record.") self.evidence_editor.EditEvidence(self.selectedevi) def onDeleteEvidence(self): @@ -1792,18 +1792,18 @@ class gui(QtGui.QWidget): if self.additivebtn.isChecked(): self.icchatinput.insert(" ") - f_char = self.m_chatmessage[CHARNAME] + f_char = self.m_chatmessage[CHARNAME].decode("utf-8") evidence = int(self.m_chatmessage[EVIDENCE])-1 t = time.localtime() - logcharname = f_char.decode("utf-8") + logcharname = f_char #TODO: UnicodeWarning: Unicode unequal comparison failed to convert both arguments to Unicode - interpreting them as being unequal #if f_char.lower() != self.charlist[f_char_id][0].lower(): # logcharname = self.charlist[f_char_id][0] + ' (' + f_char.decode("utf-8") + ')' if self.m_chatmessage[SHOWNAME]: try: - logcharname += " ("+self.m_chatmessage[SHOWNAME].decode("utf-8")+")" + logcharname += " ("+self.m_chatmessage[SHOWNAME]+")" except: logcharname += " (???)" @@ -2638,31 +2638,29 @@ class gui(QtGui.QWidget): else: self.evidencedropdown.setCurrentIndex(self.selectedevi) - def updatePlayerList(self, id, op, type, data=""): - id = str(id) + def updatePlayerList(self, pid, op, utype, data=""): + pid = str(pid) if op == 0: # Add or remove player - if type == 0: # Add a player - self.playerList.addItem("[%s]" % id) - if not id in self.playerlist: - self.playerlist[id] = ["", "", "", ""] - if type == 1: # Remove a player - item = self.playerList.findItems("[%s]" % id, QtCore.Qt.MatchStartsWith) + if utype == 0: # Add a player + self.playerList.addItem("[%s]" % pid) + if not pid in self.playerlist: + self.playerlist[pid] = ["", "", "", ""] + if utype == 1: # Remove a player + item = self.playerList.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith) if item: self.playerList.takeItem(self.playerList.row(item[0])) - if id in self.playerlist: - del self.playerlist[id] + if pid in self.playerlist: + del self.playerlist[pid] else: # Update a player - if id in self.playerlist: - self.playerlist[id][type] = data + if pid in self.playerlist: + self.playerlist[pid][utype] = data - item = self.playerList.findItems("[%s]" % id, QtCore.Qt.MatchStartsWith) + item = self.playerList.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith) if item: - name = self.playerlist[id][0] - char = self.playerlist[id][1] - charname = self.playerlist[id][2] - text = "[%s]" % id - #4 ['s', 'cornelia (og)', 'Cornelia', '0'] - #[4] cornelia (og) (Cornelia) s + name = self.playerlist[pid][0] + char = self.playerlist[pid][1] + charname = self.playerlist[pid][2] + text = "[%s]" % pid if char: text += " %s" % char if charname: @@ -3035,4 +3033,4 @@ class TCP_Thread(QtCore.QThread): elif header == 'PU': del network[0] #print "(PU) id: %s, type: %d, data: %s" % (network[0], int(network[1]), network[2]) - self.updatePlayerList.emit(network[0], 1, int(network[1]), network[2]) + self.updatePlayerList.emit(network[0], 1, int(network[1]), network[2].decode('utf-8')) diff --git a/mainmenu.py b/mainmenu.py index b7f797d..30c2315 100644 --- a/mainmenu.py +++ b/mainmenu.py @@ -629,5 +629,4 @@ class AOServerInfo(QtCore.QThread): if not pid in playerlist: playerlist[pid] = [] playerlist[pid].append(network[2]) - #print "(PU) id: %d, type: %d, data: %s" % (int(network[0]), int(network[1]), network[2]) \ No newline at end of file