From 2ef4c12157e4da37299eebe088c68395558885d5 Mon Sep 17 00:00:00 2001 From: kottochii <106819117+kottochii@users.noreply.github.com> Date: Wed, 26 Aug 2026 14:04:17 +1000 Subject: [PATCH 1/3] fix: SEGFAULT when player moves in Below The Surface --- games/BelowTheSurface/player.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/games/BelowTheSurface/player.h b/games/BelowTheSurface/player.h index 76bff091..41457fd5 100644 --- a/games/BelowTheSurface/player.h +++ b/games/BelowTheSurface/player.h @@ -532,24 +532,24 @@ void IdleState::get_input() this->player->set_facing_left(true); this->player->change_state(new RunState(0), "RunLeft"); } - if (key_down(player->input.right_key)) + else if (key_down(player->input.right_key)) { this->player->set_facing_left(false); this->player->change_state(new RunState(0), "RunRight"); } - if ((key_typed(player->input.jump_key) || key_typed(player->input.jump_key2)) && player->is_on_floor()) + else if ((key_typed(player->input.jump_key) || key_typed(player->input.jump_key2)) && player->is_on_floor()) { this->player->change_state(new JumpRiseState, "JumpRise"); } - if (key_typed(Z_KEY)) + else if (key_typed(Z_KEY)) { this->player->change_state(new DanceState, "Dance"); } - if (key_typed(player->input.attack_key)) + else if (key_typed(player->input.attack_key)) { this->player->change_state(new AttackState, "Attack"); } - if (key_down(player->input.crouch_key)) + else if (key_down(player->input.crouch_key)) { this->player->change_state(new CrouchState, "Crouch"); } @@ -603,7 +603,7 @@ void RunState::get_input() { this->player->change_state(new IdleState, "Idle"); } - if ((key_typed(player->input.jump_key) || key_typed(player->input.jump_key2)) && player->is_on_floor()) + else if ((key_typed(player->input.jump_key) || key_typed(player->input.jump_key2)) && player->is_on_floor()) { this->player->change_state(new JumpRiseState, "JumpRise"); } @@ -648,7 +648,7 @@ void JumpRiseState::get_input() if (sprite_dx(player->get_player_sprite()) > -MAX_RUN_SPEED) sprite_set_dx(player->get_player_sprite(), sprite_dx(player->get_player_sprite()) - RUN_ACCEL); } - if (key_down(player->input.right_key)) + else if (key_down(player->input.right_key)) { if (sprite_dx(player->get_player_sprite()) < MAX_RUN_SPEED) sprite_set_dx(player->get_player_sprite(), sprite_dx(player->get_player_sprite()) + RUN_ACCEL); @@ -881,6 +881,7 @@ void ClimbState::get_input() { this->player->change_state(new IdleState, "Idle"); } + return; // to avoid SEGFAULT when this->player is lost after change_state } if (key_released(player->input.jump_key) || key_released(player->input.jump_key2) || key_released(player->input.crouch_key)) { From a276584bf8667b61565a47b81b9b74be666c9a63 Mon Sep 17 00:00:00 2001 From: kottochii <106819117+kottochii@users.noreply.github.com> Date: Wed, 26 Aug 2026 15:00:00 +1000 Subject: [PATCH 2/3] fix: SEGFAULT at GameOver --- games/BelowTheSurface/screen.h | 1 + 1 file changed, 1 insertion(+) diff --git a/games/BelowTheSurface/screen.h b/games/BelowTheSurface/screen.h index 1567231b..1d754689 100644 --- a/games/BelowTheSurface/screen.h +++ b/games/BelowTheSurface/screen.h @@ -812,6 +812,7 @@ void LevelScreen::update() this->screen->level_number = 1; this->screen->current_level = get_next_level(this->screen->level_number,this->screen->get_cell_sheets(),this->screen->get_tile_size(),this->screen->get_players()); this->screen->change_state(new GameOverScreen, "GameOver"); + return; // prevents SEGFAULT after change_state } } From 8aaaee1dc21487042d598744c60594fb18ac92a9 Mon Sep 17 00:00:00 2001 From: kottochii <106819117+kottochii@users.noreply.github.com> Date: Wed, 26 Aug 2026 21:17:29 +1000 Subject: [PATCH 3/3] same problem on one of the loading screens --- games/BelowTheSurface/screen.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/games/BelowTheSurface/screen.h b/games/BelowTheSurface/screen.h index 1d754689..a204a5e2 100644 --- a/games/BelowTheSurface/screen.h +++ b/games/BelowTheSurface/screen.h @@ -434,7 +434,10 @@ void CompanyIntroScreen::update() alpha = screen_effect(alpha, screen_time, "ScreenTimer", 2); if(time_up) + { this->screen->change_state(new TeamIntroScreen, "TeamIntro"); + return; // prevents SEGFAULT + } if(key_typed(RETURN_KEY) || key_typed(screen->input_key)) {