From 799e1e9f8178c7ea716506335556b6886ea492a8 Mon Sep 17 00:00:00 2001 From: Isaac <62234577+Isaac0-dev@users.noreply.github.com> Date: Thu, 17 Mar 2022 18:20:56 +1000 Subject: [PATCH] Prevented debug binds from working with Discord (#34) --- src/game/mario.c | 11 ++++--- src/pc/controller/controller_keyboard_debug.c | 29 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/game/mario.c b/src/game/mario.c index 6f9373f3d..e95d58159 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -41,6 +41,7 @@ #include "pc/cheats.h" #include "pc/network/network.h" #include "pc/lua/smlua.h" +#include "pc/network/socket/socket.h" #include "pc/logfile.h" #ifdef BETTERCAMERA #include "bettercamera.h" @@ -1517,10 +1518,12 @@ void update_mario_inputs(struct MarioState *m) { /* Developer stuff */ #ifdef DEVELOPMENT - if (m->playerIndex == 0) { - if (m->action != ACT_DEBUG_FREE_MOVE && m->controller->buttonPressed & L_TRIG && m->controller->buttonDown & Z_TRIG) { - set_mario_action(m, ACT_DEBUG_FREE_MOVE, 0); - m->marioObj->oTimer = 0; + if (gNetworkSystem == &gNetworkSystemSocket) { + if (m->playerIndex == 0) { + if (m->action != ACT_DEBUG_FREE_MOVE && m->controller->buttonPressed & L_TRIG && m->controller->buttonDown & Z_TRIG) { + set_mario_action(m, ACT_DEBUG_FREE_MOVE, 0); + m->marioObj->oTimer = 0; + } } } #endif diff --git a/src/pc/controller/controller_keyboard_debug.c b/src/pc/controller/controller_keyboard_debug.c index 393ea1959..76e705b1e 100644 --- a/src/pc/controller/controller_keyboard_debug.c +++ b/src/pc/controller/controller_keyboard_debug.c @@ -13,6 +13,7 @@ #ifdef DEBUG #include "pc/lua/smlua.h" +#include "pc/network/socket/socket.h" static bool sHoldingAlt = false; @@ -82,24 +83,28 @@ static void debug_spawn_object(void) { } void debug_keyboard_on_key_down(int scancode) { - switch (scancode & 0xFF) { - case SCANCODE_ALT: sHoldingAlt = true; break; - case SCANCODE_3: debug_breakpoint_here(); break; + if (gNetworkSystem == &gNetworkSystemSocket) { + switch (scancode & 0xFF) { + case SCANCODE_ALT: sHoldingAlt = true; break; + case SCANCODE_3: debug_breakpoint_here(); break; #ifdef DEVELOPMENT - case SCANCODE_1: if (sHoldingAlt) { debug_warp_level1(); } break; - case SCANCODE_2: if (sHoldingAlt) { debug_warp_level2(); } break; - case SCANCODE_8: if (sHoldingAlt) { debug_spawn_object(); } break; - case SCANCODE_9: if (sHoldingAlt) { debug_warp_to(); } break; - case SCANCODE_0: if (sHoldingAlt) { debug_suicide(); } break; - case SCANCODE_F5: debug_reload_lua(); break; + case SCANCODE_1: if (sHoldingAlt) { debug_warp_level1(); } break; + case SCANCODE_2: if (sHoldingAlt) { debug_warp_level2(); } break; + case SCANCODE_8: if (sHoldingAlt) { debug_spawn_object(); } break; + case SCANCODE_9: if (sHoldingAlt) { debug_warp_to(); } break; + case SCANCODE_0: if (sHoldingAlt) { debug_suicide(); } break; + case SCANCODE_F5: debug_reload_lua(); break; #endif + } } } void debug_keyboard_on_key_up(int scancode) { - switch (scancode & 0xFF) { - case SCANCODE_ALT: sHoldingAlt = false; break; + if (gNetworkSystem == &gNetworkSystemSocket) { + switch (scancode & 0xFF) { + case SCANCODE_ALT: sHoldingAlt = false; break; + } } } -#endif \ No newline at end of file +#endif