From c89ee22517798786d685168dd237351e5442d912 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Sun, 11 Dec 2022 20:56:48 +0100 Subject: [PATCH] Add color patches --- src/client/component/colors.cpp | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/client/component/colors.cpp diff --git a/src/client/component/colors.cpp b/src/client/component/colors.cpp new file mode 100644 index 00000000..95299e3c --- /dev/null +++ b/src/client/component/colors.cpp @@ -0,0 +1,48 @@ +#include +#include "loader/component_loader.hpp" + +#include "game/game.hpp" + +#include + +namespace colors +{ + template + void patch_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a = 255) + { + auto* color_table = reinterpret_cast(0x142FF0E20_g); + auto* g_color_table = reinterpret_cast(0x142FB6CF0_g); + + uint8_t color_int[4]; + color_int[0] = r; + color_int[1] = g; + color_int[2] = b; + color_int[3] = a; + + utils::hook::copy(color_table + index * 4, color_int, sizeof(color_int)); + + float color_float[4]; + color_float[0] = static_cast(r) / 255.0f; + color_float[1] = static_cast(g) / 255.0f; + color_float[2] = static_cast(b) / 255.0f; + color_float[3] = static_cast(a) / 255.0f; + + utils::hook::copy(g_color_table + index * 4, color_float, sizeof(color_float)); + } + + class component final : public component_interface + { + public: + void post_unpack() override + { + patch_color<1>(255, 49, 49); // 1 - Red + patch_color<2>(134, 192, 0); // 2 - Green + patch_color<3>(255, 173, 34); // 3 - Yellow + patch_color<4>(0, 135, 193); // 4 - Blue + patch_color<5>(32, 197, 255); // 5 - Light Blue + patch_color<6>(151, 80, 221); // 6 - Pink + } + }; +} + +REGISTER_COMPONENT(colors::component)