Make a few packets awaited so that the client gets data on time
This commit is contained in:
parent
b6b5e3804c
commit
ad6ad5ed2c
3 changed files with 28 additions and 18 deletions
24
server/MultiplayerMatch.js
Normal file → Executable file
24
server/MultiplayerMatch.js
Normal file → Executable file
|
@ -148,10 +148,9 @@ class MultiplayerMatch {
|
|||
|
||||
this.activeMods = MatchData.activeMods;
|
||||
|
||||
if (this.gameName !== MatchData.gameName) {
|
||||
const gameNameChanged = this.gameName !== MatchData.gameName;
|
||||
this.gameName = MatchData.gameName;
|
||||
await global.DatabaseHelper.query("UPDATE mp_matches SET name = ? WHERE id = ?", [this.gameName, this.matchId]);
|
||||
}
|
||||
|
||||
if (MatchData.gamePassword == '') MatchData.gamePassword == null;
|
||||
this.gamePassword = MatchData.gamePassword;
|
||||
|
||||
|
@ -167,9 +166,20 @@ class MultiplayerMatch {
|
|||
this.matchTeamType = MatchData.matchTeamType;
|
||||
this.specialModes = MatchData.specialModes;
|
||||
|
||||
if (this.seed !== MatchData.seed) {
|
||||
const gameSeedChanged = this.seed !== MatchData.seed;
|
||||
this.seed = MatchData.seed;
|
||||
await global.DatabaseHelper.query("UPDATE mp_matches SET seed = ? WHERE id = ?", [this.seed, this.matchId]);
|
||||
|
||||
if (gameNameChanged || gameSeedChanged) {
|
||||
const queryData = [];
|
||||
if (gameNameChanged) {
|
||||
queryData.push(MatchData.gameName);
|
||||
}
|
||||
if (gameSeedChanged) {
|
||||
queryData.push(MatchData.seed);
|
||||
}
|
||||
queryData.push(this.matchId);
|
||||
|
||||
await global.DatabaseHelper.query(`UPDATE mp_matches SET ${gameNameChanged ? `name = ?${gameSeedChanged ? ", " : ""}` : ""}${gameSeedChanged ? `seed = ?` : ""} WHERE id = ?`, queryData);
|
||||
}
|
||||
|
||||
this.sendMatchUpdate();
|
||||
|
@ -430,7 +440,7 @@ class MultiplayerMatch {
|
|||
}
|
||||
}
|
||||
|
||||
onPlayerFinishMatch(MatchUser = new User) {
|
||||
async onPlayerFinishMatch(MatchUser = new User) {
|
||||
if (this.matchLoadSlots == null) {
|
||||
// Repopulate user loading slots again
|
||||
this.matchLoadSlots = [];
|
||||
|
@ -461,7 +471,7 @@ class MultiplayerMatch {
|
|||
}
|
||||
|
||||
// All players have finished playing, finish the match
|
||||
if (allLoaded) this.finishMatch();
|
||||
if (allLoaded) await this.finishMatch();
|
||||
}
|
||||
|
||||
async finishMatch() {
|
||||
|
|
4
server/Packets/Logout.js
Normal file → Executable file
4
server/Packets/Logout.js
Normal file → Executable file
|
@ -1,7 +1,7 @@
|
|||
const consoleHelper = require("../../consoleHelper.js"),
|
||||
Streams = require("../Streams.js");
|
||||
|
||||
module.exports = function(CurrentUser) {
|
||||
module.exports = async function(CurrentUser) {
|
||||
if (CurrentUser.uuid === "bot") throw "Tried to log bot out, WTF???";
|
||||
|
||||
const logoutStartTime = Date.now();
|
||||
|
@ -17,7 +17,7 @@ module.exports = function(CurrentUser) {
|
|||
// Remove user from user list
|
||||
global.users.remove(CurrentUser.uuid);
|
||||
|
||||
global.DatabaseHelper.query("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [global.users.getLength() - 1]);
|
||||
await global.DatabaseHelper.query("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [global.users.getLength() - 1]);
|
||||
|
||||
consoleHelper.printBancho(`User logged out, took ${Date.now() - logoutStartTime}ms. [User: ${CurrentUser.username}]`);
|
||||
}
|
14
server/serverHandler.js
Normal file → Executable file
14
server/serverHandler.js
Normal file → Executable file
|
@ -159,7 +159,7 @@ module.exports = async function(req, res) {
|
|||
const PacketData = osuPacketReader.Parse();
|
||||
|
||||
// Go through each packet sent by the client
|
||||
PacketData.forEach(CurrentPacket => {
|
||||
for (CurrentPacket of PacketData) {
|
||||
switch (CurrentPacket.id) {
|
||||
case packetIDs.client_changeAction:
|
||||
ChangeAction(PacketUser, CurrentPacket.data);
|
||||
|
@ -170,7 +170,7 @@ module.exports = async function(req, res) {
|
|||
break;
|
||||
|
||||
case packetIDs.client_logout:
|
||||
Logout(PacketUser);
|
||||
await Logout(PacketUser);
|
||||
break;
|
||||
|
||||
case packetIDs.client_requestStatusUpdate:
|
||||
|
@ -206,7 +206,7 @@ module.exports = async function(req, res) {
|
|||
break;
|
||||
|
||||
case packetIDs.client_createMatch:
|
||||
global.MultiplayerManager.createMultiplayerMatch(PacketUser, CurrentPacket.data);
|
||||
await global.MultiplayerManager.createMultiplayerMatch(PacketUser, CurrentPacket.data);
|
||||
break;
|
||||
|
||||
case packetIDs.client_joinMatch:
|
||||
|
@ -222,7 +222,7 @@ module.exports = async function(req, res) {
|
|||
break;
|
||||
|
||||
case packetIDs.client_matchChangeSettings:
|
||||
PacketUser.currentMatch.updateMatch(PacketUser, CurrentPacket.data);
|
||||
await PacketUser.currentMatch.updateMatch(PacketUser, CurrentPacket.data);
|
||||
break;
|
||||
|
||||
case packetIDs.client_matchNotReady:
|
||||
|
@ -230,7 +230,7 @@ module.exports = async function(req, res) {
|
|||
break;
|
||||
|
||||
case packetIDs.client_partMatch:
|
||||
global.MultiplayerManager.leaveMultiplayerMatch(PacketUser);
|
||||
await global.MultiplayerManager.leaveMultiplayerMatch(PacketUser);
|
||||
break;
|
||||
|
||||
// Also handles user kick if the slot has a user
|
||||
|
@ -267,7 +267,7 @@ module.exports = async function(req, res) {
|
|||
break;
|
||||
|
||||
case packetIDs.client_matchComplete:
|
||||
PacketUser.currentMatch.onPlayerFinishMatch(PacketUser);
|
||||
await PacketUser.currentMatch.onPlayerFinishMatch(PacketUser);
|
||||
break;
|
||||
|
||||
case packetIDs.client_matchScoreUpdate:
|
||||
|
@ -333,7 +333,7 @@ module.exports = async function(req, res) {
|
|||
console.dir(CurrentPacket);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
responseData = PacketUser.queue;
|
||||
PacketUser.clearQueue();
|
||||
|
|
Loading…
Reference in a new issue