1-frame smoothing of network area timer
This commit is contained in:
parent
5a70348efb
commit
fc8546e61d
|
@ -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 New Issue