[Localization] Generate class names for 10+ classes

This commit is contained in:
momo5502 2017-02-22 19:04:03 +01:00
parent 712f0d9ef4
commit ea3ac3ddcb
3 changed files with 22 additions and 1 deletions

View File

@ -260,6 +260,25 @@ namespace Components
Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick();
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings");
// Generate localized entries for custom classes above 10
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* /*restrict*/)
{
if (type != Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY) return;
if(name == "CLASS_SLOT1"s)
{
for(int i = 11; i <= NUM_CUSTOM_CLASSES; ++i)
{
std::string key = Utils::String::VA("CLASS_SLOT%i", i);
std::string value = asset.localize->value;
Utils::String::Replace(value, "1", Utils::String::VA("%i", i)); // Pretty ugly, but it should work
Localization::Set(key, value);
}
}
});
}
Localization::~Localization()

View File

@ -118,7 +118,8 @@ namespace Components
StructuredData::StructuredData()
{
Utils::Hook::Set<BYTE>(0x60A2FE, 15); // 15 custom classes
// 15 or more custom classes
Utils::Hook::Set<BYTE>(0x60A2FE, NUM_CUSTOM_CLASSES);
// Only execute this when building zones
if (!ZoneBuilder::IsEnabled()) return;

View File

@ -1,6 +1,7 @@
#pragma once
#define PROTOCOL 0x93
#define NUM_CUSTOM_CLASSES 15
// This allows us to compile our structures in IDA, for easier reversing :3
#ifdef __cplusplus