Skip to content

Commit

Permalink
remove canSpawn
Browse files Browse the repository at this point in the history
we're queueing spawns in-game now
it was also updating frontend too often, force-closing the modal every time (which is bad UX)
  • Loading branch information
Govorunb committed Jun 12, 2024
1 parent c11089d commit 8c41c10
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
15 changes: 0 additions & 15 deletions ebs/src/modules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions ebs/src/modules/game/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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}`);
Expand Down
10 changes: 1 addition & 9 deletions ebs/src/modules/game/messages.game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[],
// }
2 changes: 1 addition & 1 deletion ebs/src/modules/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8c41c10

Please sign in to comment.