Implement SpecialLeaveMatchChannel

This commit is contained in:
Ethan Stubbs 2021-02-05 03:18:24 +00:00
parent 44838a9629
commit 63758f61cb
2 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,30 @@
const osu = require("osu-packet");
module.exports = function(CurrentUser, MatchID) {
const match = global.MultiplayerManager.getMatch(MatchID);
if (match != null) {
match.isTourneyMatch = false;
match.tourneyClientUsers = [];
if (global.StreamsHandler.isUserInStream(match.matchStreamName, CurrentUser.uuid))
return global.consoleHelper.printBancho(`Did not add user to channel ${match.matchStreamName} because they are already in it`);
const osuPacketWriter = new osu.Bancho.Writer;
osuPacketWriter.ChannelRevoked("#multiplayer");
if (!global.StreamsHandler.isUserInStream(match.matchStreamName, CurrentUser.uuid))
global.StreamsHandler.removeUserFromStream(match.matchStreamName, CurrentUser.uuid);
CurrentUser.addActionToQueue(osuPacketWriter.toBuffer);
} else {
// Still provide feedback just in case
// TODO: Check if this has any effect, if not then remove this.
const osuPacketWriter = new osu.Bancho.Writer;
osuPacketWriter.ChannelRevoked("#multiplayer");
CurrentUser.addActionToQueue(osuPacketWriter.toBuffer);
}
}

View file

@ -114,7 +114,8 @@ const ChangeAction = require("./Packets/ChangeAction.js"),
UserStatsRequest = require("./Packets/UserStatsRequest.js"), UserStatsRequest = require("./Packets/UserStatsRequest.js"),
MultiplayerInvite = require("./Packets/MultiplayerInvite.js"), MultiplayerInvite = require("./Packets/MultiplayerInvite.js"),
TourneyMatchSpecialInfo = require("./Packets/TourneyMatchSpecialInfo.js"), TourneyMatchSpecialInfo = require("./Packets/TourneyMatchSpecialInfo.js"),
TourneyMatchJoinChannel = require("./Packets/TourneyMatchSpecialInfo.js"); TourneyMatchJoinChannel = require("./Packets/TourneyMatchSpecialInfo.js"),
TourneyMatchLeaveChannel = require("./Packets/TourneyLeaveMatchChannel.js");
// A class for managing everything multiplayer // A class for managing everything multiplayer
global.MultiplayerManager = new MultiplayerManager(); global.MultiplayerManager = new MultiplayerManager();
@ -306,6 +307,10 @@ module.exports = function(req, res) {
TourneyMatchJoinChannel(PacketUser, CurrentPacket.data); TourneyMatchJoinChannel(PacketUser, CurrentPacket.data);
break; break;
case packetIDs.client_specialLeaveMatchChannel:
TourneyMatchLeaveChannel(PacketUser, CurrentPacket.data);
break;
case packetIDs.client_invite: case packetIDs.client_invite:
MultiplayerInvite(PacketUser, CurrentPacket.data); MultiplayerInvite(PacketUser, CurrentPacket.data);
break; break;