From 6fc32f44df8f7dae461c125abc882e0affd677cb Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Apr 2020 22:41:16 -0400 Subject: [PATCH 1/2] CRumbleGenerator: Make use of fmt::print instead of printf Less need to care about formatting specifiers. --- Runtime/Input/CRumbleGenerator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Runtime/Input/CRumbleGenerator.cpp b/Runtime/Input/CRumbleGenerator.cpp index 7887c405d..ce2ee350a 100644 --- a/Runtime/Input/CRumbleGenerator.cpp +++ b/Runtime/Input/CRumbleGenerator.cpp @@ -24,8 +24,9 @@ void CRumbleGenerator::Update(float dt) { if (!b_tp) { b_tp = true; s_tp = now; - } else + } else { ms = std::chrono::duration_cast(now - s_tp).count(); + } #endif if (!xf0_24_disabled) { @@ -38,7 +39,7 @@ void CRumbleGenerator::Update(float dt) { if (xe0_commandArray[i] != EMotorState::Stop) { #if PWM_MONITOR s_tp = now; - printf("%lldms ON\n", ms); + fmt::print(FMT_STRING("{}ms ON\n"), ms); #endif xe0_commandArray[i] = EMotorState::Stop; updated = true; @@ -50,7 +51,7 @@ void CRumbleGenerator::Update(float dt) { if (xe0_commandArray[i] != EMotorState::Rumble) { #if PWM_MONITOR s_tp = now; - printf("%lldms Off\n", ms); + fmt::print(FMT_STRING("{}ms Off\n"), ms); #endif xe0_commandArray[i] = EMotorState::Rumble; updated = true; @@ -62,7 +63,7 @@ void CRumbleGenerator::Update(float dt) { if (xe0_commandArray[i] != EMotorState::Stop) { #if PWM_MONITOR s_tp = now; - printf("%lldms ON\n", ms); + fmt::print(FMT_STRING("{}ms ON\n"), ms); #endif xe0_commandArray[i] = EMotorState::Stop; updated = true; From 7d6e466b68e5c86e32abc9c52181849c26b85c5d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 13 Apr 2020 01:43:00 -0400 Subject: [PATCH 2/2] CDecalManager: Make use of std::nullopt where applicable Same thing, less verbose. --- Runtime/Particle/CDecalManager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Runtime/Particle/CDecalManager.cpp b/Runtime/Particle/CDecalManager.cpp index 831d5c6f7..19b94ec98 100644 --- a/Runtime/Particle/CDecalManager.cpp +++ b/Runtime/Particle/CDecalManager.cpp @@ -21,8 +21,9 @@ void CDecalManager::Initialize() { return; m_DecalPool.clear(); - for (int i = 0; i < 64; ++i) - m_DecalPool.emplace_back(std::optional{}, 0, i - 1, false); + for (int i = 0; i < 64; ++i) { + m_DecalPool.emplace_back(std::nullopt, 0, i - 1, false); + } m_FreeIndex = 63; m_PoolInitialized = true; @@ -39,8 +40,9 @@ void CDecalManager::Reinitialize() { Initialize(); m_DecalPool.clear(); - for (int i = 0; i < 64; ++i) - m_DecalPool.emplace_back(std::optional{}, 0, i - 1, false); + for (int i = 0; i < 64; ++i) { + m_DecalPool.emplace_back(std::nullopt, 0, i - 1, false); + } m_ActiveIndexList.clear();