From 4e7f3671d898cf9ff77e1b73a788580c4b4e3b13 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Wed, 4 Aug 2021 21:12:35 +0200 Subject: [PATCH] TimeTypes: Replace PlatformDurationMs() --- src/ai/PathFinderManager.cpp | 2 +- src/audio/Ambiance.cpp | 6 ++-- src/audio/Audio.cpp | 2 +- src/core/ArxGame.cpp | 4 +-- src/core/Core.cpp | 2 +- src/core/GameTime.cpp | 2 +- src/core/TimeTypes.h | 3 -- src/game/Player.cpp | 16 ++++----- src/game/Spells.cpp | 2 +- src/game/spell/Cheat.cpp | 6 ++-- src/game/spell/FlyingEye.cpp | 7 ++-- src/graphics/particle/MagicFlare.cpp | 2 +- src/gui/CharacterCreation.cpp | 2 +- src/gui/CinematicBorder.cpp | 4 +-- src/gui/Console.cpp | 2 +- src/gui/Credits.cpp | 4 +-- src/gui/Cursor.cpp | 2 +- src/gui/Hud.cpp | 35 +++++++++---------- src/gui/Interface.cpp | 12 +++---- src/gui/LoadLevelScreen.cpp | 2 +- src/gui/Text.h | 3 +- src/gui/book/Book.cpp | 4 +-- src/gui/debug/DebugKeys.cpp | 2 +- src/gui/hud/SecondaryInventory.cpp | 2 +- src/gui/menu/MenuCursor.cpp | 2 +- src/gui/menu/MenuFader.cpp | 2 +- src/gui/widget/KeybindWidget.cpp | 2 +- src/gui/widget/TextInputWidget.cpp | 2 +- src/input/Input.cpp | 6 ++-- .../crashhandler/CrashProcessorPOSIX.cpp | 4 +-- src/scene/GameSound.cpp | 2 +- src/scene/Interactive.cpp | 2 +- 32 files changed, 71 insertions(+), 79 deletions(-) diff --git a/src/ai/PathFinderManager.cpp b/src/ai/PathFinderManager.cpp index 36de7d2c1c..c3fbb0a33e 100644 --- a/src/ai/PathFinderManager.cpp +++ b/src/ai/PathFinderManager.cpp @@ -67,7 +67,7 @@ static constexpr const float PATHFINDER_HEURISTIC_RANGE = PATHFINDER_HEURISTIC_M static constexpr const float PATHFINDER_DISTANCE_MAX = 5000.0f; // Pathfinder Definitions -static const PlatformDuration PATHFINDER_UPDATE_INTERVAL = PlatformDurationMs(10); +static const PlatformDuration PATHFINDER_UPDATE_INTERVAL = 10ms; class PathFinderThread : public StoppableThread { diff --git a/src/audio/Ambiance.cpp b/src/audio/Ambiance.cpp index e002001553..ed2c2fa29d 100644 --- a/src/audio/Ambiance.cpp +++ b/src/audio/Ambiance.cpp @@ -113,7 +113,7 @@ struct KeySetting { !file->read(&_flags, 4)) { return false; } - min = _min, max = _max, interval = PlatformDurationMs(_interval); + min = _min, max = _max, interval = std::chrono::milliseconds(_interval); flags = KeyFlags::load(_flags); // TODO save/load flags return true; @@ -200,8 +200,8 @@ struct TrackKey { !z.load(file)) { return false; } - start = PlatformDurationMs(_start), loop = _loop + 1; - delay_min = PlatformDurationMs(_delay_min), delay_max = PlatformDurationMs(_delay_max); + start = std::chrono::milliseconds(_start), loop = _loop + 1; + delay_min = std::chrono::milliseconds(_delay_min), delay_max = std::chrono::milliseconds(_delay_max); return true; } diff --git a/src/audio/Audio.cpp b/src/audio/Audio.cpp index fbf88267ab..41b1a579af 100644 --- a/src/audio/Audio.cpp +++ b/src/audio/Audio.cpp @@ -743,7 +743,7 @@ void ambianceStop(AmbianceId ambianceId, PlatformDuration fadeInterval) { g_ambiances[ambianceId]->stop(fadeInterval); } -static const PlatformDuration ARX_SOUND_UPDATE_INTERVAL = PlatformDurationMs(100); +static constexpr PlatformDuration ARX_SOUND_UPDATE_INTERVAL = 100ms; class SoundUpdateThread : public StoppableThread { diff --git a/src/core/ArxGame.cpp b/src/core/ArxGame.cpp index 4a506153e8..871983b2ba 100644 --- a/src/core/ArxGame.cpp +++ b/src/core/ArxGame.cpp @@ -183,7 +183,7 @@ extern bool START_NEW_QUEST; SavegameHandle LOADQUEST_SLOT = SavegameHandle(); // OH NO, ANOTHER GLOBAL! - TEMP PATCH TO CLEAN CODE FLOW static fs::path g_saveToLoad; -static const PlatformDuration runeDrawPointInterval = PlatformDurationMs(16); // ~60fps +static const PlatformDuration runeDrawPointInterval = 16ms; // ~60fps extern EERIE_3DOBJ * arrowobj; @@ -597,7 +597,7 @@ ARX_PROGRAM_OPTION_ARG("loadsave", "", "Load a specific savegame file", &loadSav static bool HandleGameFlowTransitions() { - const PlatformDuration TRANSITION_DURATION = PlatformDurationMs(3600); + const PlatformDuration TRANSITION_DURATION = 3600ms; static PlatformInstant TRANSITION_START = 0; if(GameFlow::getTransition() == GameFlow::InGame) { diff --git a/src/core/Core.cpp b/src/core/Core.cpp index dbdf41b5e8..b9d985f21f 100644 --- a/src/core/Core.cpp +++ b/src/core/Core.cpp @@ -844,7 +844,7 @@ void ManageCombatModeAnimations() { Anglef desired = vectorToAngle(dest - pos); Anglef actual = unitVectorToAngle(dir); - float t = g_platformTime.lastFrameDuration() / PlatformDurationMs(100) * player.m_bowAimRatio; + float t = g_platformTime.lastFrameDuration() / 100ms * player.m_bowAimRatio; float dpitch = AngleDifference(actual.getPitch(), desired.getPitch()) * t; float dyaw = AngleDifference(desired.getYaw(), actual.getYaw()) * t; player.m_bowAimRotation.setPitch(glm::clamp(player.m_bowAimRotation.getPitch() + dpitch, -90.f, 90.f)); diff --git a/src/core/GameTime.cpp b/src/core/GameTime.cpp index 81f61790f7..3ee3ef24f7 100644 --- a/src/core/GameTime.cpp +++ b/src/core/GameTime.cpp @@ -64,7 +64,7 @@ void PlatformTime::updateFrame() { m_lastFrameDuration = currentTime - m_frameStartTime; // Limit simulation time per frame - m_lastFrameDuration = std::min(m_lastFrameDuration, PlatformDurationMs(100)); + m_lastFrameDuration = std::min(m_lastFrameDuration, PlatformDuration(100ms)); m_frameStartTime = currentTime; } diff --git a/src/core/TimeTypes.h b/src/core/TimeTypes.h index 2b181fb8bd..0a6c2a70d1 100644 --- a/src/core/TimeTypes.h +++ b/src/core/TimeTypes.h @@ -262,9 +262,6 @@ typedef DurationType PlatformDuration; return PlatformInstant(0) + std::chrono::microseconds(val); } -[[nodiscard]] inline constexpr PlatformDuration PlatformDurationMs(s64 val) noexcept { - return std::chrono::milliseconds(val); -} [[nodiscard]] inline constexpr PlatformDuration PlatformDurationMsf(float val) noexcept { return std::chrono::duration(val); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7712ced6ca..dba4167b3f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -439,12 +439,12 @@ void ARX_PLAYER_ComputePlayerFullStats() { player.Full_AimTime = PlatformDurationMsf(fFullAimTime); if(player.Full_AimTime <= 0) { - player.Full_AimTime = PlatformDurationMs(1500); + player.Full_AimTime = 1500ms; } player.Full_AimTime -= PlatformDurationMsf(fCalcHandicap); - if(player.Full_AimTime <= PlatformDurationMs(1500)) { - player.Full_AimTime = PlatformDurationMs(1500); + if(player.Full_AimTime <= 1500ms) { + player.Full_AimTime = 1500ms; } // TODO make these calculations moddable @@ -495,7 +495,7 @@ void ARX_PLAYER_ComputePlayerFullStats() { miscMod.armorClass = 100; player.m_miscMod.add(miscMod); - player.Full_AimTime = PlatformDurationMs(100); + player.Full_AimTime = 100ms; } if(sp_max) { PlayerAttribute attributeMod; @@ -525,7 +525,7 @@ void ARX_PLAYER_ComputePlayerFullStats() { miscMod.armorClass = 20; player.m_miscMod.add(miscMod); - player.Full_AimTime = PlatformDurationMs(100); + player.Full_AimTime = 100ms; } if(player.m_cheatPnuxActive) { PlayerAttribute attributeMod; @@ -1839,7 +1839,7 @@ static void PlayerMovementIterate(float DeltaTime) { if(REQUEST_JUMP != 0) { PlatformDuration t = g_platformTime.frameStart() - REQUEST_JUMP; - if(t >= 0 && t <= PlatformDurationMs(350)) { + if(t >= 0 && t <= 350ms) { REQUEST_JUMP = 0; spawnAudibleSound(player.pos, *entities.player()); ARX_SPEECH_Launch_No_Unicode_Seek("player_jump", entities.player()); @@ -1971,9 +1971,9 @@ static void PlayerMovementIterate(float DeltaTime) { float jump_mul = 1.f; PlatformDuration diff = g_platformTime.frameStart() - LAST_JUMP_ENDTIME; - if(diff < PlatformDurationMs(600)) { + if(diff < 600ms) { jump_mul = 0.5f; - if(diff >= PlatformDurationMs(300)) { + if(diff >= 300ms) { jump_mul += (toMs(LAST_JUMP_ENDTIME - g_platformTime.frameStart()) + 300.f) * (1.f / 300); if(jump_mul > 1.f) { jump_mul = 1.f; diff --git a/src/game/Spells.cpp b/src/game/Spells.cpp index 8fa921b98c..57b9d75038 100644 --- a/src/game/Spells.cpp +++ b/src/game/Spells.cpp @@ -545,7 +545,7 @@ void ARX_SPELLS_ManageMagic() { PlatformInstant now = g_platformTime.frameStart(); - const PlatformDuration interval = PlatformDurationMs(1000 / 60); + const PlatformDuration interval = std::chrono::microseconds(1s) / 60; if(ARX_FLARES_broken) { g_LastFlarePosition = pos; diff --git a/src/game/spell/Cheat.cpp b/src/game/spell/Cheat.cpp index 7a78f56e3e..79ed447b5b 100644 --- a/src/game/spell/Cheat.cpp +++ b/src/game/spell/Cheat.cpp @@ -79,9 +79,9 @@ void CheatDrawText() { PlatformDuration elapsed = g_platformTime.frameStart() - sp_max_start; - if(elapsed < PlatformDurationMs(20000)) { + if(elapsed < 20s) { - float modi = (PlatformDurationMs(20000) - elapsed) / PlatformDurationMs(2000) * 0.1f; + float modi = (20s - elapsed) / 2s * 0.1f; float sizX = 16; Vec2f p = Vec2f(g_size.center()); @@ -90,7 +90,7 @@ void CheatDrawText() { for(size_t i = 0; i < sp_max_ch.length(); i++) { Vec2f d = p + Vec2f(sizX * i, sp_max_y[i]); - sp_max_y[i] = std::sin(d.x + elapsed / PlatformDurationMs(100)) * 30.f * modi; + sp_max_y[i] = std::sin(d.x + elapsed / 100ms) * 30.f * modi; std::string tex(1, sp_max_ch[i]); UNICODE_ARXDrawTextCenter(hFontInGame, d + Vec2f(-1, -1), tex, Color::none); diff --git a/src/game/spell/FlyingEye.cpp b/src/game/spell/FlyingEye.cpp index 63902f0341..92d895c38a 100644 --- a/src/game/spell/FlyingEye.cpp +++ b/src/game/spell/FlyingEye.cpp @@ -65,14 +65,11 @@ void DrawMagicSightInterface() { } EERIEDrawBitmap(Rectf(g_size), 0.0001f, Flying_Eye, Color::gray(col)); - + if(MagicSightFader > 0.f) { col = MagicSightFader; - EERIEDrawBitmap(Rectf(g_size), 0.0001f, nullptr, Color::gray(col)); - - MagicSightFader -= g_platformTime.lastFrameDuration() / PlatformDurationMs(400); - + MagicSightFader -= g_platformTime.lastFrameDuration() / 400ms; if(MagicSightFader < 0.f) { MagicSightFader = 0.f; } diff --git a/src/graphics/particle/MagicFlare.cpp b/src/graphics/particle/MagicFlare.cpp index 2115313914..9d116e4aa8 100644 --- a/src/graphics/particle/MagicFlare.cpp +++ b/src/graphics/particle/MagicFlare.cpp @@ -384,7 +384,7 @@ void ARX_MAGICAL_FLARES_Update() { flare.tolive -= diff * 6; } - float z = flare.tolive / PlatformDurationMs(4000); + float z = flare.tolive / 4s; float size; if(flare.type == 1) { size = flare.size * 2 * z; diff --git a/src/gui/CharacterCreation.cpp b/src/gui/CharacterCreation.cpp index a84e039d04..be8e2ff7ba 100644 --- a/src/gui/CharacterCreation.cpp +++ b/src/gui/CharacterCreation.cpp @@ -92,7 +92,7 @@ static void characterCreationAddDescription(std::string_view text) { float(g_size.center().x) * 0.82f, std::string(text), Color(232 + t, 204 + t, 143 + t), - PlatformDurationMs(1000), + 1s, 0.01f, 3, 0); diff --git a/src/gui/CinematicBorder.cpp b/src/gui/CinematicBorder.cpp index 9c939527f9..11b29c7694 100644 --- a/src/gui/CinematicBorder.cpp +++ b/src/gui/CinematicBorder.cpp @@ -84,14 +84,14 @@ void CinematicBorder::set(bool status, bool smooth) { void CinematicBorder::update() { if(m_direction == 1) { - CINEMA_DECAL += g_platformTime.lastFrameDuration() / PlatformDurationMs(10); + CINEMA_DECAL += g_platformTime.lastFrameDuration() / 10ms; if(CINEMA_DECAL > 100.f) { CINEMA_DECAL = 100.f; m_direction = 0; } } else if(m_direction == -1) { - CINEMA_DECAL -= g_platformTime.lastFrameDuration() / PlatformDurationMs(10); + CINEMA_DECAL -= g_platformTime.lastFrameDuration() / 10ms; if(CINEMA_DECAL < 0.f) { CINEMA_DECAL = 0.f; diff --git a/src/gui/Console.cpp b/src/gui/Console.cpp index db4d862916..73c28fe31b 100644 --- a/src/gui/Console.cpp +++ b/src/gui/Console.cpp @@ -635,7 +635,7 @@ void ScriptConsole::draw() { // Draw cursor bool blink = true; if(mainApp->getWindow()->hasFocus()) { - blink = timeWaveSquare(g_platformTime.frameStart(), PlatformDurationMs(1200)); + blink = timeWaveSquare(g_platformTime.frameStart(), 1200ms); } if(blink) { int cursor = x; diff --git a/src/gui/Credits.cpp b/src/gui/Credits.cpp index 7ae1ae98c8..3b11dcc379 100644 --- a/src/gui/Credits.cpp +++ b/src/gui/Credits.cpp @@ -473,8 +473,8 @@ void Credits::render() { static PlatformInstant lastUserScrollTime = 0; static float scrollDirection = 1.f; - PlatformDuration keyRepeatDelay = PlatformDurationMs(256); // delay after key press before continuous scrolling - PlatformDuration autoScrollDelay = PlatformDurationMs(250); // ms after user input before resuming normal scrolling + PlatformDuration keyRepeatDelay = 256ms; // delay after key press before continuous scrolling + PlatformDuration autoScrollDelay = 250ms; // ms after user input before resuming normal scrolling // Process user input float userScroll = 20.f * GInput->getMouseWheelDir(); diff --git a/src/gui/Cursor.cpp b/src/gui/Cursor.cpp index de6dd217f8..9403bbff5b 100644 --- a/src/gui/Cursor.cpp +++ b/src/gui/Cursor.cpp @@ -193,7 +193,7 @@ class CursorAnimatedHand { CursorAnimatedHand() : m_time(0) , m_frame(0) - , m_delay(PlatformDurationMs(70)) + , m_delay(70ms) {} void reset() { diff --git a/src/gui/Hud.cpp b/src/gui/Hud.cpp index ac79769d8d..9c6527a4b5 100644 --- a/src/gui/Hud.cpp +++ b/src/gui/Hud.cpp @@ -117,7 +117,7 @@ void HitStrengthGauge::update() { if(m_flashActive) { m_flashTime += g_platformTime.lastFrameDuration(); - if(m_flashTime >= PlatformDurationMs(500)) { + if(m_flashTime >= 500ms) { m_flashActive = false; m_flashTime = 0; } @@ -208,7 +208,7 @@ void BookIconGui::update(const Rectf & parent) { if(m_haloActive) { ulBookHaloTime += g_platformTime.lastFrameDuration(); - if(ulBookHaloTime >= PlatformDurationMs(3000)) { // ms + if(ulBookHaloTime >= 3s) { m_haloActive = false; } } @@ -263,7 +263,7 @@ void BackpackIconGui::updateInput() { flDelay = g_platformTime.frameStart(); return; } - if(g_platformTime.frameStart() - flDelay < PlatformDurationMs(300)) { + if(g_platformTime.frameStart() - flDelay < 300ms) { return; } flDelay = 0; @@ -424,7 +424,7 @@ void PurseIconGui::update(const Rectf & parent) { if(m_haloActive) { m_haloTime += g_platformTime.lastFrameDuration(); - if(m_haloTime >= PlatformDurationMs(1000)) { + if(m_haloTime >= 1s) { m_haloActive = false; } } @@ -1323,10 +1323,10 @@ void PlayerInterfaceFader::requestFade(FadeDirection showhide, long smooth) { if(showhide == FadeDirection_In) { m_current = 0; } else { - m_current = PlatformDurationMs(1000); + m_current = 1s; } - lSLID_VALUE = m_current / PlatformDurationMs(10); + lSLID_VALUE = m_current / 10ms; } } @@ -1344,17 +1344,16 @@ void PlayerInterfaceFader::update() { bOk = false; PlatformInstant t = g_platformTime.frameStart(); - - if(t - SLID_START > PlatformDurationMs(10000)) { + if(t - SLID_START > 10s) { m_current += g_platformTime.lastFrameDuration(); - - if(m_current > PlatformDurationMs(1000)) - m_current = PlatformDurationMs(1000); - - lSLID_VALUE = m_current / PlatformDurationMs(10); + if(m_current > 1s) { + m_current = 1s; + } + lSLID_VALUE = m_current / 10ms; } else { bOk = true; } + } } @@ -1365,18 +1364,18 @@ void PlayerInterfaceFader::update() { m_current = 0; } - lSLID_VALUE = m_current / PlatformDurationMs(10); + lSLID_VALUE = m_current / 10ms; } } if(m_direction == 1) { m_current += g_platformTime.lastFrameDuration(); - if(m_current > PlatformDurationMs(1000)) { - m_current = PlatformDurationMs(1000); + if(m_current > 1s) { + m_current = 1s; m_direction = 0; } - lSLID_VALUE = m_current / PlatformDurationMs(10); + lSLID_VALUE = m_current / 10ms; } else if(m_direction == -1) { m_current -= g_platformTime.lastFrameDuration(); @@ -1384,7 +1383,7 @@ void PlayerInterfaceFader::update() { m_current = 0; m_direction = 0; } - lSLID_VALUE = m_current / PlatformDurationMs(10); + lSLID_VALUE = m_current / 10ms; } } diff --git a/src/gui/Interface.cpp b/src/gui/Interface.cpp index 8b084e0e87..d1647cd962 100644 --- a/src/gui/Interface.cpp +++ b/src/gui/Interface.cpp @@ -771,7 +771,7 @@ void ArxGame::managePlayerControls() { eyeball.pos.y += val - 70.f; } if(!npc) { - MagicSightFader += g_platformTime.lastFrameDuration() / PlatformDurationMs(200); + MagicSightFader += g_platformTime.lastFrameDuration() / 200ms; if(MagicSightFader > 1.f) MagicSightFader = 1.f; } @@ -1136,7 +1136,7 @@ void ArxGame::managePlayerControls() { if(eeMouseDown1()) { COMBAT_MODE_ON_START_TIME = g_platformTime.frameStart(); } else { - if(g_platformTime.frameStart() - COMBAT_MODE_ON_START_TIME > PlatformDurationMs(10)) { + if(g_platformTime.frameStart() - COMBAT_MODE_ON_START_TIME > 10ms) { ARX_INTERFACE_setCombatMode(COMBAT_MODE_ON); } } @@ -1494,10 +1494,10 @@ void ArxGame::manageKeyMouse() { } else { int borderSize = 10; - PlatformDuration borderDelay = PlatformDurationMs(100); + PlatformDuration borderDelay = 100ms; if(!dragging && !mainApp->getWindow()->isFullScreen()) { borderSize = 50; - borderDelay = PlatformDurationMs(200); + borderDelay = 200ms; } int distLeft = DANAEMouse.x - g_size.left; @@ -1510,7 +1510,7 @@ void ArxGame::manageKeyMouse() { || (!dragging && distBottom < g_size.height() / 4 && distRight <= borderSize) || (!dragging && distTop <= 4 * borderSize && distRight <= 4 * borderSize)) { borderSize = 2; - borderDelay = PlatformDurationMs(600); + borderDelay = 600ms; } rotation = Vec2f(0.f); @@ -1649,7 +1649,7 @@ void ArxGame::manageEntityDescription() { pTextManage->Clear(); std::string description = ss.str(); if(!config.input.autoDescription) { - PlatformDuration duration = PlatformDurationMs(2000 + description.length() * 60); + PlatformDuration duration = 2s + description.length() * 60ms; pTextManage->AddText(hFontInGame, std::move(description), rDraw, Color(232, 204, 143), duration); } else { pTextManage->AddText(hFontInGame, std::move(description), rDraw, Color(232, 204, 143)); diff --git a/src/gui/LoadLevelScreen.cpp b/src/gui/LoadLevelScreen.cpp index 4c657323b7..df4bf705a2 100644 --- a/src/gui/LoadLevelScreen.cpp +++ b/src/gui/LoadLevelScreen.cpp @@ -77,7 +77,7 @@ void LoadLevelScreen(long num) { // only update if time since last update to progress bar > 16ms // and progress bar's value has actually changed PlatformInstant now = platform::getTime(); - if(now - last_progress_bar_update > PlatformDurationMs(16) && OLD_PROGRESS_BAR_COUNT != PROGRESS_BAR_COUNT) { + if(now - last_progress_bar_update > 16ms && OLD_PROGRESS_BAR_COUNT != PROGRESS_BAR_COUNT) { UseTextureState textureState(TextureStage::FilterLinear, TextureStage::WrapClamp); diff --git a/src/gui/Text.h b/src/gui/Text.h index 1482eb42ff..a6cfff017d 100644 --- a/src/gui/Text.h +++ b/src/gui/Text.h @@ -72,7 +72,8 @@ void UNICODE_ARXDrawTextCenter(Font * font, const Vec2f & pos, std::string_view void UNICODE_ARXDrawTextCenteredScroll(Font * font, float x, float y, float x2, std::string && text, Color col, PlatformDuration iTimeScroll, float fSpeed, - int iNbLigne, PlatformDuration iTimeOut = PlatformDurationMs(INT_MAX)); + int iNbLigne, + PlatformDuration iTimeOut = std::chrono::milliseconds(INT_MAX)); long ARX_UNICODE_ForceFormattingInRect(Font * font, std::string_view text, const Rect & rect, bool noOneLineParagraphs = false); diff --git a/src/gui/book/Book.cpp b/src/gui/book/Book.cpp index 3abbb1b996..6cf7522258 100644 --- a/src/gui/book/Book.cpp +++ b/src/gui/book/Book.cpp @@ -746,7 +746,7 @@ void StatsPage::manageStats() float(g_size.center().x) * 0.82f, std::move(toDisplay), Color(232 + t, 204 + t, 143 + t), - PlatformDurationMs(1000), + 1s, 0.01f, 3, 0); @@ -1421,7 +1421,7 @@ void SpellsPage::drawSpells() const { UNICODE_ARXDrawTextCenteredScroll(hFontInGame, float(g_size.center().x), 12, float(g_size.center().x) * 0.82f, std::string(getLocalised(spellInfo.description)), - Color(232, 204, 143), PlatformDurationMs(1000), 0.01f, 2, 0); + Color(232, 204, 143), 1s, 0.01f, 2, 0); size_t count = 0; diff --git a/src/gui/debug/DebugKeys.cpp b/src/gui/debug/DebugKeys.cpp index 36b62ce423..ca7e8a70f6 100644 --- a/src/gui/debug/DebugKeys.cpp +++ b/src/gui/debug/DebugKeys.cpp @@ -24,7 +24,7 @@ #include "gui/debug/DebugPanel.h" #include "input/Input.h" -static const PlatformDuration g_debugTriggersDecayDuration = PlatformDurationMs(200); +static const PlatformDuration g_debugTriggersDecayDuration = 200ms; bool g_debugToggles[10]; bool g_debugTriggers[10]; diff --git a/src/gui/hud/SecondaryInventory.cpp b/src/gui/hud/SecondaryInventory.cpp index cf1d99ca10..7c1bbf971b 100644 --- a/src/gui/hud/SecondaryInventory.cpp +++ b/src/gui/hud/SecondaryInventory.cpp @@ -508,7 +508,7 @@ void SecondaryInventoryHud::clear(Entity * container) { void SecondaryInventoryHud::updateFader() { if(m_fadeDirection != Fade_stable) { - float frameDelay = g_platformTime.lastFrameDuration() / PlatformDurationMs(3); + float frameDelay = g_platformTime.lastFrameDuration() / 3ms; if((player.Interface & INTER_COMBATMODE) || player.doingmagic >= 2 || m_fadeDirection == Fade_left) { if(m_fadePosition > -160) diff --git a/src/gui/menu/MenuCursor.cpp b/src/gui/menu/MenuCursor.cpp index d12874a7f2..d524c21f53 100644 --- a/src/gui/menu/MenuCursor.cpp +++ b/src/gui/menu/MenuCursor.cpp @@ -194,7 +194,7 @@ void MenuCursor::DrawCursor() { lFrameDiff += g_platformTime.lastFrameDuration(); - if(lFrameDiff > PlatformDurationMs(70)) { + if(lFrameDiff > 70ms) { if(bMouseOver) { if(m_currentFrame < 4) { m_currentFrame++; diff --git a/src/gui/menu/MenuFader.cpp b/src/gui/menu/MenuFader.cpp index f8fa87ffd0..f246fb57ac 100644 --- a/src/gui/menu/MenuFader.cpp +++ b/src/gui/menu/MenuFader.cpp @@ -67,7 +67,7 @@ static void FadeInOut(float _fVal) { bool MenuFader_process() { - const PlatformDuration fadeDuration = PlatformDurationMs(1000); + const PlatformDuration fadeDuration = 1s; float alpha = menuFadeElapsed / fadeDuration; FadeInOut(alpha); diff --git a/src/gui/widget/KeybindWidget.cpp b/src/gui/widget/KeybindWidget.cpp index f70b245aa0..fc279aae65 100644 --- a/src/gui/widget/KeybindWidget.cpp +++ b/src/gui/widget/KeybindWidget.cpp @@ -107,7 +107,7 @@ void KeybindWidget::render(bool mouseOver) { if(m_editing) { bool blink = true; if(mainApp->getWindow()->hasFocus()) { - blink = timeWaveSquare(g_platformTime.frameStart(), PlatformDurationMs(400)); + blink = timeWaveSquare(g_platformTime.frameStart(), 400ms); } color = blink ? Color::white : (Color::red * 0.2f); } else if(!m_enabled) { diff --git a/src/gui/widget/TextInputWidget.cpp b/src/gui/widget/TextInputWidget.cpp index ff1152f98a..fb44b3c6b0 100644 --- a/src/gui/widget/TextInputWidget.cpp +++ b/src/gui/widget/TextInputWidget.cpp @@ -197,7 +197,7 @@ void TextInputWidget::render(bool mouseOver) { if(m_editing) { bool blink = true; if(mainApp->getWindow()->hasFocus()) { - blink = timeWaveSquare(g_platformTime.frameStart(), PlatformDurationMs(1200)); + blink = timeWaveSquare(g_platformTime.frameStart(), 1200ms); } if(blink) { int cursor = x; diff --git a/src/input/Input.cpp b/src/input/Input.cpp index 6c9050896c..4592d15bec 100644 --- a/src/input/Input.cpp +++ b/src/input/Input.cpp @@ -504,7 +504,7 @@ void Input::update(float time) { iOldNumClick[i]--; } - if(iMouseTimeSet[i] > 1 || (iMouseTimeSet[i] == 1 && now - iMouseTime[i][0] > PlatformDurationMs(300))) { + if(iMouseTimeSet[i] > 1 || (iMouseTimeSet[i] == 1 && now - iMouseTime[i][0] > 300ms)) { iMouseTime[i][0] = 0; iMouseTime[i][1] = 0; iMouseTimeSet[i] = 0; @@ -799,10 +799,8 @@ bool Input::getMouseButtonNowUnPressed(int buttonId) const { bool Input::getMouseButtonDoubleClick(int buttonId) const { arx_assert(buttonId >= Mouse::ButtonBase && buttonId < Mouse::ButtonMax); - const PlatformDuration interval = PlatformDurationMs(300); - int buttonIdx = buttonId - Mouse::ButtonBase; - return (iMouseTimeSet[buttonIdx] == 2 && iMouseTime[buttonIdx][1] - iMouseTime[buttonIdx][0] < interval); + return (iMouseTimeSet[buttonIdx] == 2 && iMouseTime[buttonIdx][1] - iMouseTime[buttonIdx][0] < 300ms); } int Input::getMouseButtonClicked() const { diff --git a/src/platform/crashhandler/CrashProcessorPOSIX.cpp b/src/platform/crashhandler/CrashProcessorPOSIX.cpp index bedd0ad465..acb0f2f65c 100644 --- a/src/platform/crashhandler/CrashProcessorPOSIX.cpp +++ b/src/platform/crashhandler/CrashProcessorPOSIX.cpp @@ -484,7 +484,7 @@ void CrashHandlerPOSIX::processCrashDump() { && m_pCrashInfo->processId != platform::getProcessId()) { kill(m_pCrashInfo->processId, SIGABRT); for(size_t i = 1; platform::isProcessRunning(m_pCrashInfo->processId) && i < 10; i++) { - Thread::sleep(PlatformDurationMs(100)); + Thread::sleep(100ms); } fs::path core = util::loadString(m_pCrashInfo->coreDumpFile); fs::path crashReportDir = m_crashReportDir.parent(); @@ -496,7 +496,7 @@ void CrashHandlerPOSIX::processCrashDump() { u64 oldsize, newsize = fs::file_size(core); do { oldsize = newsize; - Thread::sleep(PlatformDurationMs(500)); + Thread::sleep(500ms); newsize = fs::file_size(core); } while(newsize != oldsize); } diff --git a/src/scene/GameSound.cpp b/src/scene/GameSound.cpp index 9fde5203a0..08a9a6508e 100644 --- a/src/scene/GameSound.cpp +++ b/src/scene/GameSound.cpp @@ -91,7 +91,7 @@ using audio::FLAG_AUTOFREE; extern bool EXTERNALVIEW; static const unsigned long MAX_VARIANTS = 5; -static const PlatformDuration AMBIANCE_FADE_TIME = PlatformDurationMs(2000); +static const PlatformDuration AMBIANCE_FADE_TIME = 2s; static const float ARX_SOUND_DEFAULT_FALLSTART = 200.f; static const float ARX_SOUND_DEFAULT_FALLEND = 2200.f; diff --git a/src/scene/Interactive.cpp b/src/scene/Interactive.cpp index c614e79817..c3e30b22c2 100644 --- a/src/scene/Interactive.cpp +++ b/src/scene/Interactive.cpp @@ -205,7 +205,7 @@ void ARX_INTERACTIVE_DestroyDynamicInfo(Entity * io) { // to check again later... long count = 50; while((io->_npcdata->pathfind.pathwait == 1) && count--) { - Thread::sleep(PlatformDurationMs(1)); + Thread::sleep(1ms); } delete[] io->_npcdata->pathfind.list; io->_npcdata->pathfind = IO_PATHFIND();