mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-27 20:41:42 +00:00
Prevent level/area/object sync during credits sequence
This commit is contained in:
parent
0d05853138
commit
cbb7eb419c
4 changed files with 20 additions and 4 deletions
|
|
@ -17,7 +17,8 @@ static void player_changed_area(struct NetworkPlayer* np, s16 courseNum, s16 act
|
||||||
// find a NetworkPlayer at that area
|
// find a NetworkPlayer at that area
|
||||||
struct NetworkPlayer* npLevelAreaMatch = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex);
|
struct NetworkPlayer* npLevelAreaMatch = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex);
|
||||||
|
|
||||||
if (npLevelAreaMatch == NULL) {
|
bool inCredits = (np->currActNum == 99);
|
||||||
|
if (npLevelAreaMatch == NULL || inCredits) {
|
||||||
// no NetworkPlayer in the level
|
// no NetworkPlayer in the level
|
||||||
network_send_sync_valid(np);
|
network_send_sync_valid(np);
|
||||||
network_send_level_area_inform(np);
|
network_send_level_area_inform(np);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ static void player_changed_level(struct NetworkPlayer* np, s16 courseNum, s16 ac
|
||||||
struct NetworkPlayer* npLevelMatch = get_network_player_from_level(courseNum, actNum, levelNum);
|
struct NetworkPlayer* npLevelMatch = get_network_player_from_level(courseNum, actNum, levelNum);
|
||||||
struct NetworkPlayer* npAny = (npLevelAreaMatch == NULL) ? npLevelMatch : npLevelAreaMatch;
|
struct NetworkPlayer* npAny = (npLevelAreaMatch == NULL) ? npLevelMatch : npLevelAreaMatch;
|
||||||
|
|
||||||
if (npAny == NULL) {
|
bool inCredits = (np->currActNum == 99);
|
||||||
|
if (npAny == NULL || inCredits) {
|
||||||
// no NetworkPlayer in the level
|
// no NetworkPlayer in the level
|
||||||
network_send_sync_valid(np);
|
network_send_sync_valid(np);
|
||||||
network_send_level_area_inform(np);
|
network_send_level_area_inform(np);
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include "src/game/memory.h"
|
#include "src/game/memory.h"
|
||||||
#include "src/game/object_helpers.h"
|
#include "src/game/object_helpers.h"
|
||||||
#include "src/game/obj_behaviors.h"
|
#include "src/game/obj_behaviors.h"
|
||||||
|
#include "src/game/area.h"
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
#include "pc/utils/misc.h"
|
#include "pc/utils/misc.h"
|
||||||
|
|
||||||
|
|
@ -40,6 +41,9 @@ static float player_distance(struct MarioState* marioState, struct Object* o) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool should_own_object(struct SyncObject* so) {
|
static bool should_own_object(struct SyncObject* so) {
|
||||||
|
// always own objects in credit sequence
|
||||||
|
if (gCurrActStarNum == 99) { return true; }
|
||||||
|
|
||||||
// check for override
|
// check for override
|
||||||
u8 shouldOverride = FALSE;
|
u8 shouldOverride = FALSE;
|
||||||
u8 shouldOwn = FALSE;
|
u8 shouldOwn = FALSE;
|
||||||
|
|
@ -407,6 +411,8 @@ void network_send_object(struct Object* o) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_send_object_reliability(struct Object* o, bool reliable) {
|
void network_send_object_reliability(struct Object* o, bool reliable) {
|
||||||
|
// prevent sending objects during credits sequence
|
||||||
|
if (gCurrActStarNum == 99) { return; }
|
||||||
// sanity check SyncObject
|
// sanity check SyncObject
|
||||||
if (!network_sync_object_initialized(o)) { return; }
|
if (!network_sync_object_initialized(o)) { return; }
|
||||||
u8 syncId = o->oSyncID;
|
u8 syncId = o->oSyncID;
|
||||||
|
|
@ -453,6 +459,9 @@ void network_send_object_reliability(struct Object* o, bool reliable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_receive_object(struct Packet* p) {
|
void network_receive_object(struct Packet* p) {
|
||||||
|
// prevent receiving objects during credits sequence
|
||||||
|
if (gCurrActStarNum == 99) { return; }
|
||||||
|
|
||||||
// read the header and sanity check the packet
|
// read the header and sanity check the packet
|
||||||
u8 fromLocalIndex = 0;
|
u8 fromLocalIndex = 0;
|
||||||
struct SyncObject* so = packet_read_object_header(p, &fromLocalIndex);
|
struct SyncObject* so = packet_read_object_header(p, &fromLocalIndex);
|
||||||
|
|
@ -570,7 +579,8 @@ void network_update_objects(void) {
|
||||||
if (timeSinceUpdate < updateRate) { continue; }
|
if (timeSinceUpdate < updateRate) { continue; }
|
||||||
|
|
||||||
// update!
|
// update!
|
||||||
if (network_player_any_connected()) {
|
bool inCredits = (gCurrActStarNum == 99);
|
||||||
|
if (network_player_any_connected() && !inCredits) {
|
||||||
network_send_object(gSyncObjects[i].o);
|
network_send_object(gSyncObjects[i].o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "object_fields.h"
|
#include "object_fields.h"
|
||||||
#include "object_constants.h"
|
#include "object_constants.h"
|
||||||
#include "src/game/object_helpers.h"
|
#include "src/game/object_helpers.h"
|
||||||
|
#include "src/game/area.h"
|
||||||
#include "behavior_data.h"
|
#include "behavior_data.h"
|
||||||
#include "behavior_table.h"
|
#include "behavior_table.h"
|
||||||
//#define DISABLE_MODULE_LOG 1
|
//#define DISABLE_MODULE_LOG 1
|
||||||
|
|
@ -47,7 +48,8 @@ void network_send_spawn_objects(struct Object* objects[], u32 models[], u8 objec
|
||||||
|
|
||||||
void network_send_spawn_objects_to(u8 sendToLocalIndex, struct Object* objects[], u32 models[], u8 objectCount) {
|
void network_send_spawn_objects_to(u8 sendToLocalIndex, struct Object* objects[], u32 models[], u8 objectCount) {
|
||||||
assert(objectCount < MAX_SPAWN_OBJECTS_PER_PACKET);
|
assert(objectCount < MAX_SPAWN_OBJECTS_PER_PACKET);
|
||||||
if (sendToLocalIndex == gNetworkPlayerLocal->localIndex) { return; }
|
// prevent sending spawn objects during credits
|
||||||
|
if (gCurrActStarNum == 99) { return; }
|
||||||
|
|
||||||
struct Packet p;
|
struct Packet p;
|
||||||
packet_init(&p, PACKET_SPAWN_OBJECTS, true, true);
|
packet_init(&p, PACKET_SPAWN_OBJECTS, true, true);
|
||||||
|
|
@ -81,6 +83,8 @@ void network_send_spawn_objects_to(u8 sendToLocalIndex, struct Object* objects[]
|
||||||
|
|
||||||
void network_receive_spawn_objects(struct Packet* p) {
|
void network_receive_spawn_objects(struct Packet* p) {
|
||||||
LOG_INFO("rx spawn objects");
|
LOG_INFO("rx spawn objects");
|
||||||
|
// prevent receiving spawn objects during credits
|
||||||
|
if (gCurrActStarNum == 99) { return; }
|
||||||
|
|
||||||
u8 objectCount = 0;
|
u8 objectCount = 0;
|
||||||
packet_read(p, &objectCount, sizeof(u8));
|
packet_read(p, &objectCount, sizeof(u8));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue