Fix the multiplayer password bug while not breaking anything else, especially not multiplayer as a whole. (tested code)
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user