1-frame smoothing of network area timer

This commit is contained in:
MysterD 2021-08-10 00:48:39 -07:00
parent 7044485431
commit f82b6c7ad0
2 changed files with 10 additions and 2 deletions

View file

@ -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) {

View file

@ -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);
}