reset mario state on player disconnect (#44)

fixes some mod related bugs
This commit is contained in:
Isaac0-dev 2024-05-14 10:12:20 +10:00 committed by GitHub
parent eaa1a59996
commit 2f5b0c4880
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View file

@ -123,7 +123,7 @@ s16 set_character_animation(struct MarioState *m, s32 targetAnimID) {
struct Animation *targetAnim = m->animation->targetAnim;
s32 charAnimID = get_character_anim(m, targetAnimID);
if (!targetAnim) { return 0; }
if (load_patchable_table(m->animation, charAnimID)) {
targetAnim->values = (void *) VIRTUAL_TO_PHYSICAL((u8 *) targetAnim + (uintptr_t) targetAnim->values);
targetAnim->index = (void *) VIRTUAL_TO_PHYSICAL((u8 *) targetAnim + (uintptr_t) targetAnim->index);
@ -2379,7 +2379,7 @@ void init_mario(void) {
}
}
static void init_mario_single_from_save_file(struct MarioState* m, u16 index) {
void init_mario_single_from_save_file(struct MarioState* m, u16 index) {
if (!m) { return; }
m->playerIndex = index;
m->flags = 0;

View file

@ -64,6 +64,7 @@ s32 execute_mario_action(UNUSED struct Object *o);
s32 force_idle_state(struct MarioState* m);
void init_single_mario(struct MarioState* m);
void init_mario(void);
void init_mario_single_from_save_file(struct MarioState* m, u16 index);
void init_mario_from_save_file(void);
void set_mario_particle_flags(struct MarioState* m, u32 flags, u8 clear);
void mario_update_wall(struct MarioState* m, struct WallCollisionData* wcd);

View file

@ -15,6 +15,7 @@
#ifdef DISCORD_SDK
#include "pc/discord/discord.h"
#endif
#include "game/mario.h"
struct NetworkPlayer gNetworkPlayers[MAX_PLAYERS] = { 0 };
struct NetworkPlayer *gNetworkPlayerLocal = NULL;
@ -374,6 +375,9 @@ u8 network_player_disconnected(u8 globalIndex) {
discord_activity_update();
#endif
// reset mario state
init_mario_single_from_save_file(&gMarioStates[i], i);
return i;
}
return UNKNOWN_GLOBAL_INDEX;