Skip to content

Commit

Permalink
fix: make creategame button work
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Aug 8, 2023
1 parent b9d91b7 commit c076c90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion services/client/definitions/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions services/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}`)
Expand Down
8 changes: 4 additions & 4 deletions services/game/src/engine/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit c076c90

Please sign in to comment.