Fix the multiplayer password bug while not breaking anything else, especially not multiplayer as a whole. (tested code)
This commit is contained in:
parent
d439490029
commit
401dd5ecdb
|
@ -202,19 +202,18 @@ def createMatch(matchID):
|
||||||
|
|
||||||
# Get match binary data and build packet
|
# Get match binary data and build packet
|
||||||
match = glob.matches.matches[matchID]
|
match = glob.matches.matches[matchID]
|
||||||
matchData = match.getMatchData()
|
matchData = match.getMatchData(censored=True)
|
||||||
matchData.matchPassword = ""
|
|
||||||
return packetHelper.buildPacket(packetIDs.server_newMatch, matchData)
|
return packetHelper.buildPacket(packetIDs.server_newMatch, matchData)
|
||||||
|
|
||||||
# TODO: Add match object argument to save some CPU
|
# TODO: Add match object argument to save some CPU
|
||||||
def updateMatch(matchID):
|
def updateMatch(matchID, censored = False):
|
||||||
# Make sure the match exists
|
# Make sure the match exists
|
||||||
if matchID not in glob.matches.matches:
|
if matchID not in glob.matches.matches:
|
||||||
return bytes()
|
return bytes()
|
||||||
|
|
||||||
# Get match binary data and build packet
|
# Get match binary data and build packet
|
||||||
match = glob.matches.matches[matchID]
|
match = glob.matches.matches[matchID]
|
||||||
return packetHelper.buildPacket(packetIDs.server_updateMatch, match.getMatchData())
|
return packetHelper.buildPacket(packetIDs.server_updateMatch, match.getMatchData(censored=censored))
|
||||||
|
|
||||||
def matchStart(matchID):
|
def matchStart(matchID):
|
||||||
# Make sure the match exists
|
# Make sure the match exists
|
||||||
|
@ -271,4 +270,4 @@ def notification(message):
|
||||||
return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]])
|
return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]])
|
||||||
|
|
||||||
def banchoRestart(msUntilReconnection):
|
def banchoRestart(msUntilReconnection):
|
||||||
return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]])
|
return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]])
|
||||||
|
|
|
@ -66,7 +66,7 @@ class match:
|
||||||
# Create #multiplayer channel
|
# Create #multiplayer channel
|
||||||
glob.channels.addTempChannel("#multi_{}".format(self.matchID))
|
glob.channels.addTempChannel("#multi_{}".format(self.matchID))
|
||||||
|
|
||||||
def getMatchData(self):
|
def getMatchData(self, censored = False):
|
||||||
"""
|
"""
|
||||||
Return binary match data structure for packetHelper
|
Return binary match data structure for packetHelper
|
||||||
|
|
||||||
|
@ -80,12 +80,18 @@ class match:
|
||||||
[int(safeMatch.inProgress), dataTypes.BYTE],
|
[int(safeMatch.inProgress), dataTypes.BYTE],
|
||||||
[0, dataTypes.BYTE],
|
[0, dataTypes.BYTE],
|
||||||
[safeMatch.mods, dataTypes.UINT32],
|
[safeMatch.mods, dataTypes.UINT32],
|
||||||
[safeMatch.matchName, dataTypes.STRING],
|
[safeMatch.matchName, dataTypes.STRING]
|
||||||
[safeMatch.matchPassword, dataTypes.STRING],
|
]
|
||||||
|
if censored and safeMatch.matchPassword:
|
||||||
|
struct.append(["redacted", dataTypes.STRING])
|
||||||
|
else:
|
||||||
|
struct.append([safeMatch.matchPassword, dataTypes.STRING])
|
||||||
|
|
||||||
|
struct.extend([
|
||||||
[safeMatch.beatmapName, dataTypes.STRING],
|
[safeMatch.beatmapName, dataTypes.STRING],
|
||||||
[safeMatch.beatmapID, dataTypes.UINT32],
|
[safeMatch.beatmapID, dataTypes.UINT32],
|
||||||
[safeMatch.beatmapMD5, dataTypes.STRING],
|
[safeMatch.beatmapMD5, dataTypes.STRING]
|
||||||
]
|
])
|
||||||
|
|
||||||
# Slots status IDs, always 16 elements
|
# Slots status IDs, always 16 elements
|
||||||
for i in range(0,16):
|
for i in range(0,16):
|
||||||
|
@ -611,9 +617,11 @@ class match:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self.matchDataCache = serverPackets.updateMatch(self.matchID)
|
self.matchDataCache = serverPackets.updateMatch(self.matchID)
|
||||||
|
censoredDataCache = serverPackets.updateMatch(self.matchID, censored=True)
|
||||||
if self.matchDataCache is not None:
|
if self.matchDataCache is not None:
|
||||||
glob.streams.broadcast(self.streamName, self.matchDataCache)
|
glob.streams.broadcast(self.streamName, self.matchDataCache)
|
||||||
glob.streams.broadcast("lobby", self.matchDataCache)
|
if censoredDataCache is not None:
|
||||||
|
glob.streams.broadcast("lobby", censoredDataCache)
|
||||||
else:
|
else:
|
||||||
log.error("MPROOM{}: Can't send match update packet, match data is None!!!".format(self.matchID))
|
log.error("MPROOM{}: Can't send match update packet, match data is None!!!".format(self.matchID))
|
||||||
|
|
||||||
|
@ -671,4 +679,4 @@ class match:
|
||||||
glob.streams.broadcast(self.playingStreamName, serverPackets.matchStart(self.matchID))
|
glob.streams.broadcast(self.playingStreamName, serverPackets.matchStart(self.matchID))
|
||||||
|
|
||||||
# Send updates
|
# Send updates
|
||||||
self.sendUpdates()
|
self.sendUpdates()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user