.BANCHO. .FIX. Attempt to make getMatchData thread safe
This commit is contained in:
parent
99d14b46e8
commit
26dbdd72c1
|
@ -78,47 +78,48 @@ class match:
|
||||||
Return binary match data structure for packetHelper
|
Return binary match data structure for packetHelper
|
||||||
"""
|
"""
|
||||||
# General match info
|
# General match info
|
||||||
|
safeMatch = copy.deepcopy(self)
|
||||||
struct = [
|
struct = [
|
||||||
[self.matchID, dataTypes.UINT16],
|
[safeMatch.matchID, dataTypes.UINT16],
|
||||||
[int(self.inProgress), dataTypes.BYTE],
|
[int(safeMatch.inProgress), dataTypes.BYTE],
|
||||||
[0, dataTypes.BYTE],
|
[0, dataTypes.BYTE],
|
||||||
[self.mods, dataTypes.UINT32],
|
[safeMatch.mods, dataTypes.UINT32],
|
||||||
[self.matchName, dataTypes.STRING],
|
[safeMatch.matchName, dataTypes.STRING],
|
||||||
[self.matchPassword, dataTypes.STRING],
|
[safeMatch.matchPassword, dataTypes.STRING],
|
||||||
[self.beatmapName, dataTypes.STRING],
|
[safeMatch.beatmapName, dataTypes.STRING],
|
||||||
[self.beatmapID, dataTypes.UINT32],
|
[safeMatch.beatmapID, dataTypes.UINT32],
|
||||||
[self.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):
|
||||||
struct.append([self.slots[i].status, dataTypes.BYTE])
|
struct.append([safeMatch.slots[i].status, dataTypes.BYTE])
|
||||||
|
|
||||||
# Slot teams, always 16 elements
|
# Slot teams, always 16 elements
|
||||||
for i in range(0,16):
|
for i in range(0,16):
|
||||||
struct.append([self.slots[i].team, dataTypes.BYTE])
|
struct.append([safeMatch.slots[i].team, dataTypes.BYTE])
|
||||||
|
|
||||||
# Slot user ID. Write only if slot is occupied
|
# Slot user ID. Write only if slot is occupied
|
||||||
for i in range(0,16):
|
for i in range(0,16):
|
||||||
if self.slots[i].user is not None and self.slots[i].user in glob.tokens.tokens:
|
if safeMatch.slots[i].user is not None and safeMatch.slots[i].user in glob.tokens.tokens:
|
||||||
struct.append([glob.tokens.tokens[self.slots[i].user].userID, dataTypes.UINT32])
|
struct.append([glob.tokens.tokens[safeMatch.slots[i].user].userID, dataTypes.UINT32])
|
||||||
|
|
||||||
# Other match data
|
# Other match data
|
||||||
struct.extend([
|
struct.extend([
|
||||||
[self.hostUserID, dataTypes.SINT32],
|
[safeMatch.hostUserID, dataTypes.SINT32],
|
||||||
[self.gameMode, dataTypes.BYTE],
|
[safeMatch.gameMode, dataTypes.BYTE],
|
||||||
[self.matchScoringType, dataTypes.BYTE],
|
[safeMatch.matchScoringType, dataTypes.BYTE],
|
||||||
[self.matchTeamType, dataTypes.BYTE],
|
[safeMatch.matchTeamType, dataTypes.BYTE],
|
||||||
[self.matchModMode, dataTypes.BYTE],
|
[safeMatch.matchModMode, dataTypes.BYTE],
|
||||||
])
|
])
|
||||||
|
|
||||||
# Slot mods if free mod is enabled
|
# Slot mods if free mod is enabled
|
||||||
if self.matchModMode == matchModModes.freeMod:
|
if safeMatch.matchModMode == matchModModes.freeMod:
|
||||||
for i in range(0,16):
|
for i in range(0,16):
|
||||||
struct.append([self.slots[i].mods, dataTypes.UINT32])
|
struct.append([safeMatch.slots[i].mods, dataTypes.UINT32])
|
||||||
|
|
||||||
# Seed idk
|
# Seed idk
|
||||||
struct.append([self.seed, dataTypes.UINT32])
|
struct.append([safeMatch.seed, dataTypes.UINT32])
|
||||||
|
|
||||||
return struct
|
return struct
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user