Multiplayer optimisations

This commit is contained in:
tgpethan 2021-01-26 14:55:25 +00:00
parent 6f6c66b7a8
commit 1f531a1acc
2 changed files with 11 additions and 31 deletions

View file

@ -277,16 +277,8 @@ module.exports = class {
missingBeatmap(MatchUser) {
const osuPacketWriter = new osu.Bancho.Writer;
// Loop through all slots in the match
for (let i = 0; i < this.slots.length; i++) {
const slot = this.slots[i];
// Make sure the user in the slot is the user we want to update
if (slot.playerId != MatchUser.id) continue;
// User is missing the beatmap set the status to reflect it
slot.status = 16;
break;
}
// User is missing the beatmap set the status to reflect it
this.slots[MatchUser.matchSlotId].status = 16;
osuPacketWriter.MatchUpdate(this.createOsuMatchJSON());
@ -297,16 +289,8 @@ module.exports = class {
notMissingBeatmap(MatchUser) {
const osuPacketWriter = new osu.Bancho.Writer;
// Loop through all slots in the match
for (let i = 0; i < this.slots.length; i++) {
const slot = this.slots[i];
// Make sure the user in the slot is the user we want to update
if (slot.playerId != MatchUser.id) continue;
// The user is not missing the beatmap, set the status to normal
else slot.status = 4;
break;
}
// The user is not missing the beatmap, set the status to normal
this.slots[MatchUser.matchSlotId].status = 4;
osuPacketWriter.MatchUpdate(this.createOsuMatchJSON());
@ -363,11 +347,11 @@ module.exports = class {
}
}
transferHost(MatchUserToTransferHostTo) {
transferHost(SlotIDToTransferTo) {
const osuPacketWriter = new osu.Bancho.Writer;
// Set the lobby's host to the new user
this.host = this.slots[MatchUserToTransferHostTo].playerId;
this.host = this.slots[SlotIDToTransferTo].playerId;
osuPacketWriter.MatchUpdate(this.createOsuMatchJSON());
@ -380,13 +364,7 @@ module.exports = class {
// Check if freemod is enabled
if (this.specialModes === 1) {
const osuPacketWriter = new osu.Bancho.Writer;
for (let i = 0; i < this.slots.length; i++) {
const slot = this.slots[i];
if (slot.playerId === MatchUser.id) {
slot.mods = MatchMods;
break;
}
}
this.slots[MatchUser.matchSlotId].mods = MatchMods;
osuPacketWriter.MatchUpdate(this.createOsuMatchJSON());

View file

@ -14,8 +14,6 @@ module.exports = class {
this.spectating = 0;
this.location = [0,0];
this.joinedChannels = [];
this.currentMatch = null;
this.matchSlotId = -1;
// Presence data
this.actionID = 0;
@ -32,6 +30,10 @@ module.exports = class {
this.totalScore = 0;
this.rank = 0;
this.pp = 0;
// Multiplayer data
this.currentMatch = null;
this.matchSlotId = -1;
}
// Adds new actions to the user's queue