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

@ -5,6 +5,7 @@
#include "Network/TextEncoding.h"
#include "Utility/Cipher/XorBytes.h"
#include "Utility/Text/FormatString.h"
#include "Utility/Cipher/LocalEncryptedName.h"
#include <cstdio>
#include <windows.h>
@ -28,35 +29,6 @@ namespace {
target.MoveFrom(diagnostic);
}
template <std::size_t Length, std::uint64_t Key>
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<const char*>(this->m_text);
}
private:
/* 0000 */ std::uint8_t m_text[Length];
bool m_encrypted;
};
// INLINED
template <std::uint64_t Key, std::size_t Length>
const char* DecryptName(const std::uint8_t (&source)[Length]) {