From 036d0a0653d0d9307fa27d6693f5d2179fe0fd21 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Tue, 16 Jul 2024 13:46:37 -0400 Subject: [PATCH] Tweak --- dependencies/symbol-processor/src | 2 +- libreborn/include/libreborn/patch.h | 14 +++++++------- mods/src/bucket/bucket.cpp | 6 +++--- mods/src/death/death.cpp | 4 ++-- mods/src/game-mode/game-mode.cpp | 4 ++-- mods/src/misc/misc.cpp | 2 +- mods/src/title-screen/title-screen.cpp | 20 ++++++++++---------- mods/src/touch/touch.cpp | 6 +++--- test | Bin 18416 -> 0 bytes test.cpp | 12 ------------ 10 files changed, 29 insertions(+), 41 deletions(-) delete mode 100755 test delete mode 100644 test.cpp diff --git a/dependencies/symbol-processor/src b/dependencies/symbol-processor/src index 46c486e56a..6f792dfb16 160000 --- a/dependencies/symbol-processor/src +++ b/dependencies/symbol-processor/src @@ -1 +1 @@ -Subproject commit 46c486e56a15334ccc4bd52bcc9ab1bfbcb7d27e +Subproject commit 6f792dfb167e48e2e80b8484ac51261ab976b22d diff --git a/libreborn/include/libreborn/patch.h b/libreborn/include/libreborn/patch.h index cac7abdce6..6573295518 100644 --- a/libreborn/include/libreborn/patch.h +++ b/libreborn/include/libreborn/patch.h @@ -15,10 +15,10 @@ void overwrite_call(void *start, void *target); // Replace All Calls To Method start With target void *overwrite_calls_manual(void *start, void *target, bool allow_no_callsites = false); template -void overwrite_calls(T &target, typename T::overwrite_type replacement) { - DEBUG("Overwriting Method: %s", target.get_name()); - if (!target.overwrite(replacement)) { - ERR("Unable To Overwrite Method: %s", target.get_name()); +void overwrite_calls(T *target, typename T::overwrite_type replacement) { + DEBUG("Overwriting Method: %s", target->get_name()); + if (!target->overwrite(replacement)) { + ERR("Unable To Overwrite Method: %s", target->get_name()); } } @@ -44,9 +44,9 @@ void patch_address(void *start, void *target); // Patch VTable Entry // This does not affect subclasses. template -void patch_vtable(const T &start, typename T::ptr_type target) { - DEBUG("Patching VTable: %s", start.get_name()); - patch_address((void *) start.get_vtable_addr(), (void *) target); +void patch_vtable(const T *start, typename T::ptr_type target) { + DEBUG("Patching VTable: %s", start->get_name()); + patch_address((void *) start->get_vtable_addr(), (void *) target); } #endif diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index 4da1658088..6f45beb31e 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -136,7 +136,7 @@ static int BucketItem_getUseDuration(__attribute__((unused)) FoodItem *item, Ite static ItemInstance BucketItem_useTimeDepleted(FoodItem *item, ItemInstance *item_instance, Level *level, Player *player) { if (item_instance->auxiliary == 1) { - *item_instance = FoodItem_useTimeDepleted.get()(item, item_instance, level, player); + *item_instance = FoodItem_useTimeDepleted->get()(item, item_instance, level, player); // Set it to a empty bucket item_instance->auxiliary = 0; item_instance->count = 1; @@ -154,7 +154,7 @@ static bool BucketItem_isFood(__attribute__((unused)) FoodItem *item) { static ItemInstance *BucketItem_use(FoodItem *item, ItemInstance *item_instance, __attribute__((unused)) Level *level, Player *player) { if (item_instance->auxiliary == 1) { - return FoodItem_use.get()(item, item_instance, level, player); + return FoodItem_use->get()(item, item_instance, level, player); } return item_instance; } @@ -188,7 +188,7 @@ static FoodItem *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, // Construct FoodItem *item = new FoodItem; ALLOC_CHECK(item); - Item_constructor.get()((Item *) item, id); // FoodItem's Constructor Was Inlined + Item_constructor->get()((Item *) item, id); // FoodItem's Constructor Was Inlined // Set VTable item->vtable = get_bucket_vtable(); diff --git a/mods/src/death/death.cpp b/mods/src/death/death.cpp index 40b236f63d..792066a2e9 100644 --- a/mods/src/death/death.cpp +++ b/mods/src/death/death.cpp @@ -93,7 +93,7 @@ static void Player_actuallyHurt_injection(Self *player, int32_t damage) { int32_t old_health = player->health; // Call Original Method - Mob_actuallyHurt.get()((Mob *) player, damage); + Mob_actuallyHurt->get()((Mob *) player, damage); if (is_hurt) { return; } @@ -122,7 +122,7 @@ void init_death() { // Death Messages if (feature_has("Implement Death Messages", server_auto)) { patch_vtable(ServerPlayer_die, [](ServerPlayer *player, Entity *cause) { - Player_die_injection(Player_die.get(), player, cause); + Player_die_injection(Player_die->get(), player, cause); }); overwrite_calls(LocalPlayer_die, Player_die_injection); patch_vtable(LocalPlayer_actuallyHurt, Player_actuallyHurt_injection); diff --git a/mods/src/game-mode/game-mode.cpp b/mods/src/game-mode/game-mode.cpp index c6847908f7..c5d321294f 100644 --- a/mods/src/game-mode/game-mode.cpp +++ b/mods/src/game-mode/game-mode.cpp @@ -21,7 +21,7 @@ static void set_is_survival(bool new_is_survival) { patch((void *) 0x16ee4, size_patch); // Replace Default CreatorMode Constructor With CreatorMode Or SurvivalMode Constructor - overwrite_call((void *) 0x16ef4, new_is_survival ? (void *) SurvivalMode_constructor.get() : (void *) CreatorMode_constructor.get()); + overwrite_call((void *) 0x16ef4, new_is_survival ? (void *) SurvivalMode_constructor->get() : (void *) CreatorMode_constructor->get()); is_survival = new_is_survival; } @@ -54,7 +54,7 @@ void init_game_mode() { overwrite_calls(Minecraft_setIsCreativeMode, Minecraft_setIsCreativeMode_injection); // Replace CreatorLevel With ServerLevel (This Fixes Beds And Mob Spawning) - overwrite_call((void *) 0x16f84, (void *) ServerLevel_constructor.get()); + overwrite_call((void *) 0x16f84, (void *) ServerLevel_constructor->get()); // Allocate Correct Size For ServerLevel uint32_t level_size = sizeof(ServerLevel); diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index 8d2c9971ab..ed1527af94 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -90,7 +90,7 @@ static void Gui_renderHearts_injection(Gui_renderHearts_t original, Gui *gui) { original(gui); } static GuiComponent_blit_t get_blit_with_classic_hud_offset() { - return use_classic_hud ? Gui_renderHearts_GuiComponent_blit_hearts_injection : GuiComponent_blit.get(); + return use_classic_hud ? Gui_renderHearts_GuiComponent_blit_hearts_injection : GuiComponent_blit->get(); } #define PINK_HEART_FULL 70 #define PINK_HEART_HALF 79 diff --git a/mods/src/title-screen/title-screen.cpp b/mods/src/title-screen/title-screen.cpp index d9dba760b1..9d33ea394c 100644 --- a/mods/src/title-screen/title-screen.cpp +++ b/mods/src/title-screen/title-screen.cpp @@ -70,7 +70,7 @@ static Screen *last_screen = nullptr; static std::string current_splash; static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x, int y, float param_1) { // Call Original Method - Screen_render.get()(screen, x, y, param_1); + Screen_render->get()(screen, x, y, param_1); // Load Splashes static std::vector splashes; @@ -83,28 +83,28 @@ static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x } // Display Splash - if (splashes.size() > 0) { + if (!splashes.empty()) { // Pick Splash if (last_screen != screen) { last_screen = screen; current_splash = splashes[rand() % splashes.size()]; } // Choose Position - float multiplier = touch_gui ? 0.5f : 1.0f; - float splash_x = (float(screen->width) / 2.0f) + (94.0f * multiplier); - float splash_y = 4.0f + (36.0f * multiplier); - float max_width = 86; - float max_scale = 2.0f; + const float multiplier = touch_gui ? 0.5f : 1.0f; + const float splash_x = (float(screen->width) / 2.0f) + (94.0f * multiplier); + const float splash_y = 4.0f + (36.0f * multiplier); + const float max_width = 86; + const float max_scale = 2.0f; // Draw (From https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/client/gui/screens/StartMenuScreen.cpp#L699-L718) glPushMatrix(); // Position glTranslatef(splash_x, splash_y, 0.0f); glRotatef(-20.0f, 0.0f, 0.0f, 1.0f); // Scale - int textWidth = screen->font->width(current_splash); - float timeMS = float(Common::getTimeMs() % 1000) / 1000.0f; + const int textWidth = screen->font->width(current_splash); + const float timeMS = float(Common::getTimeMs() % 1000) / 1000.0f; float scale = max_scale - Mth::abs(0.1f * Mth::sin(2.0f * float(M_PI) * timeMS)); - float real_text_width = textWidth * max_scale; + const float real_text_width = textWidth * max_scale; if (real_text_width > max_width) { scale *= max_width / real_text_width; } diff --git a/mods/src/touch/touch.cpp b/mods/src/touch/touch.cpp index 85cb681312..4dc9cd965b 100644 --- a/mods/src/touch/touch.cpp +++ b/mods/src/touch/touch.cpp @@ -73,10 +73,10 @@ void init_touch() { // Force Touch Inventory if (feature_has("Force Touch GUI Inventory", server_disabled)) { overwrite_call((void *) 0x2943c, (void *) operator_new_IngameBlockSelectionScreen_injection); - overwrite_call((void *) 0x29444, (void *) Touch_IngameBlockSelectionScreen_constructor.get()); + overwrite_call((void *) 0x29444, (void *) Touch_IngameBlockSelectionScreen_constructor->get()); // Make "Craft" And "Armor" Buttons Use Classic GUI Style (Button And TButton Have The Same Size) - overwrite_call((void *) 0x3b060, (void *) Button_constructor.get()); - overwrite_call((void *) 0x3b08c, (void *) Button_constructor.get()); + overwrite_call((void *) 0x3b060, (void *) Button_constructor->get()); + overwrite_call((void *) 0x3b08c, (void *) Button_constructor->get()); } // Force Touch Button Behavior diff --git a/test b/test deleted file mode 100755 index 2133302f68ad85a7bea9da56b5b2e2c5c459d3c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18416 zcmeHPdvIJ;89#S7+ue5aY!aF@&}@;GLd+(cq@_I4=GktvkJzSK5WL;&-eh-3cH{2d zG(p5NRcvjmG2~J+IP7t@N(voy3Me9110qGKJMH$Z5 zij`sk_!23z^j#K#)=DpVX48O@dqD|TN0~Y3m6ljA+yb9K~j5vt_@tb2dGu;&NP3#t}=nV+wan;g|}xSCr#P zF`;9vil>vdLPv?I6PHvtC+)Lff+>|jY5Q3-@lnbfRJhWRbR(RU%VEmpeF`{=%ZE*T znYXF(=DQA$s5mlJms7NirH0pZw2UR1$5QG1RP)r@HO*@}!nsViO;&;G6~aM%YU7q2 zbXks*OodT+_EbYG?nTa$5j|}@KTdSMGyz4`9Lgh*EuKUEz&!E|kk93Z>L0@4OjO^HQwaX! z^T;2E{OUREg|3f|XVQAkjAcz-7y7`^W<6nKjnP!jG_pgRd&e?qV<~tpHMb3Y zdP}5L*W*)DvEkHYq%ETBljA8pJ{HU6ba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