diff --git a/Source/Archive/GPak.cpp b/Source/Archive/GPak.cpp index 7a05659da..a1f706da6 100644 --- a/Source/Archive/GPak.cpp +++ b/Source/Archive/GPak.cpp @@ -6,6 +6,7 @@ #include "Utility/Hash/XxHash32.h" #include "Utility/Random/RandomBytes.h" #include "Utility/Hash/XxHash3.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -21,36 +22,6 @@ #include namespace { - template - class EncryptedName { - public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - // INLINED - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; #pragma pack(push, 1) diff --git a/Source/Client/Mode/GameMode.cpp b/Source/Client/Mode/GameMode.cpp index f4cdedb88..7909ec1cf 100644 --- a/Source/Client/Mode/GameMode.cpp +++ b/Source/Client/Mode/GameMode.cpp @@ -98,6 +98,7 @@ #include "UI/Login/UINewSelectCharWnd.h" #include "Network/TextEncoding.h" #include "Resource/MSGSTRINGID.h" +#include "Utility/Cipher/LocalEncryptedName.h" extern "C" long long _Xtime_get_ticks(); @@ -5565,40 +5566,10 @@ void CPingLiveSchedule::Process(const std::uint64_t& now) { namespace { -template -class GameModeEncryptedName { -public: - // INLINED - explicit GameModeEncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~GameModeEncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptGameModeName(const char (&source)[Length]) { - thread_local GameModeEncryptedName name(source); + thread_local EncryptedName name(source); return name.Text(); } @@ -5638,7 +5609,7 @@ int CGameMode::Run() { if (!message.empty()) { const char source[] = {'\x53', '\x11', '\xF9', '\xA6', '\x8D', '\x7E', '\xA6', '\xD9', '\x1D', '\x06', '\xEA', '\xA4', '\x9C', '\x5C', '\xB0', '\xCC', '\x4F', '\x25', '\x8B'}; - thread_local GameModeEncryptedName name(source); + thread_local EncryptedName name(source); MessageBoxA(hWnd, message.c_str(), name.Text(), 0); } } @@ -6758,7 +6729,6 @@ void CGameMode::End() { g_session.SetPlayerSkillMode(0); } - // OFFSET: 0x00CE8DE0 // FUNCTION: fn_21342 void CGameMode::ReloadScene() { @@ -7210,8 +7180,6 @@ void CGameMode::PlayItemUseEffect(int itemId, std::uint32_t aid) { #include #include - - // GLOBAL: gl_24776 int g_visibleMinX; @@ -8003,7 +7971,6 @@ void CGameMode::Initialize(const char* name) { this->isInitializing[0] = 0; } - // OFFSET: 0x00D07030 // FUNCTION: fn_21580 void CGameMode::ReceiveSkillList(int packetType, const std::vector& skills) { @@ -8136,7 +8103,6 @@ void CGameMode::ShowActorNameBalloon(std::uint32_t id) { this->PlaceWindowAtActor(this->nameBalloon, reinterpret_cast(item)); } - // OFFSET: 0x00CE18A0 // FUNCTION: fn_21332 void CGameMode::ProcessActorClick(int& handled, ActorPickInfo* pick, CGameActor* actor) { @@ -8453,7 +8419,6 @@ int CGameMode::ProcessMousePick(int result, ActorPickInfo* pick) { #include "Contents/World/WorldModelView.h" #include "Contents/World/WorldTerrainPicking.h" - // OFFSET: 0x00CE0210 // FUNCTION: fn_21329 int CGameMode::ProcessGroundClick(int result) { @@ -8733,7 +8698,6 @@ int CGameMode::ProcessGroundClick(int result) { #include "UI/Dialogs/UIMenuWnd.h" #include "UI/Window/InputFocus.h" - #include "Client/Application/ApplicationMessages.h" #include "Client/Mode/ModeFade.h" #include "Contents/Actors/ActorNameCard.h" diff --git a/Source/Client/Mode/GameModeMiniMap.cpp b/Source/Client/Mode/GameModeMiniMap.cpp index 1900f7129..69868bba8 100644 --- a/Source/Client/Mode/GameModeMiniMap.cpp +++ b/Source/Client/Mode/GameModeMiniMap.cpp @@ -24,6 +24,7 @@ #include "Utility/Math/AffineMatrix.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -31,40 +32,8 @@ #include #include - namespace { -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - // INLINED - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED __forceinline const char* TimeFontActionName() { const char source[] = {'\xB1', '\x4F', '\xAD', '\xDA', '\xD7', '\xA1', '\x01', '\x29', '\x18', '\xEE', '\x0E', '\x4D', '\x7E', '\x61', '\x29', '\x53', '\x10', '\xE0', '\x1F', '\x0B'}; @@ -86,7 +55,6 @@ __forceinline const char* TimeFontSpriteName() { // GLOBAL: gl_25107 CFile g_whisperFile; - // OFFSET: 0x00CCFCE0 // FUNCTION: fn_21246 void MiniMapNoOp() { @@ -581,7 +549,6 @@ int g_minimapCoordinateDigits; // GLOBAL: gl_25046 int g_minimapCoordinateDigitValues[4]; - // OFFSET: 0x00CD2A10 // FUNCTION: fn_21261 void CGameMode::DrawMiniMapNumber() { diff --git a/Source/Client/Mode/LoginModeNotices.cpp b/Source/Client/Mode/LoginModeNotices.cpp index b67ea8cfe..e18e46e65 100644 --- a/Source/Client/Mode/LoginModeNotices.cpp +++ b/Source/Client/Mode/LoginModeNotices.cpp @@ -8,6 +8,7 @@ #include "Network/Connection/Connection.h" #include "UI/Window/UIWindowMgr.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Resource/MSGSTRINGID.h" #include @@ -19,41 +20,6 @@ #include namespace { - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; #pragma pack(push, 1) struct BillingInfoPacket { @@ -72,7 +38,6 @@ namespace { static_assert(sizeof(NotifyBanPacket) == 3); } - // OFFSET: 0x00D9A350 // FUNCTION: fn_22311 void CLoginMode::ReceiveBillingInfo(const unsigned char* data) { diff --git a/Source/Contents/Achievement/AchievementMgr.cpp b/Source/Contents/Achievement/AchievementMgr.cpp index 93a657dde..33f091008 100644 --- a/Source/Contents/Achievement/AchievementMgr.cpp +++ b/Source/Contents/Achievement/AchievementMgr.cpp @@ -3,6 +3,7 @@ #include "Script/NLuaState.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" extern "C" { #include @@ -205,40 +206,6 @@ bool CAchievementMgr::FindTab(int id, int& group, int& index) { return false; } -namespace { - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - // OFFSET: 0x0066EAA0 // FUNCTION: fn_05322 bool CAchievementMgr::LoadAchievementInfo() { diff --git a/Source/Contents/Actors/RenderObject.cpp b/Source/Contents/Actors/RenderObject.cpp index 50ef333f7..5de96a2e4 100644 --- a/Source/Contents/Actors/RenderObject.cpp +++ b/Source/Contents/Actors/RenderObject.cpp @@ -72,10 +72,10 @@ #include #include #include "Contents/Guild/GuildInfo.h" +#include "Utility/Cipher/LocalEncryptedName.h" extern template void std::list::push_back(CRenderObject*&&); - // GLOBAL: gl_25173 int g_playerPoisoned; @@ -93,43 +93,9 @@ struct CharacterRenderDrawItem { RenderCommand* command; }; - // GLOBAL: gl_24798 int g_multiHitInterval = 200; -namespace { - -template -class EncryptedName { -public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - class CGrannyCorpse3d : public CGameObject { public: explicit CGrannyCorpse3d(const char* name); @@ -702,7 +668,6 @@ void CRenderObject::SetAnimationSpeed(float speed) { } } - // OFFSET: 0x00CC2810 // FUNCTION: fn_21142 void CGameActor::SetHealthState(int value) { @@ -4816,7 +4781,6 @@ CCharacterNpc::~CCharacterNpc() { } } - // OFFSET: 0x00CBFC40 // FUNCTION: fn_21120 void CGameActor::SetStatusStates(int bodyState, std::uint32_t stateFlags, int effectState, bool notify) { diff --git a/Source/Contents/Effects/Core/EffectLists.cpp b/Source/Contents/Effects/Core/EffectLists.cpp index aecd87505..d87621322 100644 --- a/Source/Contents/Effects/Core/EffectLists.cpp +++ b/Source/Contents/Effects/Core/EffectLists.cpp @@ -66,6 +66,7 @@ #include "Contents/Effects/Skills/TriangleShotArrow.h" #include "Contents/Effects/Skills/ViolentQuakeEffect.h" #include "Contents/Effects/Skills/WindEffect.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Client/Mode/CGameMode.h" #include "Client/Session/Session.h" @@ -436,35 +437,6 @@ void DestroyEffectMgr() { namespace { -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - /* 0000 */ std::uint8_t m_text[Length]; - /* 0044 */ bool m_encrypted; -}; - template struct CEffectAllocator : CAllocator { CEffectAllocator() {} diff --git a/Source/Contents/Effects/Particles/CharacterParticleBundle.cpp b/Source/Contents/Effects/Particles/CharacterParticleBundle.cpp index 86d1f3757..52b58031a 100644 --- a/Source/Contents/Effects/Particles/CharacterParticleBundle.cpp +++ b/Source/Contents/Effects/Particles/CharacterParticleBundle.cpp @@ -1,4 +1,5 @@ #include "Contents/Effects/Particles/CharacterParticleBundle.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Client/Mode/CGameMode.h" #include "Client/Mode/ModeMgr.h" @@ -21,36 +22,6 @@ #include namespace { - template - class EncryptedName { - public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; // GLOBAL: gl_24870 std::unordered_map> g_clawMarkRings; diff --git a/Source/Contents/Effects/Particles/SpriteEffect.cpp b/Source/Contents/Effects/Particles/SpriteEffect.cpp index e0b2510c9..2e0543322 100644 --- a/Source/Contents/Effects/Particles/SpriteEffect.cpp +++ b/Source/Contents/Effects/Particles/SpriteEffect.cpp @@ -1,5 +1,6 @@ #include "Contents/Effects/Core/EffectTypes.h" #include "Contents/Effects/Particles/SpriteEffect.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Client/Mode/CGameMode.h" #include "Client/Mode/ModeMgr.h" @@ -14,36 +15,6 @@ namespace { -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const char (&source)[Length]) { diff --git a/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp b/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp index c2cdc9823..e10183889 100644 --- a/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp +++ b/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -19,35 +20,6 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp index 536dcbbca..2a3b4419c 100644 --- a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp +++ b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -20,35 +21,6 @@ namespace { target.MoveFrom(diagnostic); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Emblems/EmblemUpload.cpp b/Source/Contents/Emblems/EmblemUpload.cpp index 1749b2ee2..73302136e 100644 --- a/Source/Contents/Emblems/EmblemUpload.cpp +++ b/Source/Contents/Emblems/EmblemUpload.cpp @@ -5,6 +5,7 @@ #include "UI/Window/UIWindowMgr.h" #include "Utility/Async/AsyncDiagnostic.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Resource/MSGSTRINGID.h" #include @@ -20,37 +21,6 @@ namespace { #pragma pack(pop) static_assert(sizeof(EmblemVersionPacket) == 10); - template - class EncryptedName { - public: - // INLINED - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - // INLINED - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Map/MapNameTable.cpp b/Source/Contents/Map/MapNameTable.cpp index bdf8048af..23c0fcc6e 100644 --- a/Source/Contents/Map/MapNameTable.cpp +++ b/Source/Contents/Map/MapNameTable.cpp @@ -5,6 +5,7 @@ #include "Render/Renderer.h" #include "Resource/Bitmap/BitmapResource.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -12,40 +13,6 @@ #include #include -namespace { - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - // OFFSET: 0x00DE8740 // FUNCTION: fn_23498 bool CSession::LoadMapNameTable() { diff --git a/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp b/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp index 0ec8cc0dc..c5af6378e 100644 --- a/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp +++ b/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -26,35 +27,6 @@ namespace { target.MoveFrom(diagnostic); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Party/LoadMyPartyAsyncWork.cpp b/Source/Contents/Party/LoadMyPartyAsyncWork.cpp index 18d6a19d0..40c3a3b35 100644 --- a/Source/Contents/Party/LoadMyPartyAsyncWork.cpp +++ b/Source/Contents/Party/LoadMyPartyAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -26,38 +27,6 @@ namespace { target.MoveFrom(diagnostic); } - template - class EncryptedName { - public: - // INLINED - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - // INLINED - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp b/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp index 6758911d3..ef5cf9c4e 100644 --- a/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp +++ b/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -19,35 +20,6 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Party/LoadPartyListAsyncWork.cpp b/Source/Contents/Party/LoadPartyListAsyncWork.cpp index 45a4090cd..1a5fe3309 100644 --- a/Source/Contents/Party/LoadPartyListAsyncWork.cpp +++ b/Source/Contents/Party/LoadPartyListAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -19,35 +20,6 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Party/RegisterPartyAsyncWork.cpp b/Source/Contents/Party/RegisterPartyAsyncWork.cpp index 8db221b32..44d0f46ec 100644 --- a/Source/Contents/Party/RegisterPartyAsyncWork.cpp +++ b/Source/Contents/Party/RegisterPartyAsyncWork.cpp @@ -6,6 +6,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -14,35 +15,6 @@ namespace { constexpr char sourceFile[] = "C:\\repositories\\RagnarokClient\\RagnarokClient\\Contents\\AdventurerAgency\\CRegisterPartyAsyncWork.cpp"; - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Party/StopRecruitingAsyncWork.cpp b/Source/Contents/Party/StopRecruitingAsyncWork.cpp index ec965cb22..a85c121ba 100644 --- a/Source/Contents/Party/StopRecruitingAsyncWork.cpp +++ b/Source/Contents/Party/StopRecruitingAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -26,35 +27,6 @@ namespace { target.MoveFrom(diagnostic); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Pet/PetTalkNames.cpp b/Source/Contents/Pet/PetTalkNames.cpp index 748bf9d40..99f50500b 100644 --- a/Source/Contents/Pet/PetTalkNames.cpp +++ b/Source/Contents/Pet/PetTalkNames.cpp @@ -1,42 +1,13 @@ #include "Contents/Jobs/JobId.h" #include "Client/Session/Session.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include namespace { -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const char (&source)[Length]) { diff --git a/Source/Contents/Skills/SkillActionAlitea.cpp b/Source/Contents/Skills/SkillActionAlitea.cpp index 698921098..180827cca 100644 --- a/Source/Contents/Skills/SkillActionAlitea.cpp +++ b/Source/Contents/Skills/SkillActionAlitea.cpp @@ -15,6 +15,7 @@ #include "Contents/Skills/SkillInfo.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Math/Vector3d.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -24,49 +25,6 @@ #include #include -namespace { - -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - template - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - class CSkillAction_AnimalForm : public CSkillAction { public: bool CanUse(CGameActor* actor); @@ -2039,7 +1997,6 @@ void __stdcall OnSkillObjectCreate(int a, int b, int c) { void __stdcall OnSkillObjectRemove(int a) { } - // OFFSET: 0x005AF4E0 // FUNCTION: fn_03326 int CSkillAction_AT_PRIMAL_CLAW::GetSkillAttackMotion() { diff --git a/Source/Contents/Skills/SkillActionDruid.cpp b/Source/Contents/Skills/SkillActionDruid.cpp index 30f489422..0a791de6e 100644 --- a/Source/Contents/Skills/SkillActionDruid.cpp +++ b/Source/Contents/Skills/SkillActionDruid.cpp @@ -15,6 +15,7 @@ #include "Contents/Skills/SkillInfo.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Math/Vector3d.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -22,49 +23,6 @@ #include #include -namespace { - -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - template - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - class CSkillAction_AnimalForm : public CSkillAction { public: bool CanUse(CGameActor* actor); diff --git a/Source/Contents/Skills/SkillActionKarnos.cpp b/Source/Contents/Skills/SkillActionKarnos.cpp index 0b7f103d4..70bf9176f 100644 --- a/Source/Contents/Skills/SkillActionKarnos.cpp +++ b/Source/Contents/Skills/SkillActionKarnos.cpp @@ -15,6 +15,7 @@ #include "Contents/Skills/SkillInfo.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Math/Vector3d.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -25,49 +26,6 @@ #include #include -namespace { - -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - template - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - class CSkillAction_AnimalForm : public CSkillAction { public: bool CanUse(CGameActor* actor); diff --git a/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp b/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp index acd3f166f..3e9df997b 100644 --- a/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp +++ b/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp @@ -6,6 +6,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -24,42 +25,6 @@ namespace { return AsyncDiagnostic(&success, &message, file, &line); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/Tables/TipBoxTitles.cpp b/Source/Contents/Tables/TipBoxTitles.cpp index 0e45ac695..db6e65b60 100644 --- a/Source/Contents/Tables/TipBoxTitles.cpp +++ b/Source/Contents/Tables/TipBoxTitles.cpp @@ -6,6 +6,7 @@ #include "Resource/Bitmap/TextureNames.h" #include "Script/NLuaState.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" extern "C" { #include @@ -26,35 +27,6 @@ extern "C" { CTipBoxMgr* g_itemTagOwner = nullptr; namespace { - template - class EncryptedName { - public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; // INLINED template diff --git a/Source/Contents/Time/ClientTiming.cpp b/Source/Contents/Time/ClientTiming.cpp index 5f48384fa..94a690b3c 100644 --- a/Source/Contents/Time/ClientTiming.cpp +++ b/Source/Contents/Time/ClientTiming.cpp @@ -14,6 +14,7 @@ #include "UI/Window/UIWindowMgr.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -31,36 +32,6 @@ int g_serviceMode; namespace { -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const char (&source)[Length]) { diff --git a/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp b/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp index e4bfa667a..720de2ffa 100644 --- a/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp +++ b/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -22,42 +23,6 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp b/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp index 01eb1262b..6ce17262b 100644 --- a/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp +++ b/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -28,35 +29,6 @@ namespace { target.MoveFrom(diagnostic); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp index 96100b2d6..a5ed4f3ec 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp +++ b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -21,35 +22,6 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp b/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp index 5705350f2..bfb894432 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp +++ b/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp @@ -5,6 +5,7 @@ #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -28,35 +29,6 @@ namespace { target.MoveFrom(diagnostic); } - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED template const char* DecryptName(const std::uint8_t (&source)[Length]) { diff --git a/Source/Security/NProtectGameGuardMgr.cpp b/Source/Security/NProtectGameGuardMgr.cpp index a911116bc..0020534a7 100644 --- a/Source/Security/NProtectGameGuardMgr.cpp +++ b/Source/Security/NProtectGameGuardMgr.cpp @@ -7,6 +7,7 @@ #include "Utility/Cipher/XorBytes.h" #include "Utility/Text/FormatString.h" #include "Utility/Threading/NSyncObject.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Resource/MSGSTRINGID.h" #include @@ -46,42 +47,6 @@ public: }; namespace { - template - class EncryptedName { - public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; // INLINED template diff --git a/Source/UI/AdventureGuide/UIAdventureGuide.cpp b/Source/UI/AdventureGuide/UIAdventureGuide.cpp index 5df15adea..fc92d22ab 100644 --- a/Source/UI/AdventureGuide/UIAdventureGuide.cpp +++ b/Source/UI/AdventureGuide/UIAdventureGuide.cpp @@ -23,6 +23,7 @@ #include "Contents/Items/ItemDescription.h" #include "UI/Window/UIRegisterMgr.h" #include "Resource/MSGSTRINGID.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include #include @@ -38,61 +39,6 @@ extern template void std::_List_node::_Free_no extern template void std::_List_node::_Free_non_head( std::allocator>&, std::_List_node*) noexcept; -namespace { - -template -class EncryptedSource { -public: - // INLINED - template - constexpr explicit EncryptedSource(const Byte (&source)[Length]) : data{} { - for (std::size_t index = 0; index < Length; ++index) { - this->data[index] = static_cast(source[index]); - } - } - - char data[Length]; -}; - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const EncryptedSource& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = static_cast(source.data[index]); - } - } - - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - template void CUIListBoxEx::UpdateScrollBar(); template void CUIListBox::UpdateScrollBar(); template void CUIListBox::UpdateScrollBar(); @@ -2516,7 +2462,6 @@ void CUIIntro::OnCreate(int width, int height) { this->AddChild(this->contents); } - // OFFSET: 0x009C6F50 // FUNCTION: fn_14002 void CUIItem::OnCreate(int width, int height) { @@ -2716,7 +2661,6 @@ void CUIItem::OnCreate(int width, int height) { this->AddChild(this->navigationButton); } - // OFFSET: 0x009CDD40 // FUNCTION: fn_14006 void CUIQuest::OnCreate(int width, int height) { @@ -2916,7 +2860,6 @@ void CUIQuest::OnCreate(int width, int height) { this->AddChild(this->navigationButton); } - // OFFSET: 0x009CAE30 // FUNCTION: fn_14004 void CUIMonster::OnCreate(int width, int height) { diff --git a/Source/UI/Dialogs/UILocaleTextWnd.cpp b/Source/UI/Dialogs/UILocaleTextWnd.cpp index c8403603d..65108eeff 100644 --- a/Source/UI/Dialogs/UILocaleTextWnd.cpp +++ b/Source/UI/Dialogs/UILocaleTextWnd.cpp @@ -1,55 +1,13 @@ #include "UI/Lists/UIListBoxTemplate.h" #include "UI/Text/UIStaticTextControl.h" #include "Utility/Cipher/XorBytes.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include #include #include -namespace { - -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - template - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - /* 0000 */ std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - namespace AdventureGuide { // OFFSET: 0x009D1830 diff --git a/Source/UI/Dialogs/UIMessageBox.cpp b/Source/UI/Dialogs/UIMessageBox.cpp index c8228d553..a08c47d53 100644 --- a/Source/UI/Dialogs/UIMessageBox.cpp +++ b/Source/UI/Dialogs/UIMessageBox.cpp @@ -98,6 +98,7 @@ #include "Resource/Sprites/ImfResource.h" #include "Resource/Bitmap/PaletteResource.h" #include "Contents/Jobs/JobInheritance.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Resource/MSGSTRINGID.h" // GLOBAL: gl_25153 @@ -109,36 +110,6 @@ static const std::string s_messageBoxItemLinkClosing = ""; namespace { constexpr char prefix[] = "유저인터페이스\\"; - template - class EncryptedName { - public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; - // INLINED int TileCount(int length, int tile) { const std::div_t tiles = std::div(length, tile); diff --git a/Source/UI/Enchant/UIEnchantUI.cpp b/Source/UI/Enchant/UIEnchantUI.cpp index 615b8f74f..7d9772560 100644 --- a/Source/UI/Enchant/UIEnchantUI.cpp +++ b/Source/UI/Enchant/UIEnchantUI.cpp @@ -9,6 +9,7 @@ #include "UI/Text/UIStaticTextControl.h" #include "Utility/Cipher/XorBytes.h" #include "UI/Window/UIRegisterMgr.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include #include @@ -19,60 +20,6 @@ extern template char* std::_UIntegral_to_buff(char*, unsigned int); -namespace { - -template -class EncryptedSource { -public: - // INLINED - template - constexpr explicit EncryptedSource(const Byte (&source)[Length]) : data{} { - for (std::size_t index = 0; index < Length; ++index) { - this->data[index] = static_cast(source[index]); - } - } - - char data[Length]; -}; - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const EncryptedSource& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = static_cast(source.data[index]); - } - } - - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - // GLOBAL: gl_24882 template <> CEnchantMgr* Singleton::s_instance = nullptr; diff --git a/Source/UI/Exchange/UIExchangeUI.cpp b/Source/UI/Exchange/UIExchangeUI.cpp index 77b7a1deb..4eedf250c 100644 --- a/Source/UI/Exchange/UIExchangeUI.cpp +++ b/Source/UI/Exchange/UIExchangeUI.cpp @@ -2,6 +2,7 @@ #include "UI/Window/WindowId.h" #include "UI/Exchange/UIExchangeUI.h" #include "UI/Window/UIEnums.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Client/Session/Session.h" #include "Client/Mode/CGameMode.h" @@ -52,8 +53,6 @@ void CUIListBoxEx::AddNewItem(); template <> void CUIListBoxEx::LoadSkin(bool resolveSkin); - - // INLINED template static const char* DecryptName(const char (&source)[Length]) { @@ -600,40 +599,6 @@ void CUIExchangeUI::FreezeItems(bool mine) { list->Invalidate(); } -namespace { - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - // OFFSET: 0x00A149B0 // FUNCTION: fn_15192 void ExchangeUI::CUIItem::OnCreate(int width, int height) { diff --git a/Source/UI/GameSettings/GameSettingsUI.cpp b/Source/UI/GameSettings/GameSettingsUI.cpp index 8690719e1..7daa7fec1 100644 --- a/Source/UI/GameSettings/GameSettingsUI.cpp +++ b/Source/UI/GameSettings/GameSettingsUI.cpp @@ -36,6 +36,7 @@ #include "Utility/Text/StringUtil.h" #include "UI/Window/UIRegisterMgr.h" #include "Resource/MSGSTRINGID.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include #include @@ -45,51 +46,6 @@ #include #include -namespace { -template -class EncryptedSource { -public: - // INLINED - constexpr explicit EncryptedSource(const std::uint8_t (&source)[Length]) : data{} { - for (std::size_t index = 0; index < Length; ++index) { - this->data[index] = static_cast(source[index]); - } - } - - char data[Length]; -}; - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const EncryptedSource& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = static_cast(source.data[index]); - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; -} - namespace { struct RodexSpamOptionPacket { /* 0000 */ std::int16_t id; @@ -102,7 +58,6 @@ namespace { // GLOBAL: gl_24768 int g_configuredRenderBackend; - // GLOBAL: gl_24509 int g_textureFiltering; diff --git a/Source/UI/Items/UIEquipmentPropertiesWnd.cpp b/Source/UI/Items/UIEquipmentPropertiesWnd.cpp index 749480296..bb2d9303a 100644 --- a/Source/UI/Items/UIEquipmentPropertiesWnd.cpp +++ b/Source/UI/Items/UIEquipmentPropertiesWnd.cpp @@ -1,6 +1,7 @@ #include "UI/Window/UIEnums.h" #include "UI/Window/WindowId.h" #include "UI/Items/UIEquipmentPropertiesWnd.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Contents/Tables/MessageTable.h" #include "Contents/Messenger/ClientMessenger.h" @@ -268,47 +269,6 @@ void CUIListBoxExAddChild(this->scrollBar); } -namespace { - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - // INLINED - explicit EncryptedName(const std::array& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - -} - // OFFSET: 0x00A09130 // FUNCTION: fn_15035 void CUIEquipmentPropertiesWnd::OnCreate(int width, int height) { diff --git a/Source/UI/Login/UIWaitDBSaveWnd.cpp b/Source/UI/Login/UIWaitDBSaveWnd.cpp index 0aa21cbe5..7aa1176e3 100644 --- a/Source/UI/Login/UIWaitDBSaveWnd.cpp +++ b/Source/UI/Login/UIWaitDBSaveWnd.cpp @@ -1,5 +1,6 @@ #include "UI/Login/UIWaitDBSaveWnd.h" #include "UI/Window/WindowId.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Render/Textures/SpritePixels.h" #include "Resource/Bitmap/BitmapResource.h" @@ -19,37 +20,6 @@ namespace { -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED __forceinline const char* WaitSpriteName() { const char spriteSource[] = {'\x1A', '\x44', '\xF0', '\x3D', '\x17', '\x01', '\xD2', '\x66', '\x3B', '\x40', '\xC5', '\x07', '\x3C', diff --git a/Source/UI/Macro/UIMacroReport.cpp b/Source/UI/Macro/UIMacroReport.cpp index f90281b95..3265f9b3a 100644 --- a/Source/UI/Macro/UIMacroReport.cpp +++ b/Source/UI/Macro/UIMacroReport.cpp @@ -14,6 +14,7 @@ #include "UI/Window/WindowManagerWindows.h" #include "Utility/Cipher/XorBytes.h" #include "UI/Window/UIRegisterMgr.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include @@ -23,37 +24,6 @@ namespace { -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const char (&source)[Length]) { diff --git a/Source/UI/ProbabilityTable/UIProbabilityTable.cpp b/Source/UI/ProbabilityTable/UIProbabilityTable.cpp index 227225041..732c31f71 100644 --- a/Source/UI/ProbabilityTable/UIProbabilityTable.cpp +++ b/Source/UI/ProbabilityTable/UIProbabilityTable.cpp @@ -1,5 +1,6 @@ #include "UI/Window/WindowId.h" #include "UI/ProbabilityTable/UIProbabilityTable.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Network/TextEncoding.h" #include "UI/Edit/UIEditBoxEx.h" @@ -31,37 +32,6 @@ static const std::string g_probabilityHighlightEnd = "^000000"; namespace { -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const char (&source)[Length]) { diff --git a/Source/UI/SelectPackageItemBox/UISelectPackageItemBox.cpp b/Source/UI/SelectPackageItemBox/UISelectPackageItemBox.cpp index eef7e562f..5e32b7b65 100644 --- a/Source/UI/SelectPackageItemBox/UISelectPackageItemBox.cpp +++ b/Source/UI/SelectPackageItemBox/UISelectPackageItemBox.cpp @@ -18,6 +18,7 @@ #include "Utility/Text/FormatString.h" #include "UI/Window/UIRegisterMgr.h" #include "Resource/MSGSTRINGID.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include #include #include @@ -691,58 +692,6 @@ void CUISelectPackageItemBox::OnSelectTab(SelectPackageItemBox::CUITabInfo*, con namespace { -template -class EncryptedSource { -public: - // INLINED - template - constexpr explicit EncryptedSource(const Byte (&source)[Length]) : data{} { - for (std::size_t index = 0; index < Length; ++index) { - this->data[index] = static_cast(source[index]); - } - } - - char data[Length]; -}; - -template -class EncryptedName { -public: - // INLINED - explicit EncryptedName(const EncryptedSource& source) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = static_cast(source.data[index]); - } - } - - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const Byte (&source)[Length]) { diff --git a/Source/UI/Skill/UINewSkillListWnd.cpp b/Source/UI/Skill/UINewSkillListWnd.cpp index f07006205..40ab885a3 100644 --- a/Source/UI/Skill/UINewSkillListWnd.cpp +++ b/Source/UI/Skill/UINewSkillListWnd.cpp @@ -44,6 +44,7 @@ #include "Resource/Sprites/ActionResource.h" #include "Resource/Sprites/SpriteResource.h" #include "Client/Mode/CMode.h" +#include "Utility/Cipher/LocalEncryptedName.h" #include "Resource/MSGSTRINGID.h" #include @@ -53,37 +54,6 @@ #include #include -namespace { - template - class EncryptedName { - public: - explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - - private: - std::uint8_t m_text[Length]; - bool m_encrypted; - }; -} - // INLINED static int SkillTabOf(int skillId) { if (skillId >= NV_BASIC && skillId <= ALL_RESURRECTION) { diff --git a/Source/UI/SkillDelayInfo/UISkillDelayInfo.cpp b/Source/UI/SkillDelayInfo/UISkillDelayInfo.cpp index 8fdf37a84..f9fa008aa 100644 --- a/Source/UI/SkillDelayInfo/UISkillDelayInfo.cpp +++ b/Source/UI/SkillDelayInfo/UISkillDelayInfo.cpp @@ -20,6 +20,7 @@ #include #include #include "Resource/MSGSTRINGID.h" +#include "Utility/Cipher/LocalEncryptedName.h" extern template std::string std::operator+(std::string&&, const char* const); @@ -38,37 +39,6 @@ void CUIListBoxEx: namespace { -template -class EncryptedName { -public: - // INLINED - template - explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = source[index]; - } - } - - ~EncryptedName() { - for (std::uint64_t index = 0; index < Length; ++index) { - this->m_text[index] = 0; - } - } - - const char* Text() { - if (this->m_encrypted) { - utility::XorBytes(this->m_text, Length, Key); - this->m_encrypted = false; - } - - return reinterpret_cast(this->m_text); - } - -private: - std::uint8_t m_text[Length]; - bool m_encrypted; -}; - // INLINED template const char* DecryptName(const char (&source)[Length]) { diff --git a/Source/Utility/Cipher/LocalEncryptedName.h b/Source/Utility/Cipher/LocalEncryptedName.h new file mode 100644 index 000000000..d1ec686f6 --- /dev/null +++ b/Source/Utility/Cipher/LocalEncryptedName.h @@ -0,0 +1,79 @@ +#ifndef RAGNAROK_SOURCE_UTILITY_CIPHER_LOCALENCRYPTEDNAME_H +#define RAGNAROK_SOURCE_UTILITY_CIPHER_LOCALENCRYPTEDNAME_H + +#include "Utility/Cipher/XorBytes.h" + +#include +#include +#include + +template +class EncryptedSource { +public: + // INLINED + template + constexpr explicit EncryptedSource(const Byte (&source)[Length]) : data{} { + for (std::size_t index = 0; index < Length; ++index) { + this->data[index] = static_cast(source[index]); + } + } + + char data[Length]; +}; + +namespace { + template + class EncryptedName { + public: + // INLINED + explicit EncryptedName(const char (&source)[Length]) : m_encrypted(true) { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = source[index]; + } + } + + // INLINED + template + explicit EncryptedName(const Byte (&source)[Length]) : m_encrypted(true) { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = source[index]; + } + } + + // INLINED + template + explicit EncryptedName(const std::array& source) : m_encrypted(true) { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = source[index]; + } + } + + // INLINED + explicit EncryptedName(const EncryptedSource& source) : m_encrypted(true) { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = static_cast(source.data[index]); + } + } + + ~EncryptedName() { + for (std::uint64_t index = 0; index < Length; ++index) { + this->m_text[index] = 0; + } + } + + // INLINED + const char* Text() { + if (this->m_encrypted) { + utility::XorBytes(this->m_text, Length, Key); + this->m_encrypted = false; + } + + return reinterpret_cast(this->m_text); + } + + /* 0000 */ std::uint8_t m_text[Length]; + bool m_encrypted; + }; +} + +#endif