Binato/server/Packets/TourneyLeaveMatchChannel.js

32 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

const osu = require("osu-packet"),
2022-08-26 12:52:00 +01:00
consoleHelper = require("../../consoleHelper.js"),
Streams = require("../Streams.js");
2021-02-05 03:18:24 +00:00
module.exports = function(CurrentUser, MatchID) {
const match = global.MultiplayerManager.getMatch(MatchID);
2021-02-05 03:18:24 +00:00
if (match != null) {
2021-02-05 03:18:24 +00:00
match.isTourneyMatch = false;
match.tourneyClientUsers = [];
2021-02-05 03:18:24 +00:00
2022-08-26 12:52:00 +01:00
if (Streams.isUserInStream(match.matchChatStreamName, CurrentUser.uuid))
return consoleHelper.printBancho(`Did not add user to channel ${match.matchChatStreamName} because they are already in it`);
2021-02-05 03:18:24 +00:00
const osuPacketWriter = new osu.Bancho.Writer;
2021-02-05 03:18:24 +00:00
osuPacketWriter.ChannelRevoked("#multiplayer");
2022-08-26 12:52:00 +01:00
if (!Streams.isUserInStream(match.matchChatStreamName, CurrentUser.uuid))
Streams.removeUserFromStream(match.matchChatStreamName, CurrentUser.uuid);
2021-02-05 03:18:24 +00:00
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;
2021-02-05 03:18:24 +00:00
osuPacketWriter.ChannelRevoked("#multiplayer");
2021-02-05 03:18:24 +00:00
CurrentUser.addActionToQueue(osuPacketWriter.toBuffer);
}
2021-02-05 03:18:24 +00:00
}