Files
AyeZeeBB 94a616feb9 Map downloads: one that has begun goes on when the session stops waiting
Follow-up to #225. The session still waits 30 minutes in all for a map
(checking, the two-minute question, download, install, apply, join), and
servers and lobbies still let a player go at 30 minutes. But a download
that has begun is no longer cut off at 27 minutes: a large map on a slow
connection never came at all that way.

- Once the download has begun, the session's deadline is the session's
  alone. The download goes on (up to its own four hours, as before #225),
  installs and is applied, and the player is told to join again; no
  rejoin is tried past the deadline, where the server would turn them
  away. "Map still downloading" says so when the session stops waiting.
- Before the download, the deadline still ends the check and the question.
  Declining or cancelling still stops it and removes the partial file.
- A download whose session has gone is not cancelled by joining another
  session; a new map need is turned away until it is done.
- The 27-minute transfer budget and its completion reserve are gone from
  map_fetch_policy.h, with their tests; the map download tests cover the
  new behaviour.
- The HTTPS timeout test compiles with warnings as errors (a signed and
  unsigned comparison), and get_text's stale-file removal is indented again.
- README: map downloads described as they now are.
2026-10-15 14:23:06 -05:00

25 lines
1.1 KiB
C++

#pragma once
#include <algorithm>
#include <cstdint>
namespace dingosdk::multiplayer::map_fetch_policy {
inline constexpr std::uint64_t second_us = 1000000;
// How long a session waits on a map being fetched: checking, confirmation, download, install,
// apply and join. The download itself is not cut short by it: one the session gave up on goes
// on to the end and installs, and the player joins again (map_download.cpp).
inline constexpr std::uint64_t session_us = 30ull * 60 * second_us;
inline constexpr std::uint64_t confirmation_us = 2ull * 60 * second_us;
inline constexpr std::uint64_t installed_load_us = 30ull * second_us;
// All timestamps belong to one process's monotonic clock; none go on the wire.
constexpr bool expired(std::uint64_t deadline, std::uint64_t now) noexcept {
return deadline && now >= deadline;
}
constexpr std::uint64_t remaining(std::uint64_t deadline, std::uint64_t now) noexcept {
return now < deadline ? deadline - now : 0;
}
constexpr bool host_expired(std::uint64_t started, std::uint64_t now) noexcept {
return started && now >= started && now - started >= session_us;
}
}