Override localized strings
This commit is contained in:
parent
de3c598885
commit
32040ce966
@ -11,6 +11,8 @@
|
|||||||
#include "game/demonware/servers/umbrella_server.hpp"
|
#include "game/demonware/servers/umbrella_server.hpp"
|
||||||
#include "game/demonware/server_registry.hpp"
|
#include "game/demonware/server_registry.hpp"
|
||||||
|
|
||||||
|
#include "localized_strings.hpp"
|
||||||
|
|
||||||
#define TCP_BLOCKING true
|
#define TCP_BLOCKING true
|
||||||
#define UDP_BLOCKING false
|
#define UDP_BLOCKING false
|
||||||
|
|
||||||
@ -497,6 +499,8 @@ namespace demonware
|
|||||||
utils::hook::set<uint64_t>(0x141F03130_g, 0xC300000001B8); // Kill LPC_DeleteStale
|
utils::hook::set<uint64_t>(0x141F03130_g, 0xC300000001B8); // Kill LPC_DeleteStale
|
||||||
|
|
||||||
utils::hook::set<uint8_t>(0x141E0AA1B_g, 0xEB); // Release un-handled reportReward spamming loop
|
utils::hook::set<uint8_t>(0x141E0AA1B_g, 0xEB); // Release un-handled reportReward spamming loop
|
||||||
|
|
||||||
|
localized_strings::override("MENU_CONNECTING_DW", "Emulating Online Service");
|
||||||
}
|
}
|
||||||
|
|
||||||
void pre_destroy() override
|
void pre_destroy() override
|
||||||
|
52
src/client/component/localized_strings.cpp
Normal file
52
src/client/component/localized_strings.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include <std_include.hpp>
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
#include "localized_strings.hpp"
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
#include <utils/string.hpp>
|
||||||
|
#include <utils/concurrency.hpp>
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
|
namespace localized_strings
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
utils::hook::detour seh_string_ed_get_string_hook;
|
||||||
|
|
||||||
|
using localized_map = std::unordered_map<std::string, std::string>;
|
||||||
|
utils::concurrency::container<localized_map> localized_overrides;
|
||||||
|
|
||||||
|
const char* seh_string_ed_get_string(const char* reference)
|
||||||
|
{
|
||||||
|
return localized_overrides.access<const char*>([&](const localized_map& map)
|
||||||
|
{
|
||||||
|
const auto entry = map.find(reference);
|
||||||
|
if (entry != map.end())
|
||||||
|
{
|
||||||
|
return utils::string::va("%s", entry->second.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
return seh_string_ed_get_string_hook.invoke<const char*>(reference);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void override(const std::string& key, const std::string& value)
|
||||||
|
{
|
||||||
|
localized_overrides.access([&](localized_map& map)
|
||||||
|
{
|
||||||
|
map[key] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public client_component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
// Change some localized strings
|
||||||
|
seh_string_ed_get_string_hook.create(0x1422796E0_g, &seh_string_ed_get_string);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(localized_strings::component)
|
6
src/client/component/localized_strings.hpp
Normal file
6
src/client/component/localized_strings.hpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace localized_strings
|
||||||
|
{
|
||||||
|
void override(const std::string& key, const std::string& value);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user