Maintenance: Centralize EncryptedName: delete 44 per-unit copies (incl. GameModeEncryptedName) and 4 EncryptedSource copies; units in

Batch #16852 by ragnarok-clanker: no function's compiled code changes; checked with 44 compiled unit(s), including every includer of Source/Utility/Cipher/LocalEncryptedName.h.
This commit is contained in:
ragnarok-clanker 2026-11-11 10:05:15 +00:00
commit d074dedcd7
45 changed files with 125 additions and 1528 deletions

View file

@ -23,6 +23,7 @@
#include "Contents/Items/ItemDescription.h"
#include "UI/Window/UIRegisterMgr.h"
#include "Resource/MSGSTRINGID.h"
#include "Utility/Cipher/LocalEncryptedName.h"
#include <cstring>
#include <format>
#include <list>
@ -38,61 +39,6 @@ extern template void std::_List_node<AdventureGuide::CItemData, void*>::_Free_no
extern template void std::_List_node<AdventureGuide::CQuestInfo, void*>::_Free_non_head(
std::allocator<std::_List_node<AdventureGuide::CQuestInfo, void*>>&, std::_List_node<AdventureGuide::CQuestInfo, void*>*) noexcept;
namespace {
template <std::size_t Length>
class EncryptedSource {
public:
// INLINED
template <typename Byte>
constexpr explicit EncryptedSource(const Byte (&source)[Length]) : data{} {
for (std::size_t index = 0; index < Length; ++index) {
this->data[index] = static_cast<char>(source[index]);
}
}
char data[Length];
};
template <std::size_t Length, std::uint64_t Key>
class EncryptedName {
public:
// INLINED
explicit EncryptedName(const EncryptedSource<Length>& source) : m_encrypted(true) {
for (std::uint64_t index = 0; index < Length; ++index) {
this->m_text[index] = static_cast<std::uint8_t>(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<const char*>(this->m_text);
}
private:
std::uint8_t m_text[Length];
bool m_encrypted;
};
}
template void CUIListBoxEx<AdventureGuide::CUIMonsterInfo, AdventureGuide::CMonsterData>::UpdateScrollBar();
template void CUIListBox<AdventureGuide::CUITab>::UpdateScrollBar();
template void CUIListBox<AdventureGuide::CUISubTab>::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) {