mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-28 18:44:16 +00:00
sanitize profane usernames
This commit is contained in:
@@ -60,13 +60,13 @@ export interface LobbyConfig {
|
||||
|
||||
export function joinLobby(
|
||||
lobbyConfig: LobbyConfig,
|
||||
onjoin: () => void,
|
||||
onjoin: () => void
|
||||
): () => void {
|
||||
const eventBus = new EventBus();
|
||||
initRemoteSender(eventBus);
|
||||
|
||||
consolex.log(
|
||||
`joinging lobby: gameID: ${lobbyConfig.gameID}, clientID: ${lobbyConfig.clientID}, persistentID: ${lobbyConfig.persistentID}`,
|
||||
`joinging lobby: gameID: ${lobbyConfig.gameID}, clientID: ${lobbyConfig.clientID}, persistentID: ${lobbyConfig.persistentID}`
|
||||
);
|
||||
|
||||
const serverConfig = getServerConfig();
|
||||
@@ -84,7 +84,7 @@ export function joinLobby(
|
||||
lobbyConfig,
|
||||
gameConfig,
|
||||
eventBus,
|
||||
serverConfig,
|
||||
serverConfig
|
||||
);
|
||||
|
||||
const onconnect = () => {
|
||||
@@ -96,7 +96,7 @@ export function joinLobby(
|
||||
consolex.log("lobby: game started");
|
||||
onjoin();
|
||||
createClientGame(lobbyConfig, message.config, eventBus, transport).then(
|
||||
(r) => r.start(),
|
||||
(r) => r.start()
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -111,18 +111,22 @@ export async function createClientGame(
|
||||
lobbyConfig: LobbyConfig,
|
||||
gameConfig: GameConfig,
|
||||
eventBus: EventBus,
|
||||
transport: Transport,
|
||||
transport: Transport
|
||||
): Promise<ClientGameRunner> {
|
||||
const config = getConfig(gameConfig);
|
||||
|
||||
const gameMap = await loadTerrainMap(gameConfig.gameMap);
|
||||
const worker = new WorkerClient(lobbyConfig.gameID, gameConfig);
|
||||
const worker = new WorkerClient(
|
||||
lobbyConfig.gameID,
|
||||
gameConfig,
|
||||
lobbyConfig.clientID
|
||||
);
|
||||
await worker.initialize();
|
||||
const gameView = new GameView(
|
||||
worker,
|
||||
config,
|
||||
gameMap.gameMap,
|
||||
lobbyConfig.clientID,
|
||||
lobbyConfig.clientID
|
||||
);
|
||||
|
||||
consolex.log("going to init path finder");
|
||||
@@ -132,11 +136,11 @@ export async function createClientGame(
|
||||
canvas,
|
||||
gameView,
|
||||
eventBus,
|
||||
lobbyConfig.clientID,
|
||||
lobbyConfig.clientID
|
||||
);
|
||||
|
||||
consolex.log(
|
||||
`creating private game got difficulty: ${gameConfig.difficulty}`,
|
||||
`creating private game got difficulty: ${gameConfig.difficulty}`
|
||||
);
|
||||
|
||||
return new ClientGameRunner(
|
||||
@@ -146,7 +150,7 @@ export async function createClientGame(
|
||||
new InputHandler(canvas, eventBus),
|
||||
transport,
|
||||
worker,
|
||||
gameView,
|
||||
gameView
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,7 +168,7 @@ export class ClientGameRunner {
|
||||
private input: InputHandler,
|
||||
private transport: Transport,
|
||||
private worker: WorkerClient,
|
||||
private gameView: GameView,
|
||||
private gameView: GameView
|
||||
) {}
|
||||
|
||||
public start() {
|
||||
@@ -212,7 +216,7 @@ export class ClientGameRunner {
|
||||
}
|
||||
if (this.turnsSeen != message.turn.turnNumber) {
|
||||
consolex.error(
|
||||
`got wrong turn have turns ${this.turnsSeen}, received turn ${message.turn.turnNumber}`,
|
||||
`got wrong turn have turns ${this.turnsSeen}, received turn ${message.turn.turnNumber}`
|
||||
);
|
||||
} else {
|
||||
this.worker.sendTurn(message.turn);
|
||||
@@ -235,7 +239,7 @@ export class ClientGameRunner {
|
||||
}
|
||||
const cell = this.renderer.transformHandler.screenToWorldCoordinates(
|
||||
event.x,
|
||||
event.y,
|
||||
event.y
|
||||
);
|
||||
if (!this.gameView.isValidCoord(cell.x, cell.y)) {
|
||||
return;
|
||||
@@ -265,8 +269,8 @@ export class ClientGameRunner {
|
||||
this.eventBus.emit(
|
||||
new SendAttackIntentEvent(
|
||||
this.gameView.owner(tile).id(),
|
||||
this.myPlayer.troops() * this.renderer.uiState.attackRatio,
|
||||
),
|
||||
this.myPlayer.troops() * this.renderer.uiState.attackRatio
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user