player list kick + ban + unicode

This commit is contained in:
cidoku 2025-02-13 18:36:10 -03:00
parent 87c7a522d8
commit 0767cf31e3
2 changed files with 22 additions and 25 deletions

View File

@ -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'))

View File

@ -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])