.BANCHO. Some code refactoring

This commit is contained in:
Nyo
2016-09-02 17:16:22 +02:00
parent 653303831b
commit 3703618112
11 changed files with 191 additions and 182 deletions

View File

@@ -13,7 +13,7 @@ npRegex = re.compile("^https?:\\/\\/osu\\.ppy\\.sh\\/b\\/(\\d*)")
def connect():
"""Add FokaBot to connected users and send userpanel/stats packet to everyone"""
token = glob.tokens.addToken(999)
token.actionID = actions.idle
token.actionID = actions.IDLE
glob.tokens.enqueueAll(serverPackets.userPanel(999))
glob.tokens.enqueueAll(serverPackets.userStats(999))

View File

@@ -86,47 +86,47 @@ class match():
"""
# General match info
struct = [
[self.matchID, dataTypes.uInt16],
[int(self.inProgress), dataTypes.byte],
[0, dataTypes.byte],
[self.mods, dataTypes.uInt32],
[self.matchName, dataTypes.string],
[self.matchPassword, dataTypes.string],
[self.beatmapName, dataTypes.string],
[self.beatmapID, dataTypes.uInt32],
[self.beatmapMD5, dataTypes.string],
[self.matchID, dataTypes.UINT16],
[int(self.inProgress), dataTypes.BYTE],
[0, dataTypes.BYTE],
[self.mods, dataTypes.UINT32],
[self.matchName, dataTypes.STRING],
[self.matchPassword, dataTypes.STRING],
[self.beatmapName, dataTypes.STRING],
[self.beatmapID, dataTypes.UINT32],
[self.beatmapMD5, dataTypes.STRING],
]
# Slots status IDs, always 16 elements
for i in range(0,16):
struct.append([self.slots[i].status, dataTypes.byte])
struct.append([self.slots[i].status, dataTypes.BYTE])
# Slot teams, always 16 elements
for i in range(0,16):
struct.append([self.slots[i].team, dataTypes.byte])
struct.append([self.slots[i].team, dataTypes.BYTE])
# Slot user ID. Write only if slot is occupied
for i in range(0,16):
uid = self.slots[i].userID
if uid > -1:
struct.append([uid, dataTypes.uInt32])
struct.append([uid, dataTypes.UINT32])
# Other match data
struct.extend([
[self.hostUserID, dataTypes.sInt32],
[self.gameMode, dataTypes.byte],
[self.matchScoringType, dataTypes.byte],
[self.matchTeamType, dataTypes.byte],
[self.matchModMode, dataTypes.byte],
[self.hostUserID, dataTypes.SINT32],
[self.gameMode, dataTypes.BYTE],
[self.matchScoringType, dataTypes.BYTE],
[self.matchTeamType, dataTypes.BYTE],
[self.matchModMode, dataTypes.BYTE],
])
# Slot mods if free mod is enabled
if self.matchModMode == matchModModes.freeMod:
for i in range(0,16):
struct.append([self.slots[i].mods, dataTypes.uInt32])
struct.append([self.slots[i].mods, dataTypes.UINT32])
# Seed idk
struct.append([self.seed, dataTypes.uInt32])
struct.append([self.seed, dataTypes.UINT32])
return struct

View File

@@ -52,7 +52,7 @@ class token():
self.spamRate = 0
# Stats cache
self.actionID = actions.idle
self.actionID = actions.IDLE
self.actionText = ""
self.actionMd5 = ""
self.actionMods = 0