diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/alignment.h | 7 | ||||
| -rw-r--r-- | src/common/settings.h | 5 | ||||
| -rw-r--r-- | src/common/string_util.cpp | 12 | ||||
| -rw-r--r-- | src/common/string_util.h | 2 |
4 files changed, 15 insertions, 11 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h index 1b56569d1..8570c7d3c 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h | |||
| @@ -64,7 +64,7 @@ public: | |||
| 64 | using propagate_on_container_copy_assignment = std::true_type; | 64 | using propagate_on_container_copy_assignment = std::true_type; |
| 65 | using propagate_on_container_move_assignment = std::true_type; | 65 | using propagate_on_container_move_assignment = std::true_type; |
| 66 | using propagate_on_container_swap = std::true_type; | 66 | using propagate_on_container_swap = std::true_type; |
| 67 | using is_always_equal = std::true_type; | 67 | using is_always_equal = std::false_type; |
| 68 | 68 | ||
| 69 | constexpr AlignmentAllocator() noexcept = default; | 69 | constexpr AlignmentAllocator() noexcept = default; |
| 70 | 70 | ||
| @@ -83,6 +83,11 @@ public: | |||
| 83 | struct rebind { | 83 | struct rebind { |
| 84 | using other = AlignmentAllocator<T2, Align>; | 84 | using other = AlignmentAllocator<T2, Align>; |
| 85 | }; | 85 | }; |
| 86 | |||
| 87 | template <typename T2, size_t Align2> | ||
| 88 | constexpr bool operator==(const AlignmentAllocator<T2, Align2>&) const noexcept { | ||
| 89 | return std::is_same_v<T, T2> && Align == Align2; | ||
| 90 | } | ||
| 86 | }; | 91 | }; |
| 87 | 92 | ||
| 88 | } // namespace Common | 93 | } // namespace Common |
diff --git a/src/common/settings.h b/src/common/settings.h index 402339443..9ff4cf85d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | #include <array> | 8 | #include <array> |
| 9 | #include <atomic> | 9 | #include <atomic> |
| 10 | #include <chrono> | ||
| 11 | #include <map> | 10 | #include <map> |
| 12 | #include <optional> | 11 | #include <optional> |
| 13 | #include <string> | 12 | #include <string> |
| @@ -487,9 +486,9 @@ struct Values { | |||
| 487 | // System | 486 | // System |
| 488 | Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"}; | 487 | Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"}; |
| 489 | // Measured in seconds since epoch | 488 | // Measured in seconds since epoch |
| 490 | std::optional<std::chrono::seconds> custom_rtc; | 489 | std::optional<s64> custom_rtc; |
| 491 | // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` | 490 | // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` |
| 492 | std::chrono::seconds custom_rtc_differential; | 491 | s64 custom_rtc_differential; |
| 493 | 492 | ||
| 494 | BasicSetting<s32> current_user{0, "current_user"}; | 493 | BasicSetting<s32> current_user{0, "current_user"}; |
| 495 | RangedSetting<s32> language_index{1, 0, 17, "language_index"}; | 494 | RangedSetting<s32> language_index{1, 0, 17, "language_index"}; |
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index e6344fd41..662171138 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -180,20 +180,20 @@ std::wstring UTF8ToUTF16W(const std::string& input) { | |||
| 180 | 180 | ||
| 181 | #endif | 181 | #endif |
| 182 | 182 | ||
| 183 | std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { | 183 | std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) { |
| 184 | std::size_t len = 0; | 184 | std::size_t len = 0; |
| 185 | while (len < max_len && buffer[len] != '\0') | 185 | while (len < buffer.length() && len < max_len && buffer[len] != '\0') { |
| 186 | ++len; | 186 | ++len; |
| 187 | 187 | } | |
| 188 | return std::string(buffer, len); | 188 | return std::string(buffer.begin(), buffer.begin() + len); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, | 191 | std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, |
| 192 | std::size_t max_len) { | 192 | std::size_t max_len) { |
| 193 | std::size_t len = 0; | 193 | std::size_t len = 0; |
| 194 | while (len < max_len && buffer[len] != '\0') | 194 | while (len < buffer.length() && len < max_len && buffer[len] != '\0') { |
| 195 | ++len; | 195 | ++len; |
| 196 | 196 | } | |
| 197 | return std::u16string(buffer.begin(), buffer.begin() + len); | 197 | return std::u16string(buffer.begin(), buffer.begin() + len); |
| 198 | } | 198 | } |
| 199 | 199 | ||
diff --git a/src/common/string_util.h b/src/common/string_util.h index 7e90a9ca5..f0dd632ee 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -63,7 +63,7 @@ template <typename InIt> | |||
| 63 | * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't | 63 | * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't |
| 64 | * NUL-terminated then the string ends at max_len characters. | 64 | * NUL-terminated then the string ends at max_len characters. |
| 65 | */ | 65 | */ |
| 66 | [[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, | 66 | [[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, |
| 67 | std::size_t max_len); | 67 | std::size_t max_len); |
| 68 | 68 | ||
| 69 | /** | 69 | /** |