From 25feb8f95fe6579ab50a474be6b6d560e7aeed37 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 16 Jul 2023 17:40:15 +0200 Subject: [PATCH 1/3] added input_disconnect_all --- src/corelib/input.c | 4 ++++ src/corelib/input.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/corelib/input.c b/src/corelib/input.c index ab769cc..bb99222 100644 --- a/src/corelib/input.c +++ b/src/corelib/input.c @@ -189,3 +189,7 @@ int input_get_mousedown(int mousebtn) { uint32_t mask = SDL_BUTTON(mousebtn); return (SDL_GetMouseState(NULL, NULL) & mask) != 0; } + +void input_disconnect_all() { + g_key_listeners_endptr = g_key_listeners; +} diff --git a/src/corelib/input.h b/src/corelib/input.h index 3cca76d..a219ddc 100644 --- a/src/corelib/input.h +++ b/src/corelib/input.h @@ -30,6 +30,8 @@ extern void input_init(); extern void update_input(); extern void input_notify_event(SDL_Event event); +extern void input_disconnect_all(); + #ifdef __cplusplus } #endif -- 2.34.1 From bd2e5cbcd0c602d9cf80c742c4cd77170dfe851e Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 16 Jul 2023 17:40:55 +0200 Subject: [PATCH 2/3] loading a scene now disconnects all input --- src/corelib/scene.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/scene.c b/src/corelib/scene.c index 61090c2..689fee9 100644 --- a/src/corelib/scene.c +++ b/src/corelib/scene.c @@ -1,6 +1,7 @@ #include "scene.h" #include "ctype.h" +#include "input.h" #include "stdint.h" #include "stddef.h" #include "stdlib.h" @@ -200,6 +201,7 @@ int _validate_scene(FILE* file) { void load_scene(const char* filename) { FILE* file = fopen(filename, "r"); if(_validate_scene(file)) { + input_disconnect_all(); world_clear(); _parse_scene(file); fclose(file); @@ -209,6 +211,7 @@ void load_scene(const char* filename) { void load_scene_additive(const char* filename) { FILE* file = fopen(filename, "r"); if(_validate_scene(file)) { + input_disconnect_all(); _parse_scene(file); fclose(file); } -- 2.34.1 From 415a0d5c97206eb8eb93df40c1b36b2b4ec6bac5 Mon Sep 17 00:00:00 2001 From: Sara Date: Sun, 16 Jul 2023 17:42:17 +0200 Subject: [PATCH 3/3] removed input_disconnect_all from load_scene_additive --- src/corelib/scene.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/scene.c b/src/corelib/scene.c index 689fee9..ec870f3 100644 --- a/src/corelib/scene.c +++ b/src/corelib/scene.c @@ -211,7 +211,6 @@ void load_scene(const char* filename) { void load_scene_additive(const char* filename) { FILE* file = fopen(filename, "r"); if(_validate_scene(file)) { - input_disconnect_all(); _parse_scene(file); fclose(file); } -- 2.34.1