From 265a3c6b03d0790220a71aa23559c043a68ccf5e Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Mon, 10 Apr 2023 10:31:45 -0700 Subject: [PATCH] Hopefully fix 3 crashes (#341) * Hopefully fix 3 crashes --- src/game/area.c | 4 ++++ src/pc/network/packets/packet_download.c | 5 +++++ src/pc/network/packets/packet_mod_list.c | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/game/area.c b/src/game/area.c index f66dc314..3401634b 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -161,6 +161,10 @@ u32 get_mario_spawn_type(struct Object *o) { } struct ObjectWarpNode *area_get_warp_node(u8 id) { + if (gCurrentArea == NULL || gCurrentArea->warpNodes == NULL) { + return NULL; + } + struct ObjectWarpNode *node = NULL; for (node = gCurrentArea->warpNodes; node != NULL; node = node->next) { diff --git a/src/pc/network/packets/packet_download.c b/src/pc/network/packets/packet_download.c index e418c877..03cdef9f 100644 --- a/src/pc/network/packets/packet_download.c +++ b/src/pc/network/packets/packet_download.c @@ -332,6 +332,11 @@ static void open_mod_file(struct Mod* mod, struct ModFile* file) { } void network_receive_download(struct Packet* p) { + if (p == NULL) { + LOG_ERROR("Received null packet"); + return; + } + SOFT_ASSERT(gNetworkType == NT_CLIENT); if (p->localIndex != UNKNOWN_LOCAL_INDEX) { if (gNetworkPlayerServer == NULL || gNetworkPlayerServer->localIndex != p->localIndex) { diff --git a/src/pc/network/packets/packet_mod_list.c b/src/pc/network/packets/packet_mod_list.c index 92fe88b2..dfe32c5e 100644 --- a/src/pc/network/packets/packet_mod_list.c +++ b/src/pc/network/packets/packet_mod_list.c @@ -28,7 +28,10 @@ void network_send_mod_list_request(void) { } void network_receive_mod_list_request(UNUSED struct Packet* p) { - SOFT_ASSERT(gNetworkType == NT_SERVER); + if (gNetworkType != NT_SERVER) { + LOG_ERROR("Network type should be server!"); + return; + } LOG_INFO("received mod list request"); network_send_mod_list();