From c076c90b3b25a0fe8ddcd200bf9f6942393468b9 Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Tue, 8 Aug 2023 03:33:43 +0000 Subject: [PATCH] fix: make creategame button work --- services/client/definitions/global.d.ts | 2 +- services/client/src/index.tsx | 7 ++++--- services/game/src/engine/client.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/services/client/definitions/global.d.ts b/services/client/definitions/global.d.ts index 4c9786c4f..7cdc59dc4 100644 --- a/services/client/definitions/global.d.ts +++ b/services/client/definitions/global.d.ts @@ -110,7 +110,7 @@ type ModuleType = { } cluster: { - createGame: (name: string) => void + createGame: (preset: string, mode: string) => void connect: (name: string, password: string) => void send: (channel: number, dataPtr: number, dataLength: number) => void receive: (dataPtr: number, dataLengthPtr: number) => void diff --git a/services/client/src/index.tsx b/services/client/src/index.tsx index 06b187ad9..061f6a6ab 100644 --- a/services/client/src/index.tsx +++ b/services/client/src/index.tsx @@ -417,7 +417,7 @@ function App() { guibar ] [ ${CONFIG.menuOptions} - guibutton "create private game..." "creategame ffa mood" + guibutton "create private game..." "creategame ffa" ] guibutton "random map.." "map random" guibutton "server browser.." "showgui servers" @@ -702,11 +702,12 @@ function App() { } Module.cluster = { - createGame: (preset: string) => { + createGame: (preset: string, mode: string) => { log.info('creating private game...') ;(async () => { try { - const result = await runCommand('creategame') + console.log(`creategame ${preset} ${mode}`); + const result = await runCommand(`creategame ${preset} ${mode}`) log.success('created game!') } catch (e) { log.error(`failed to create private game: ${e}`) diff --git a/services/game/src/engine/client.cpp b/services/game/src/engine/client.cpp index 9991bb8ba..6acdc42fc 100644 --- a/services/game/src/engine/client.cpp +++ b/services/game/src/engine/client.cpp @@ -124,13 +124,13 @@ void leave(bool async, bool cleanup) mainmenu = 1; } -void createsourgame(const char *presetname) +void createsourgame(const char *presetname, const char *modename) { EM_ASM({ - Module.cluster.createGame(UTF8ToString($0)) - }, presetname); + Module.cluster.createGame(UTF8ToString($0), UTF8ToString($1)) + }, presetname, modename); } -ICOMMAND(creategame, "s", (char *presetname), createsourgame(presetname)); +ICOMMAND(creategame, "ss", (char *presetname, char *modename), createsourgame(presetname, modename)); void tryleave(bool local) {