From c60b3557abd5ebb42faa26ebc04f69f4b298bbec Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sun, 7 Jan 2024 20:51:29 -0600 Subject: [PATCH] Round times, add best * 110% as another gold time --- src/p_setup.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index a1af94db5..fa3e56442 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -8853,6 +8853,11 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l return lumpinfo; } +static tic_t round_to_next_second(tic_t time) +{ + return static_cast(std::ceil(time / static_cast(TICRATE)) * TICRATE); +} + static void P_DeriveAutoMedalTimes(mapheader_t& map) { // Gather staff ghost times @@ -8881,21 +8886,25 @@ static void P_DeriveAutoMedalTimes(mapheader_t& map) std::sort(stafftimes.begin(), stafftimes.end()); // Auto Platinum is the best staff ghost time - // Auto Gold is the median staff ghost time - // Silver and Bronze are 10% longer successively + // Auto Gold is the median staff ghost time or 10% longer than Platinum, whichever is higher + // Silver and Bronze are 10% longer and 10% longer successively + // Gold, Silver and Bronze are rounded up to the next second tic_t best = stafftimes.at(0); - tic_t gold = stafftimes.at(stafftimes.size() / 2); + tic_t gold = std::max( + round_to_next_second(stafftimes.at(stafftimes.size() / 2)), + round_to_next_second(static_cast(std::ceil(best * 1.1f))) + ); if (gold == best) { gold += 1; } - tic_t silver = static_cast(std::ceil(gold * 1.1f)); + tic_t silver = round_to_next_second(static_cast(std::ceil(gold * 1.1f))); if (silver == gold) { silver += 1; } - tic_t bronze = static_cast(std::ceil(silver * 1.1f)); + tic_t bronze = round_to_next_second(static_cast(std::ceil(silver * 1.1f))); if (bronze == silver) { bronze += 1;