mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +00:00
Remove two-player hack for controlled warp
This commit is contained in:
parent
48aee0c7be
commit
9f158de95d
6 changed files with 24 additions and 20 deletions
|
@ -49,7 +49,7 @@
|
||||||
#define WARP_NODE_CREDITS_MIN 0xF8
|
#define WARP_NODE_CREDITS_MIN 0xF8
|
||||||
|
|
||||||
struct SavedWarpValues gReceiveWarp = { 0 };
|
struct SavedWarpValues gReceiveWarp = { 0 };
|
||||||
u8 gControlledWarp = 0;
|
u8 gControlledWarpGlobalIndex = 0;
|
||||||
extern s8 sReceivedLoadedActNum;
|
extern s8 sReceivedLoadedActNum;
|
||||||
u8 gRejectInstantWarp = 0;
|
u8 gRejectInstantWarp = 0;
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ static void check_received_warp(void) {
|
||||||
D_80339EE0 = gReceiveWarp.D_80339EE0;
|
D_80339EE0 = gReceiveWarp.D_80339EE0;
|
||||||
gPaintingMarioYEntry = gReceiveWarp.paintingMarioYEntry;
|
gPaintingMarioYEntry = gReceiveWarp.paintingMarioYEntry;
|
||||||
|
|
||||||
if (!gControlledWarp) {
|
if (gControlledWarpGlobalIndex != gNetworkPlayerLocal->globalIndex) {
|
||||||
// force well behaved state
|
// force well behaved state
|
||||||
extern s16 gMenuMode;
|
extern s16 gMenuMode;
|
||||||
gMenuMode = -1;
|
gMenuMode = -1;
|
||||||
|
|
|
@ -55,7 +55,7 @@ s8 sSelectableStarIndex = 0;
|
||||||
// Act Selector menu timer that keeps counting until you choose an act.
|
// Act Selector menu timer that keeps counting until you choose an act.
|
||||||
static s32 sActSelectorMenuTimer = 0;
|
static s32 sActSelectorMenuTimer = 0;
|
||||||
|
|
||||||
extern u8 gControlledWarp;
|
extern u8 gControlledWarpGlobalIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Act Selector Star Type Loop Action
|
* Act Selector Star Type Loop Action
|
||||||
|
@ -177,7 +177,7 @@ void bhv_act_selector_loop(void) {
|
||||||
// Sometimes, stars are not selectable even if they appear on the screen.
|
// Sometimes, stars are not selectable even if they appear on the screen.
|
||||||
// This code filters selectable and non-selectable stars.
|
// This code filters selectable and non-selectable stars.
|
||||||
sSelectedActIndex = 0;
|
sSelectedActIndex = 0;
|
||||||
if (gControlledWarp) {
|
if (gControlledWarpGlobalIndex == gNetworkPlayerLocal->globalIndex) {
|
||||||
s8 oldIndex = sSelectableStarIndex;
|
s8 oldIndex = sSelectableStarIndex;
|
||||||
handle_menu_scrolling(MENU_SCROLL_HORIZONTAL, &sSelectableStarIndex, 0, sObtainedStars);
|
handle_menu_scrolling(MENU_SCROLL_HORIZONTAL, &sSelectableStarIndex, 0, sObtainedStars);
|
||||||
if (oldIndex != sSelectableStarIndex) { network_send_inside_painting(); }
|
if (oldIndex != sSelectableStarIndex) { network_send_inside_painting(); }
|
||||||
|
@ -195,7 +195,7 @@ void bhv_act_selector_loop(void) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If all stars are collected then they are all selectable.
|
// If all stars are collected then they are all selectable.
|
||||||
if (gControlledWarp) {
|
if (gControlledWarpGlobalIndex == gNetworkPlayerLocal->globalIndex) {
|
||||||
s8 oldIndex = sSelectableStarIndex;
|
s8 oldIndex = sSelectableStarIndex;
|
||||||
handle_menu_scrolling(MENU_SCROLL_HORIZONTAL, &sSelectableStarIndex, 0, sVisibleStars - 1);
|
handle_menu_scrolling(MENU_SCROLL_HORIZONTAL, &sSelectableStarIndex, 0, sVisibleStars - 1);
|
||||||
if (oldIndex != sSelectableStarIndex) { network_send_inside_painting(); }
|
if (oldIndex != sSelectableStarIndex) { network_send_inside_painting(); }
|
||||||
|
@ -299,7 +299,7 @@ void print_act_selector_strings(void) {
|
||||||
create_dl_ortho_matrix();
|
create_dl_ortho_matrix();
|
||||||
|
|
||||||
// display disclaimer that the other player has to select
|
// display disclaimer that the other player has to select
|
||||||
if (!gControlledWarp) {
|
if (gControlledWarpGlobalIndex != gNetworkPlayerLocal->globalIndex) {
|
||||||
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
|
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
|
||||||
u8 a = ((gGlobalTimer % 24) >= 12) ? 160 : 130;
|
u8 a = ((gGlobalTimer % 24) >= 12) ? 160 : 130;
|
||||||
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, a);
|
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, a);
|
||||||
|
@ -436,7 +436,7 @@ s32 lvl_init_act_selector_values_and_stars(UNUSED s32 arg, UNUSED s32 unused) {
|
||||||
* Also updates objects and returns act number selected after is chosen.
|
* Also updates objects and returns act number selected after is chosen.
|
||||||
*/
|
*/
|
||||||
s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused) {
|
s32 lvl_update_obj_and_load_act_button_actions(UNUSED s32 arg, UNUSED s32 unused) {
|
||||||
if (gControlledWarp && sActSelectorMenuTimer >= 11) {
|
if ((gControlledWarpGlobalIndex == gNetworkPlayerLocal->globalIndex) && sActSelectorMenuTimer >= 11) {
|
||||||
// If any of these buttons are pressed, play sound and go to course act
|
// If any of these buttons are pressed, play sound and go to course act
|
||||||
#ifndef VERSION_EU
|
#ifndef VERSION_EU
|
||||||
if ((gPlayer3Controller->buttonPressed & A_BUTTON)
|
if ((gPlayer3Controller->buttonPressed & A_BUTTON)
|
||||||
|
@ -473,5 +473,5 @@ void star_select_finish_selection(void) {
|
||||||
}
|
}
|
||||||
gDialogCourseActNum = sSelectedActIndex + 1;
|
gDialogCourseActNum = sSelectedActIndex + 1;
|
||||||
|
|
||||||
if (gControlledWarp) { network_send_inside_painting(); }
|
if (gControlledWarpGlobalIndex == gNetworkPlayerLocal->globalIndex) { network_send_inside_painting(); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#define DISABLE_MODULE_LOG
|
#define DISABLE_MODULE_LOG
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
extern u8 gControlledWarp;
|
extern u8 gControlledWarpGlobalIndex;
|
||||||
|
|
||||||
extern u8 sSelectableStarIndex;
|
extern u8 sSelectableStarIndex;
|
||||||
extern u8 sSelectedActIndex;
|
extern u8 sSelectedActIndex;
|
||||||
|
@ -42,8 +42,7 @@ void network_receive_inside_painting(struct Packet* p) {
|
||||||
struct PacketInsidePaintingData remote = { 0 };
|
struct PacketInsidePaintingData remote = { 0 };
|
||||||
packet_read(p, &remote, sizeof(struct PacketInsidePaintingData));
|
packet_read(p, &remote, sizeof(struct PacketInsidePaintingData));
|
||||||
|
|
||||||
// two-player hack: gControlledWarp is a bool instead of an index
|
if (gControlledWarpGlobalIndex == gNetworkPlayerLocal->globalIndex) {
|
||||||
if (gControlledWarp) {
|
|
||||||
LOG_ERROR("this should never happen, received inside_painting when gControlledWarp");
|
LOG_ERROR("this should never happen, received inside_painting when gControlledWarp");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,16 @@
|
||||||
#define DISABLE_MODULE_LOG
|
#define DISABLE_MODULE_LOG
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
|
// two-player hack
|
||||||
|
// this entire system needs to be ripped out and replaced
|
||||||
|
|
||||||
static u8 eventId = 0;
|
static u8 eventId = 0;
|
||||||
static u8 remoteFinishedEventId[2] = { (u8)-1, (u8)-1 };
|
static u8 remoteFinishedEventId[2] = { (u8)-1, (u8)-1 };
|
||||||
|
|
||||||
extern s16 gTTCSpeedSetting;
|
extern s16 gTTCSpeedSetting;
|
||||||
extern s16 D_80339EE0;
|
extern s16 D_80339EE0;
|
||||||
extern float gPaintingMarioYEntry;
|
extern float gPaintingMarioYEntry;
|
||||||
extern u8 gControlledWarp; // two-player hack
|
extern u8 gControlledWarpGlobalIndex;
|
||||||
|
|
||||||
extern struct SavedWarpValues gReceiveWarp;
|
extern struct SavedWarpValues gReceiveWarp;
|
||||||
struct SavedWarpValues saved = { 0 };
|
struct SavedWarpValues saved = { 0 };
|
||||||
|
@ -36,7 +39,7 @@ struct PacketLevelWarpData {
|
||||||
static void populate_packet_data(struct PacketLevelWarpData* data, bool done, u8 packetEventId) {
|
static void populate_packet_data(struct PacketLevelWarpData* data, bool done, u8 packetEventId) {
|
||||||
data->eventId = packetEventId;
|
data->eventId = packetEventId;
|
||||||
data->done = done;
|
data->done = done;
|
||||||
data->controlledWarp = gControlledWarp;
|
data->controlledWarp = gControlledWarpGlobalIndex;
|
||||||
data->warpDest = saved.warpDest;
|
data->warpDest = saved.warpDest;
|
||||||
data->inWarpCheckpoint = saved.inWarpCheckpoint;
|
data->inWarpCheckpoint = saved.inWarpCheckpoint;
|
||||||
data->ttcSpeedSetting = saved.ttcSpeedSetting;
|
data->ttcSpeedSetting = saved.ttcSpeedSetting;
|
||||||
|
@ -53,9 +56,9 @@ void network_send_level_warp_begin(void) {
|
||||||
saved.paintingMarioYEntry = gPaintingMarioYEntry;
|
saved.paintingMarioYEntry = gPaintingMarioYEntry;
|
||||||
|
|
||||||
float elapsedSinceDone = (clock() - lastDoneEvent) / CLOCKS_PER_SEC;
|
float elapsedSinceDone = (clock() - lastDoneEvent) / CLOCKS_PER_SEC;
|
||||||
gControlledWarp = (elapsedSinceDone < 1.0f)
|
gControlledWarpGlobalIndex = (elapsedSinceDone < 1.0f)
|
||||||
? (gNetworkType == NT_SERVER) // two-player hack
|
? 0
|
||||||
: true;
|
: gNetworkPlayerLocal->globalIndex;
|
||||||
|
|
||||||
eventId++;
|
eventId++;
|
||||||
if (eventId == (u8)-1) { eventId++; }
|
if (eventId == (u8)-1) { eventId++; }
|
||||||
|
@ -136,7 +139,7 @@ void network_receive_level_warp(struct Packet* p) {
|
||||||
} else if (!isInWarp) {
|
} else if (!isInWarp) {
|
||||||
// client initiated warp
|
// client initiated warp
|
||||||
LOG_INFO("client initiated warp!");
|
LOG_INFO("client initiated warp!");
|
||||||
gControlledWarp = !remote.controlledWarp; // two-player hack
|
gControlledWarpGlobalIndex = remote.controlledWarp;
|
||||||
|
|
||||||
saved.warpDest = remote.warpDest;
|
saved.warpDest = remote.warpDest;
|
||||||
saved.inWarpCheckpoint = remote.inWarpCheckpoint;
|
saved.inWarpCheckpoint = remote.inWarpCheckpoint;
|
||||||
|
@ -165,7 +168,7 @@ void network_receive_level_warp(struct Packet* p) {
|
||||||
|
|
||||||
// server initiated warp
|
// server initiated warp
|
||||||
LOG_INFO("server initiated warp!");
|
LOG_INFO("server initiated warp!");
|
||||||
gControlledWarp = !remote.controlledWarp; // two-player hack
|
gControlledWarpGlobalIndex = remote.controlledWarp;
|
||||||
|
|
||||||
saved.warpDest = remote.warpDest;
|
saved.warpDest = remote.warpDest;
|
||||||
saved.inWarpCheckpoint = remote.inWarpCheckpoint;
|
saved.inWarpCheckpoint = remote.inWarpCheckpoint;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "course_table.h"
|
#include "course_table.h"
|
||||||
#include "src/game/interaction.h"
|
#include "src/game/interaction.h"
|
||||||
#include "src/engine/math_util.h"
|
#include "src/engine/math_util.h"
|
||||||
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
#define RESERVATION_COUNT 10
|
#define RESERVATION_COUNT 10
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ void network_send_reservation(u8 toLocalIndex) {
|
||||||
packet_init(&p, PACKET_RESERVATION, true, false);
|
packet_init(&p, PACKET_RESERVATION, true, false);
|
||||||
packet_write(&p, reservedObjs, sizeof(u8) * RESERVATION_COUNT);
|
packet_write(&p, reservedObjs, sizeof(u8) * RESERVATION_COUNT);
|
||||||
network_send_to(toLocalIndex, &p);
|
network_send_to(toLocalIndex, &p);
|
||||||
|
LOG_INFO("sent reservation list to %d", toLocalIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_receive_reservation(struct Packet* p) {
|
void network_receive_reservation(struct Packet* p) {
|
||||||
|
@ -66,4 +68,5 @@ void network_receive_reservation(struct Packet* p) {
|
||||||
if (gSyncObjects[index].o != NULL) { continue; }
|
if (gSyncObjects[index].o != NULL) { continue; }
|
||||||
gSyncObjects[index].reserved = gNetworkPlayerLocal->globalIndex;
|
gSyncObjects[index].reserved = gNetworkPlayerLocal->globalIndex;
|
||||||
}
|
}
|
||||||
|
LOG_INFO("received reservation list");
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,7 @@ void network_receive_spawn_objects(struct Packet* p) {
|
||||||
|
|
||||||
packet_read(p, &objectCount, sizeof(u8));
|
packet_read(p, &objectCount, sizeof(u8));
|
||||||
|
|
||||||
// two-player hack
|
u8 reserveId = gNetworkLevelLoaded ? gNetworkPlayers[p->localIndex].globalIndex : 0;
|
||||||
u8 reserveId = (gNetworkLevelLoaded && gNetworkType == NT_SERVER) ? 1 : 0;
|
|
||||||
bool receivedReservedSyncObject = false;
|
bool receivedReservedSyncObject = false;
|
||||||
|
|
||||||
struct Object* spawned[MAX_SPAWN_OBJECTS_PER_PACKET] = { 0 };
|
struct Object* spawned[MAX_SPAWN_OBJECTS_PER_PACKET] = { 0 };
|
||||||
|
|
Loading…
Reference in a new issue