diff --git a/constants/serverPackets.py b/constants/serverPackets.py index f8eb309..101d0cd 100644 --- a/constants/serverPackets.py +++ b/constants/serverPackets.py @@ -202,19 +202,18 @@ def createMatch(matchID): # Get match binary data and build packet match = glob.matches.matches[matchID] - matchData = match.getMatchData() - matchData.matchPassword = "" + matchData = match.getMatchData(censored=True) return packetHelper.buildPacket(packetIDs.server_newMatch, matchData) # TODO: Add match object argument to save some CPU -def updateMatch(matchID): +def updateMatch(matchID, censored = False): # Make sure the match exists if matchID not in glob.matches.matches: return bytes() # Get match binary data and build packet 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): # Make sure the match exists @@ -271,4 +270,4 @@ def notification(message): return packetHelper.buildPacket(packetIDs.server_notification, [[message, dataTypes.STRING]]) def banchoRestart(msUntilReconnection): - return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]]) \ No newline at end of file + return packetHelper.buildPacket(packetIDs.server_restart, [[msUntilReconnection, dataTypes.UINT32]]) diff --git a/objects/match.py b/objects/match.py index 796941e..f51eeeb 100644 --- a/objects/match.py +++ b/objects/match.py @@ -66,7 +66,7 @@ class match: # Create #multiplayer channel glob.channels.addTempChannel("#multi_{}".format(self.matchID)) - def getMatchData(self): + def getMatchData(self, censored = False): """ Return binary match data structure for packetHelper @@ -80,12 +80,18 @@ class match: [int(safeMatch.inProgress), dataTypes.BYTE], [0, dataTypes.BYTE], [safeMatch.mods, dataTypes.UINT32], - [safeMatch.matchName, dataTypes.STRING], - [safeMatch.matchPassword, dataTypes.STRING], + [safeMatch.matchName, 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.beatmapID, dataTypes.UINT32], - [safeMatch.beatmapMD5, dataTypes.STRING], - ] + [safeMatch.beatmapMD5, dataTypes.STRING] + ]) # Slots status IDs, always 16 elements for i in range(0,16): @@ -611,9 +617,11 @@ class match: :return: """ self.matchDataCache = serverPackets.updateMatch(self.matchID) + censoredDataCache = serverPackets.updateMatch(self.matchID, censored=True) if self.matchDataCache is not None: glob.streams.broadcast(self.streamName, self.matchDataCache) - glob.streams.broadcast("lobby", self.matchDataCache) + if censoredDataCache is not None: + glob.streams.broadcast("lobby", censoredDataCache) else: 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)) # Send updates - self.sendUpdates() \ No newline at end of file + self.sendUpdates()