From 7fc6d4c540fed152735226cf6424b344f8044b40 Mon Sep 17 00:00:00 2001 From: Nyo Date: Sun, 4 Sep 2016 16:24:00 +0200 Subject: [PATCH] .BANCHO. Force stop spectating/quit match if user is not spectating or multiplaying --- events/changeActionEvent.py | 8 ++++---- objects/match.py | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/events/changeActionEvent.py b/events/changeActionEvent.py index 24de2ca..e9559bf 100644 --- a/events/changeActionEvent.py +++ b/events/changeActionEvent.py @@ -24,12 +24,12 @@ def handle(userToken, packetData): packetData = clientPackets.userActionChange(packetData) # If we are not in spectate status but we're spectating someone, stop spectating - #if userToken.spectating != 0 and userToken.actionID != actions.watching and userToken.actionID != actions.idle and userToken.actionID != actions.afk: - # userToken.stopSpectating() + if userToken.spectating != 0 and userToken.actionID != actions.watching and userToken.actionID != actions.idle and userToken.actionID != actions.afk: + userToken.stopSpectating() # If we are not in multiplayer but we are in a match, part match - #if userToken.matchID != -1 and userToken.actionID != actions.multiplaying and userToken.actionID != actions.multiplayer and userToken.actionID != actions.afk: - # userToken.partMatch() + if userToken.matchID != -1 and userToken.actionID != actions.multiplaying and userToken.actionID != actions.multiplayer and userToken.actionID != actions.afk: + userToken.partMatch() # Update cached stats if our pp changedm if we've just submitted a score or we've changed gameMode if (userToken.actionID == actions.PLAYING or userToken.actionID == actions.MULTIPLAYING) or (userToken.pp != userHelper.getPP(userID, userToken.gameMode)) or (userToken.gameMode != packetData["gameMode"]): diff --git a/objects/match.py b/objects/match.py index 9d99b43..337a2dc 100644 --- a/objects/match.py +++ b/objects/match.py @@ -391,6 +391,12 @@ class match: return -- True if join success, False if fail (room is full) """ + # Make sure we're not in this match + for i in range(0,16): + if self.slots[i].userID == userID: + # Set bugged slot to free + self.setSlot(i, slotStatuses.free, 0, -1, 0) + # Find first free slot for i in range(0,16): if self.slots[i].status == slotStatuses.free: