Fixed glitchy animations on remote when in dialog

This commit is contained in:
MysterD 2020-09-08 09:33:55 -07:00
parent cc550e1de5
commit 29cb0935fb
7 changed files with 26 additions and 19 deletions

View file

@ -369,6 +369,7 @@ struct MarioState
/*0xCA*/ struct Object* heldByObj; /*0xCA*/ struct Object* heldByObj;
/*????*/ u8 isSnoring; /*????*/ u8 isSnoring;
/*????*/ struct Object* bubbleObj; /*????*/ struct Object* bubbleObj;
/*????*/ u8 freeze;
}; };
#define PLAY_MODE_NORMAL 0 #define PLAY_MODE_NORMAL 0

View file

@ -93,8 +93,6 @@ struct OpenableGrill {
const Collision *collision; const Collision *collision;
}; };
extern u16 gFreezeMario;
s32 D_8032F0C0[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP }; s32 D_8032F0C0[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP };
// Boo Roll // Boo Roll

View file

@ -84,7 +84,7 @@ void bhv_spawned_star_loop(void) {
if (o->oTimer == 0) { if (o->oTimer == 0) {
if (nearest_mario_state_to_object(o) == &gMarioStates[0]) { if (nearest_mario_state_to_object(o) == &gMarioStates[0]) {
cutscene_object(CUTSCENE_STAR_SPAWN, o); cutscene_object(CUTSCENE_STAR_SPAWN, o);
gFreezeMario = 1000; gMarioStates[0].freeze = 200;
} }
//set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); //set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
//o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; //o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
@ -126,7 +126,7 @@ void bhv_spawned_star_loop(void) {
spawn_object(o, MODEL_NONE, bhvSparkleSpawn); spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
} else if (o->oAction == 2) { } else if (o->oAction == 2) {
if (gCamera->cutscene == 0 && gRecentCutscene == 0) { if (gCamera->cutscene == 0 && gRecentCutscene == 0) {
gFreezeMario = 0; gMarioStates[0].freeze = 0;
clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oAction++; o->oAction++;

View file

@ -47,7 +47,7 @@ void bhv_star_spawn_init(void) {
cutscene_object(CUTSCENE_STAR_SPAWN, o); cutscene_object(CUTSCENE_STAR_SPAWN, o);
else else
cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o); cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o);
gFreezeMario = 1000; gMarioStates[0].freeze = 200;
} }
//set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); //set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
@ -99,7 +99,7 @@ void bhv_star_spawn_loop(void) {
case 3: case 3:
o->oFaceAngleYaw += 0x800; o->oFaceAngleYaw += 0x800;
if (o->oTimer == 20) { if (o->oTimer == 20) {
gFreezeMario = 0; gMarioStates[0].freeze = 0;
gObjCutsceneDone = TRUE; gObjCutsceneDone = TRUE;
clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;

View file

@ -47,8 +47,6 @@
#define MAX_HANG_PREVENTION 64 #define MAX_HANG_PREVENTION 64
u16 gFreezeMario = 0;
u32 unused80339F10; u32 unused80339F10;
s8 filler80339F1C[20]; s8 filler80339F1C[20];
@ -1452,7 +1450,7 @@ void update_mario_inputs(struct MarioState *m) {
m->particleFlags = 0; m->particleFlags = 0;
if (m->playerIndex == 0) { m->input = 0; } if (m->playerIndex == 0) { m->input = 0; }
u8 localIsPaused = (m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED); u8 localIsPaused = (m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED || m->freeze > 0);
m->collidedObjInteractTypes = m->marioObj->collidedObjInteractTypes; m->collidedObjInteractTypes = m->marioObj->collidedObjInteractTypes;
m->flags &= 0xFFFFFF; m->flags &= 0xFFFFFF;
@ -1461,7 +1459,7 @@ void update_mario_inputs(struct MarioState *m) {
update_mario_joystick_inputs(m); update_mario_joystick_inputs(m);
// prevent any inputs when paused // prevent any inputs when paused
if ((m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED)) { if ((m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED || m->freeze > 0)) {
m->input = 0; m->input = 0;
m->intendedMag = 0; m->intendedMag = 0;
} }
@ -1881,8 +1879,9 @@ s32 execute_mario_action(UNUSED struct Object *o) {
// don't update mario when in a cutscene // don't update mario when in a cutscene
if (gMarioState->playerIndex == 0) { if (gMarioState->playerIndex == 0) {
extern s16 gDialogID; extern s16 gDialogID;
if (gFreezeMario > 0) { gFreezeMario--; } if (gMarioState->freeze > 0) { gMarioState->freeze--; }
if (gFreezeMario < 1 && gDialogID != -1) { gFreezeMario = 1; } if (gMarioState->freeze < 2 && gDialogID != -1) { gMarioState->freeze = 2; }
if (gMarioState->freeze < 2 && sCurrPlayMode == PLAY_MODE_PAUSED) { gMarioState->freeze = 2; }
} }
// two-player hack: drop held object if server is holding it // two-player hack: drop held object if server is holding it
@ -1901,9 +1900,9 @@ s32 execute_mario_action(UNUSED struct Object *o) {
// if a loop of actions were found, but there has not been a situation found. // if a loop of actions were found, but there has not been a situation found.
while (inLoop) { while (inLoop) {
// don't update mario when in a cutscene // don't update mario when in a cutscene
if (gMarioState->playerIndex == 0 && gFreezeMario > 0 && (gMarioState->action & ACT_GROUP_MASK) != ACT_GROUP_CUTSCENE) { /*if (gMarioState->freeze > 0 && (gMarioState->action & ACT_GROUP_MASK) != ACT_GROUP_CUTSCENE) {
break; break;
} }*/
// this block can get stuck in an infinite loop due to unexpected circumstances arising from networked players // this block can get stuck in an infinite loop due to unexpected circumstances arising from networked players
if (prevent_hang(hangPreventionActions, &hangPreventionIndex)) { if (prevent_hang(hangPreventionActions, &hangPreventionIndex)) {
@ -1986,6 +1985,8 @@ static void init_single_mario(struct MarioState* m) {
struct SpawnInfo* spawnInfo = &gPlayerSpawnInfos[playerIndex]; struct SpawnInfo* spawnInfo = &gPlayerSpawnInfos[playerIndex];
unused80339F10 = 0; unused80339F10 = 0;
m->freeze = 0;
m->actionTimer = 0; m->actionTimer = 0;
m->framesSinceA = 0xFF; m->framesSinceA = 0xFF;
m->framesSinceB = 0xFF; m->framesSinceB = 0xFF;
@ -2082,7 +2083,6 @@ static void init_single_mario(struct MarioState* m) {
} }
void init_mario(void) { void init_mario(void) {
gFreezeMario = 0;
gInsidePainting = false; gInsidePainting = false;
for (int i = 0; i < MAX_PLAYERS; i++) { for (int i = 0; i < MAX_PLAYERS; i++) {

View file

@ -47,8 +47,6 @@
#define OBJ_COL_FLAG_NO_Y_VEL (1 << 3) #define OBJ_COL_FLAG_NO_Y_VEL (1 << 3)
#define OBJ_COL_FLAGS_LANDED (OBJ_COL_FLAG_GROUNDED | OBJ_COL_FLAG_NO_Y_VEL) #define OBJ_COL_FLAGS_LANDED (OBJ_COL_FLAG_GROUNDED | OBJ_COL_FLAG_NO_Y_VEL)
extern u16 gFreezeMario;
/** /**
* Current object floor as defined in object_step. * Current object floor as defined in object_step.
*/ */

View file

@ -5,6 +5,9 @@
#include "sm64.h" #include "sm64.h"
#include "src/audio/external.h" #include "src/audio/external.h"
#define SET_BIT(val, num) ((((u8)(val)) & 0x01) << (num));
#define GET_BIT(val, num) (((val) >> (num)) & 0x01)
void network_send_player(void) { void network_send_player(void) {
if (gMarioStates[0].marioObj == NULL) { return; } if (gMarioStates[0].marioObj == NULL) { return; }
u32 heldSyncID = (gMarioStates[0].heldObj != NULL) u32 heldSyncID = (gMarioStates[0].heldObj != NULL)
@ -14,6 +17,8 @@ void network_send_player(void) {
? gMarioStates[0].heldByObj->oSyncID ? gMarioStates[0].heldByObj->oSyncID
: 0; : 0;
u8 customFlags = SET_BIT((gMarioStates[0].freeze > 0), 0);
struct Packet p; struct Packet p;
packet_init(&p, PACKET_PLAYER, false); packet_init(&p, PACKET_PLAYER, false);
packet_write(&p, &gMarioStates[0], sizeof(u32) * 24); packet_write(&p, &gMarioStates[0], sizeof(u32) * 24);
@ -26,7 +31,7 @@ void network_send_player(void) {
packet_write(&p, &gMarioStates[0].actionArg, sizeof(u32)); packet_write(&p, &gMarioStates[0].actionArg, sizeof(u32));
packet_write(&p, &gMarioStates[0].currentRoom, sizeof(s16)); packet_write(&p, &gMarioStates[0].currentRoom, sizeof(s16));
packet_write(&p, &gMarioStates[0].squishTimer, sizeof(u8)); packet_write(&p, &gMarioStates[0].squishTimer, sizeof(u8));
packet_write(&p, &customFlags, sizeof(u8));
packet_write(&p, &heldSyncID, sizeof(u32)); packet_write(&p, &heldSyncID, sizeof(u32));
packet_write(&p, &heldBySyncID, sizeof(u32)); packet_write(&p, &heldBySyncID, sizeof(u32));
network_send(&p); network_send(&p);
@ -38,10 +43,11 @@ void network_receive_player(struct Packet* p) {
// save previous state // save previous state
u32 heldSyncID = 0; u32 heldSyncID = 0;
u32 heldBySyncID = 0; u32 heldBySyncID = 0;
u16 playerIndex = gMarioStates[1].playerIndex;
u8 customFlags = 0;
u32 oldAction = gMarioStates[1].action; u32 oldAction = gMarioStates[1].action;
u16 oldActionState = gMarioStates[1].actionState; u16 oldActionState = gMarioStates[1].actionState;
u16 oldActionArg = gMarioStates[1].actionArg; u16 oldActionArg = gMarioStates[1].actionArg;
u16 playerIndex = gMarioStates[1].playerIndex;
u32 oldBehParams = gMarioStates[1].marioObj->oBehParams; u32 oldBehParams = gMarioStates[1].marioObj->oBehParams;
// load mario information from packet // load mario information from packet
@ -55,9 +61,13 @@ void network_receive_player(struct Packet* p) {
packet_read(p, &gMarioStates[1].actionArg, sizeof(u32)); packet_read(p, &gMarioStates[1].actionArg, sizeof(u32));
packet_read(p, &gMarioStates[1].currentRoom, sizeof(s16)); packet_read(p, &gMarioStates[1].currentRoom, sizeof(s16));
packet_read(p, &gMarioStates[1].squishTimer, sizeof(u8)); packet_read(p, &gMarioStates[1].squishTimer, sizeof(u8));
packet_read(p, &customFlags, sizeof(u8));
packet_read(p, &heldSyncID, sizeof(u32)); packet_read(p, &heldSyncID, sizeof(u32));
packet_read(p, &heldBySyncID, sizeof(u32)); packet_read(p, &heldBySyncID, sizeof(u32));
// read custom flags
gMarioStates[1].freeze = GET_BIT(customFlags, 0);
// reset player index // reset player index
gMarioStates[1].playerIndex = playerIndex; gMarioStates[1].playerIndex = playerIndex;
gMarioStates[1].marioObj->oBehParams = oldBehParams; gMarioStates[1].marioObj->oBehParams = oldBehParams;