From 78c6c19bfa1f7bef7a4696e052fc39b47b2fd329 Mon Sep 17 00:00:00 2001 From: TurtleP Date: Mon, 1 Apr 2024 17:42:19 -0400 Subject: [PATCH] fix timer sleep on Wii U --- debug/src/main.rs | 2 +- include/common/error.hpp | 2 +- platform/cafe/source/modules/timer/Timer.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/debug/src/main.rs b/debug/src/main.rs index c32e9aba..12eba6ee 100644 --- a/debug/src/main.rs +++ b/debug/src/main.rs @@ -37,7 +37,7 @@ fn main() { let mut file = File::create(&filename).expect("Failed to create log file"); loop { - let bytes_read = stream.read(&mut buffer) else { break; }; + let bytes_read = stream.read(&mut buffer).expect("Failed to read data from stream"); if bytes_read == 0 { break; diff --git a/include/common/error.hpp b/include/common/error.hpp index 9c57a344..018f2b59 100644 --- a/include/common/error.hpp +++ b/include/common/error.hpp @@ -14,7 +14,7 @@ namespace love #define E_PHYSFS_NOT_INITIALIZED "PHYSFS is not initialized." #define E_DATA_NOT_WRITTEN "Data could not be written." #define E_COULD_NOT_OPEN_FILE "Could not open file at path {}." -#define E_PHYSFS_COULD_NOT_OPEN_FILE "Could not open file {} {:s}" +#define E_PHYSFS_COULD_NOT_OPEN_FILE "Could not open file {} ({:s})" #define E_FILE_NOT_OPEN_FOR_WRITING "File not open for writing." #define E_INVALID_READ_SIZE "Invalid read size." #define E_INVALID_WRITE_SIZE "Invalid write size." diff --git a/platform/cafe/source/modules/timer/Timer.cpp b/platform/cafe/source/modules/timer/Timer.cpp index 88102da0..4da57ab4 100644 --- a/platform/cafe/source/modules/timer/Timer.cpp +++ b/platform/cafe/source/modules/timer/Timer.cpp @@ -15,13 +15,15 @@ namespace love double Timer::getTime() { const auto ns = OSTicksToNanoseconds(OSGetSystemTick() - Timer::reference); - return ns / 1'000'000'000.0; + return ns / Timer::SECONDS_TO_NS; } void Timer::sleep(double seconds) const { - const auto time = std::chrono::duration(seconds); - OSSleepTicks(std::chrono::duration(time).count()); + const auto time = std::chrono::duration(seconds); + const auto nanoseconds = std::chrono::duration(time).count(); + + OSSleepTicks(OSNanosecondsToTicks(nanoseconds)); } double Timer::step()