mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-28 23:13:02 +00:00
1-frame smoothing of network area timer
This commit is contained in:
parent
7044485431
commit
f82b6c7ad0
2 changed files with 10 additions and 2 deletions
|
@ -266,7 +266,15 @@ void network_update(void) {
|
|||
network_on_loaded_area();
|
||||
}
|
||||
}
|
||||
|
||||
// update network area timer
|
||||
u32 desiredNAT = gNetworkAreaTimer + 1;
|
||||
gNetworkAreaTimer = (clock_elapsed_ticks() - gNetworkAreaTimerClock);
|
||||
if (gNetworkAreaTimer < desiredNAT) {
|
||||
gNetworkAreaTimer++;
|
||||
} else if (gNetworkAreaTimer > desiredNAT) {
|
||||
gNetworkAreaTimer--;
|
||||
}
|
||||
|
||||
// send out update packets
|
||||
if (gNetworkType != NT_NONE) {
|
||||
|
|
|
@ -56,14 +56,14 @@ static u64 clock_elapsed_ns(void) {
|
|||
if (!sClockInitialized) {
|
||||
struct timespec clock_start;
|
||||
_clock_gettime(&clock_start);
|
||||
clock_start_ns = ((u64)clock_start.tv_sec) * 1000000000 + clock_start.tv_nsec;
|
||||
clock_start_ns = ((u64)clock_start.tv_sec) * 1000000000 + ((u64)clock_start.tv_nsec);
|
||||
sClockInitialized = true;
|
||||
}
|
||||
|
||||
struct timespec clock_current;
|
||||
_clock_gettime(&clock_current);
|
||||
|
||||
u64 clock_current_ns = ((u64)clock_current.tv_sec) * 1000000000 + clock_current.tv_nsec;
|
||||
u64 clock_current_ns = ((u64)clock_current.tv_sec) * 1000000000 + ((u64)clock_current.tv_nsec);
|
||||
return (clock_current_ns - clock_start_ns);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue