mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-08 19:59:20 +00:00
All players must join game before spawn (#380)
## Description: The server stores all players that have joined, and once the game starts it sends a list of players to all clients. Players cannot join after the game has started. Server now generated the PlayerID instead of the client. The is necessary for team mode, we need to know how who is playing the game before it starts so we can properly assign teams based on clans. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
@@ -33,8 +33,7 @@ ctx.addEventListener("message", async (e: MessageEvent<MainThreadMessage>) => {
|
||||
case "init":
|
||||
try {
|
||||
gameRunner = createGameRunner(
|
||||
message.gameID,
|
||||
message.gameConfig,
|
||||
message.gameStartInfo,
|
||||
message.clientID,
|
||||
gameUpdate,
|
||||
).then((gr) => {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import {
|
||||
PlayerActions,
|
||||
PlayerID,
|
||||
PlayerInfo,
|
||||
PlayerProfile,
|
||||
PlayerBorderTiles,
|
||||
} from "../game/Game";
|
||||
import { ErrorUpdate, GameUpdateViewData } from "../game/GameUpdates";
|
||||
import { ClientID, GameConfig, GameID, Turn } from "../Schemas";
|
||||
import { ClientID, GameStartInfo, Turn } from "../Schemas";
|
||||
import { generateID } from "../Util";
|
||||
import { WorkerMessage } from "./WorkerMessages";
|
||||
|
||||
@@ -19,8 +18,7 @@ export class WorkerClient {
|
||||
) => void;
|
||||
|
||||
constructor(
|
||||
private gameID: GameID,
|
||||
private gameConfig: GameConfig,
|
||||
private gameStartInfo: GameStartInfo,
|
||||
private clientID: ClientID,
|
||||
) {
|
||||
this.worker = new Worker(new URL("./Worker.worker.ts", import.meta.url));
|
||||
@@ -68,8 +66,7 @@ export class WorkerClient {
|
||||
this.worker.postMessage({
|
||||
type: "init",
|
||||
id: messageId,
|
||||
gameID: this.gameID,
|
||||
gameConfig: this.gameConfig,
|
||||
gameStartInfo: this.gameStartInfo,
|
||||
clientID: this.clientID,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { GameUpdateViewData } from "../game/GameUpdates";
|
||||
import { ClientID, GameConfig, GameID, Turn } from "../Schemas";
|
||||
import {
|
||||
ClientID,
|
||||
Turn,
|
||||
ServerStartGameMessage,
|
||||
GameStartInfo,
|
||||
} from "../Schemas";
|
||||
import {
|
||||
PlayerActions,
|
||||
PlayerID,
|
||||
@@ -33,8 +38,7 @@ export interface HeartbeatMessage extends BaseWorkerMessage {
|
||||
// Messages from main thread to worker
|
||||
export interface InitMessage extends BaseWorkerMessage {
|
||||
type: "init";
|
||||
gameID: GameID;
|
||||
gameConfig: GameConfig;
|
||||
gameStartInfo: GameStartInfo;
|
||||
clientID: ClientID;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user