Updated star count on host/join

This commit is contained in:
MysterD 2021-08-01 13:40:31 -07:00
parent 7a61c61051
commit 05432c692a
4 changed files with 18 additions and 0 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -1,8 +1,21 @@
#include <PR/ultratypes.h>
#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;
}
}

View file

@ -2,5 +2,6 @@
#define UTILS_MISC_H
float smoothstep(float edge0, float edge1, float x);
void update_all_mario_stars(void);
#endif