mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-26 05:55:15 +00:00
Rewrote level synchronization
Synchronized exit course from pause menu
This commit is contained in:
parent
2e768869e3
commit
6701b6096d
8 changed files with 56 additions and 56 deletions
|
@ -425,6 +425,18 @@ void render_game(void) {
|
|||
}
|
||||
}
|
||||
|
||||
// only render 'synchronizing' text if we've been waiting for a while
|
||||
static u8 syncLevelTime = 0;
|
||||
if (sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) {
|
||||
if (syncLevelTime < 30) {
|
||||
syncLevelTime++;
|
||||
} else {
|
||||
render_sync_level_screen();
|
||||
}
|
||||
} else {
|
||||
syncLevelTime = 0;
|
||||
}
|
||||
|
||||
D_8032CE74 = NULL;
|
||||
D_8032CE78 = 0;
|
||||
}
|
||||
|
|
|
@ -3167,9 +3167,6 @@ s16 render_menus_and_dialogs() {
|
|||
case 3:
|
||||
mode = render_course_complete_screen();
|
||||
break;
|
||||
case 4:
|
||||
mode = render_sync_level_screen();
|
||||
break;
|
||||
}
|
||||
|
||||
gDialogColorFadeTimer = (s16) gDialogColorFadeTimer + 0x1000;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#define RENDER_PAUSE_SCREEN 1
|
||||
#define RENDER_COURSE_DONE_SCREEN 2
|
||||
#define RENDER_SYNC_LEVEL_SCREEN 4
|
||||
|
||||
|
||||
extern s8 gDialogCourseActNum;
|
||||
|
|
|
@ -670,7 +670,7 @@ void initiate_painting_warp(void) {
|
|||
} else if (pWarpNode->id != 0) {
|
||||
initiate_painting_warp_node(pWarpNode, false);
|
||||
gControlPainting = true;
|
||||
gWaitingForRemotePainting = true;
|
||||
gWaitingForRemotePainting = (networkType != NT_NONE);
|
||||
set_mario_action(gMarioState, ACT_DISAPPEARED, 0);
|
||||
gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
|
||||
}
|
||||
|
@ -710,6 +710,9 @@ void initiate_painting_warp_node(struct WarpNode *pWarpNode, u8 instant) {
|
|||
* Return the time left until the delayed warp is initiated.
|
||||
*/
|
||||
s16 level_trigger_warp(struct MarioState *m, s32 warpOp) {
|
||||
// only allow for local player
|
||||
if (m != &gMarioStates[0]) { return 0; }
|
||||
|
||||
gControlPainting = FALSE;
|
||||
s32 val04 = TRUE;
|
||||
|
||||
|
@ -1008,8 +1011,12 @@ s32 play_mode_normal(void) {
|
|||
// warp, change play mode accordingly.
|
||||
if (sCurrPlayMode == PLAY_MODE_NORMAL) {
|
||||
if (sWarpDest.type == WARP_TYPE_CHANGE_LEVEL) {
|
||||
set_play_mode(PLAY_MODE_CHANGE_LEVEL);
|
||||
set_play_mode((networkType != NT_NONE) ? PLAY_MODE_SYNC_LEVEL : PLAY_MODE_CHANGE_LEVEL);
|
||||
network_send_level_warp();
|
||||
} else if (sTransitionTimer != 0) {
|
||||
////////////////////////////////////
|
||||
// todo: synchronize change_area. //
|
||||
////////////////////////////////////
|
||||
set_play_mode(PLAY_MODE_CHANGE_AREA);
|
||||
} else if (pressed_pause()) {
|
||||
lower_background_noise(1);
|
||||
|
@ -1038,6 +1045,8 @@ s32 play_mode_paused(void) {
|
|||
fade_into_special_warp(0, 0);
|
||||
gSavedCourseNum = COURSE_NONE;
|
||||
}
|
||||
set_play_mode((networkType != NT_NONE) ? PLAY_MODE_SYNC_LEVEL : PLAY_MODE_CHANGE_LEVEL);
|
||||
network_send_level_warp();
|
||||
} else if (gPauseScreenMode == 3) {
|
||||
// We should only be getting "int 3" to here
|
||||
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
|
||||
|
@ -1051,7 +1060,6 @@ s32 play_mode_paused(void) {
|
|||
}
|
||||
|
||||
s32 play_mode_sync_level(void) {
|
||||
set_menu_mode(RENDER_SYNC_LEVEL_SCREEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1251,10 +1259,6 @@ s32 init_level(void) {
|
|||
sound_banks_disable(2, 0x0330);
|
||||
}
|
||||
|
||||
if (networkType != NT_NONE) {
|
||||
set_play_mode(PLAY_MODE_SYNC_LEVEL);
|
||||
}
|
||||
|
||||
// set mario/luigi model
|
||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
if (i == 0) {
|
||||
|
|
|
@ -94,6 +94,7 @@ static void keyboard_read(OSContPad *pad) {
|
|||
if (keyboard_buttons_down & L_TRIG) {
|
||||
debug_breakpoint_here();
|
||||
}
|
||||
|
||||
pad->button |= keyboard_buttons_down;
|
||||
const u32 xstick = keyboard_buttons_down & STICK_XMASK;
|
||||
const u32 ystick = keyboard_buttons_down & STICK_YMASK;
|
||||
|
|
|
@ -47,12 +47,9 @@ void network_send(struct Packet* p) {
|
|||
void network_update(void) {
|
||||
if (networkType == NT_NONE) { return; }
|
||||
|
||||
// TODO: refactor the way we do these update functions, it will get messy quick
|
||||
if (gInsidePainting && sCurrPlayMode == PLAY_MODE_CHANGE_LEVEL) {
|
||||
network_update_inside_painting();
|
||||
} else if (sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) {
|
||||
network_update_level_warp();
|
||||
} else {
|
||||
} else if (sCurrPlayMode == PLAY_MODE_NORMAL) {
|
||||
network_update_player();
|
||||
network_update_objects();
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ void network_receive_spawn_objects(struct Packet* p);
|
|||
void network_send_spawn_star(struct Object* o, u8 starType, f32 x, f32 y, f32 z);
|
||||
void network_receive_spawn_star(struct Packet* p);
|
||||
|
||||
void network_update_level_warp(void);
|
||||
void network_send_level_warp(void);
|
||||
void network_receive_level_warp(struct Packet* p);
|
||||
|
||||
void network_update_inside_painting(void);
|
||||
|
|
|
@ -5,61 +5,51 @@
|
|||
|
||||
int matchCount = 0;
|
||||
|
||||
extern s16 gMenuMode;
|
||||
|
||||
void network_send_level_warp(void) {
|
||||
struct Packet p;
|
||||
packet_init(&p, PACKET_LEVEL_WARP, false);
|
||||
packet_init(&p, PACKET_LEVEL_WARP, true);
|
||||
packet_write(&p, &sCurrPlayMode, sizeof(s16));
|
||||
packet_write(&p, &gCurrLevelNum, sizeof(s16));
|
||||
packet_write(&p, &sDelayedWarpArg, sizeof(s32));
|
||||
packet_write(&p, &sSourceWarpNodeId, sizeof(s16));
|
||||
packet_write(&p, &sWarpDest, sizeof(struct WarpDest));
|
||||
|
||||
network_send(&p);
|
||||
}
|
||||
|
||||
void network_receive_level_warp(struct Packet* p) {
|
||||
s16 remotePlayMode;
|
||||
s16 remoteLevelNum;
|
||||
s32 remoteWarpArg;
|
||||
s16 remoteWarpNodeId;
|
||||
struct WarpDest remoteWarpDest;
|
||||
|
||||
packet_read(p, &remotePlayMode, sizeof(s16));
|
||||
packet_read(p, &remoteLevelNum, sizeof(s16));
|
||||
packet_read(p, &remoteWarpArg, sizeof(s32));
|
||||
packet_read(p, &remoteWarpNodeId, sizeof(s16));
|
||||
packet_read(p, &remoteWarpDest, sizeof(struct WarpDest));
|
||||
|
||||
bool matching = (remoteLevelNum == gCurrLevelNum)
|
||||
&& (remoteWarpArg == sDelayedWarpArg)
|
||||
&& (remoteWarpNodeId == sSourceWarpNodeId);
|
||||
bool matchingDest = memcmp(&remoteWarpDest, &sWarpDest, sizeof(struct WarpDest)) == 0;
|
||||
|
||||
if (matching) {
|
||||
if (sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) {
|
||||
// our levels match now, lets play!
|
||||
set_play_mode(PLAY_MODE_NORMAL);
|
||||
set_menu_mode((s16)-1);
|
||||
}
|
||||
// our levels match, make sure the other player knows that
|
||||
if (matchCount++ < 3) {
|
||||
network_send_level_warp();
|
||||
} else {
|
||||
matchCount = 0;
|
||||
}
|
||||
if (remotePlayMode == PLAY_MODE_SYNC_LEVEL && (sCurrPlayMode == PLAY_MODE_NORMAL || sCurrPlayMode == PLAY_MODE_PAUSED)) {
|
||||
sCurrPlayMode = PLAY_MODE_SYNC_LEVEL;
|
||||
sWarpDest = remoteWarpDest;
|
||||
gMenuMode = -1;
|
||||
gPauseScreenMode = 1;
|
||||
if (sTransitionTimer < 1) { sTransitionTimer = 1; }
|
||||
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
|
||||
network_send_level_warp();
|
||||
return;
|
||||
}
|
||||
matchCount = 0;
|
||||
|
||||
// remote isn't trying to sync, don't warp
|
||||
if (remotePlayMode != PLAY_MODE_SYNC_LEVEL) { return; }
|
||||
if (remotePlayMode == PLAY_MODE_SYNC_LEVEL && sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) {
|
||||
if (matchingDest) {
|
||||
sCurrPlayMode = PLAY_MODE_CHANGE_LEVEL;
|
||||
} else {
|
||||
if (networkType == NT_CLIENT) {
|
||||
// two-player hack: would need to use player index as priority
|
||||
sWarpDest = remoteWarpDest;
|
||||
}
|
||||
}
|
||||
network_send_level_warp();
|
||||
return;
|
||||
}
|
||||
|
||||
// we're trying to sync, don't warp
|
||||
if (sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) { return; }
|
||||
|
||||
// warp to the level
|
||||
sDelayedWarpTimer = 1;
|
||||
sDelayedWarpArg = remoteWarpArg;
|
||||
sSourceWarpNodeId = remoteWarpNodeId;
|
||||
sDelayedWarpOp = WARP_OP_FORCE_SYNC;
|
||||
}
|
||||
|
||||
void network_update_level_warp(void) {
|
||||
network_send_level_warp();
|
||||
if (remotePlayMode == PLAY_MODE_CHANGE_LEVEL && sCurrPlayMode == PLAY_MODE_SYNC_LEVEL) {
|
||||
sCurrPlayMode = PLAY_MODE_CHANGE_LEVEL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue