From a6e0cd8f1389a0f85b6f9ba59890f7ebdde3b2c3 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sat, 9 Mar 2024 13:01:52 -0500 Subject: [PATCH] Fix history editing bug - Use the `get_` pattern for chat's `history`. - Make the Biome_map comment clearer --- mods/src/chat/ui.cpp | 11 +++++++---- symbols/src/item/ItemInHandRenderer.def | 2 ++ symbols/src/level/Biome.def | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mods/src/chat/ui.cpp b/mods/src/chat/ui.cpp index bdc2dc2f12..12157b7133 100644 --- a/mods/src/chat/ui.cpp +++ b/mods/src/chat/ui.cpp @@ -10,7 +10,10 @@ #include #include -std::vector history; +static std::vector &get_history() { + static std::vector history = {}; + return history; +} // Structure struct ChatScreen { @@ -26,7 +29,7 @@ CUSTOM_VTABLE(chat_screen, Screen) { original_init(super); ChatScreen *self = (ChatScreen *) super; // Text Input - self->chat = TextInputBox::create("", "", &history); + self->chat = TextInputBox::create("", "", &get_history()); self->super.m_textInputs->push_back(self->chat); self->chat->init(super->font); self->chat->setFocused(true); @@ -81,7 +84,8 @@ CUSTOM_VTABLE(chat_screen, Screen) { if (key == 0x0d && self->chat->isFocused()) { if (self->chat->getText().length() > 0) { std::string text = self->chat->getText(); - if (self->chat->history_pos != int(history.size() - 1)) { + std::vector &history = get_history(); + if (history.size() == 0 || text != history.back()) { history.push_back(text); } _chat_queue_message(text.c_str()); @@ -119,7 +123,6 @@ static Screen *create_chat_screen() { // Init void _init_chat_ui() { - history = {}; misc_run_on_game_key_press([](Minecraft *minecraft, int key) { if (key == 0x54) { if (Minecraft_isLevelGenerated(minecraft) && minecraft->screen == NULL) { diff --git a/symbols/src/item/ItemInHandRenderer.def b/symbols/src/item/ItemInHandRenderer.def index ac3f3ed723..e6cbe76882 100644 --- a/symbols/src/item/ItemInHandRenderer.def +++ b/symbols/src/item/ItemInHandRenderer.def @@ -5,3 +5,5 @@ property Minecraft *mc = 0x18; method void renderItem(Mob *mob, ItemInstance *item) = 0x4b824; method void render(float param_1) = 0x4bfcc; + +static-property ItemInHandRenderer *instance = 0x137bc0; \ No newline at end of file diff --git a/symbols/src/level/Biome.def b/symbols/src/level/Biome.def index 4b5fa33abb..3fed3d514c 100644 --- a/symbols/src/level/Biome.def +++ b/symbols/src/level/Biome.def @@ -16,5 +16,5 @@ virtual-method float getCreatureProbability() = 0x20; property int color = 0x2c; property int leaf_color = 0x34; -// 64x64, Temp x humidity +// This is a Biome*[64x64], temp x humidity static-property-array Biome *map = 0x17c970;