From b158bee1e8b9567a503f04c77b0d035b44cbdae4 Mon Sep 17 00:00:00 2001 From: En Yi Date: Mon, 1 Jul 2024 20:48:48 +0800 Subject: [PATCH] Remove unused ActionResult There is only one focused scene at a time as part of the design limitation. Thus, it is no longer needed --- engine/engine.c | 4 ++-- engine/engine.h | 9 ++------- scene_man_test.c | 3 +-- scenes/editor_scene.c | 3 +-- scenes/game_scene.c | 3 +-- scenes/menu_scene.c | 3 +-- water_test.c | 3 +-- 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/engine/engine.c b/engine/engine.c index 8be7a07..2b36796 100644 --- a/engine/engine.c +++ b/engine/engine.c @@ -238,9 +238,9 @@ inline void render_scene(Scene_t* scene) EndDrawing(); } -inline ActionResult do_action(Scene_t* scene, ActionType_t action, bool pressed) +inline void do_action(Scene_t* scene, ActionType_t action, bool pressed) { - return scene->action_function(scene, action, pressed); + scene->action_function(scene, action, pressed); } void process_active_scene_inputs(GameEngine_t* engine) diff --git a/engine/engine.h b/engine/engine.h index fe791a6..e03b0a1 100644 --- a/engine/engine.h +++ b/engine/engine.h @@ -43,13 +43,8 @@ typedef struct GameEngine { #define SCENE_RENDER_BIT (1 << 1) // Whether to render #define SCENE_COMPLETE_ACTIVE (SCENE_ACTIVE_BIT | SCENE_RENDER_BIT) -typedef enum ActionResult { - ACTION_PROPAGATE = 0, - ACTION_CONSUMED, -} ActionResult; - typedef void(*system_func_t)(Scene_t*); -typedef ActionResult(*action_func_t)(Scene_t*, ActionType_t, bool); +typedef void(*action_func_t)(Scene_t*, ActionType_t, bool); sc_array_def(system_func_t, systems); typedef struct RenderLayer { @@ -102,7 +97,7 @@ void update_sfx_list(GameEngine_t* engine); // Inline functions, for convenience extern void update_scene(Scene_t* scene, float delta_time); extern void render_scene(Scene_t* scene); -extern ActionResult do_action(Scene_t* scene, ActionType_t action, bool pressed); +extern void do_action(Scene_t* scene, ActionType_t action, bool pressed); void init_scene(Scene_t* scene, action_func_t action_func); bool add_scene_layer(Scene_t* scene, int width, int height, Rectangle render_area); diff --git a/scene_man_test.c b/scene_man_test.c index 7def810..f242e78 100644 --- a/scene_man_test.c +++ b/scene_man_test.c @@ -65,7 +65,7 @@ static void print_number_sys(Scene_t* scene) } } -static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pressed) +static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed) { CPlayerState_t* p_playerstate; sc_map_foreach_value(&scene->ent_manager.component_map[CPLAYERSTATE_T], p_playerstate) @@ -96,7 +96,6 @@ static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pr default: break; } - return ACTION_PROPAGATE; } int main(void) diff --git a/scenes/editor_scene.c b/scenes/editor_scene.c index b7c86a3..9234f6f 100644 --- a/scenes/editor_scene.c +++ b/scenes/editor_scene.c @@ -797,7 +797,7 @@ static void restart_editor_level(Scene_t* scene) } } -static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pressed) +static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed) { LevelSceneData_t* data = &(CONTAINER_OF(scene, LevelScene_t, scene)->data); Entity_t* p_player; @@ -1002,7 +1002,6 @@ static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pr break; } } - return ACTION_PROPAGATE; } void init_sandbox_scene(LevelScene_t* scene) diff --git a/scenes/game_scene.c b/scenes/game_scene.c index b68ecdc..e78498a 100644 --- a/scenes/game_scene.c +++ b/scenes/game_scene.c @@ -45,7 +45,7 @@ static void level_scene_render_func(Scene_t* scene) EndTextureMode(); } -static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pressed) +static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed) { CPlayerState_t* p_playerstate; sc_map_foreach_value(&scene->ent_manager.component_map[CPLAYERSTATE_T], p_playerstate) @@ -96,7 +96,6 @@ static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pr break; } } - return ACTION_PROPAGATE; } static void render_regular_game_scene(Scene_t* scene) diff --git a/scenes/menu_scene.c b/scenes/menu_scene.c index 8979cb2..8faf61f 100644 --- a/scenes/menu_scene.c +++ b/scenes/menu_scene.c @@ -34,7 +34,7 @@ static void exec_component_function(Scene_t* scene, int sel) } } -static ActionResult menu_do_action(Scene_t* scene, ActionType_t action, bool pressed) +static void menu_do_action(Scene_t* scene, ActionType_t action, bool pressed) { MenuSceneData_t* data = &(CONTAINER_OF(scene, MenuScene_t, scene)->data); unsigned int new_selection = data->selected_comp; @@ -83,7 +83,6 @@ static ActionResult menu_do_action(Scene_t* scene, ActionType_t action, bool pre exec_component_function(scene, data->selected_comp); } } - return ACTION_PROPAGATE; } static void gui_loop(Scene_t* scene) diff --git a/water_test.c b/water_test.c index b3dbe3d..31637dd 100644 --- a/water_test.c +++ b/water_test.c @@ -343,7 +343,7 @@ static void toggle_block_system(Scene_t* scene) } } -static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pressed) +static void level_do_action(Scene_t* scene, ActionType_t action, bool pressed) { CPlayerState_t* p_playerstate; sc_map_foreach_value(&scene->ent_manager.component_map[CPLAYERSTATE_T], p_playerstate) @@ -377,7 +377,6 @@ static ActionResult level_do_action(Scene_t* scene, ActionType_t action, bool pr default: break; } - return ACTION_PROPAGATE; } static void player_simple_movement_system(Scene_t* scene)