summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Roversi <diegor@tiscali.it>2019-09-15 15:37:30 +0200
committerDiego Roversi <diegor@tiscali.it>2019-09-15 15:37:30 +0200
commitfbf3c57576fcc20381b2cba4c8b483ef0b958107 (patch)
tree2fa1defc1c237f68ddd4e7b04656ec7907dd0626
parent76e9a932c6f942502b6b7fc7db4a949ed96d6d7a (diff)
fix import and convert some string in to bytes
-rw-r--r--common/gamesrv.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/common/gamesrv.py b/common/gamesrv.py
index ecf6cdc..303d7d0 100644
--- a/common/gamesrv.py
+++ b/common/gamesrv.py
@@ -425,7 +425,7 @@ class Client:
self.initialdata = MSG_WELCOME
self.initialized = 0
self.msgl = [message(MSG_PING)]
- self.buf = ""
+ self.buf = b""
self.players = { }
self.sounds = None
self.has_sound = 0
@@ -440,7 +440,7 @@ class Client:
def opengame(self, game):
if self.initialized == 0:
- self.initialdata += game.FnDesc + '\n'
+ self.initialdata += game.FnDesc.encode() + b'\n'
self.initialized = 1
if self.initialized == 1:
if game.broadcast_port:
@@ -1004,13 +1004,13 @@ def openpingsocket(only_port=None):
only_port = only_port or PORTS.get('PING', None)
s = findsocket('PING')
if s is None:
- from . import hostchooser
+ import hostchooser
s = hostchooser.serverside_ping(only_port)
if s is None:
return None
def pingsocket_handler(s=s):
global game
- from . import hostchooser
+ import hostchooser
if game is not None:
args = game.FnDesc, ('', game.address[1]), game.FnExtraDesc()
else:
@@ -1165,7 +1165,7 @@ class Game:
else:
try:
self.broadcast_s.sendto(BROADCAST_MESSAGE,
- ('<broadcast>', self.broadcast_port))
+ (b'<broadcast>', self.broadcast_port))
#print "Broadcast ping"
except error:
pass # ignore failed broadcasts
@@ -1174,8 +1174,8 @@ class Game:
return delay
def sendudpdata(self):
- sprites[0] = ''
- udpdata = ''.join(sprites)
+ sprites[0] = b''
+ udpdata = b''.join(sprites)
if len(broadcast_clients) >= 2:
broadcast_extras = {}
else:
@@ -1188,7 +1188,7 @@ class Game:
udpdata = ''.join(list(broadcast_extras.keys()) + [udpdata])
try:
self.broadcast_s.sendto(udpdata,
- ('<broadcast>', self.broadcast_port))
+ (b'<broadcast>', self.broadcast_port))
#print "Broadcast UDP data"
except error:
pass # ignore failed broadcasts