mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-26 14:03:01 +00:00
Synchronized WDW initial water level
This commit is contained in:
parent
333a77b647
commit
1536ce87c8
3 changed files with 33 additions and 16 deletions
|
@ -46,9 +46,8 @@
|
|||
|
||||
#define WARP_NODE_CREDITS_MIN 0xF8
|
||||
|
||||
struct SavedWarpValues gReceiveWarp = { 0 };
|
||||
u8 gControlledWarp = 0;
|
||||
u8 gReceiveWarp = 0;
|
||||
struct WarpDest gReceiveWarpDest = { 0 };
|
||||
extern s8 sReceivedLoadedActNum;
|
||||
|
||||
#ifdef VERSION_JP
|
||||
|
@ -991,9 +990,16 @@ void basic_update(UNUSED s16 *arg) {
|
|||
}
|
||||
|
||||
static void check_received_warp(void) {
|
||||
if (!gReceiveWarp) { return; }
|
||||
gReceiveWarp = FALSE;
|
||||
sWarpDest = gReceiveWarpDest;
|
||||
extern float gPaintingMarioYEntry;
|
||||
if (!gReceiveWarp.received) { return; }
|
||||
gReceiveWarp.received = FALSE;
|
||||
|
||||
// keep do_warp(void) in sync with this
|
||||
sWarpDest = gReceiveWarp.warpDest;
|
||||
gInWarpCheckpoint = gReceiveWarp.inWarpCheckpoint;
|
||||
gTTCSpeedSetting = gReceiveWarp.ttcSpeedSetting;
|
||||
D_80339EE0 = gReceiveWarp.D_80339EE0;
|
||||
gPaintingMarioYEntry = gReceiveWarp.paintingMarioYEntry;
|
||||
|
||||
if (!gControlledWarp) {
|
||||
// force well behaved state
|
||||
|
@ -1054,7 +1060,7 @@ s32 play_mode_normal(void) {
|
|||
} else if (sTransitionTimer != 0) {
|
||||
set_play_mode(PLAY_MODE_CHANGE_AREA);
|
||||
}
|
||||
} else if (!gReceiveWarp) {
|
||||
} else if (!gReceiveWarp.received) {
|
||||
if (sWarpDest.type == WARP_TYPE_CHANGE_LEVEL) {
|
||||
set_play_mode(PLAY_MODE_SYNC_LEVEL);
|
||||
network_send_level_warp_begin();
|
||||
|
|
|
@ -84,6 +84,15 @@ struct WarpDest {
|
|||
u32 arg;
|
||||
};
|
||||
|
||||
struct SavedWarpValues {
|
||||
u8 received;
|
||||
struct WarpDest warpDest;
|
||||
s8 inWarpCheckpoint;
|
||||
s16 ttcSpeedSetting;
|
||||
s16 D_80339EE0;
|
||||
f32 paintingMarioYEntry;
|
||||
};
|
||||
|
||||
extern struct WarpDest sWarpDest;
|
||||
extern s8 gInWarpCheckpoint;
|
||||
|
||||
|
|
|
@ -15,16 +15,11 @@ static u8 remoteLastSeqId = (u8)-1;
|
|||
|
||||
extern s16 gTTCSpeedSetting;
|
||||
extern s16 D_80339EE0;
|
||||
extern float gPaintingMarioYEntry;
|
||||
extern u8 gControlledWarp; // two-player hack
|
||||
extern u8 gReceiveWarp;
|
||||
extern struct WarpDest gReceiveWarpDest;
|
||||
|
||||
struct SavedWarpValues {
|
||||
struct WarpDest warpDest;
|
||||
s8 inWarpCheckpoint;
|
||||
s16 ttcSpeedSetting;
|
||||
s16 D_80339EE0;
|
||||
} saved = { 0 };
|
||||
extern struct SavedWarpValues gReceiveWarp;
|
||||
struct SavedWarpValues saved = { 0 };
|
||||
|
||||
static clock_t lastDoneEvent = 0;
|
||||
static bool isInWarp = FALSE;
|
||||
|
@ -39,6 +34,7 @@ struct PacketLevelWarpData {
|
|||
s8 inWarpCheckpoint;
|
||||
s16 ttcSpeedSetting;
|
||||
s16 D_80339EE0;
|
||||
f32 paintingMarioYEntry;
|
||||
};
|
||||
|
||||
static void populate_packet_data(struct PacketLevelWarpData* data, bool done, u8 packetEventId) {
|
||||
|
@ -50,6 +46,7 @@ static void populate_packet_data(struct PacketLevelWarpData* data, bool done, u8
|
|||
data->inWarpCheckpoint = saved.inWarpCheckpoint;
|
||||
data->ttcSpeedSetting = saved.ttcSpeedSetting;
|
||||
data->D_80339EE0 = saved.D_80339EE0;
|
||||
data->paintingMarioYEntry = saved.paintingMarioYEntry;
|
||||
}
|
||||
|
||||
void network_send_level_warp_begin(void) {
|
||||
|
@ -58,6 +55,7 @@ void network_send_level_warp_begin(void) {
|
|||
saved.inWarpCheckpoint = gInWarpCheckpoint;
|
||||
saved.ttcSpeedSetting = gTTCSpeedSetting;
|
||||
saved.D_80339EE0 = D_80339EE0;
|
||||
saved.paintingMarioYEntry = gPaintingMarioYEntry;
|
||||
|
||||
float elapsedSinceDone = (clock() - lastDoneEvent) / CLOCKS_PER_SEC;
|
||||
gControlledWarp = (elapsedSinceDone < 1.0f)
|
||||
|
@ -113,11 +111,13 @@ static void network_send_level_warp_done(u8 remoteEventId) {
|
|||
}
|
||||
|
||||
static void do_warp(void) {
|
||||
gReceiveWarpDest = saved.warpDest;
|
||||
// keep check_received_warp(void) in sync with this
|
||||
gReceiveWarp = saved;
|
||||
gReceiveWarp.received = TRUE;
|
||||
gInWarpCheckpoint = saved.inWarpCheckpoint;
|
||||
gTTCSpeedSetting = saved.ttcSpeedSetting;
|
||||
D_80339EE0 = saved.D_80339EE0;
|
||||
gReceiveWarp = TRUE;
|
||||
gPaintingMarioYEntry = saved.paintingMarioYEntry;
|
||||
}
|
||||
|
||||
void network_receive_level_warp(struct Packet* p) {
|
||||
|
@ -160,6 +160,7 @@ void network_receive_level_warp(struct Packet* p) {
|
|||
saved.inWarpCheckpoint = remote.inWarpCheckpoint;
|
||||
saved.ttcSpeedSetting = remote.ttcSpeedSetting;
|
||||
saved.D_80339EE0 = remote.D_80339EE0;
|
||||
saved.paintingMarioYEntry = remote.paintingMarioYEntry;
|
||||
|
||||
do_warp();
|
||||
network_send_level_warp_done(remote.eventId);
|
||||
|
@ -188,6 +189,7 @@ void network_receive_level_warp(struct Packet* p) {
|
|||
saved.inWarpCheckpoint = remote.inWarpCheckpoint;
|
||||
saved.ttcSpeedSetting = remote.ttcSpeedSetting;
|
||||
saved.D_80339EE0 = remote.D_80339EE0;
|
||||
saved.paintingMarioYEntry = remote.paintingMarioYEntry;
|
||||
|
||||
LOG_INFO("finished event [%d]!", remote.eventId);
|
||||
do_warp();
|
||||
|
|
Loading…
Reference in a new issue