Fix various bugs with multiplayer teams and mp commands
This commit is contained in:
parent
def4891008
commit
29359ad4fd
|
@ -10,7 +10,7 @@ from common import generalUtils
|
|||
from common.constants import mods
|
||||
from common.log import logUtils as log
|
||||
from common.ripple import userUtils
|
||||
from constants import exceptions, slotStatuses, matchModModes, matchTeams
|
||||
from constants import exceptions, slotStatuses, matchModModes, matchTeams, matchTeamTypes
|
||||
from common.constants import gameModes
|
||||
from common.constants import privileges
|
||||
from constants import serverPackets
|
||||
|
@ -924,6 +924,7 @@ def multiplayer(fro, chan, message):
|
|||
_match.beatmapName = beatmapData["song_name"]
|
||||
_match.beatmapMD5 = beatmapData["beatmap_md5"]
|
||||
_match.gameMode = gameMode
|
||||
_match.resetReady()
|
||||
_match.sendUpdates()
|
||||
return "Match map has been updated"
|
||||
|
||||
|
@ -939,10 +940,16 @@ def multiplayer(fro, chan, message):
|
|||
raise exceptions.invalidArgumentsException("Match team type must be between 0 and 3")
|
||||
if not 0 <= matchScoringType <= 3:
|
||||
raise exceptions.invalidArgumentsException("Match scoring type must be between 0 and 3")
|
||||
oldMatchTeamType = _match.matchTeamType
|
||||
_match.matchTeamType = matchTeamType
|
||||
_match.matchScoringType = matchScoringType
|
||||
if len(message) >= 4:
|
||||
_match.forceSize(int(message[3]))
|
||||
if _match.matchTeamType != oldMatchTeamType:
|
||||
_match.initializeTeams()
|
||||
if _match.matchTeamType == matchTeamTypes.TAG_COOP or _match.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
|
||||
_match.matchModMode = matchModModes.NORMAL
|
||||
|
||||
_match.sendUpdates()
|
||||
return "Match settings have been updated!"
|
||||
|
||||
|
@ -1002,8 +1009,10 @@ def multiplayer(fro, chan, message):
|
|||
freeMod = True
|
||||
|
||||
_match.matchModMode = matchModModes.FREE_MOD if freeMod else matchModModes.NORMAL
|
||||
_match.resetReady()
|
||||
if _match.matchModMode == matchModModes.FREE_MOD:
|
||||
_match.resetMods()
|
||||
_match.changeMods(newMods)
|
||||
|
||||
return "Match mods have been updated!"
|
||||
|
||||
def mpTeam():
|
||||
|
@ -1039,10 +1048,10 @@ def multiplayer(fro, chan, message):
|
|||
readableStatus = readableStatuses[slot.status]
|
||||
empty = False
|
||||
msg += "* [{team}] <{status}> ~ {username}{mods}\n".format(
|
||||
team="red" if slot.team == 0 else "blue",
|
||||
team="red" if slot.team == matchTeams.RED else "blue" if slot.team == matchTeams.BLUE else "!! no team !!",
|
||||
status=readableStatus,
|
||||
username=glob.tokens.tokens[slot.user].username,
|
||||
mods=" (+ {})".format(generalUtils.readableMods(slot.mods))
|
||||
mods=" (+ {})".format(generalUtils.readableMods(slot.mods)) if slot.mods > 0 else ""
|
||||
)
|
||||
if empty:
|
||||
msg += "\nNobody."
|
||||
|
|
|
@ -71,6 +71,7 @@ def handle(userToken, packetData):
|
|||
|
||||
oldBeatmapMD5 = match.beatmapMD5
|
||||
oldMods = match.mods
|
||||
oldMatchTeamType = match.matchTeamType
|
||||
|
||||
match.mods = packetData["mods"]
|
||||
match.beatmapMD5 = packetData["beatmapMD5"]
|
||||
|
@ -80,31 +81,19 @@ def handle(userToken, packetData):
|
|||
|
||||
# Reset ready if needed
|
||||
if oldMods != match.mods or oldBeatmapMD5 != match.beatmapMD5:
|
||||
for i in range(0,16):
|
||||
if match.slots[i].status == slotStatuses.READY:
|
||||
match.slots[i].status = slotStatuses.NOT_READY
|
||||
match.resetReady()
|
||||
|
||||
# Reset mods if needed
|
||||
if match.matchModMode == matchModModes.NORMAL:
|
||||
# Reset slot mods if not freeMods
|
||||
for i in range(0,16):
|
||||
match.slots[i].mods = 0
|
||||
match.resetMods()
|
||||
else:
|
||||
# Reset match mods if freemod
|
||||
match.mods = 0
|
||||
|
||||
# Set/reset teams
|
||||
if match.matchTeamType == matchTeamTypes.TEAM_VS or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
|
||||
# Set teams
|
||||
c=0
|
||||
for i in range(0,16):
|
||||
if match.slots[i].team == matchTeams.NO_TEAM:
|
||||
match.slots[i].team = matchTeams.RED if c % 2 == 0 else matchTeams.BLUE
|
||||
c+=1
|
||||
else:
|
||||
# Reset teams
|
||||
for i in range(0,16):
|
||||
match.slots[i].team = matchTeams.NO_TEAM
|
||||
# Initialize teams if team type changed
|
||||
if match.matchTeamType != oldMatchTeamType:
|
||||
match.initializeTeams()
|
||||
|
||||
# Force no freemods if tag coop
|
||||
if match.matchTeamType == matchTeamTypes.TAG_COOP or match.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
|
||||
|
|
|
@ -26,7 +26,7 @@ def handle(userToken, packetData):
|
|||
|
||||
# Check password
|
||||
if match.matchPassword != "" and match.matchPassword != password:
|
||||
raise exceptions.matchWrongPasswordException
|
||||
raise exceptions.matchWrongPasswordException()
|
||||
|
||||
# Password is correct, join match
|
||||
userToken.joinMatch(matchID)
|
||||
|
|
|
@ -15,7 +15,7 @@ from objects import glob
|
|||
class slot:
|
||||
def __init__(self):
|
||||
self.status = slotStatuses.FREE
|
||||
self.team = 0
|
||||
self.team = matchTeams.NO_TEAM
|
||||
self.userID = -1
|
||||
self.user = None
|
||||
self.mods = 0
|
||||
|
@ -77,6 +77,7 @@ class match:
|
|||
def getMatchData(self, censored = False):
|
||||
"""
|
||||
Return binary match data structure for packetHelper
|
||||
Return binary match data structure for packetHelper
|
||||
|
||||
:return:
|
||||
"""
|
||||
|
@ -411,7 +412,7 @@ class match:
|
|||
self.inProgress = False
|
||||
|
||||
# Reset slots
|
||||
self.resetSlotsReady()
|
||||
self.resetSlots()
|
||||
|
||||
# Send match update
|
||||
self.sendUpdates()
|
||||
|
@ -426,7 +427,7 @@ class match:
|
|||
# Console output
|
||||
log.info("MPROOM{}: Match completed".format(self.matchID))
|
||||
|
||||
def resetSlotsReady(self):
|
||||
def resetSlots(self):
|
||||
for i in range(0,16):
|
||||
if self.slots[i].user is not None and self.slots[i].status == slotStatuses.PLAYING:
|
||||
self.slots[i].status = slotStatuses.NOT_READY
|
||||
|
@ -465,7 +466,10 @@ class match:
|
|||
for i in range(0,16):
|
||||
if self.slots[i].status == slotStatuses.FREE:
|
||||
# Occupy slot
|
||||
self.setSlot(i, slotStatuses.NOT_READY, 0, user.token, 0)
|
||||
team = matchTeams.NO_TEAM
|
||||
if self.matchTeamType == matchTeamTypes.TEAM_VS or self.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
|
||||
team = matchTeams.RED if i % 2 == 0 else matchTeams.BLUE
|
||||
self.setSlot(i, slotStatuses.NOT_READY, team, user.token, 0)
|
||||
|
||||
# Send updated match data
|
||||
self.sendUpdates()
|
||||
|
@ -786,9 +790,28 @@ class match:
|
|||
return
|
||||
self.inProgress = False
|
||||
self.isStarting = False
|
||||
self.resetSlotsReady()
|
||||
self.resetSlots()
|
||||
self.sendUpdates()
|
||||
glob.streams.broadcast(self.playingStreamName, serverPackets.matchAbort())
|
||||
glob.streams.dispose(self.playingStreamName)
|
||||
glob.streams.remove(self.playingStreamName)
|
||||
log.info("MPROOM{}: Match aborted".format(self.matchID))
|
||||
|
||||
def initializeTeams(self):
|
||||
if self.matchTeamType == matchTeamTypes.TEAM_VS or self.matchTeamType == matchTeamTypes.TAG_TEAM_VS:
|
||||
# Set teams
|
||||
for i, _slot in enumerate(self.slots):
|
||||
_slot.team = matchTeams.RED if i % 2 == 0 else matchTeams.BLUE
|
||||
else:
|
||||
# Reset teams
|
||||
for _slot in self.slots:
|
||||
_slot.team = matchTeams.NO_TEAM
|
||||
|
||||
def resetMods(self):
|
||||
for _slot in self.slots:
|
||||
_slot.mods = 0
|
||||
|
||||
def resetReady(self):
|
||||
for _slot in self.slots:
|
||||
if _slot.status == slotStatuses.READY:
|
||||
_slot.status = slotStatuses.NOT_READY
|
Loading…
Reference in New Issue
Block a user