Play your Steam library's Windows games on a jailbroken PS5.
C++
Show Queue sizes and speeds in decimal units
Leonardo Lobatod2051ef19a1c
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex 14900a8..0d1ed92 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -37,7 +37,8 @@ namespace playden::homebrew {std::string FormatDownloadRate(std::optional<std::uint64_t> rate, std::optional<int> eta, const std::string& server_name) {if (!rate) return "—";char text[64];- std::snprintf(text, sizeof(text), "%.1f MB/s", static_cast<double>(*rate) / (1024.0 * 1024.0));+ // Decimal megabytes, as the sizes beside it and the download server picker.+ std::snprintf(text, sizeof(text), "%.1f MB/s", static_cast<double>(*rate) / 1e6);std::string result = server_name.empty() ? std::string(text) : server_name + " · " + text;result += " · ";if (!eta || *eta < 0) return result + "—";diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cppindex 1a8492f..6b716a8 100644--- a/src/homebrew/view.cpp+++ b/src/homebrew/view.cpp@@ -200,8 +200,9 @@ std::string byte_count(std::optional<std::uint64_t> bytes){if (!bytes)return "Unknown";- constexpr double mib = 1024.0 * 1024.0;- constexpr double gib = 1024.0 * mib;+ // Decimal units, as the rest of Playden (game pages, sheets, storage) and macOS show sizes.+ constexpr double mib = 1000.0 * 1000.0;+ constexpr double gib = 1000.0 * mib;std::array<char, 32> value{};// Below a gigabyte, megabytes: "0.2 GB" says little about a small game.if (*bytes < static_cast<std::uint64_t>(gib))diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cppindex fb90744..4e2f2cf 100644--- a/tests/homebrew_live_model_test.cpp+++ b/tests/homebrew_live_model_test.cpp@@ -671,17 +671,17 @@ void live_download_telemetry() {model.UpdateInstalls({job}, {});check(model.state().jobs.size() == 1 && model.state().jobs[0].bytes_per_second == 40055603 &&model.state().jobs[0].eta_seconds == 300, "live transfer telemetry reaches the Downloads model");- check(FormatDownloadRate(job.bytes_per_second, job.eta_seconds) == "38.2 MB/s · ~5 min left", "rate and ETA formatting");+ check(FormatDownloadRate(job.bytes_per_second, job.eta_seconds) == "40.1 MB/s · ~5 min left", "rate and ETA formatting");check(FormatDownloadRate(0, {}) == "0.0 MB/s · —", "stalled rate has no invented ETA");- check(FormatDownloadRate(1048576, {}) == "1.0 MB/s · —", "unknown total keeps rate but hides ETA");+ check(FormatDownloadRate(1000000, {}) == "1.0 MB/s · —", "unknown total keeps rate but hides ETA");check(FormatDownloadRate({}, 300) == "—", "unknown rate hides stale ETA");- check(FormatDownloadRate(1048576, 61, "Fastly") == "Fastly · 1.0 MB/s · ~2 min left", "the server comes first");+ check(FormatDownloadRate(1000000, 61, "Fastly") == "Fastly · 1.0 MB/s · ~2 min left", "the server comes first");check(FormatDownloadRate({}, 61, "Fastly") == "—", "no rate, no server");job.server_name = "Akamai";model.UpdateInstalls({job}, {});check(model.state().jobs[0].server_name == "Akamai", "the live server name reaches the Queue");- check(FormatDownloadRate(1048576, 59) == "1.0 MB/s · ~59 sec left", "short ETA");- check(FormatDownloadRate(1048576, 61) == "1.0 MB/s · ~2 min left", "ETA rounds up");+ check(FormatDownloadRate(1000000, 59) == "1.0 MB/s · ~59 sec left", "short ETA");+ check(FormatDownloadRate(1000000, 61) == "1.0 MB/s · ~2 min left", "ETA rounds up");for (const auto state : {JobState::Paused, JobState::Queued, JobState::Failed}) {job.state = state; // stale incoming fields must never appear outside an active transfermodel.UpdateInstalls({job}, {});diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cppindex 170bf93..ef489ff 100644--- a/tests/homebrew_simulation_test.cpp+++ b/tests/homebrew_simulation_test.cpp@@ -1468,7 +1468,7 @@ void synthetic_download_servers(const std::filesystem::path& fixtures, const stdplayden::homebrew::FormatDownloadRate(restarted.state().jobs.front().bytes_per_second,restarted.state().jobs.front().eta_seconds,restarted.state().jobs.front().server_name) ==- "Fastly · 17.4 MB/s · ~3 min left",+ "Fastly · 18.2 MB/s · ~3 min left","the Queue row names the download server");}