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): def onEditEvidence(self):
if not self.evidence: 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) self.evidence_editor.EditEvidence(self.selectedevi)
def onDeleteEvidence(self): def onDeleteEvidence(self):
@ -1792,18 +1792,18 @@ class gui(QtGui.QWidget):
if self.additivebtn.isChecked(): if self.additivebtn.isChecked():
self.icchatinput.insert(" ") 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 evidence = int(self.m_chatmessage[EVIDENCE])-1
t = time.localtime() 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 #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(): #if f_char.lower() != self.charlist[f_char_id][0].lower():
# logcharname = self.charlist[f_char_id][0] + ' (' + f_char.decode("utf-8") + ')' # logcharname = self.charlist[f_char_id][0] + ' (' + f_char.decode("utf-8") + ')'
if self.m_chatmessage[SHOWNAME]: if self.m_chatmessage[SHOWNAME]:
try: try:
logcharname += " ("+self.m_chatmessage[SHOWNAME].decode("utf-8")+")" logcharname += " ("+self.m_chatmessage[SHOWNAME]+")"
except: except:
logcharname += " (???)" logcharname += " (???)"
@ -2638,31 +2638,29 @@ class gui(QtGui.QWidget):
else: else:
self.evidencedropdown.setCurrentIndex(self.selectedevi) self.evidencedropdown.setCurrentIndex(self.selectedevi)
def updatePlayerList(self, id, op, type, data=""): def updatePlayerList(self, pid, op, utype, data=""):
id = str(id) pid = str(pid)
if op == 0: # Add or remove player if op == 0: # Add or remove player
if type == 0: # Add a player if utype == 0: # Add a player
self.playerList.addItem("[%s]" % id) self.playerList.addItem("[%s]" % pid)
if not id in self.playerlist: if not pid in self.playerlist:
self.playerlist[id] = ["", "", "", ""] self.playerlist[pid] = ["", "", "", ""]
if type == 1: # Remove a player if utype == 1: # Remove a player
item = self.playerList.findItems("[%s]" % id, QtCore.Qt.MatchStartsWith) item = self.playerList.findItems("[%s]" % pid, QtCore.Qt.MatchStartsWith)
if item: if item:
self.playerList.takeItem(self.playerList.row(item[0])) self.playerList.takeItem(self.playerList.row(item[0]))
if id in self.playerlist: if pid in self.playerlist:
del self.playerlist[id] del self.playerlist[pid]
else: # Update a player else: # Update a player
if id in self.playerlist: if pid in self.playerlist:
self.playerlist[id][type] = data 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: if item:
name = self.playerlist[id][0] name = self.playerlist[pid][0]
char = self.playerlist[id][1] char = self.playerlist[pid][1]
charname = self.playerlist[id][2] charname = self.playerlist[pid][2]
text = "[%s]" % id text = "[%s]" % pid
#4 ['s', 'cornelia (og)', 'Cornelia', '0']
#[4] cornelia (og) (Cornelia) s
if char: if char:
text += " %s" % char text += " %s" % char
if charname: if charname:
@ -3035,4 +3033,4 @@ class TCP_Thread(QtCore.QThread):
elif header == 'PU': elif header == 'PU':
del network[0] del network[0]
#print "(PU) id: %s, type: %d, data: %s" % (network[0], int(network[1]), network[2]) #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: if not pid in playerlist:
playerlist[pid] = [] playerlist[pid] = []
playerlist[pid].append(network[2]) playerlist[pid].append(network[2])
#print "(PU) id: %d, type: %d, data: %s" % (int(network[0]), int(network[1]), network[2])