mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-28 00:17:08 +01:00
Coordinate custom-map downloads with the multiplayer deadline
Co-authored-by: Jean-LucTch <88255067+Jean-LucTch@users.noreply.github.com>
This commit is contained in:
1 parent
28118efc27
commit
8eddcab142
17 files changed
+919
-70
No files matched your search
@@ -211,7 +211,7 @@ void Host::fetching(Guest &guest) {
|
||||
guest.fetching_since = now_;
|
||||
log_("[map] " + guest_name(guest) + " is downloading the map");
|
||||
}
|
||||
if (now_ - guest.fetching_since > map_fetch_limit_us) return;
|
||||
if (map_fetch_policy::host_expired(guest.fetching_since, now_)) return;
|
||||
if (!guest.handshaken) guest.connected_at = now_;
|
||||
else if (guest.travel_since) guest.travel_since = now_;
|
||||
}
|
||||
@@ -1093,6 +1093,9 @@ void Host::receive(std::uint64_t peer, std::span<const std::uint8_t> bytes, std:
|
||||
if (!decoded || decoded->session != secret_ || decoded->source != peer)
|
||||
return drop(peer, "Join code, sender identity, or multiplayer protocol did not match.");
|
||||
const auto &p = *decoded;
|
||||
if (link->fetching_since && (!link->handshaken || link->travel_since) &&
|
||||
map_fetch_policy::host_expired(link->fetching_since, now_))
|
||||
return drop(peer, "The server stopped waiting for the map download.");
|
||||
link->traffic.total.in[traffic_kind(p.kind)] += bytes.size();
|
||||
traffic_.total.in[traffic_kind(p.kind)] += bytes.size();
|
||||
switch (p.kind) {
|
||||
@@ -1790,6 +1793,11 @@ void Host::tick(std::uint64_t now) {
|
||||
auto &g = *(it++)->second;
|
||||
// Authorized arrivals get time for loading; this deadline is absolute, so
|
||||
// requests cannot hold an unused slot indefinitely.
|
||||
if (g.fetching_since && (!g.handshaken || g.travel_since) &&
|
||||
map_fetch_policy::host_expired(g.fetching_since, now_)) {
|
||||
drop(g.member.id, "The server stopped waiting for the map download.");
|
||||
continue;
|
||||
}
|
||||
const std::uint64_t handshake_timeout = g.map_authorized ? 180000000 : 8000000;
|
||||
if (g.handshaken && g.travel_since) {
|
||||
if (now_ - g.travel_since > 180000000) drop(g.member.id, "Could not finish loading the new map.");
|
||||
|
||||
Reference in new issue
Block a user