From 3fb3cbe1f12b38c0773f11d87343a59fd5ddaf44 Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 3 May 2022 22:01:06 -0700 Subject: [PATCH 1/6] Possible fix for snow crash --- src/game/envfx_snow.c | 2 +- src/pc/mods/mod_cache.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game/envfx_snow.c b/src/game/envfx_snow.c index 23cba4d2..85b5e9f0 100644 --- a/src/game/envfx_snow.c +++ b/src/game/envfx_snow.c @@ -438,7 +438,7 @@ Gfx *envfx_update_snow_internal(s32 snowMode, Vec3s marioPos, Vec3s camFrom, Vec vertex2 = gSnowFlakeVertex2; vertex3 = gSnowFlakeVertex3; - if (interpolated) { + if (interpolated && sSnowGfxPos) { gfxStart = sSnowGfxPos; } else { gfxStart = (Gfx *) alloc_display_list((gSnowParticleCount * 6 + 3) * sizeof(Gfx)); diff --git a/src/pc/mods/mod_cache.c b/src/pc/mods/mod_cache.c index d604d59b..f1000ae7 100644 --- a/src/pc/mods/mod_cache.c +++ b/src/pc/mods/mod_cache.c @@ -4,6 +4,7 @@ #include "mods.h" #include "mod.h" #include "mods_utils.h" +#define DISABLE_MODULE_LOG 1 #include "pc/debuglog.h" #include "pc/utils/md5.h" From 8e01c6e4ef1c9192ba391e834fc7c20a3330ad92 Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 3 May 2022 22:08:30 -0700 Subject: [PATCH 2/6] Add null checks to initiate_delayed_warp() --- src/game/level_update.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/game/level_update.c b/src/game/level_update.c index 824cfbdf..4b8865c2 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -975,7 +975,7 @@ void initiate_delayed_warp(void) { if ((gCurrCreditsEntry != NULL) && (gCurrCreditsEntry->levelNum == gLevelValues.skipCreditsAt)) { lvl_skip_credits(); - } else { + } else if (gCurrCreditsEntry != NULL) { // instance players in the credits gCurrActStarNum = 99; gCurrActNum = 99; @@ -991,7 +991,7 @@ void initiate_delayed_warp(void) { if ((gCurrCreditsEntry != NULL) && (gCurrCreditsEntry->levelNum == gLevelValues.skipCreditsAt)) { lvl_skip_credits(); - } else { + } else if (gCurrCreditsEntry != NULL) { gCurrActNum = gCurrCreditsEntry->unk02 & 0x07; if ((gCurrCreditsEntry + 1)->levelNum == LEVEL_NONE) { destWarpNode = WARP_NODE_CREDITS_END; @@ -1006,12 +1006,14 @@ void initiate_delayed_warp(void) { default: warpNode = area_get_warp_node(sSourceWarpNodeId); - initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea, - warpNode->node.destNode, sDelayedWarpArg); + if (warpNode != NULL) { + initiate_warp(warpNode->node.destLevel & 0x7F, warpNode->node.destArea, + warpNode->node.destNode, sDelayedWarpArg); - check_if_should_set_warp_checkpoint(&warpNode->node); - if (sWarpDest.type != WARP_TYPE_CHANGE_LEVEL) { - level_set_transition(2, NULL); + check_if_should_set_warp_checkpoint(&warpNode->node); + if (sWarpDest.type != WARP_TYPE_CHANGE_LEVEL) { + level_set_transition(2, NULL); + } } break; } From 63a30f7838a80c77aa4dce6631eb5e5e354fae7c Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 3 May 2022 22:11:44 -0700 Subject: [PATCH 3/6] Possible fix for crash in gfx_texture_cache_lookup() --- src/pc/gfx/gfx_pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index b3447c0a..0238b8be 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -308,7 +308,7 @@ static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, co } node = &(*node)->next; } - if (gfx_texture_cache.pool_pos == sizeof(gfx_texture_cache.pool) / sizeof(struct TextureHashmapNode)) { + if (gfx_texture_cache.pool_pos >= sizeof(gfx_texture_cache.pool) / sizeof(struct TextureHashmapNode)) { // Pool is full. We just invalidate everything and start over. gfx_texture_cache.pool_pos = 0; node = &gfx_texture_cache.hashmap[hash]; From 3a2bcd8c25b27e20b134354dc7ef054800da41c2 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 4 May 2022 05:50:30 -0700 Subject: [PATCH 4/6] Another possible fix for snow crash --- src/game/envfx_snow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/envfx_snow.c b/src/game/envfx_snow.c index 85b5e9f0..93eff5ff 100644 --- a/src/game/envfx_snow.c +++ b/src/game/envfx_snow.c @@ -431,7 +431,7 @@ Gfx *envfx_update_snow_internal(s32 snowMode, Vec3s marioPos, Vec3s camFrom, Vec s16 radius, pitch, yaw; Vec3s snowCylinderPos; struct SnowFlakeVertex vertex1, vertex2, vertex3; - Gfx *gfxStart; + Gfx *gfxStart = NULL; Gfx *gfx; vertex1 = gSnowFlakeVertex1; From bb8d84623742acd94782b274724ad1f159ca38e4 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 4 May 2022 06:00:46 -0700 Subject: [PATCH 5/6] Possible fix for crash handler --- src/pc/crash_handler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pc/crash_handler.c b/src/pc/crash_handler.c index 82c51ab2..dae4b77f 100644 --- a/src/pc/crash_handler.c +++ b/src/pc/crash_handler.c @@ -120,6 +120,9 @@ void render_create_dl_ortho_matrix() { } static void crash_handler_produce_one_frame() { + extern u8 gRenderingInterpolated; + gRenderingInterpolated = false; + // Start frame gfx_start_frame(); load_gfx_memory_pool(); From 7320883fb477ea4b95a674bb9936c90b0f0ca9bd Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 4 May 2022 06:26:40 -0700 Subject: [PATCH 6/6] Another snow crash fix --- src/game/envfx_snow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/envfx_snow.c b/src/game/envfx_snow.c index 93eff5ff..f48cd90d 100644 --- a/src/game/envfx_snow.c +++ b/src/game/envfx_snow.c @@ -455,7 +455,9 @@ Gfx *envfx_update_snow_internal(s32 snowMode, Vec3s marioPos, Vec3s camFrom, Vec return NULL; } - envfx_update_snowflake_count(snowMode, marioPos); + if (!interpolated) { + envfx_update_snowflake_count(snowMode, marioPos); + } // Note: to and from are inverted here, so the resulting vector goes towards the camera orbit_from_positions(camTo, camFrom, &radius, &pitch, &yaw);