diff --git a/Source/UI/Text/NavigationLink.cpp b/Source/UI/Text/NavigationLink.cpp index b28f8bb..c9d6bca 100644 --- a/Source/UI/Text/NavigationLink.cpp +++ b/Source/UI/Text/NavigationLink.cpp @@ -3,6 +3,7 @@ #include #include #include +#include // OFFSET: 0x00833160 // FUNCTION: fn_10409 @@ -30,6 +31,26 @@ int DecodeNavigationNumber(std::string value) { return static_cast(result); } +// OFFSET: 0x00833270 +// FUNCTION: fn_10410 +std::string EncodeNavigationNumber(int value) { + const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + std::vector characters; + + do { + characters.push_back(digits[value % 62]); + value /= 62; + } while (value >= 62); + characters.push_back(digits[value]); + + std::string result; + const std::size_t count = characters.size(); + for (std::size_t index = 0; index < count; ++index) { + result += characters[count - 1 - index]; + } + return result; +} + // OFFSET: 0x00835890 // FUNCTION: fn_10420 bool ParseNavigationLink(std::string value, std::string& name, int& x, int& y) { diff --git a/Source/UI/Text/NavigationLink.h b/Source/UI/Text/NavigationLink.h index ceab1a7..679ee8a 100644 --- a/Source/UI/Text/NavigationLink.h +++ b/Source/UI/Text/NavigationLink.h @@ -4,6 +4,7 @@ #include int DecodeNavigationNumber(std::string value); +std::string EncodeNavigationNumber(int value); bool ParseNavigationLink(std::string value, std::string& name, int& x, int& y); std::string FormatNavigationLink(std::string value, bool brackets); void DisplayNavigationLink(std::string& output, std::string value);