From 22121eea6b0a44f6736bfcae8138a97b22d232e6 Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 10 Aug 2021 22:25:34 -0700 Subject: [PATCH] Fixed loading of certain save flags, e.g. lakitu --- src/game/level_update.c | 16 ++++++++++++++++ src/game/level_update.h | 2 ++ src/pc/djui/djui_panel_host_message.c | 2 ++ src/pc/network/packets/packet_join.c | 3 +++ 4 files changed, 23 insertions(+) diff --git a/src/game/level_update.c b/src/game/level_update.c index a1270026..51f6ca3c 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1443,3 +1443,19 @@ s32 lvl_exiting_credits(UNUSED s16 arg0, UNUSED s32 arg1) { gCurrActNum = 0; return 1; } + +void fake_lvl_init_from_save_file(void) { + sWarpDest.type = WARP_TYPE_NOT_WARPING; + sDelayedWarpOp = WARP_OP_NONE; + gShouldNotPlayCastleMusic = !save_file_exists(gCurrSaveFileNum - 1) && gServerSettings.skipIntro; + if (gNetworkType == NT_NONE) { gShouldNotPlayCastleMusic = true; } + + gCurrCreditsEntry = NULL; + gSpecialTripleJump = 0; + + init_mario_from_save_file(); + disable_warp_checkpoint(); + save_file_move_cap_to_default_location(); + select_mario_cam_mode(); + set_yoshi_as_not_dead(); +} \ No newline at end of file diff --git a/src/game/level_update.h b/src/game/level_update.h index b9077bcc..977456bb 100644 --- a/src/game/level_update.h +++ b/src/game/level_update.h @@ -155,4 +155,6 @@ void star_select_finish_selection(void); s32 lvl_exiting_credits(UNUSED s16 arg0, UNUSED s32 arg1); +void fake_lvl_init_from_save_file(void); + #endif // LEVEL_UPDATE_H diff --git a/src/pc/djui/djui_panel_host_message.c b/src/pc/djui/djui_panel_host_message.c index 22269efa..ae1ebc10 100644 --- a/src/pc/djui/djui_panel_host_message.c +++ b/src/pc/djui/djui_panel_host_message.c @@ -5,6 +5,7 @@ #include "src/pc/utils/misc.h" #include "src/pc/configfile.h" #include "pc/utils/misc.h" +#include "src/game/level_update.h" #ifdef DISCORD_SDK static char* sWarningDiscord = "\ @@ -38,6 +39,7 @@ void djui_panel_host_message_do_host(struct DjuiBase* caller) { } #endif network_init(NT_SERVER); + fake_lvl_init_from_save_file(); extern s16 gChangeLevel; gChangeLevel = 16; } diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index db15aa0b..559d3706 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -7,6 +7,7 @@ #include "src/game/interaction.h" #include "src/engine/math_util.h" #include "src/game/save_file.h" +#include "src/game/level_update.h" #include "src/pc/fs/fs.h" #include "PR/os_eeprom.h" #include "pc/network/version.h" @@ -208,6 +209,8 @@ void network_receive_join(struct Packet* p) { djui_panel_shutdown(); update_all_mario_stars(); + + fake_lvl_init_from_save_file(); extern s16 gChangeLevel; gChangeLevel = 16; }