mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-12-09 09:32:55 +00:00
Re-request level or area if stuck in invalid state for a while
This commit is contained in:
parent
8ce66b76c6
commit
32e0c9eda2
4 changed files with 31 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ u32 gNetworkAreaTimerClock = 0;
|
|||
u32 gNetworkAreaTimer = 0;
|
||||
void* gNetworkServerAddr = NULL;
|
||||
bool gNetworkSentJoin = false;
|
||||
u8 gNetworkRequestLocationTimer = 0;
|
||||
|
||||
u8 gDebugPacketIdBuffer[256] = { 0xFF };
|
||||
u8 gDebugPacketSentBuffer[256] = { 0 };
|
||||
|
|
@ -424,6 +425,33 @@ void network_update(void) {
|
|||
network_update_reliable();
|
||||
packet_ordered_update();
|
||||
}
|
||||
|
||||
// update level/area request timers
|
||||
struct NetworkPlayer* np = gNetworkPlayerLocal;
|
||||
if (np != NULL && !np->currLevelSyncValid) {
|
||||
gNetworkRequestLocationTimer++;
|
||||
if (gNetworkRequestLocationTimer > 90) {
|
||||
// find a NetworkPlayer around that location
|
||||
struct NetworkPlayer *npLevelAreaMatch = get_network_player_from_area(np->currCourseNum, np->currActNum, np->currLevelNum, np->currAreaIndex);
|
||||
struct NetworkPlayer *npLevelMatch = get_network_player_from_level(np->currCourseNum, np->currActNum, np->currLevelNum);
|
||||
struct NetworkPlayer *npAny = (npLevelAreaMatch == NULL) ? npLevelMatch : npLevelAreaMatch;
|
||||
|
||||
bool inCredits = (np->currActNum == 99);
|
||||
if (npAny == NULL || inCredits) {
|
||||
// no NetworkPlayer in the level
|
||||
network_send_sync_valid(np, np->currCourseNum, np->currActNum, np->currLevelNum, np->currAreaIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
// matching NetworkPlayer is client
|
||||
if (npAny == npLevelAreaMatch) {
|
||||
network_send_level_area_request(np, npAny);
|
||||
} else {
|
||||
network_send_level_request(np, npAny);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void network_register_mod(char* modName) {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ extern struct SyncObject gSyncObjects[];
|
|||
extern struct ServerSettings gServerSettings;
|
||||
extern struct StringLinkedList gRegisteredMods;
|
||||
extern bool gNetworkSentJoin;
|
||||
|
||||
extern u8 gNetworkRequestLocationTimer;
|
||||
extern u8 gDebugPacketIdBuffer[];
|
||||
extern u8 gDebugPacketSentBuffer[];
|
||||
extern u8 gDebugPacketOnBuffer;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_area_request(struct NetworkPlayer* fromNp, struct NetworkPlayer* toNp) {
|
||||
gNetworkRequestLocationTimer = 0;
|
||||
if (gNetworkType == NT_SERVER && toNp == gNetworkPlayerLocal) {
|
||||
// requesting server's area, send it immediately
|
||||
network_send_area(fromNp);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_level_request(struct NetworkPlayer* fromNp, struct NetworkPlayer* toNp) {
|
||||
gNetworkRequestLocationTimer = 0;
|
||||
if (gNetworkType == NT_SERVER && toNp == gNetworkPlayerLocal) {
|
||||
// requesting server's level, send it immediately
|
||||
network_send_level(fromNp, false);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue