This commit is contained in:
TheBrokenRail 2024-07-16 13:46:37 -04:00
parent e837610380
commit 036d0a0653
10 changed files with 29 additions and 41 deletions

@ -1 +1 @@
Subproject commit 46c486e56a15334ccc4bd52bcc9ab1bfbcb7d27e
Subproject commit 6f792dfb167e48e2e80b8484ac51261ab976b22d

View File

@ -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 <typename T>
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 <typename T>
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

View File

@ -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();

View File

@ -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<ServerPlayer, Player>(Player_die.get(), player, cause);
Player_die_injection<ServerPlayer, Player>(Player_die->get(), player, cause);
});
overwrite_calls(LocalPlayer_die, Player_die_injection<LocalPlayer, LocalPlayer>);
patch_vtable(LocalPlayer_actuallyHurt, Player_actuallyHurt_injection);

View File

@ -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);

View File

@ -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

View File

@ -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<std::string> 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;
}

View File

@ -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

BIN
test

Binary file not shown.

View File

@ -1,12 +0,0 @@
class A {
void hi() {}
int a;
};
class B : public A {
virtual void bye() {}
};
int main() {
B b;
}