TCP and unicode fixes
This commit is contained in:
parent
5da47f070a
commit
e2162401e1
30
AOsocket.py
30
AOsocket.py
@ -3,10 +3,11 @@ import platform
|
||||
|
||||
import websocket
|
||||
import ssl
|
||||
from PyQt4.QtCore import QString
|
||||
|
||||
from constants import *
|
||||
|
||||
printPackets = False
|
||||
printPackets = False # Enable for debugging packets sent and received
|
||||
|
||||
class AOtcpSocket(object):
|
||||
def __init__(self):
|
||||
@ -50,13 +51,24 @@ class AOtcpSocket(object):
|
||||
totals[i] = totals[i].split("#")
|
||||
del totals[i][-1]
|
||||
if printPackets:
|
||||
print "[packet] Got:", totals
|
||||
try:
|
||||
print "[packet] <-", totals[0]
|
||||
except:
|
||||
print "(unable to print)"
|
||||
return 0, totals
|
||||
|
||||
def send(self, data):
|
||||
if printPackets:
|
||||
print "[packet] Sent:", data
|
||||
return self.sock.send(data)
|
||||
try:
|
||||
print "[packet] ->", data
|
||||
except:
|
||||
print "(unable to print)"
|
||||
# Qt pls
|
||||
if isinstance(data, QString):
|
||||
#return self.sock.send(unicode(data).encode('utf-8'))
|
||||
return self.sock.send(str(data.toUtf8()))
|
||||
else:
|
||||
return self.sock.send(data.encode('utf-8'))
|
||||
|
||||
def close(self):
|
||||
self.sock.close()
|
||||
@ -106,12 +118,18 @@ class AOwebSocket(object):
|
||||
del totals[i][-1]
|
||||
|
||||
if printPackets:
|
||||
print "[packet] Got:", totals
|
||||
try:
|
||||
print "[packet] <-", totals[0]
|
||||
except:
|
||||
print "(unable to print)"
|
||||
return 0, totals
|
||||
|
||||
def send(self, data):
|
||||
if printPackets:
|
||||
print "[packet] Sent:", data
|
||||
try:
|
||||
print "[packet] ->", data
|
||||
except:
|
||||
print "(unable to print)"
|
||||
return self.sock.send(unicode(data))
|
||||
|
||||
def close(self):
|
||||
|
||||
@ -183,7 +183,7 @@ class charselect(QtGui.QWidget):
|
||||
self.showCharPage()
|
||||
|
||||
def selectChar(self, charIndex):
|
||||
self.parent.tcp.send("CC#0#"+str(charIndex)+"#ur mom gay#%")
|
||||
self.parent.tcp.send("CC#0#"+str(charIndex)+"##%")
|
||||
|
||||
def onCancel(self):
|
||||
self.hide()
|
||||
|
||||
@ -2264,7 +2264,7 @@ class GUI(QtGui.QWidget):
|
||||
server_is_2_8 = "additive" in self.features and "looping_sfx" in self.features and "effects" in self.features
|
||||
|
||||
if server_is_2_8:
|
||||
self.tcp.send("SP#"+self.charSide+"#%") # all hail new AO 2.8 packet
|
||||
self.tcp.send("SP#" + self.charSide + "#%") # all hail new AO 2.8 packet
|
||||
else:
|
||||
self.sendOOCchat(self.OOCNameInput.text().toUtf8(), "/pos "+self.charSide)
|
||||
|
||||
@ -3690,7 +3690,7 @@ class GUI(QtGui.QWidget):
|
||||
self.bench.setPixmap(bench)
|
||||
self.bench.move(self.viewport.width() / 2 - bench.size().width() / 2, 0)
|
||||
|
||||
def setBench(self, isPreanim = False):
|
||||
def setBench(self, isPreanim = False, side = "wit"):
|
||||
if self.animIsEmpty:
|
||||
return
|
||||
|
||||
@ -3887,7 +3887,7 @@ class GUI(QtGui.QWidget):
|
||||
self.slideLastPos = None
|
||||
|
||||
if (emoteMod == PRE or emoteMod == PRE_SHOUT or emoteMod == NOPRE_ZOOM_SHOUT):
|
||||
self.setBench(True)
|
||||
self.setBench(True, side)
|
||||
self.playPre(False)
|
||||
elif emoteMod == NOPRE or emoteMod == NOPRE_ZOOM:
|
||||
if self.mChatMessage[NO_INTERRUPT] == "0":
|
||||
@ -3942,10 +3942,10 @@ class GUI(QtGui.QWidget):
|
||||
|
||||
def handleChatMessage3(self):
|
||||
self.startChatTicking()
|
||||
self.setBench(False)
|
||||
|
||||
fEvidenceId = int(self.mChatMessage[EVIDENCE])
|
||||
fSide = self.mChatMessage[SIDE]
|
||||
self.setBench(False, fSide)
|
||||
|
||||
emoteMod = int(self.mChatMessage[EMOTE_MOD])
|
||||
|
||||
|
||||
@ -491,6 +491,10 @@ class AOServerInfo(QtCore.QThread):
|
||||
return
|
||||
|
||||
for network in totals:
|
||||
if not network:
|
||||
print "[debug] Received empty packet"
|
||||
continue
|
||||
|
||||
header = network[0]
|
||||
|
||||
if header == 'PN':
|
||||
|
||||
@ -13,7 +13,7 @@ def handlePackets(caller, total, record=True):
|
||||
header = network[0]
|
||||
if header == 'MS':
|
||||
if len(network) < 15:
|
||||
print '[warning]', 'malformed/incomplete MS#chat (IC chat) network message was received'
|
||||
print '[warning]', 'Malformed/incomplete MS packet was received'
|
||||
continue
|
||||
|
||||
if isinstance(network[CHATMSG], unicode):
|
||||
@ -47,10 +47,10 @@ def handlePackets(caller, total, record=True):
|
||||
elif header == 'CT':
|
||||
name = decodeAOString(network[1].decode('utf-8'))
|
||||
chatmsg = decodeAOString(network[2].decode('utf-8').replace("\n", "<br />"))
|
||||
caller.OOC_Log.emit("<b>%s:</b> %s" % (name, chatmsg.replace("<", "<").replace("<br />","<br />") if network[3] == "0" else chatmsg))
|
||||
caller.OOC_Log.emit("<b>%s:</b> %s" % (name, chatmsg.replace("<", "<").replace("<br />","<br />") if len(network) > 3 and network[3] == "0" else chatmsg))
|
||||
|
||||
elif header == 'PV':
|
||||
caller.parent.myChar = int(network[3])
|
||||
caller.parent.myChar = int(network[3]) if network[3] else 0
|
||||
caller.parent.charSelect.hide()
|
||||
caller.newChar.emit(caller.parent.charList[caller.parent.myChar][0])
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user