mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +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();
|
network_on_loaded_area();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update network area timer
|
||||||
|
u32 desiredNAT = gNetworkAreaTimer + 1;
|
||||||
gNetworkAreaTimer = (clock_elapsed_ticks() - gNetworkAreaTimerClock);
|
gNetworkAreaTimer = (clock_elapsed_ticks() - gNetworkAreaTimerClock);
|
||||||
|
if (gNetworkAreaTimer < desiredNAT) {
|
||||||
|
gNetworkAreaTimer++;
|
||||||
|
} else if (gNetworkAreaTimer > desiredNAT) {
|
||||||
|
gNetworkAreaTimer--;
|
||||||
|
}
|
||||||
|
|
||||||
// send out update packets
|
// send out update packets
|
||||||
if (gNetworkType != NT_NONE) {
|
if (gNetworkType != NT_NONE) {
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,14 @@ static u64 clock_elapsed_ns(void) {
|
||||||
if (!sClockInitialized) {
|
if (!sClockInitialized) {
|
||||||
struct timespec clock_start;
|
struct timespec clock_start;
|
||||||
_clock_gettime(&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;
|
sClockInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec clock_current;
|
struct timespec clock_current;
|
||||||
_clock_gettime(&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);
|
return (clock_current_ns - clock_start_ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue