diff --git a/src/pc/djui/djui_panel_host_message.c b/src/pc/djui/djui_panel_host_message.c index 491386c7..22269efa 100644 --- a/src/pc/djui/djui_panel_host_message.c +++ b/src/pc/djui/djui_panel_host_message.c @@ -4,6 +4,7 @@ #include "src/pc/network/discord/discord.h" #include "src/pc/utils/misc.h" #include "src/pc/configfile.h" +#include "pc/utils/misc.h" #ifdef DISCORD_SDK static char* sWarningDiscord = "\ @@ -25,6 +26,7 @@ void djui_panel_host_message_do_host(struct DjuiBase* caller) { djui_panel_shutdown(); extern s16 gCurrSaveFileNum; gCurrSaveFileNum = configHostSaveSlot; + update_all_mario_stars(); #ifndef DISCORD_SDK configNetworkSystem = 1; network_set_system(NS_SOCKET); diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index e0c366e5..6db81996 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -15,6 +15,7 @@ #include "pc/utils/string_builder.h" //#define DISABLE_MODULE_LOG 1 #include "pc/debuglog.h" +#include "pc/utils/misc.h" extern u8* gOverrideEeprom; static u8 eeprom[512] = { 0 }; @@ -183,6 +184,7 @@ void network_receive_join(struct Packet* p) { save_file_load_all(TRUE); djui_panel_shutdown(); + update_all_mario_stars(); extern s16 gChangeLevel; gChangeLevel = 16; } diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index 8314a4ad..3917583d 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -1,8 +1,21 @@ +#include #include "misc.h" +#include "course_table.h" +#include "game/area.h" +#include "game/level_update.h" +#include "game/save_file.h" + float smoothstep(float edge0, float edge1, float x) { float t = (x - edge0) / (edge1 - edge0); if (t < 0) { t = 0; } if (t > 1) { t = 1; } return t * t * (3.0 - 2.0 * t); +} + +void update_all_mario_stars(void) { + s32 numStars = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1); + for (int i = 0; i < MAX_PLAYERS; i++) { + gMarioStates[i].numStars = numStars; + } } \ No newline at end of file diff --git a/src/pc/utils/misc.h b/src/pc/utils/misc.h index d69b77d1..75f8602e 100644 --- a/src/pc/utils/misc.h +++ b/src/pc/utils/misc.h @@ -2,5 +2,6 @@ #define UTILS_MISC_H float smoothstep(float edge0, float edge1, float x); +void update_all_mario_stars(void); #endif \ No newline at end of file