From 8c41c1095dc297965d8914b95724a2ea7846b58b Mon Sep 17 00:00:00 2001 From: Govorunb Date: Wed, 12 Jun 2024 17:39:42 +1000 Subject: [PATCH] remove canSpawn we're queueing spawns in-game now it was also updating frontend too often, force-closing the modal every time (which is bad UX) --- ebs/src/modules/config.ts | 15 --------------- ebs/src/modules/game/connection.ts | 3 +-- ebs/src/modules/game/messages.game.ts | 10 +--------- ebs/src/modules/transactions.ts | 2 +- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/ebs/src/modules/config.ts b/ebs/src/modules/config.ts index 84d31aa..7ec44ca 100644 --- a/ebs/src/modules/config.ts +++ b/ebs/src/modules/config.ts @@ -35,10 +35,6 @@ function processConfig(data: Config) { if (!ingameState) { Object.values(config.redeems!) .forEach((redeem) => (redeem.disabled = true)); - } else if (!canSpawnState) { - Object.values(config.redeems!) - .filter(r => r.id.includes("spawn")) // if it works it works - .forEach((redeem) => (redeem.disabled = true)); } return config; } @@ -64,28 +60,17 @@ export async function broadcastConfigRefresh(config: Config) { } let ingameState: boolean = false; -let canSpawnState: boolean = false; export function isIngame() { return ingameState; } -export function canSpawn() { - return canSpawnState; -} - export function setIngame(newIngame: boolean) { if (ingameState == newIngame) return; ingameState = newIngame; setActiveConfig(configData!); } -export function setCanSpawn(newCanSpawn: boolean) { - if (canSpawnState == newCanSpawn) return; - canSpawnState = newCanSpawn; - setActiveConfig(configData!); -} - async function refreshConfig() { configData = await fetchConfig(); activeConfig = processConfig(configData); diff --git a/ebs/src/modules/game/connection.ts b/ebs/src/modules/game/connection.ts index f9bbb43..89dfa0f 100644 --- a/ebs/src/modules/game/connection.ts +++ b/ebs/src/modules/game/connection.ts @@ -4,7 +4,7 @@ import * as ServerWS from "ws"; import { v4 as uuid } from "uuid"; import { CommandInvocationSource, RedeemMessage, ServerMessage } from "./messages.server"; import { Cart, Redeem } from "common/types"; -import { setCanSpawn, setIngame } from "../config"; +import { setIngame } from "../config"; const VERSION = "0.1.0"; @@ -82,7 +82,6 @@ export class GameConnection { break; case MessageType.IngameStateChanged: setIngame(msg.ingame); - setCanSpawn(msg.canSpawn); break; default: this.logMessage(msg, `Unknown message type ${msg.messageType}`); diff --git a/ebs/src/modules/game/messages.game.ts b/ebs/src/modules/game/messages.game.ts index e61802b..ba93afd 100644 --- a/ebs/src/modules/game/messages.game.ts +++ b/ebs/src/modules/game/messages.game.ts @@ -31,14 +31,6 @@ export type ResultMessage = GameMessageBase & { export type IngameStateChangedMessage = GameMessageBase & { messageType: MessageType.IngameStateChanged, - // if false, commands that need Player.main will be disabled + // disable all redeems if false ingame: boolean, - // being on land or inside base/seatruck should disable spawns - canSpawn: boolean, } - -// export type CommandAvailabilityChangedMessage = GameMessageBase & { -// messageType: MessageType.CommandAvailabilityChanged, -// becameAvailable: string[], -// becameUnavailable: string[], -// } \ No newline at end of file diff --git a/ebs/src/modules/transactions.ts b/ebs/src/modules/transactions.ts index 64e98c1..3d3fdcf 100644 --- a/ebs/src/modules/transactions.ts +++ b/ebs/src/modules/transactions.ts @@ -249,7 +249,7 @@ app.post("/public/transaction", async (req, res) => { console.log(`[${resMsg.guid}] Redeem succeeded: ${JSON.stringify(resMsg)}`); let msg: string = "Your transaction was successful! Your redeem will appear on stream soon."; if (resMsg.message) { - msg += "\n" + resMsg.message; + msg += "\n\n" + resMsg.message; } res.status(200).send(msg); }