From 326dc43326a38e5859d32915526758c7999f132e Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Fri, 5 May 2023 06:26:50 +1000 Subject: [PATCH] fix some crashes and bugs (#381) - fix crash in bhv_lll_bowser_puzzle_piece_update (thanks to djoslin) - fix crash in platform_on_track_act_init - fix chat commands not working on dev builds - log when the crash handler is called - if a custom level tries to set an invalid background, change it to BACKGROUND_OCEAN_SKY --- src/dev/chat.c | 2 ++ src/engine/graph_node.c | 7 +++++++ src/game/behaviors/platform_on_track.inc.c | 2 ++ src/pc/crash_handler.c | 2 ++ 4 files changed, 13 insertions(+) diff --git a/src/dev/chat.c b/src/dev/chat.c index 54757ac5..1409e35d 100644 --- a/src/dev/chat.c +++ b/src/dev/chat.c @@ -112,6 +112,8 @@ bool exec_dev_chat_command(char* command) { smlua_exec_file(&command[6]); return true; } + + return false; } void dev_display_chat_commands(void) { diff --git a/src/engine/graph_node.c b/src/engine/graph_node.c index 0af6661f..c6426d62 100644 --- a/src/engine/graph_node.c +++ b/src/engine/graph_node.c @@ -8,6 +8,8 @@ #include "game/rendering_graph_node.h" #include "game/area.h" #include "geo_layout.h" +#include "include/geo_commands.h" +#include "pc/debuglog.h" // unused Mtx(s) s16 identityMtx[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; @@ -486,6 +488,11 @@ struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *poo if (graphNode != NULL) { init_scene_graph_node_links(&graphNode->fnNode.node, GRAPH_NODE_TYPE_BACKGROUND); + if (background > BACKGROUND_CUSTOM) { + LOG_ERROR("invalid background id"); + background = BACKGROUND_OCEAN_SKY; + } + graphNode->background = (background << 16) | background; graphNode->fnNode.func = backgroundFunc; graphNode->unused = zero; // always 0, unused diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c index 31bf4a27..7413c102 100644 --- a/src/game/behaviors/platform_on_track.inc.c +++ b/src/game/behaviors/platform_on_track.inc.c @@ -315,6 +315,8 @@ static void platform_on_track_rock_ski_lift(void) { * Update function for bhvPlatformOnTrack. */ void bhv_platform_on_track_update(void) { + if (!o->oPlatformOnTrackStartWaypoint) { return; } + switch (o->oAction) { case PLATFORM_ON_TRACK_ACT_INIT: platform_on_track_act_init(); diff --git a/src/pc/crash_handler.c b/src/pc/crash_handler.c index aaa58032..405db830 100644 --- a/src/pc/crash_handler.c +++ b/src/pc/crash_handler.c @@ -24,6 +24,7 @@ #include "pc/network/network.h" #include "pc/gfx/gfx_rendering_api.h" #include "pc/mods/mods.h" +#include "pc/debuglog.h" typedef struct { s32 x, y; @@ -298,6 +299,7 @@ static CRASH_HANDLER_TYPE crash_handler(EXCEPTION_POINTERS *ExceptionInfo) { #elif __linux__ static void crash_handler(const int signalNum, siginfo_t *info, ucontext_t *context) { #endif + LOG_INFO("game crashed! preparing crash screen..."); memset(sCrashHandlerText, 0, sizeof(sCrashHandlerText)); CrashHandlerText *pText = &sCrashHandlerText[0]; gDjuiDisabled = true;