diff options
| author | Caladius <Caladius@users.noreply.github.com> | 2025-10-18 19:54:45 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-18 19:54:45 -0400 |
| commit | 5ccd9a0798fb90dee2098bc24028cd4640b05f5b (patch) | |
| tree | a17d2446c0a3e5a20cbd815194fd36cb43297c9f /mm | |
| parent | 44bda0fd55159248f6562adb54e0eb2cf8e0f0f5 (diff) | |
Remove Special Characters from seed Gen (#1291)
Diffstat (limited to 'mm')
| -rw-r--r-- | mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp | 2 | ||||
| -rw-r--r-- | mm/2s2h/ShipUtils.cpp | 11 | ||||
| -rw-r--r-- | mm/2s2h/ShipUtils.h | 1 |
3 files changed, 13 insertions, 1 deletions
diff --git a/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp b/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp index 25041eee6..f9d691a73 100644 --- a/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp +++ b/mm/2s2h/Rando/MiscBehavior/OnFileCreate.cpp @@ -43,7 +43,7 @@ void Rando::MiscBehavior::OnFileCreate(s16 fileNum) { // SpoilerFileIndex == 0 means we're generating a new one if (CVarGetInteger("gRando.SpoilerFileIndex", 0) == 0) { bool hadInputSeed = true; - std::string inputSeed = CVarGetString("gRando.InputSeed", ""); + std::string inputSeed = Ship_RemoveSpecialCharacters(CVarGetString("gRando.InputSeed", "")); if (inputSeed.empty()) { inputSeed = std::to_string(Ship_Random(0, 1000000)); hadInputSeed = false; diff --git a/mm/2s2h/ShipUtils.cpp b/mm/2s2h/ShipUtils.cpp index 3d5193cb4..ca4971391 100644 --- a/mm/2s2h/ShipUtils.cpp +++ b/mm/2s2h/ShipUtils.cpp @@ -109,6 +109,17 @@ std::string Ship_FormatTimeDisplay(uint32_t value) { return fmt::format("{}:{:0>2}:{:0>2}.{}", hh, mm, ss, ds); } +std::string Ship_RemoveSpecialCharacters(const std::string& str) { + std::string result; + for (char ch : str) { + // Only keep alphanumeric characters (letters and digits) + if (std::isalnum(static_cast<unsigned char>(ch))) { + result += ch; + } + } + return result; +} + constexpr f32 fourByThree = 4.0f / 3.0f; // Gets the additional ratio of the screen compared to the original 4:3 ratio, clamping to 1 if smaller diff --git a/mm/2s2h/ShipUtils.h b/mm/2s2h/ShipUtils.h index 492a7640e..e684afcfe 100644 --- a/mm/2s2h/ShipUtils.h +++ b/mm/2s2h/ShipUtils.h @@ -12,6 +12,7 @@ #include <imgui.h> void LoadGuiTextures(); std::string convertEnumToReadableName(const std::string& input); +std::string Ship_RemoveSpecialCharacters(const std::string& str); extern std::array<const char*, 11> digitList; extern std::string Ship_FormatTimeDisplay(uint32_t value); extern std::map<uint32_t, ImVec4> itemColorMap; |
