diff --git a/index.html b/index.html
index d8d2a04..76c2a7e 100644
--- a/index.html
+++ b/index.html
@@ -11,7 +11,6 @@
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.171.0/build/three.module.min.js",
- "three/examples/jsm/controls/PointerLockControls": "https://cdn.jsdelivr.net/npm/three@0.171.0/examples/jsm/controls/PointerLockControls.js",
"cannon": "https://cdn.jsdelivr.net/npm/cannon-es@0.20.0/dist/cannon-es.js"
}
}
diff --git a/src/main.js b/src/main.js
index 2efe1a5..862db03 100644
--- a/src/main.js
+++ b/src/main.js
@@ -7,7 +7,7 @@ import { MenuRegistry } from "./overlay/MenuRegistry.js";
import { AudioManager } from "./client/audio/AudioManager.js";
import { Controls } from "./client/controls/Keybinds.js";
import { Stats } from "./overlay/Stats.js";
-import { Lobby } from "./networking/Lobby.js";
+import { Server } from "./networking/Server.js";
async function init() {
window.g_AudioManager = new AudioManager();
@@ -21,7 +21,7 @@ async function init() {
window.g_Controls = Controls;
window.g_Client = new ClientPlayer();
window.g_ConnectionManager = new ConnectionManager();
- window.g_Lobby = new Lobby();
+ window.g_Lobby = new Server();
window.runtimeStats = new Stats();
diff --git a/src/networking/Packets.js b/src/networking/Packets.js
index ce2bc22..5951d03 100644
--- a/src/networking/Packets.js
+++ b/src/networking/Packets.js
@@ -195,7 +195,11 @@ export class StartGamePacket extends GenericPacket {
};
}
- static handleStartGame(packet) {
+ static handleStartGame(packet, senderID) {
+ if (senderID !== g_Lobby.leader) {
+ console.error('Non-leader tried to initiate game')
+ return;
+ }
g_Menu.hideAllMenus();
startGameLoop();
g_ConnectionManager.broadcastPacket(new JoinGamePacket(packet));
diff --git a/src/networking/Lobby.js b/src/networking/Server.js
similarity index 94%
rename from src/networking/Lobby.js
rename to src/networking/Server.js
index 3ed8070..21538eb 100644
--- a/src/networking/Lobby.js
+++ b/src/networking/Server.js
@@ -1,7 +1,7 @@
import {JoinGamePacket, KickPlayerPacket, LobbyReadyPacket, StartGamePacket} from "./Packets.js";
import {PlayerBody} from "../client/player/PlayerBody.js";
-export class Lobby {
+export class Server {
constructor() {
this.leader = g_ConnectionManager.peerId;
this.lobbyReadied = false;
@@ -97,6 +97,13 @@ export class Lobby {
readyButton() {
this.lobbyReadied = !this.lobbyReadied;
+
+ if (this.lobbyReadied) {
+ document.getElementById('lobby-title').classList.add("lobby-ready");
+ } else {
+ document.getElementById('lobby-title').classList.remove("lobby-ready");
+ }
+
g_ConnectionManager.broadcastPacket(new LobbyReadyPacket(this.lobbyReadied));
}