From 66a4fc8962ab9660d920c2e2ae54f3ce9520e7cb Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 13 Aug 2020 18:53:01 -0700 Subject: [PATCH] Sound fixes for remote player --- src/game/mario_actions_object.c | 10 +++++++++- src/pc/network/packets/packet_player.c | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/game/mario_actions_object.c b/src/game/mario_actions_object.c index 87453ed6..801b75f4 100644 --- a/src/game/mario_actions_object.c +++ b/src/game/mario_actions_object.c @@ -39,12 +39,20 @@ s32 mario_update_punch_sequence(struct MarioState *m) { case 0: play_sound(SOUND_MARIO_PUNCH_YAH, m->marioObj->header.gfx.cameraToObject); // Fall-through: + case 99: + // Fall-through: case 1: set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH); if (is_anim_past_end(m)) { m->actionArg = 2; } else { - m->actionArg = 1; + if (m->actionArg == 1 && m->playerIndex != 0) { + // hack: play remote YAH punch sound, gets skipped without this + play_sound(SOUND_MARIO_PUNCH_YAH, m->marioObj->header.gfx.cameraToObject); + m->actionArg = 99; + } else { + m->actionArg = 1; + } } if (m->marioObj->header.gfx.unk38.animFrame >= 2) { diff --git a/src/pc/network/packets/packet_player.c b/src/pc/network/packets/packet_player.c index 1731c059..2f20c2fa 100644 --- a/src/pc/network/packets/packet_player.c +++ b/src/pc/network/packets/packet_player.c @@ -2,6 +2,7 @@ #include "../network.h" #include "object_fields.h" #include "object_constants.h" +#include "sm64.h" void network_send_player(void) { if (gMarioStates[0].marioObj == NULL) { return; } @@ -19,6 +20,10 @@ void network_send_player(void) { packet_write(&p, gMarioStates[0].marioObj->rawData.asU32, sizeof(u32) * 80); packet_write(&p, &gMarioStates[0].health, sizeof(s16)); packet_write(&p, &gMarioStates[0].marioObj->header.gfx.node.flags, sizeof(s16)); + packet_write(&p, &gMarioStates[0].actionState, sizeof(u16)); + packet_write(&p, &gMarioStates[0].actionTimer, sizeof(u16)); + packet_write(&p, &gMarioStates[0].actionArg, sizeof(u32)); + packet_write(&p, &heldSyncID, sizeof(u32)); packet_write(&p, &heldBySyncID, sizeof(u32)); network_send(&p); @@ -31,14 +36,22 @@ void network_receive_player(struct Packet* p) { u32 heldBySyncID = NULL; u16 playerIndex = gMarioStates[1].playerIndex; + u32 oldAction = gMarioStates[1].action; packet_read(p, &gMarioStates[1], sizeof(u32) * 24); packet_read(p, gMarioStates[1].controller, 20); packet_read(p, &gMarioStates[1].marioObj->rawData.asU32, sizeof(u32) * 80); packet_read(p, &gMarioStates[1].health, sizeof(s16)); packet_read(p, &gMarioStates[1].marioObj->header.gfx.node.flags, sizeof(s16)); + packet_read(p, &gMarioStates[1].actionState, sizeof(u16)); + packet_read(p, &gMarioStates[1].actionTimer, sizeof(u16)); + packet_read(p, &gMarioStates[1].actionArg, sizeof(u32)); + packet_read(p, &heldSyncID, sizeof(u32)); packet_read(p, &heldBySyncID, sizeof(u32)); gMarioStates[1].playerIndex = playerIndex; + if (gMarioStates[1].action != oldAction) { + gMarioStates[1].flags &= ~(MARIO_ACTION_SOUND_PLAYED | MARIO_MARIO_SOUND_PLAYED); + } if (heldSyncID != NULL && syncObjects[heldSyncID].o != NULL) { // TODO: do we have to move graphics nodes around to make this visible?