mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Make sure lag_compensation_get_local_state() always returns a MarioState
This commit is contained in:
parent
f7ef932629
commit
1406f15995
1 changed files with 4 additions and 4 deletions
|
|
@ -40,16 +40,16 @@ void lag_compensation_store(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MarioState* lag_compensation_get_local_state(struct NetworkPlayer* otherNp) {
|
struct MarioState* lag_compensation_get_local_state(struct NetworkPlayer* otherNp) {
|
||||||
if (!otherNp) { return NULL; }
|
if (!otherNp) { return &gMarioStates[0]; }
|
||||||
if (gNetworkType == NT_NONE) { return NULL; }
|
if (gNetworkType == NT_NONE) { return &gMarioStates[0]; }
|
||||||
if (!sLocalStateHistoryReady) { return NULL; }
|
if (!sLocalStateHistoryReady) { return &gMarioStates[0]; }
|
||||||
|
|
||||||
s32 pingToTicks = (otherNp->ping / 1000.0f) * 30;
|
s32 pingToTicks = (otherNp->ping / 1000.0f) * 30;
|
||||||
if (pingToTicks > (MAX_LOCAL_STATE_HISTORY-1)) {
|
if (pingToTicks > (MAX_LOCAL_STATE_HISTORY-1)) {
|
||||||
pingToTicks = (MAX_LOCAL_STATE_HISTORY-1);
|
pingToTicks = (MAX_LOCAL_STATE_HISTORY-1);
|
||||||
}
|
}
|
||||||
//LOG_INFO("Ping: %s :: %u :: %d", otherNp->name, otherNp->ping, pingToTicks);
|
//LOG_INFO("Ping: %s :: %u :: %d", otherNp->name, otherNp->ping, pingToTicks);
|
||||||
if (pingToTicks == 0) { return NULL; }
|
if (pingToTicks == 0) { return &gMarioStates[0]; }
|
||||||
|
|
||||||
s32 index = (s32)sLocalStateHistoryIndex - pingToTicks;
|
s32 index = (s32)sLocalStateHistoryIndex - pingToTicks;
|
||||||
while (index < 0) { index += MAX_LOCAL_STATE_HISTORY; }
|
while (index < 0) { index += MAX_LOCAL_STATE_HISTORY; }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue