From f0157d8c01252ebcdd238ea2c42b3cce4531bac3 Mon Sep 17 00:00:00 2001 From: Delilah Hoare Date: Tue, 28 Jun 2022 23:38:51 +1000 Subject: [PATCH 1/2] Ensure functions always return a value This prevents compiler warnings and segfaults when compiled with recent GCC. --- src/ap_maps.cpp | 1 + src/ap_play.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ap_maps.cpp b/src/ap_maps.cpp index 8e41b79..74e6258 100644 --- a/src/ap_maps.cpp +++ b/src/ap_maps.cpp @@ -224,6 +224,7 @@ int MapPack::set_currentlevel(int newlvl) { return -1; // the map pack is over, we don't load any map load_map(); + return 0; } void MapPack::reload_level() { diff --git a/src/ap_play.cpp b/src/ap_play.cpp index 4ebbf56..6f228ff 100644 --- a/src/ap_play.cpp +++ b/src/ap_play.cpp @@ -936,6 +936,7 @@ int play_level(MapPack &mappack) { if (!game.still_alive()) return 2; if (game.has_won()) return 3; + return 0; } From 7817f5c10b715ad44161fff998367aa449591d16 Mon Sep 17 00:00:00 2001 From: Delilah Hoare Date: Tue, 28 Jun 2022 23:40:50 +1000 Subject: [PATCH 2/2] Add a zero terminator to key_table processevent() expects this. This prevents the game from hanging on input when compiled with recent Clang. --- src/ap_input.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ap_input.cpp b/src/ap_input.cpp index 177ae45..ad45675 100644 --- a/src/ap_input.cpp +++ b/src/ap_input.cpp @@ -125,8 +125,9 @@ static struct {SDLK_KP7, TRUE, '7', '7', CTL_PAD7, ALT_PAD7}, {SDLK_KP8, TRUE, '8', '8', CTL_PAD8, ALT_PAD8}, {SDLK_KP9, TRUE, '9', '9', CTL_PAD9, ALT_PAD9}, - {SDLK_WORLD_0,0,0,0,0}, - {SDLK_SPACE, FALSE, ' ', ' ', ' ', ' '} + {SDLK_WORLD_0,FALSE,0,0,0,0}, + {SDLK_SPACE, FALSE, ' ', ' ', ' ', ' '}, + {SDLK_UNKNOWN,FALSE,0,0,0,0} }; #endif