Modding Changes

This commit is contained in:
TheBrokenRail 2024-09-20 21:30:47 -04:00
parent f1fe1c140c
commit c0156336df
61 changed files with 501 additions and 473 deletions

@ -1 +1 @@
Subproject commit 2a63f1ff521087f3faf23bf281503cc07a50d2df Subproject commit 5d2b146b08f48bc0e185d224eb69cb718c62bf72

View File

@ -8,7 +8,7 @@
// Syscall Method // Syscall Method
static uint32_t trampoline_syscall(const uint32_t id, const uint32_t length, const unsigned char *args) { static uint32_t trampoline_syscall(const uint32_t id, const uint32_t length, const unsigned char *args) {
// Make Syscall // Make Syscall
long ret = syscall(TRAMPOLINE_SYSCALL, id, length, args); const long ret = syscall(TRAMPOLINE_SYSCALL, id, length, args);
if (ret == -1) { if (ret == -1) {
// Error // Error
ERR("Trampoline Error: %s", strerror(errno)); ERR("Trampoline Error: %s", strerror(errno));
@ -23,7 +23,7 @@ static int get_pipe(const char *env) {
if (value == nullptr) { if (value == nullptr) {
IMPOSSIBLE(); IMPOSSIBLE();
} }
std::string str = value; const std::string str = value;
return std::stoi(str); return std::stoi(str);
} }
static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) { static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) {

View File

@ -25,7 +25,7 @@ struct copy_array {
this->size = length * sizeof(T); this->size = length * sizeof(T);
this->data = arr; this->data = arr;
} }
copy_array(const char *str) { explicit copy_array(const char *str) {
this->size = str != nullptr ? (strlen(str) + 1) : 0; this->size = str != nullptr ? (strlen(str) + 1) : 0;
this->data = str; this->data = str;
} }

View File

@ -3,7 +3,7 @@
#include "../common/common.h" #include "../common/common.h"
// Trampoline Function // Trampoline Function
extern "C" std::remove_pointer<trampoline_t>::type trampoline; extern "C" std::remove_pointer_t<trampoline_t> trampoline;
// Macro // Macro
typedef uint32_t handler_t(trampoline_writer_t writer, const unsigned char *args); typedef uint32_t handler_t(trampoline_writer_t writer, const unsigned char *args);
@ -17,9 +17,9 @@ __attribute__((visibility("internal"))) void _add_handler(unsigned char id, hand
__attribute__((unused)) TrampolineArguments args(raw_args); \ __attribute__((unused)) TrampolineArguments args(raw_args); \
static typeof(name) *func = name; static typeof(name) *func = name;
// Arguemnts // Arguments
struct TrampolineArguments { struct TrampolineArguments {
TrampolineArguments(const unsigned char *args) { explicit TrampolineArguments(const unsigned char *args) {
this->raw_args = args; this->raw_args = args;
this->position = 0; this->position = 0;
} }

View File

@ -10,6 +10,6 @@ extern "C" {
std::string chat_send_api_command(const Minecraft *minecraft, const std::string &str); std::string chat_send_api_command(const Minecraft *minecraft, const std::string &str);
// Override using the HOOK() macro to provide customized chat behavior. // Override using the HOOK() macro to provide customized chat behavior.
void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, char *username, char *message); void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, const char *username, const char *message);
void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet); void chat_handle_packet_send(const Minecraft *minecraft, ChatPacket *packet);
} }

View File

@ -2,7 +2,9 @@
KEY(BACKSPACE, 0x8) KEY(BACKSPACE, 0x8)
KEY(DELETE, 0x2e) KEY(DELETE, 0x2e)
KEY(LEFT, 0x25) KEY(LEFT, 0x25)
KEY(UP, 0x26)
KEY(RIGHT, 0x27) KEY(RIGHT, 0x27)
KEY(DOWN, 0x28)
KEY(F1, 0x70) KEY(F1, 0x70)
KEY(F2, 0x71) KEY(F2, 0x71)
KEY(F3, 0x72) KEY(F3, 0x72)

View File

@ -6,8 +6,8 @@
#include <symbols/minecraft.h> #include <symbols/minecraft.h>
extern "C" { extern "C" {
int32_t misc_get_real_selected_slot(Player *player); int32_t misc_get_real_selected_slot(const Player *player);
void misc_render_background(int color, Minecraft *minecraft, int x, int y, int width, int height); void misc_render_background(int color, const Minecraft *minecraft, int x, int y, int width, int height);
extern bool is_in_chat; extern bool is_in_chat;

View File

@ -5,14 +5,12 @@
#include <map> #include <map>
class ServerProperties { class ServerProperties {
private:
std::map<std::string, std::string> properties; std::map<std::string, std::string> properties;
public: public:
void load(std::istream& fstream); void load(std::istream &stream);
std::string get_string(std::string const& name, std::string const& def); [[nodiscard]] std::string get_string(const std::string &name, const std::string &def) const;
int get_int(std::string const& name, std::string const& def); [[nodiscard]] int get_int(const std::string &name, const std::string &def) const;
bool get_bool(std::string const& name, std::string const& def); [[nodiscard]] bool get_bool(const std::string &name, const std::string &def) const;
}; };

View File

@ -3,22 +3,23 @@
#include <symbols/minecraft.h> #include <symbols/minecraft.h>
struct TextInputBox { struct TextInputBox {
static TextInputBox *create(const std::string &placeholder = "", const std::string &text = ""); explicit TextInputBox(const std::string &placeholder = "", const std::string &text = "");
~TextInputBox();
GuiComponent super; GuiComponent *component;
void setSize(int x, int y, int width = 200, int height = 12); void setSize(int x, int y, int width = 200, int height = 12);
void init(Font *pFont); void init(Font *pFont);
void setEnabled(bool bEnabled); void setEnabled(bool bEnabled);
void keyPressed(int key); void keyPressed(int key);
void charPressed(int chr); void charPressed(int k);
void render(); void render();
void tick(); void tick();
void setFocused(bool b); void setFocused(bool b);
void onClick(int x, int y); void onClick(int x, int y);
[[nodiscard]] bool clicked(int x, int y) const; [[nodiscard]] bool clicked(int xPos, int yPos) const;
[[nodiscard]] std::string getText() const; [[nodiscard]] std::string getText() const;
void setText(std::string text); void setText(const std::string &text);
[[nodiscard]] bool isFocused() const; [[nodiscard]] bool isFocused() const;
void setMaxLength(int max_length); void setMaxLength(int max_length);

View File

@ -5,8 +5,31 @@
#include <mods/text-input-box/TextInputBox.h> #include <mods/text-input-box/TextInputBox.h>
struct TextInputScreen { struct TextInputScreen {
Screen super; std::vector<TextInputBox *> *m_textInputs = nullptr;
std::vector<TextInputBox *> *m_textInputs;
static void setup(Screen_vtable *vtable); template <typename T>
static void setup(Screen_vtable *vtable) {
#define PATCH_VTABLE(name) \
static Screen_##name##_t original_##name = vtable->name; \
vtable->name = [](Screen *super, auto... args) { \
original_##name(super, std::forward<decltype(args)>(args)...); \
T *self = (T *) super; \
self->data.text_input.name(std::forward<decltype(args)>(args)...); \
}
PATCH_VTABLE(keyPressed);
PATCH_VTABLE(keyboardNewChar);
PATCH_VTABLE(mouseClicked);
PATCH_VTABLE(render);
PATCH_VTABLE(init);
PATCH_VTABLE(removed);
#undef PATCH_VTABLE
}
private:
void keyPressed(int key) const;
void keyboardNewChar(char key) const;
void mouseClicked(int x, int y, int param_1) const;
void render(int x, int y, float param_1) const;
void init();
void removed() const;
}; };

View File

@ -4,5 +4,5 @@
extern int touch_gui; extern int touch_gui;
extern "C" { extern "C" {
Button *touch_create_button(int id, std::string text); Button *touch_create_button(int id, const std::string &text);
} }

View File

@ -7,9 +7,9 @@
#include <mods/init/init.h> #include <mods/init/init.h>
// Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled // Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled
static void ItemRenderer_renderGuiItemCorrect_injection_one(ItemRenderer_renderGuiItemCorrect_t original, Font *font, Textures *textures, const ItemInstance *item_instance, int32_t param_1, int32_t param_2) { static void ItemRenderer_renderGuiItemCorrect_injection_one(ItemRenderer_renderGuiItemCorrect_t original, Font *font, Textures *textures, const ItemInstance *item_instance, const int32_t param_1, const int32_t param_2) {
int32_t leaves_id = Tile::leaves->id; const int32_t leaves_id = Tile::leaves->id;
int32_t grass_id = Tile::grass->id; const int32_t grass_id = Tile::grass->id;
// Replace Rendered Item With Carried Variant // Replace Rendered Item With Carried Variant
ItemInstance carried_item_instance; ItemInstance carried_item_instance;
bool use_carried = false; bool use_carried = false;
@ -24,7 +24,7 @@ static void ItemRenderer_renderGuiItemCorrect_injection_one(ItemRenderer_renderG
} }
// Fix Toolbar Rendering // Fix Toolbar Rendering
GLboolean depth_test_was_enabled = glIsEnabled(GL_DEPTH_TEST); const GLboolean depth_test_was_enabled = glIsEnabled(GL_DEPTH_TEST);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
// Call Original Method // Call Original Method
@ -57,7 +57,7 @@ static void Tesselator_color_injection(Tesselator_color_t original, Tesselator *
// Call Original Method // Call Original Method
original(tesselator, r, g, b, a); original(tesselator, r, g, b, a);
} }
static void Tesselator_begin_injection(Tesselator_begin_t original, Tesselator *tesselator, int32_t mode) { static void Tesselator_begin_injection(Tesselator_begin_t original, Tesselator *tesselator, const int32_t mode) {
// Call Original Method // Call Original Method
original(tesselator, mode); original(tesselator, mode);
@ -74,7 +74,7 @@ static void InventoryPane_renderBatch_Tesselator_color_injection(Tesselator *tes
// Enable Item Color Fix // Enable Item Color Fix
item_color_fix_mode = 2; item_color_fix_mode = 2;
} }
static void ItemRenderer_renderGuiItem_two_injection_one(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, float param_1, float param_2, float param_3, float param_4, bool param_5) { static void ItemRenderer_renderGuiItem_two_injection_one(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, const float param_1, const float param_2, const float param_3, const float param_4, const bool param_5) {
// Call Original Method // Call Original Method
original(font, textures, item_instance, param_1, param_2, param_3, param_4, param_5); original(font, textures, item_instance, param_1, param_2, param_3, param_4, param_5);
@ -92,7 +92,7 @@ static void FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection(Font *
// Smooth Scrolling // Smooth Scrolling
static float target_x; static float target_x;
static float target_y; static float target_y;
static void ItemRenderer_renderGuiItem_two_injection_two(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) { static void ItemRenderer_renderGuiItem_two_injection_two(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, const float x, const float y, const float w, const float h, const bool param_5) {
target_x = x; target_x = x;
target_y = y; target_y = y;
original(font, textures, item_instance, x, y, w, h, param_5); original(font, textures, item_instance, x, y, w, h, param_5);

View File

@ -40,7 +40,7 @@ static void start_world(Minecraft *minecraft) {
minecraft->selectLevel(name, name, settings); minecraft->selectLevel(name, name, settings);
// Open ProgressScreen // Open ProgressScreen
ProgressScreen *screen = new ProgressScreen; ProgressScreen *screen = ProgressScreen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen = screen->constructor(); screen = screen->constructor();
minecraft->setScreen((Screen *) screen); minecraft->setScreen((Screen *) screen);
@ -54,7 +54,7 @@ static void handle_swap_buffers() {
// Track Ticks // Track Ticks
static unsigned long long int ticks = 0; static unsigned long long int ticks = 0;
static void Minecraft_tick_injection(__attribute__((unused)) Minecraft *minecraft) { static void Minecraft_tick_injection(__attribute__((unused)) const Minecraft *minecraft) {
ticks++; ticks++;
} }

View File

@ -184,9 +184,9 @@ CUSTOM_VTABLE(bucket, FoodItem) {
} }
// Create Items // Create Items
static FoodItem *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, std::string name) { static FoodItem *create_bucket(const int32_t id, int32_t texture_x, int32_t texture_y, std::string name) {
// Construct // Construct
FoodItem *item = new FoodItem; FoodItem *item = FoodItem::allocate();
ALLOC_CHECK(item); ALLOC_CHECK(item);
Item_constructor->get(false)((Item *) item, id); // FoodItem's Constructor Was Inlined Item_constructor->get(false)((Item *) item, id); // FoodItem's Constructor Was Inlined
@ -253,7 +253,7 @@ static HitResult Mob_pick_Level_clip_injection(Level *level, const Vec3 &param_1
// Call Original Method // Call Original Method
return level->clip(param_1, param_2, is_holding_bucket, clip_hitboxes); return level->clip(param_1, param_2, is_holding_bucket, clip_hitboxes);
} }
static void handle_tick(Minecraft *minecraft) { static void handle_tick(const Minecraft *minecraft) {
LocalPlayer *player = minecraft->player; LocalPlayer *player = minecraft->player;
if (player != nullptr) { if (player != nullptr) {
// Get Selected Slot // Get Selected Slot
@ -261,14 +261,14 @@ static void handle_tick(Minecraft *minecraft) {
Inventory *inventory = player->inventory; Inventory *inventory = player->inventory;
// Get Item // Get Item
ItemInstance *inventory_item = inventory->getItem(selected_slot); const ItemInstance *inventory_item = inventory->getItem(selected_slot);
// Check // Check
is_holding_bucket = inventory_item != nullptr && inventory_item->id == bucket->id && inventory_item->auxiliary == 0; is_holding_bucket = inventory_item != nullptr && inventory_item->id == bucket->id && inventory_item->auxiliary == 0;
} }
} }
// Prevent Breaking Liquid // Prevent Breaking Liquid
static bool is_calm_liquid(int32_t id) { static bool is_calm_liquid(const int32_t id) {
if (id == Tile::calmWater->id) { if (id == Tile::calmWater->id) {
return true; return true;
} else if (id == Tile::calmLava->id) { } else if (id == Tile::calmLava->id) {
@ -277,14 +277,14 @@ static bool is_calm_liquid(int32_t id) {
return false; return false;
} }
} }
static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t original, Minecraft *minecraft, int param_1, bool can_destroy) { static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t original, Minecraft *minecraft, const int param_1, bool can_destroy) {
// Check // Check
Level *level = minecraft->level; Level *level = minecraft->level;
if (level != nullptr) { if (level != nullptr) {
int32_t x = minecraft->hit_result.x; int32_t x = minecraft->hit_result.x;
int32_t y = minecraft->hit_result.y; int32_t y = minecraft->hit_result.y;
int32_t z = minecraft->hit_result.z; int32_t z = minecraft->hit_result.z;
int32_t tile = level->getTile(x, y, z); const int32_t tile = level->getTile(x, y, z);
if (is_calm_liquid(tile)) { if (is_calm_liquid(tile)) {
can_destroy = false; can_destroy = false;
} }
@ -297,9 +297,9 @@ static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t orig
// Custom Crafting Recipes // Custom Crafting Recipes
static void Recipes_injection(Recipes *recipes) { static void Recipes_injection(Recipes *recipes) {
// Add // Add
Recipes_Type type1 = { constexpr Recipes_Type type1 = {
.item = 0, .item = nullptr,
.tile = 0, .tile = nullptr,
.instance = { .instance = {
.count = 3, .count = 3,
.id = 265, .id = 265,
@ -314,7 +314,7 @@ static void Recipes_injection(Recipes *recipes) {
}; };
std::string line1 = "# #"; std::string line1 = "# #";
std::string line2 = " # "; std::string line2 = " # ";
std::vector<Recipes_Type> types = {type1}; std::vector types = {type1};
recipes->addShapedRecipe_2(result, line1, line2, types); recipes->addShapedRecipe_2(result, line1, line2, types);
} }

View File

@ -16,7 +16,7 @@ static std::string Cake_getDescriptionId(__attribute__((unused)) Tile *tile) {
} }
// Textures // Textures
static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face, __attribute__((unused)) int data) { static int Cake_getTexture2(__attribute__((unused)) Tile *tile, const int face, __attribute__((unused)) int data) {
if (face == 1) { if (face == 1) {
// Top texture // Top texture
return 121; return 121;
@ -28,10 +28,10 @@ static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face, __attr
return 122; return 122;
} }
static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *level, int x, int y, int z, int face) { static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *level, int x, int y, int z, const int face) {
// Eaten face // Eaten face
if (face == 3) { if (face == 3) {
int data = level->getData(x, y, z); const int data = level->getData(x, y, z);
if (data != 0 && data < 6) { if (data != 0 && data < 6) {
// Sliced texture // Sliced texture
return 123; return 123;
@ -69,7 +69,7 @@ static AABB *Cake_getAABB(Tile *tile, Level *level, int x, int y, int z) {
// Get the size of the slices // Get the size of the slices
int data = level->getData(x, y, z); int data = level->getData(x, y, z);
if (data >= 6) data = 0; if (data >= 6) data = 0;
float slice_size = (1.0 / 7.0) * (float) data; const float slice_size = (1.0 / 7.0) * (float) data;
// Corner 1 // Corner 1
AABB *aabb = &tile->aabb; AABB *aabb = &tile->aabb;
@ -90,7 +90,7 @@ static void Cake_updateShape(Tile *tile, LevelSource *level, int x, int y, int z
int data = level->getData(x, y, z); int data = level->getData(x, y, z);
if (data >= 6) data = 0; if (data >= 6) data = 0;
// Get slice amount // Get slice amount
float slice_size = (1.0 / 7.0) * (float) data; const float slice_size = (1.0 / 7.0) * (float) data;
tile->setShape( tile->setShape(
CAKE_LEN, 0.0, CAKE_LEN, CAKE_LEN, 0.0, CAKE_LEN,
1.0 - CAKE_LEN, 0.5, (1.0 - CAKE_LEN) - slice_size 1.0 - CAKE_LEN, 0.5, (1.0 - CAKE_LEN) - slice_size
@ -116,7 +116,7 @@ static int Cake_use(__attribute__((unused)) Tile *tile, Level *level, int x, int
// Makes the cakes // Makes the cakes
static void make_cake() { static void make_cake() {
// Construct // Construct
cake = new Tile; cake = Tile::allocate();
ALLOC_CHECK(cake); ALLOC_CHECK(cake);
int texture = 122; int texture = 122;
cake->constructor(92, texture, Material::dirt); cake->constructor(92, texture, Material::dirt);
@ -170,9 +170,9 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
// Recipe (only when buckets are enabled) // Recipe (only when buckets are enabled)
static void Recipes_injection(Recipes *recipes) { static void Recipes_injection(Recipes *recipes) {
// Sugar // Sugar
Recipes_Type sugar = { constexpr Recipes_Type sugar = {
.item = 0, .item = nullptr,
.tile = 0, .tile = nullptr,
.instance = { .instance = {
.count = 1, .count = 1,
.id = 353, .id = 353,
@ -181,9 +181,9 @@ static void Recipes_injection(Recipes *recipes) {
.letter = 's' .letter = 's'
}; };
// Wheat // Wheat
Recipes_Type wheat = { constexpr Recipes_Type wheat = {
.item = 0, .item = nullptr,
.tile = 0, .tile = nullptr,
.instance = { .instance = {
.count = 1, .count = 1,
.id = 296, .id = 296,
@ -192,9 +192,9 @@ static void Recipes_injection(Recipes *recipes) {
.letter = 'w' .letter = 'w'
}; };
// Eggs // Eggs
Recipes_Type eggs = { constexpr Recipes_Type eggs = {
.item = 0, .item = nullptr,
.tile = 0, .tile = nullptr,
.instance = { .instance = {
.count = 1, .count = 1,
.id = 344, .id = 344,
@ -203,9 +203,9 @@ static void Recipes_injection(Recipes *recipes) {
.letter = 'e' .letter = 'e'
}; };
// Milk // Milk
Recipes_Type milk = { constexpr Recipes_Type milk = {
.item = 0, .item = nullptr,
.tile = 0, .tile = nullptr,
.instance = { .instance = {
.count = 1, .count = 1,
.id = 325, .id = 325,

View File

@ -16,7 +16,7 @@ static EntityRenderDispatcher *EntityRenderDispatcher_injection(EntityRenderDisp
original(dispatcher); original(dispatcher);
// Register TripodCameraRenderer // Register TripodCameraRenderer
TripodCameraRenderer *renderer = new TripodCameraRenderer; TripodCameraRenderer *renderer = TripodCameraRenderer::allocate();
ALLOC_CHECK(renderer); ALLOC_CHECK(renderer);
renderer->constructor(); renderer->constructor();
dispatcher->assign((unsigned char) 0x5, (EntityRenderer *) renderer); dispatcher->assign((unsigned char) 0x5, (EntityRenderer *) renderer);
@ -25,7 +25,7 @@ static EntityRenderDispatcher *EntityRenderDispatcher_injection(EntityRenderDisp
} }
// Display Smoke From TripodCamera Higher // Display Smoke From TripodCamera Higher
static void TripodCamera_tick_Level_addParticle_call_injection(Level *level, const std::string &particle, float x, float y, float z, float deltaX, float deltaY, float deltaZ, int count) { static void TripodCamera_tick_Level_addParticle_call_injection(Level *level, const std::string &particle, float x, const float y, float z, float deltaX, float deltaY, float deltaZ, int count) {
// Call Original Method // Call Original Method
level->addParticle(particle, x, y + 0.5, z, deltaX, deltaY, deltaZ, count); level->addParticle(particle, x, y + 0.5, z, deltaX, deltaY, deltaZ, count);
} }

View File

@ -8,10 +8,10 @@
#define MAX_CHAT_MESSAGE_LENGTH 256 #define MAX_CHAT_MESSAGE_LENGTH 256
// Message Prefix // Message Prefix
__attribute__((visibility("internal"))) std::string _chat_get_prefix(char *username); __attribute__((visibility("internal"))) std::string _chat_get_prefix(const char *username);
// Queue Message For Sending // Queue Message For Sending
__attribute__((visibility("internal"))) void _chat_send_message(Minecraft *minecraft, const char *message); __attribute__((visibility("internal"))) void _chat_send_message(const Minecraft *minecraft, const char *message);
// Init Chat UI // Init Chat UI
__attribute__((visibility("internal"))) void _init_chat_ui(); __attribute__((visibility("internal"))) void _init_chat_ui();

View File

@ -25,16 +25,16 @@ std::string chat_send_api_command(const Minecraft *minecraft, const std::string
} }
// Send API Chat Command // Send API Chat Command
static void send_api_chat_command(Minecraft *minecraft, const char *str) { static void send_api_chat_command(const Minecraft *minecraft, const char *str) {
const std::string command = std::string("chat.post(") + str + ")\n"; const std::string command = std::string("chat.post(") + str + ")\n";
chat_send_api_command(minecraft, command); chat_send_api_command(minecraft, command);
} }
// Send Message To Players // Send Message To Players
std::string _chat_get_prefix(char *username) { std::string _chat_get_prefix(const char *username) {
return std::string("<") + username + "> "; return std::string("<") + username + "> ";
} }
void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, char *username, char *message) { void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, const char *username, const char *message) {
std::string full_message = _chat_get_prefix(username) + message; std::string full_message = _chat_get_prefix(username) + message;
char *raw_str = strdup(full_message.c_str()); char *raw_str = strdup(full_message.c_str());
ALLOC_CHECK(raw_str); ALLOC_CHECK(raw_str);
@ -44,7 +44,7 @@ void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, ch
server_side_network_handler->displayGameMessage(full_message); server_side_network_handler->displayGameMessage(full_message);
} }
// Handle Chat packet Send // Handle Chat packet Send
void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) { void chat_handle_packet_send(const Minecraft *minecraft, ChatPacket *packet) {
RakNetInstance *rak_net_instance = minecraft->rak_net_instance; RakNetInstance *rak_net_instance = minecraft->rak_net_instance;
if (rak_net_instance->isServer()) { if (rak_net_instance->isServer()) {
// Hosting Multiplayer // Hosting Multiplayer
@ -58,8 +58,8 @@ void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) {
} }
// Manually Send (And Loopback) ChatPacket // Manually Send (And Loopback) ChatPacket
static void CommandServer_parse_CommandServer_dispatchPacket_injection(CommandServer *command_server, Packet *packet) { static void CommandServer_parse_CommandServer_dispatchPacket_injection(const CommandServer *command_server, Packet *packet) {
Minecraft *minecraft = command_server->minecraft; const Minecraft *minecraft = command_server->minecraft;
if (minecraft != nullptr) { if (minecraft != nullptr) {
chat_handle_packet_send(minecraft, (ChatPacket *) packet); chat_handle_packet_send(minecraft, (ChatPacket *) packet);
} }
@ -67,17 +67,17 @@ static void CommandServer_parse_CommandServer_dispatchPacket_injection(CommandSe
// Handle ChatPacket Server-Side // Handle ChatPacket Server-Side
static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetworkHandler *server_side_network_handler, const RakNet_RakNetGUID &rak_net_guid, ChatPacket *chat_packet) { static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetworkHandler *server_side_network_handler, const RakNet_RakNetGUID &rak_net_guid, ChatPacket *chat_packet) {
Player *player = server_side_network_handler->getPlayer(rak_net_guid); const Player *player = server_side_network_handler->getPlayer(rak_net_guid);
if (player != nullptr) { if (player != nullptr) {
const char *username = player->username.c_str(); const char *username = player->username.c_str();
const char *message = chat_packet->message.c_str(); const char *message = chat_packet->message.c_str();
chat_send_message(server_side_network_handler, (char *) username, (char *) message); chat_send_message(server_side_network_handler, username, message);
} }
} }
// Send Message // Send Message
void _chat_send_message(Minecraft *minecraft, const char *message) { void _chat_send_message(const Minecraft *minecraft, const char *message) {
send_api_chat_command(minecraft, (char *) message); send_api_chat_command(minecraft, message);
} }
// Init // Init

View File

@ -15,14 +15,14 @@ static std::vector<std::string> &get_history() {
} }
// Structure // Structure
struct ChatScreen { EXTEND_STRUCT(ChatScreen, Screen, struct {
TextInputScreen super; TextInputScreen text_input;
TextInputBox *chat; TextInputBox *chat;
Button *send; Button *send;
int history_pos; int history_pos;
}; });
CUSTOM_VTABLE(chat_screen, Screen) { CUSTOM_VTABLE(chat_screen, Screen) {
TextInputScreen::setup(vtable); TextInputScreen::setup<ChatScreen>(vtable);
// Init // Init
static std::vector<std::string> local_history = {}; static std::vector<std::string> local_history = {};
static Screen_init_t original_init = vtable->init; static Screen_init_t original_init = vtable->init;
@ -30,21 +30,21 @@ CUSTOM_VTABLE(chat_screen, Screen) {
original_init(super); original_init(super);
ChatScreen *self = (ChatScreen *) super; ChatScreen *self = (ChatScreen *) super;
// Text Input // Text Input
self->chat = TextInputBox::create(); self->data.chat = new TextInputBox;
self->super.m_textInputs->push_back(self->chat); self->data.text_input.m_textInputs->push_back(self->data.chat);
self->chat->init(super->font); self->data.chat->init(super->font);
self->chat->setFocused(true); self->data.chat->setFocused(true);
self->history_pos = get_history().size(); self->data.history_pos = get_history().size();
local_history = get_history(); local_history = get_history();
local_history.push_back(""); local_history.push_back("");
// Determine Max Length // Determine Max Length
std::string prefix = _chat_get_prefix(Strings::default_username); const std::string prefix = _chat_get_prefix(Strings::default_username);
int max_length = MAX_CHAT_MESSAGE_LENGTH - prefix.length(); const int max_length = MAX_CHAT_MESSAGE_LENGTH - prefix.length();
self->chat->setMaxLength(max_length); self->data.chat->setMaxLength(max_length);
// Send Button // Send Button
self->send = touch_create_button(1, "Send"); self->data.send = touch_create_button(1, "Send");
super->rendered_buttons.push_back(self->send); super->rendered_buttons.push_back(self->data.send);
super->selectable_buttons.push_back(self->send); super->selectable_buttons.push_back(self->data.send);
// Hide Chat Messages // Hide Chat Messages
is_in_chat = true; is_in_chat = true;
}; };
@ -53,13 +53,13 @@ CUSTOM_VTABLE(chat_screen, Screen) {
vtable->removed = [](Screen *super) { vtable->removed = [](Screen *super) {
original_removed(super); original_removed(super);
is_in_chat = false; is_in_chat = false;
ChatScreen *self = (ChatScreen *) super; const ChatScreen *self = (ChatScreen *) super;
delete self->chat; delete self->data.chat;
self->send->destructor_deleting(); self->data.send->destructor_deleting();
}; };
// Rendering // Rendering
static Screen_render_t original_render = vtable->render; static Screen_render_t original_render = vtable->render;
vtable->render = [](Screen *super, int x, int y, float param_1) { vtable->render = [](Screen *super, const int x, const int y, const float param_1) {
// Background // Background
super->renderBackground(); super->renderBackground();
// Render Chat // Render Chat
@ -71,46 +71,46 @@ CUSTOM_VTABLE(chat_screen, Screen) {
static Screen_setupPositions_t original_setupPositions = vtable->setupPositions; static Screen_setupPositions_t original_setupPositions = vtable->setupPositions;
vtable->setupPositions = [](Screen *super) { vtable->setupPositions = [](Screen *super) {
original_setupPositions(super); original_setupPositions(super);
ChatScreen *self = (ChatScreen *) super; const ChatScreen *self = (ChatScreen *) super;
self->send->height = 24; self->data.send->height = 24;
self->send->width = 40; self->data.send->width = 40;
int x = 0; constexpr int x = 0;
int y = super->height - self->send->height; const int y = super->height - self->data.send->height;
int width = super->width - self->send->width; const int width = super->width - self->data.send->width;
self->chat->setSize(x, y, width, self->send->height); self->data.chat->setSize(x, y, width, self->data.send->height);
self->send->y = super->height - self->send->height; self->data.send->y = super->height - self->data.send->height;
self->send->x = x + width; self->data.send->x = x + width;
}; };
// Key Presses // Key Presses
static Screen_keyPressed_t original_keyPressed = vtable->keyPressed; static Screen_keyPressed_t original_keyPressed = vtable->keyPressed;
vtable->keyPressed = [](Screen *super, int key) { vtable->keyPressed = [](Screen *super, const int key) {
// Handle Enter // Handle Enter
ChatScreen *self = (ChatScreen *) super; ChatScreen *self = (ChatScreen *) super;
if (self->chat->isFocused()) { if (self->data.chat->isFocused()) {
if (key == 0x0d) { if (key == MC_KEY_RETURN) {
if (self->chat->getText().length() > 0) { if (self->data.chat->getText().length() > 0) {
std::string text = self->chat->getText(); const std::string text = self->data.chat->getText();
if (get_history().size() == 0 || text != get_history().back()) { if (get_history().size() == 0 || text != get_history().back()) {
get_history().push_back(text); get_history().push_back(text);
} }
_chat_send_message(super->minecraft, text.c_str()); _chat_send_message(super->minecraft, text.c_str());
} }
super->minecraft->setScreen(nullptr); super->minecraft->setScreen(nullptr);
} else if (key == 0x26) { } else if (key == MC_KEY_UP) {
// Up // Up
local_history.at(self->history_pos) = self->chat->getText(); local_history.at(self->data.history_pos) = self->data.chat->getText();
// Change // Change
self->history_pos -= 1; self->data.history_pos -= 1;
if (self->history_pos < 0) self->history_pos = local_history.size() - 1; if (self->data.history_pos < 0) self->data.history_pos = local_history.size() - 1;
self->chat->setText(local_history.at(self->history_pos)); self->data.chat->setText(local_history.at(self->data.history_pos));
return; return;
} else if (key == 0x28) { } else if (key == MC_KEY_DOWN) {
// Down // Down
local_history.at(self->history_pos) = self->chat->getText(); local_history.at(self->data.history_pos) = self->data.chat->getText();
// Change // Change
self->history_pos += 1; self->data.history_pos += 1;
if (self->history_pos > int(local_history.size()) - 1) self->history_pos = 0; if (self->data.history_pos > int(local_history.size()) - 1) self->data.history_pos = 0;
self->chat->setText(local_history.at(self->history_pos)); self->data.chat->setText(local_history.at(self->data.history_pos));
return; return;
} }
} }
@ -121,9 +121,9 @@ CUSTOM_VTABLE(chat_screen, Screen) {
static Screen_buttonClicked_t original_buttonClicked = vtable->buttonClicked; static Screen_buttonClicked_t original_buttonClicked = vtable->buttonClicked;
vtable->buttonClicked = [](Screen *super, Button *button) { vtable->buttonClicked = [](Screen *super, Button *button) {
ChatScreen *self = (ChatScreen *) super; ChatScreen *self = (ChatScreen *) super;
if (button == self->send) { if (button == self->data.send) {
// Send // Send
self->chat->setFocused(true); self->data.chat->setFocused(true);
super->keyPressed(0x0d); super->keyPressed(0x0d);
} else { } else {
// Call Original Method // Call Original Method
@ -135,10 +135,10 @@ static Screen *create_chat_screen() {
// Construct // Construct
ChatScreen *screen = new ChatScreen; ChatScreen *screen = new ChatScreen;
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen->super.super.constructor(); screen->super()->constructor();
// Set VTable // Set VTable
screen->super.super.vtable = get_chat_screen_vtable(); screen->super()->vtable = get_chat_screen_vtable();
// Return // Return
return (Screen *) screen; return (Screen *) screen;
@ -146,7 +146,7 @@ static Screen *create_chat_screen() {
// Init // Init
void _init_chat_ui() { void _init_chat_ui() {
misc_run_on_game_key_press([](Minecraft *minecraft, int key) { misc_run_on_game_key_press([](Minecraft *minecraft, const int key) {
if (key == MC_KEY_t) { if (key == MC_KEY_t) {
if (minecraft->isLevelGenerated() && minecraft->screen == nullptr) { if (minecraft->isLevelGenerated() && minecraft->screen == nullptr) {
minecraft->setScreen(create_chat_screen()); minecraft->setScreen(create_chat_screen());

View File

@ -17,17 +17,17 @@
#define CREATIVE_STR GAME_MODE_STR("Creative") #define CREATIVE_STR GAME_MODE_STR("Creative")
// Structure // Structure
struct CreateWorldScreen { EXTEND_STRUCT(CreateWorldScreen, Screen, struct {
TextInputScreen super; TextInputScreen text_input;
TextInputBox *name; TextInputBox *name;
TextInputBox *seed; TextInputBox *seed;
Button *game_mode; Button *game_mode;
Button *create; Button *create;
Button *back; Button *back;
}; });
static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed); static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed_str);
CUSTOM_VTABLE(create_world_screen, Screen) { CUSTOM_VTABLE(create_world_screen, Screen) {
TextInputScreen::setup(vtable); TextInputScreen::setup<CreateWorldScreen>(vtable);
// Constants // Constants
static int line_height = 8; static int line_height = 8;
static int bottom_padding = 4; static int bottom_padding = 4;
@ -43,42 +43,42 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
original_init(super); original_init(super);
CreateWorldScreen *self = (CreateWorldScreen *) super; CreateWorldScreen *self = (CreateWorldScreen *) super;
// Name // Name
self->name = TextInputBox::create("World Name", "Unnamed world"); self->data.name = new TextInputBox("World Name", "Unnamed world");
self->super.m_textInputs->push_back(self->name); self->data.text_input.m_textInputs->push_back(self->data.name);
self->name->init(super->font); self->data.name->init(super->font);
self->name->setFocused(true); self->data.name->setFocused(true);
// Seed // Seed
self->seed = TextInputBox::create("Seed"); self->data.seed = new TextInputBox("Seed");
self->super.m_textInputs->push_back(self->seed); self->data.text_input.m_textInputs->push_back(self->data.seed);
self->seed->init(super->font); self->data.seed->init(super->font);
self->seed->setFocused(false); self->data.seed->setFocused(false);
// Game Mode // Game Mode
self->game_mode = touch_create_button(1, CREATIVE_STR); self->data.game_mode = touch_create_button(1, CREATIVE_STR);
super->rendered_buttons.push_back(self->game_mode); super->rendered_buttons.push_back(self->data.game_mode);
super->selectable_buttons.push_back(self->game_mode); super->selectable_buttons.push_back(self->data.game_mode);
// Create // Create
self->create = touch_create_button(2, "Create"); self->data.create = touch_create_button(2, "Create");
super->rendered_buttons.push_back(self->create); super->rendered_buttons.push_back(self->data.create);
super->selectable_buttons.push_back(self->create); super->selectable_buttons.push_back(self->data.create);
// Back // Back
self->back = touch_create_button(3, "Back"); self->data.back = touch_create_button(3, "Back");
super->rendered_buttons.push_back(self->back); super->rendered_buttons.push_back(self->data.back);
super->selectable_buttons.push_back(self->back); super->selectable_buttons.push_back(self->data.back);
}; };
// Removal // Removal
static Screen_removed_t original_removed = vtable->removed; static Screen_removed_t original_removed = vtable->removed;
vtable->removed = [](Screen *super) { vtable->removed = [](Screen *super) {
original_removed(super); original_removed(super);
CreateWorldScreen *self = (CreateWorldScreen *) super; CreateWorldScreen *self = (CreateWorldScreen *) super;
delete self->name; delete self->data.name;
delete self->seed; delete self->data.seed;
self->game_mode->destructor_deleting(); self->data.game_mode->destructor_deleting();
self->back->destructor_deleting(); self->data.back->destructor_deleting();
self->create->destructor_deleting(); self->data.create->destructor_deleting();
}; };
// Rendering // Rendering
static Screen_render_t original_render = vtable->render; static Screen_render_t original_render = vtable->render;
vtable->render = [](Screen *super, int x, int y, float param_1) { vtable->render = [](Screen *super, const int x, const int y, const float param_1) {
// Background // Background
misc_render_background(80, super->minecraft, 0, 0, super->width, super->height); misc_render_background(80, super->minecraft, 0, 0, super->width, super->height);
misc_render_background(32, super->minecraft, 0, content_y_offset_top, super->width, super->height - content_y_offset_top - content_y_offset_bottom); misc_render_background(32, super->minecraft, 0, content_y_offset_top, super->width, super->height - content_y_offset_top - content_y_offset_bottom);
@ -89,9 +89,9 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
super->drawCenteredString(super->font, title, super->width / 2, title_padding, 0xffffffff); super->drawCenteredString(super->font, title, super->width / 2, title_padding, 0xffffffff);
// Game Mode Description // Game Mode Description
CreateWorldScreen *self = (CreateWorldScreen *) super; CreateWorldScreen *self = (CreateWorldScreen *) super;
bool is_creative = self->game_mode->text == CREATIVE_STR; const bool is_creative = self->data.game_mode->text == CREATIVE_STR;
std::string description = is_creative ? Strings::creative_mode_description : Strings::survival_mode_description; std::string description = is_creative ? Strings::creative_mode_description : Strings::survival_mode_description;
super->drawString(super->font, description, self->game_mode->x, self->game_mode->y + self->game_mode->height + description_padding, 0xa0a0a0); super->drawString(super->font, description, self->data.game_mode->x, self->data.game_mode->y + self->data.game_mode->height + description_padding, 0xa0a0a0);
}; };
// Positioning // Positioning
static Screen_setupPositions_t original_setupPositions = vtable->setupPositions; static Screen_setupPositions_t original_setupPositions = vtable->setupPositions;
@ -99,33 +99,33 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
original_setupPositions(super); original_setupPositions(super);
CreateWorldScreen *self = (CreateWorldScreen *) super; CreateWorldScreen *self = (CreateWorldScreen *) super;
// Height/Width // Height/Width
int width = 120; constexpr int width = 120;
int height = button_height; const int height = button_height;
self->create->width = self->back->width = self->game_mode->width = width; self->data.create->width = self->data.back->width = self->data.game_mode->width = width;
int seed_width = self->game_mode->width; int seed_width = self->data.game_mode->width;
int name_width = width * 1.5f; int name_width = width * 1.5f;
self->create->height = self->back->height = self->game_mode->height = height; self->data.create->height = self->data.back->height = self->data.game_mode->height = height;
int text_box_height = self->game_mode->height; int text_box_height = self->data.game_mode->height;
// Find Center Y // Find Center Y
int top = content_y_offset_top; const int top = content_y_offset_top;
int bottom = super->height - content_y_offset_bottom; const int bottom = super->height - content_y_offset_bottom;
int center_y = ((bottom - top) / 2) + top; int center_y = ((bottom - top) / 2) + top;
center_y -= (description_padding + line_height) / 2; center_y -= (description_padding + line_height) / 2;
// X/Y // X/Y
self->create->y = self->back->y = super->height - bottom_padding - height; self->data.create->y = self->data.back->y = super->height - bottom_padding - height;
self->create->x = self->game_mode->x = (super->width / 2) - inner_padding - width; self->data.create->x = self->data.game_mode->x = (super->width / 2) - inner_padding - width;
self->back->x = (super->width / 2) + inner_padding; self->data.back->x = (super->width / 2) + inner_padding;
int seed_x = self->back->x; const int seed_x = self->data.back->x;
int name_x = (super->width / 2) - (name_width / 2); const int name_x = (super->width / 2) - (name_width / 2);
int name_y = center_y - inner_padding - height; const int name_y = center_y - inner_padding - height;
self->game_mode->y = center_y + inner_padding; self->data.game_mode->y = center_y + inner_padding;
int seed_y = self->game_mode->y; const int seed_y = self->data.game_mode->y;
// Update Text Boxes // Update Text Boxes
self->name->setSize(name_x, name_y, name_width, text_box_height); self->data.name->setSize(name_x, name_y, name_width, text_box_height);
self->seed->setSize(seed_x, seed_y, seed_width, text_box_height); self->data.seed->setSize(seed_x, seed_y, seed_width, text_box_height);
}; };
// ESC // ESC
vtable->handleBackEvent = [](Screen *super, bool do_nothing) { vtable->handleBackEvent = [](Screen *super, const bool do_nothing) {
if (!do_nothing) { if (!do_nothing) {
super->minecraft->screen_chooser.setScreen(5); super->minecraft->screen_chooser.setScreen(5);
} }
@ -134,16 +134,16 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
// Button Click // Button Click
vtable->buttonClicked = [](Screen *super, Button *button) { vtable->buttonClicked = [](Screen *super, Button *button) {
CreateWorldScreen *self = (CreateWorldScreen *) super; CreateWorldScreen *self = (CreateWorldScreen *) super;
bool is_creative = self->game_mode->text == CREATIVE_STR; const bool is_creative = self->data.game_mode->text == CREATIVE_STR;
if (button == self->game_mode) { if (button == self->data.game_mode) {
// Toggle Game Mode // Toggle Game Mode
self->game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR; self->data.game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR;
} else if (button == self->back) { } else if (button == self->data.back) {
// Back // Back
super->handleBackEvent(false); super->handleBackEvent(false);
} else if (button == self->create) { } else if (button == self->data.create) {
// Create // Create
create_world(super->minecraft, self->name->getText(), is_creative, self->seed->getText()); create_world(super->minecraft, self->data.name->getText(), is_creative, self->data.seed->getText());
} }
}; };
} }
@ -151,10 +151,10 @@ static Screen *create_create_world_screen() {
// Construct // Construct
CreateWorldScreen *screen = new CreateWorldScreen; CreateWorldScreen *screen = new CreateWorldScreen;
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen->super.super.constructor(); screen->super()->constructor();
// Set VTable // Set VTable
screen->super.super.vtable = get_create_world_screen_vtable(); screen->super()->vtable = get_create_world_screen_vtable();
// Return // Return
return (Screen *) screen; return (Screen *) screen;
@ -170,7 +170,7 @@ static std::string getUniqueLevelName(LevelStorageSource *source, const std::str
maps.insert(ls.folder); maps.insert(ls.folder);
} }
std::string out = in; std::string out = in;
while (maps.find(out) != maps.end()) { while (maps.contains(out)) {
out += "-"; out += "-";
} }
return out; return out;
@ -192,14 +192,14 @@ int get_seed_from_string(std::string str) {
} }
return seed; return seed;
} }
static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed_str) { static void create_world(Minecraft *minecraft, std::string name, const bool is_creative, std::string seed_str) {
// Get Seed // Get Seed
int seed = get_seed_from_string(std::move(seed_str)); const int seed = get_seed_from_string(std::move(seed_str));
// Get Folder Name // Get Folder Name
name = Util::stringTrim(name); name = Util::stringTrim(name);
std::string folder = ""; std::string folder = "";
for (char c : name) { for (const char c : name) {
if ( if (
c >= ' ' && c <= '~' && c >= ' ' && c <= '~' &&
c != '/' && c != '/' &&
@ -233,7 +233,7 @@ static void create_world(Minecraft *minecraft, std::string name, bool is_creativ
minecraft->hostMultiplayer(19132); minecraft->hostMultiplayer(19132);
// Open ProgressScreen // Open ProgressScreen
ProgressScreen *screen = new ProgressScreen; ProgressScreen *screen = ProgressScreen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen = screen->constructor(); screen = screen->constructor();
minecraft->setScreen((Screen *) screen); minecraft->setScreen((Screen *) screen);

View File

@ -6,7 +6,7 @@
#include "input-internal.h" #include "input-internal.h"
// Translator // Translator
static int32_t sdl_key_to_minecraft_key_injection(Common_sdl_key_to_minecraft_key_t original, int32_t sdl_key) { static int32_t sdl_key_to_minecraft_key_injection(Common_sdl_key_to_minecraft_key_t original, const int32_t sdl_key) {
switch (sdl_key) { switch (sdl_key) {
#define KEY(name, value) case SDLK_##name: return MC_KEY_##name; #define KEY(name, value) case SDLK_##name: return MC_KEY_##name;
#include <mods/input/key-list.h> #include <mods/input/key-list.h>

View File

@ -23,7 +23,7 @@ static void _handle_back(Minecraft *minecraft) {
} }
// Fix OptionsScreen Ignoring The Back Button // Fix OptionsScreen Ignoring The Back Button
static bool OptionsScreen_handleBackEvent_injection(OptionsScreen *screen, bool do_nothing) { static bool OptionsScreen_handleBackEvent_injection(OptionsScreen *screen, const bool do_nothing) {
if (!do_nothing) { if (!do_nothing) {
Minecraft *minecraft = screen->minecraft; Minecraft *minecraft = screen->minecraft;
minecraft->setScreen(nullptr); minecraft->setScreen(nullptr);
@ -59,7 +59,7 @@ static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(Minecraft *
} }
// Block UI Interaction When Mouse Is Locked // Block UI Interaction When Mouse Is Locked
static void Gui_handleClick_injection(Gui_handleClick_t original, Gui *gui, int32_t param_2, int32_t param_3, int32_t param_4) { static void Gui_handleClick_injection(Gui_handleClick_t original, Gui *gui, const int32_t param_2, const int32_t param_3, const int32_t param_4) {
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) { if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
// Call Original Method // Call Original Method
original(gui, param_2, param_3, param_4); original(gui, param_2, param_3, param_4);

View File

@ -7,7 +7,7 @@
#include <mods/misc/misc.h> #include <mods/misc/misc.h>
// Handle Toggle Options // Handle Toggle Options
static bool _handle_toggle_options(Minecraft *minecraft, int key) { static bool _handle_toggle_options(Minecraft *minecraft, const int key) {
Options *options = &minecraft->options; Options *options = &minecraft->options;
if (key == MC_KEY_F1) { if (key == MC_KEY_F1) {
// Toggle Hide GUI // Toggle Hide GUI
@ -49,13 +49,13 @@ static void revert_rotation(Entity *entity) {
} }
static bool is_front_facing = false; static bool is_front_facing = false;
static LocalPlayer *stored_player = nullptr; static LocalPlayer *stored_player = nullptr;
static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t original, GameRenderer *game_renderer, float param_1, int param_2) { static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t original, GameRenderer *game_renderer, const float param_1, const int param_2) {
// Get Objects // Get Objects
Minecraft *minecraft = game_renderer->minecraft; Minecraft *minecraft = game_renderer->minecraft;
stored_player = minecraft->player; stored_player = minecraft->player;
// Check If In Third-Person // Check If In Third-Person
Options *options = &minecraft->options; const Options *options = &minecraft->options;
is_front_facing = (options->third_person == 2); is_front_facing = (options->third_person == 2);
// Invert Rotation // Invert Rotation
@ -71,7 +71,7 @@ static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t origin
revert_rotation((Entity *) stored_player); revert_rotation((Entity *) stored_player);
} }
} }
static void ParticleEngine_render_injection(ParticleEngine_render_t original, ParticleEngine *particle_engine, Entity *entity, float param_2) { static void ParticleEngine_render_injection(ParticleEngine_render_t original, ParticleEngine *particle_engine, Entity *entity, const float param_2) {
// Invert Rotation // Invert Rotation
if (is_front_facing && (Entity *) stored_player == entity) { if (is_front_facing && (Entity *) stored_player == entity) {
invert_rotation((Entity *) stored_player); invert_rotation((Entity *) stored_player);

View File

@ -55,7 +55,7 @@ void misc_run_on_update(const std::function<void(Minecraft *)> &func) {
}); });
} }
void misc_run_on_tick(const std::function<void(Minecraft *)> &func) { void misc_run_on_tick(const std::function<void(Minecraft *)> &func) {
overwrite_calls(Minecraft_tick, [func](Minecraft_tick_t original, Minecraft *self, int tick, int max_ticks) { overwrite_calls(Minecraft_tick, [func](Minecraft_tick_t original, Minecraft *self, const int tick, const int max_ticks) {
original(self, tick, max_ticks); original(self, tick, max_ticks);
func(self); func(self);
}); });
@ -93,7 +93,7 @@ void misc_run_on_language_setup(const std::function<void()> &func) {
}); });
} }
void misc_run_on_game_key_press(const std::function<bool(Minecraft *, int)> &func) { void misc_run_on_game_key_press(const std::function<bool(Minecraft *, int)> &func) {
overwrite_calls(Gui_handleKeyPressed, [func](Gui_handleKeyPressed_t original, Gui *self, int key) { overwrite_calls(Gui_handleKeyPressed, [func](Gui_handleKeyPressed_t original, Gui *self, const int key) {
if (func(self->minecraft, key)) { if (func(self->minecraft, key)) {
return; return;
} }
@ -102,7 +102,7 @@ void misc_run_on_game_key_press(const std::function<bool(Minecraft *, int)> &fun
} }
void misc_run_on_key_press(const std::function<bool(Minecraft *, int)> &func) { void misc_run_on_key_press(const std::function<bool(Minecraft *, int)> &func) {
misc_run_on_game_key_press(func); misc_run_on_game_key_press(func);
overwrite_calls(Screen_keyPressed, [func](Screen_keyPressed_t original, Screen *self, int key) { overwrite_calls(Screen_keyPressed, [func](Screen_keyPressed_t original, Screen *self, const int key) {
if (func(self->minecraft, key)) { if (func(self->minecraft, key)) {
return; return;
} }
@ -111,7 +111,7 @@ void misc_run_on_key_press(const std::function<bool(Minecraft *, int)> &func) {
} }
// Render Fancy Background // Render Fancy Background
void misc_render_background(int color, Minecraft *minecraft, int x, int y, int width, int height) { void misc_render_background(int color, const Minecraft *minecraft, const int x, const int y, const int width, const int height) {
// https://github.com/ReMinecraftPE/mcpe/blob/f0d65eaecec1b3fe9c2f2b251e114a890c54ab77/source/client/gui/components/RolledSelectionList.cpp#L169-L179 // https://github.com/ReMinecraftPE/mcpe/blob/f0d65eaecec1b3fe9c2f2b251e114a890c54ab77/source/client/gui/components/RolledSelectionList.cpp#L169-L179
glColor4f(1, 1, 1, 1); glColor4f(1, 1, 1, 1);
minecraft->textures->loadAndBindTexture("gui/background.png"); minecraft->textures->loadAndBindTexture("gui/background.png");

View File

@ -114,7 +114,7 @@ static int32_t FurnaceScreen_handleAddItem_injection(FurnaceScreen_handleAddItem
} }
// Get Real Selected Slot // Get Real Selected Slot
int32_t misc_get_real_selected_slot(Player *player) { int32_t misc_get_real_selected_slot(const Player *player) {
// Get Selected Slot // Get Selected Slot
const Inventory *inventory = player->inventory; const Inventory *inventory = player->inventory;
int32_t selected_slot = inventory->selectedSlot; int32_t selected_slot = inventory->selectedSlot;
@ -376,7 +376,7 @@ static void LocalPlayer_tick_injection(LocalPlayer_tick_t original, LocalPlayer
const bool synced = self->getSharedFlag(FLAG_SNEAKING); const bool synced = self->getSharedFlag(FLAG_SNEAKING);
if (real != synced) { if (real != synced) {
// Send To Server // Send To Server
PlayerActionPacket *packet = new PlayerActionPacket; PlayerActionPacket *packet = PlayerActionPacket::allocate();
Packet_constructor->get(false)((Packet *) packet); Packet_constructor->get(false)((Packet *) packet);
packet->vtable = PlayerActionPacket_vtable_base; packet->vtable = PlayerActionPacket_vtable_base;
packet->entity_id = self->id; packet->entity_id = self->id;

View File

@ -33,7 +33,7 @@ static void Gui_renderHearts_injection(Gui_renderHearts_t original, Gui *gui) {
} }
#define PINK_HEART_FULL 70 #define PINK_HEART_FULL 70
#define PINK_HEART_HALF 79 #define PINK_HEART_HALF 79
static void Gui_renderHearts_GuiComponent_blit_overlay_empty_injection(Gui *gui, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t w1, int32_t h1, int32_t w2, int32_t h2) { static void Gui_renderHearts_GuiComponent_blit_overlay_empty_injection(Gui *gui, const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2, const int32_t w1, const int32_t h1, const int32_t w2, const int32_t h2) {
// Call Original Method // Call Original Method
get_blit_with_classic_hud_offset()((GuiComponent *) gui, x1, y1, x2, y2, w1, h1, w2, h2); get_blit_with_classic_hud_offset()((GuiComponent *) gui, x1, y1, x2, y2, w1, h1, w2, h2);
// Render The Overlay // Render The Overlay
@ -47,7 +47,7 @@ static void Gui_renderHearts_GuiComponent_blit_overlay_empty_injection(Gui *gui,
heal_amount_drawing -= 2; heal_amount_drawing -= 2;
} }
} }
static void Gui_renderHearts_GuiComponent_blit_overlay_hearts_injection(Gui *gui, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t w1, int32_t h1, int32_t w2, int32_t h2) { static void Gui_renderHearts_GuiComponent_blit_overlay_hearts_injection(Gui *gui, const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2, const int32_t w1, const int32_t h1, const int32_t w2, const int32_t h2) {
// Offset the overlay // Offset the overlay
if (x2 == 52) { if (x2 == 52) {
heal_amount_drawing += 2; heal_amount_drawing += 2;
@ -100,7 +100,7 @@ static void Gui_tick_injection(Gui_tick_t original, Gui *gui) {
} }
} }
// Trigger Reset Selected Item Text Timer On Slot Select // Trigger Reset Selected Item Text Timer On Slot Select
static void Inventory_selectSlot_injection(Inventory_selectSlot_t original, Inventory *inventory, int32_t slot) { static void Inventory_selectSlot_injection(Inventory_selectSlot_t original, Inventory *inventory, const int32_t slot) {
// Call Original Method // Call Original Method
original(inventory, slot); original(inventory, slot);

View File

@ -15,7 +15,7 @@
// Setup // Setup
static Storage *storage = nullptr; static Storage *storage = nullptr;
static void setup_multidraw(int chunks, GLuint *buffers) { static void setup_multidraw(const int chunks, GLuint *buffers) {
delete storage; delete storage;
storage = new Storage(chunks); storage = new Storage(chunks);
for (int i = 0; i < chunks; i++) { for (int i = 0; i < chunks; i++) {

View File

@ -37,7 +37,7 @@ void Storage::free_block(Block *block) {
} }
// Find Block // Find Block
std::vector<Block *>::iterator it = std::find(used_blocks.begin(), used_blocks.end(), block); std::vector<Block *>::iterator it = std::ranges::find(used_blocks, block);
if (it == used_blocks.end()) { if (it == used_blocks.end()) {
return; return;
} }

View File

@ -26,14 +26,14 @@ struct Storage {
Buffer *buffer; Buffer *buffer;
// Chunks // Chunks
std::vector<Block *> chunk_to_block; std::vector<Block *> chunk_to_block = {};
void upload(int chunk, ssize_t size, const void *data); void upload(int chunk, ssize_t size, const void *data);
// Management // Management
ssize_t total_size; ssize_t total_size;
ssize_t used_size; ssize_t used_size;
std::vector<Block *> free_blocks; std::vector<Block *> free_blocks = {};
std::vector<Block *> used_blocks; std::vector<Block *> used_blocks = {};
void free_block(Block *block); void free_block(Block *block);
void recreate(ssize_t extra_size = 0); void recreate(ssize_t extra_size = 0);
void check_fragmentation(); void check_fragmentation();

View File

@ -136,7 +136,7 @@ static void position_info(Font *font, int width, int height) {
// Third Stage (Find Line Button Width) // Third Stage (Find Line Button Width)
line_button_width = 0; line_button_width = 0;
for (int i = 0; i < info_size; i++) { for (int i = 0; i < info_size; i++) {
int text_width = font->width(info[i].button_text); const int text_width = font->width(info[i].button_text);
if (text_width > line_button_width) { if (text_width > line_button_width) {
line_button_width = text_width; line_button_width = text_width;
} }
@ -144,11 +144,11 @@ static void position_info(Font *font, int width, int height) {
line_button_width += line_button_padding * 2; line_button_width += line_button_padding * 2;
// Fourth Stage (Centering) // Fourth Stage (Centering)
int info_height = y; const int info_height = y;
int info_width = info_text_width + padding + line_button_width; const int info_width = info_text_width + padding + line_button_width;
content_height = height - content_y_offset_top - content_y_offset_bottom; content_height = height - content_y_offset_top - content_y_offset_bottom;
int info_y_offset = ((content_height - info_height) / 2) + content_y_offset_top; const int info_y_offset = ((content_height - info_height) / 2) + content_y_offset_top;
int info_x_offset = (width - info_width) / 2; const int info_x_offset = (width - info_width) / 2;
for (int i = 0; i < info_size; i++) { for (int i = 0; i < info_size; i++) {
positioned_info[i].button.x += info_x_offset; positioned_info[i].button.x += info_x_offset;
positioned_info[i].button.y += info_y_offset; positioned_info[i].button.y += info_y_offset;
@ -195,9 +195,9 @@ CUSTOM_VTABLE(info_screen, Screen) {
self->selectable_buttons.push_back(back); self->selectable_buttons.push_back(back);
}; };
// Handle Back // Handle Back
vtable->handleBackEvent = [](Screen *self, bool do_nothing) { vtable->handleBackEvent = [](Screen *self, const bool do_nothing) {
if (!do_nothing) { if (!do_nothing) {
OptionsScreen *screen = new OptionsScreen; OptionsScreen *screen = OptionsScreen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen->constructor(); screen->constructor();
self->minecraft->setScreen((Screen *) screen); self->minecraft->setScreen((Screen *) screen);
@ -206,7 +206,7 @@ CUSTOM_VTABLE(info_screen, Screen) {
}; };
// Rendering // Rendering
static Screen_render_t original_render = vtable->render; static Screen_render_t original_render = vtable->render;
vtable->render = [](Screen *self, int x, int y, float param_1) { vtable->render = [](Screen *self, const int x, const int y, const float param_1) {
// Background // Background
misc_render_background(80, self->minecraft, 0, 0, self->width, self->height); misc_render_background(80, self->minecraft, 0, 0, self->width, self->height);
misc_render_background(32, self->minecraft, 0, content_y_offset_top, self->width, content_height); misc_render_background(32, self->minecraft, 0, content_y_offset_top, self->width, content_height);
@ -224,7 +224,7 @@ CUSTOM_VTABLE(info_screen, Screen) {
// Positioning // Positioning
vtable->setupPositions = [](Screen *self) { vtable->setupPositions = [](Screen *self) {
// Height/Width // Height/Width
int width = 120; constexpr int width = 120;
discord->width = back->width = width; discord->width = back->width = width;
discord->height = back->height = line_button_height; discord->height = back->height = line_button_height;
// X/Y // X/Y
@ -257,7 +257,7 @@ CUSTOM_VTABLE(info_screen, Screen) {
open_url(MCPI_DISCORD_INVITE); open_url(MCPI_DISCORD_INVITE);
} else if (button->id >= INFO_ID_START) { } else if (button->id >= INFO_ID_START) {
// Open Info URL // Open Info URL
int i = button->id - INFO_ID_START; const int i = button->id - INFO_ID_START;
open_url(info[i].button_url); open_url(info[i].button_url);
} }
}; };
@ -266,7 +266,7 @@ CUSTOM_VTABLE(info_screen, Screen) {
// Create Screen // Create Screen
Screen *_create_options_info_screen() { Screen *_create_options_info_screen() {
// Allocate // Allocate
Screen *screen = new Screen; Screen *screen = Screen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen->constructor(); screen->constructor();

View File

@ -75,7 +75,7 @@ static void Minecraft_init_injection(Minecraft_init_t original, Minecraft *minec
} }
// Smooth Lighting // Smooth Lighting
static bool TileRenderer_tesselateBlockInWorld_injection(TileRenderer_tesselateBlockInWorld_t original, TileRenderer *tile_renderer, Tile *tile, int32_t x, int32_t y, int32_t z) { static bool TileRenderer_tesselateBlockInWorld_injection(TileRenderer_tesselateBlockInWorld_t original, TileRenderer *tile_renderer, Tile *tile, const int32_t x, const int32_t y, const int32_t z) {
// Set Variable // Set Variable
Minecraft::useAmbientOcclusion = stored_options->ambient_occlusion; Minecraft::useAmbientOcclusion = stored_options->ambient_occlusion;
@ -103,20 +103,20 @@ static void Options_save_Options_addOptionToSaveOutput_injection(Options *option
// MCPI's OptionsFile::getOptionStrings is broken, this is the version in v0.7.0 // MCPI's OptionsFile::getOptionStrings is broken, this is the version in v0.7.0
static std::vector<std::string> OptionsFile_getOptionStrings_injection(__attribute__((unused)) OptionsFile_getOptionStrings_t original, OptionsFile *options_file) { static std::vector<std::string> OptionsFile_getOptionStrings_injection(__attribute__((unused)) OptionsFile_getOptionStrings_t original, OptionsFile *options_file) {
// Get options.txt Path // Get options.txt Path
std::string path = options_file->options_txt_path; const std::string path = options_file->options_txt_path;
// Parse // Parse
std::vector<std::string> ret; std::vector<std::string> ret;
FILE *stream = fopen(path.c_str(), "r"); FILE *stream = fopen(path.c_str(), "r");
char line[128];
if (stream != nullptr) { if (stream != nullptr) {
char line[128];
while (fgets(line, 0x80, stream) != nullptr) { while (fgets(line, 0x80, stream) != nullptr) {
size_t sVar1 = strlen(line); const size_t sVar1 = strlen(line);
if (2 < sVar1) { if (2 < sVar1) {
std::stringstream string_stream(line); std::stringstream string_stream(line);
while (true) { while (true) {
std::string data; std::string data;
std::getline(string_stream, data, ':'); std::getline(string_stream, data, ':');
int iVar2 = data.find_last_not_of(" \n\r\t"); const int iVar2 = data.find_last_not_of(" \n\r\t");
data.erase(iVar2 + 1); data.erase(iVar2 + 1);
if (data.length() == 0) { if (data.length() == 0) {
break; break;
@ -210,7 +210,7 @@ void init_options() {
// Replace String // Replace String
patch_address((void *) &Strings::feedback_vibration_options_txt_name, (void *) "gfx_ao"); patch_address((void *) &Strings::feedback_vibration_options_txt_name, (void *) "gfx_ao");
// Loading // Loading
unsigned char offset = (unsigned char) offsetof(Options, ambient_occlusion); const unsigned char offset = (unsigned char) offsetof(Options, ambient_occlusion);
unsigned char gfx_ao_loading_patch[4] = {offset, 0x10, 0x84, 0xe2}; // "add r1, r4, #OFFSET" unsigned char gfx_ao_loading_patch[4] = {offset, 0x10, 0x84, 0xe2}; // "add r1, r4, #OFFSET"
patch((void *) 0x193b8, gfx_ao_loading_patch); patch((void *) 0x193b8, gfx_ao_loading_patch);
// Saving // Saving
@ -223,7 +223,7 @@ void init_options() {
// Replace String // Replace String
patch_address((void *) &Strings::gfx_lowquality_options_txt_name, (void *) "gfx_anaglyph"); patch_address((void *) &Strings::gfx_lowquality_options_txt_name, (void *) "gfx_anaglyph");
// Loading // Loading
unsigned char offset = (unsigned char) offsetof(Options, anaglyph_3d); const unsigned char offset = (unsigned char) offsetof(Options, anaglyph_3d);
unsigned char gfx_anaglyph_loading_patch[4] = {offset, 0x10, 0x84, 0xe2}; // "add r1, r4, #OFFSET" unsigned char gfx_anaglyph_loading_patch[4] = {offset, 0x10, 0x84, 0xe2}; // "add r1, r4, #OFFSET"
patch((void *) 0x19400, gfx_anaglyph_loading_patch); patch((void *) 0x19400, gfx_anaglyph_loading_patch);
// Disable Loading Side Effects // Disable Loading Side Effects

View File

@ -1,5 +1,4 @@
#include <string> #include <string>
#include <algorithm>
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#include <symbols/minecraft.h> #include <symbols/minecraft.h>
@ -22,9 +21,9 @@ static OptionButton *OptionsPane_unknown_toggle_creating_function_OptionButton_i
} }
// Modify Option Toggles // Modify Option Toggles
static void OptionsPane_unknown_toggle_creating_function_injection(OptionsPane_unknown_toggle_creating_function_t original, OptionsPane *options_pane, uint32_t group_id, std::string *name_ptr, Options_Option *option) { static void OptionsPane_unknown_toggle_creating_function_injection(OptionsPane_unknown_toggle_creating_function_t original, OptionsPane *options_pane, const uint32_t group_id, std::string *name_ptr, Options_Option *option) {
// Modify // Modify
std::string name = *name_ptr; const std::string name = *name_ptr;
std::string new_name = name; std::string new_name = name;
if (name == "Fancy Graphics") { if (name == "Fancy Graphics") {
option = &Options_Option::GRAPHICS; option = &Options_Option::GRAPHICS;
@ -97,7 +96,7 @@ static void OptionsScreen_init_injection(OptionsScreen_init_t original, OptionsS
original(self); original(self);
// Add Button // Add Button
Touch_TButton *button = new Touch_TButton; Touch_TButton *button = Touch_TButton::allocate();
ALLOC_CHECK(button); ALLOC_CHECK(button);
std::string name = "Reborn"; std::string name = "Reborn";
button->constructor(INFO_BUTTON_ID, name); button->constructor(INFO_BUTTON_ID, name);
@ -109,7 +108,7 @@ static void OptionsScreen_setupPositions_injection(OptionsScreen_setupPositions_
original(self); original(self);
// Find Button // Find Button
Button *prevButton = nullptr; const Button *prevButton = nullptr;
Button *button = nullptr; Button *button = nullptr;
for (Button *x : self->selectable_buttons) { for (Button *x : self->selectable_buttons) {
if (x->id == INFO_BUTTON_ID) { if (x->id == INFO_BUTTON_ID) {

View File

@ -1,7 +1,5 @@
#define __USE_LARGEFILE64 #define __USE_LARGEFILE64
#include <cstddef>
#include <cstdint>
#include <dirent.h> #include <dirent.h>
// Minecraft: Pi Edition Was Not Compiled With 64-Bit Filesystem Support, So This Shims readdir() To Read Directories Properly // Minecraft: Pi Edition Was Not Compiled With 64-Bit Filesystem Support, So This Shims readdir() To Read Directories Properly
@ -9,7 +7,7 @@
#define FILENAME_SIZE 256 #define FILENAME_SIZE 256
dirent *readdir(DIR *dirp) { dirent *readdir(DIR *dirp) {
dirent64 *original = readdir64(dirp); const dirent64 *original = readdir64(dirp);
if (original == nullptr) { if (original == nullptr) {
return nullptr; return nullptr;
} }

View File

@ -31,7 +31,7 @@ static std::string get_screenshot(const std::string &filename) {
} }
// Take Screenshot // Take Screenshot
static int save_png(const char *filename, unsigned char *pixels, int line_size, int width, int height) { static int save_png(const char *filename, const unsigned char *pixels, const int line_size, const int width, const int height) {
// Setup // Setup
stbi_flip_vertically_on_write(1); stbi_flip_vertically_on_write(1);
@ -110,7 +110,7 @@ void init_screenshot() {
// Create Directory // Create Directory
get_screenshot_dir(); get_screenshot_dir();
// Take Screenshot On F2 // Take Screenshot On F2
misc_run_on_key_press([](Minecraft *mc, int key) { misc_run_on_key_press([](Minecraft *mc, const int key) {
if (key == MC_KEY_F2) { if (key == MC_KEY_F2) {
screenshot_take(&mc->gui); screenshot_take(&mc->gui);
return true; return true;

View File

@ -50,7 +50,7 @@ ServerProperties &get_server_properties() {
// Get World Name // Get World Name
static std::string get_world_name() { static std::string get_world_name() {
std::string name = get_server_properties().get_string("world-name", DEFAULT_WORLD_NAME); const std::string name = get_server_properties().get_string("world-name", DEFAULT_WORLD_NAME);
char *safe_name_c = to_cp437(name.c_str()); char *safe_name_c = to_cp437(name.c_str());
std::string safe_name = safe_name_c; std::string safe_name = safe_name_c;
free(safe_name_c); free(safe_name_c);
@ -88,7 +88,7 @@ static void start_world(Minecraft *minecraft) {
} }
// Open ProgressScreen // Open ProgressScreen
ProgressScreen *screen = new ProgressScreen; ProgressScreen *screen = ProgressScreen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen = screen->constructor(); screen = screen->constructor();
minecraft->setScreen((Screen *) screen); minecraft->setScreen((Screen *) screen);
@ -111,22 +111,22 @@ static std::vector<Player *> get_players_in_level(Level *level) {
} }
// Get Player's Username // Get Player's Username
static std::string get_player_username(Player *player) { static std::string get_player_username(Player *player) {
std::string *username = &player->username; const std::string *username = &player->username;
char *safe_username_c = from_cp437(username->c_str()); char *safe_username_c = from_cp437(username->c_str());
std::string safe_username = safe_username_c; std::string safe_username = safe_username_c;
free(safe_username_c); free(safe_username_c);
return safe_username; return safe_username;
} }
// Get Level From Minecraft // Get Level From Minecraft
static Level *get_level(Minecraft *minecraft) { static Level *get_level(const Minecraft *minecraft) {
return minecraft->level; return minecraft->level;
} }
// Find Players With Username And Run Callback // Find Players With Username And Run Callback
typedef void (*player_callback_t)(Minecraft *minecraft, const std::string &username, Player *player); typedef void (*player_callback_t)(Minecraft *minecraft, const std::string &username, Player *player);
static void find_players(Minecraft *minecraft, const std::string &target_username, player_callback_t callback, bool all_players) { static void find_players(Minecraft *minecraft, const std::string &target_username, const player_callback_t callback, const bool all_players) {
Level *level = get_level(minecraft); Level *level = get_level(minecraft);
std::vector<Player *> players = get_players_in_level(level); const std::vector<Player *> players = get_players_in_level(level);
bool found_player = false; bool found_player = false;
for (std::size_t i = 0; i < players.size(); i++) { for (std::size_t i = 0; i < players.size(); i++) {
// Iterate Players // Iterate Players
@ -151,19 +151,19 @@ static RakNet_SystemAddress get_system_address(RakNet_RakPeer *rak_peer, RakNet_
// Get SystemAddress // Get SystemAddress
return rak_peer->GetSystemAddressFromGuid(guid); return rak_peer->GetSystemAddressFromGuid(guid);
} }
static RakNet_RakPeer *get_rak_peer(Minecraft *minecraft) { static RakNet_RakPeer *get_rak_peer(const Minecraft *minecraft) {
return minecraft->rak_net_instance->peer; return minecraft->rak_net_instance->peer;
} }
static char *get_rak_net_guid_ip(RakNet_RakPeer *rak_peer, RakNet_RakNetGUID guid) { static char *get_rak_net_guid_ip(RakNet_RakPeer *rak_peer, const RakNet_RakNetGUID &guid) {
RakNet_SystemAddress address = get_system_address(rak_peer, guid); RakNet_SystemAddress address = get_system_address(rak_peer, guid);
// Get IP // Get IP
return address.ToString(false, '|'); return address.ToString(false, '|');
} }
// Get IP From Player // Get IP From Player
static char *get_player_ip(Minecraft *minecraft, Player *player) { static char *get_player_ip(const Minecraft *minecraft, Player *player) {
RakNet_RakPeer *rak_peer = get_rak_peer(minecraft); RakNet_RakPeer *rak_peer = get_rak_peer(minecraft);
RakNet_RakNetGUID guid = get_rak_net_guid(player); const RakNet_RakNetGUID guid = get_rak_net_guid(player);
// Return // Return
return get_rak_net_guid_ip(rak_peer, guid); return get_rak_net_guid_ip(rak_peer, guid);
} }
@ -206,17 +206,17 @@ static void list_callback(Minecraft *minecraft, const std::string &username, Pla
static long long int get_time() { static long long int get_time() {
timespec ts = {}; timespec ts = {};
clock_gettime(CLOCK_MONOTONIC_RAW, &ts); clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
long long int a = (long long int) ts.tv_nsec; const long long int a = (long long int) ts.tv_nsec;
long long int b = ((long long int) ts.tv_sec) * NANOSECONDS_IN_SECOND; const long long int b = ((long long int) ts.tv_sec) * NANOSECONDS_IN_SECOND;
return a + b; return a + b;
} }
static bool is_last_tick_time_set = false; static bool is_last_tick_time_set = false;
static long long int last_tick_time; static long long int last_tick_time;
static double tps = 0; static double tps = 0;
static void Minecraft_tick_injection(__attribute__((unused)) Minecraft *minecraft) { static void Minecraft_tick_injection(__attribute__((unused)) const Minecraft *minecraft) {
long long int time = get_time(); const long long int time = get_time();
if (is_last_tick_time_set) { if (is_last_tick_time_set) {
long long int tick_time = time - last_tick_time; const long long int tick_time = time - last_tick_time;
tps = ((double) NANOSECONDS_IN_SECOND) / ((double) tick_time); tps = ((double) NANOSECONDS_IN_SECOND) / ((double) tick_time);
} else { } else {
is_last_tick_time_set = true; is_last_tick_time_set = true;
@ -225,7 +225,7 @@ static void Minecraft_tick_injection(__attribute__((unused)) Minecraft *minecraf
} }
// Get ServerSideNetworkHandler From Minecraft // Get ServerSideNetworkHandler From Minecraft
static ServerSideNetworkHandler *get_server_side_network_handler(Minecraft *minecraft) { static ServerSideNetworkHandler *get_server_side_network_handler(const Minecraft *minecraft) {
return (ServerSideNetworkHandler *) minecraft->network_handler; return (ServerSideNetworkHandler *) minecraft->network_handler;
} }
@ -289,18 +289,18 @@ static void handle_commands(Minecraft *minecraft) {
static std::string help_command("help"); static std::string help_command("help");
if (!is_whitelist() && data.rfind(ban_command, 0) == 0) { if (!is_whitelist() && data.rfind(ban_command, 0) == 0) {
// IP-Ban Target Username // IP-Ban Target Username
std::string ban_username = data.substr(ban_command.length()); const std::string ban_username = data.substr(ban_command.length());
find_players(minecraft, ban_username, ban_callback, false); find_players(minecraft, ban_username, ban_callback, false);
} else if (data == reload_command) { } else if (data == reload_command) {
INFO("Reloading %s", is_whitelist() ? "Whitelist" : "Blacklist"); INFO("Reloading %s", is_whitelist() ? "Whitelist" : "Blacklist");
is_ip_in_blacklist(nullptr); is_ip_in_blacklist(nullptr);
} else if (data.rfind(kill_command, 0) == 0) { } else if (data.rfind(kill_command, 0) == 0) {
// Kill Target Username // Kill Target Username
std::string kill_username = data.substr(kill_command.length()); const std::string kill_username = data.substr(kill_command.length());
find_players(minecraft, kill_username, kill_callback, false); find_players(minecraft, kill_username, kill_callback, false);
} else if (data.rfind(say_command, 0) == 0) { } else if (data.rfind(say_command, 0) == 0) {
// Format Message // Format Message
std::string message = "[Server] " + data.substr(say_command.length()); const std::string message = "[Server] " + data.substr(say_command.length());
char *safe_message = to_cp437(message.c_str()); char *safe_message = to_cp437(message.c_str());
std::string cpp_string = safe_message; std::string cpp_string = safe_message;
// Post Message To Chat // Post Message To Chat
@ -367,7 +367,7 @@ static bool is_ip_in_blacklist(const char *ip) {
// Reload // Reload
ips.clear(); ips.clear();
// Check banned-ips.txt // Check banned-ips.txt
std::string blacklist_file_path = get_blacklist_file(); const std::string blacklist_file_path = get_blacklist_file();
std::ifstream blacklist_file(blacklist_file_path); std::ifstream blacklist_file(blacklist_file_path);
if (blacklist_file) { if (blacklist_file) {
if (blacklist_file.good()) { if (blacklist_file.good()) {
@ -400,7 +400,7 @@ static bool is_ip_in_blacklist(const char *ip) {
// Ban Players // Ban Players
static bool RakNet_RakPeer_IsBanned_injection(__attribute__((unused)) RakNet_RakPeer_IsBanned_t original, __attribute__((unused)) RakNet_RakPeer *rakpeer, const char *ip) { static bool RakNet_RakPeer_IsBanned_injection(__attribute__((unused)) RakNet_RakPeer_IsBanned_t original, __attribute__((unused)) RakNet_RakPeer *rakpeer, const char *ip) {
// Check List // Check List
bool ret = is_ip_in_blacklist(ip); const bool ret = is_ip_in_blacklist(ip);
if (is_whitelist()) { if (is_whitelist()) {
return !ret; return !ret;
} else { } else {
@ -416,8 +416,8 @@ static Player *ServerSideNetworkHandler_onReady_ClientGeneration_ServerSideNetwo
// Check If Player Is Null // Check If Player Is Null
if (player != nullptr) { if (player != nullptr) {
// Get Data // Get Data
std::string *username = &player->username; const std::string *username = &player->username;
Minecraft *minecraft = server_side_network_handler->minecraft; const Minecraft *minecraft = server_side_network_handler->minecraft;
RakNet_RakPeer *rak_peer = get_rak_peer(minecraft); RakNet_RakPeer *rak_peer = get_rak_peer(minecraft);
char *ip = get_rak_net_guid_ip(rak_peer, guid); char *ip = get_rak_net_guid_ip(rak_peer, guid);

View File

@ -11,26 +11,26 @@ void ServerProperties::load(std::istream& stream) {
if (line[0] == '#') { if (line[0] == '#') {
continue; continue;
} }
size_t i = line.find('='); const size_t i = line.find('=');
if (i == std::string::npos) { if (i == std::string::npos) {
continue; continue;
} }
properties.insert(std::pair<std::string, std::string>(line.substr(0, i), line.substr(i + 1))); properties.insert(std::pair(line.substr(0, i), line.substr(i + 1)));
} }
} }
} }
std::string ServerProperties::get_string(std::string const& name, std::string const& def) { std::string ServerProperties::get_string(const std::string &name, const std::string &def) const {
return properties.count(name) > 0 ? properties.at(name) : def; return properties.contains(name) ? properties.at(name) : def;
} }
int ServerProperties::get_int(std::string const& name, std::string const& def) { int ServerProperties::get_int(const std::string &name, const std::string &def) const {
return properties.count(name) > 0 ? std::stoi(properties.at(name)) : std::stoi(def); return properties.contains(name) ? std::stoi(properties.at(name)) : std::stoi(def);
} }
bool ServerProperties::get_bool(std::string const& name, std::string const& def) { bool ServerProperties::get_bool(const std::string &name, const std::string &def) const {
if (properties.count(name) > 0) { if (properties.contains(name)) {
std::string const& val = properties.at(name); const std::string &val = properties.at(name);
return is_true(val); return is_true(val);
} }
return is_true(def); return is_true(def);

View File

@ -11,7 +11,7 @@
static void LocalPlayer_openTextEdit_injection(__attribute__((unused)) LocalPlayer_openTextEdit_t original, LocalPlayer *local_player, TileEntity *sign) { static void LocalPlayer_openTextEdit_injection(__attribute__((unused)) LocalPlayer_openTextEdit_t original, LocalPlayer *local_player, TileEntity *sign) {
if (sign->type == 4) { if (sign->type == 4) {
Minecraft *minecraft = local_player->minecraft; Minecraft *minecraft = local_player->minecraft;
TextEditScreen *screen = new TextEditScreen; TextEditScreen *screen = TextEditScreen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen = screen->constructor((SignTileEntity *) sign); screen = screen->constructor((SignTileEntity *) sign);
minecraft->setScreen((Screen *) screen); minecraft->setScreen((Screen *) screen);

View File

@ -32,7 +32,7 @@ static void load_pending_skins(__attribute__((unused)) Minecraft *minecraft) {
pthread_mutex_lock(&pending_skins_lock); pthread_mutex_lock(&pending_skins_lock);
// Loop // Loop
for (pending_skin &skin : get_pending_skins()) { for (const pending_skin &skin : get_pending_skins()) {
// Read PNG Info // Read PNG Info
int width = 0, height = 0, channels = 0; int width = 0, height = 0, channels = 0;
stbi_uc *img = stbi_load_from_memory((unsigned char *) skin.data, skin.size, &width, &height, &channels, STBI_rgb_alpha); stbi_uc *img = stbi_load_from_memory((unsigned char *) skin.data, skin.size, &width, &height, &channels, STBI_rgb_alpha);
@ -52,7 +52,7 @@ static void load_pending_skins(__attribute__((unused)) Minecraft *minecraft) {
} }
// Free // Free
for (pending_skin &skin : get_pending_skins()) { for (const pending_skin &skin : get_pending_skins()) {
free(skin.data); free(skin.data);
} }
@ -80,10 +80,10 @@ struct loader_data {
}; };
static void *loader_thread(void *user_data) { static void *loader_thread(void *user_data) {
// Loader Data // Loader Data
loader_data *data = (loader_data *) user_data; const loader_data *data = (loader_data *) user_data;
// Download // Download
std::string url = get_skin_server() + '/' + data->name + ".png"; const std::string url = get_skin_server() + '/' + data->name + ".png";
int return_code; int return_code;
const char *command[] = {"wget", "-O", "-", url.c_str(), nullptr}; const char *command[] = {"wget", "-O", "-", url.c_str(), nullptr};
size_t output_size = 0; size_t output_size = 0;
@ -95,7 +95,7 @@ static void *loader_thread(void *user_data) {
DEBUG("Downloaded Skin: %s", data->name.c_str()); DEBUG("Downloaded Skin: %s", data->name.c_str());
// Add To Pending Skins // Add To Pending Skins
pending_skin skin; pending_skin skin = {};
skin.texture_id = data->texture_id; skin.texture_id = data->texture_id;
skin.data = output; skin.data = output;
skin.size = (int) output_size; skin.size = (int) output_size;
@ -116,7 +116,7 @@ static void *loader_thread(void *user_data) {
// Intercept Texture Creation // Intercept Texture Creation
static int32_t Textures_assignTexture_injection(Textures_assignTexture_t original, Textures *textures, const std::string &name, unsigned char *data) { static int32_t Textures_assignTexture_injection(Textures_assignTexture_t original, Textures *textures, const std::string &name, unsigned char *data) {
// Call Original Method // Call Original Method
int32_t id = original(textures, name, data); const int32_t id = original(textures, name, data);
// Load Skin // Load Skin
if (starts_with(name.c_str(), "$")) { if (starts_with(name.c_str(), "$")) {

View File

@ -18,8 +18,8 @@ static std::string base64_encode(const std::string &data) {
'4', '5', '6', '7', '8', '9', '+', '/' '4', '5', '6', '7', '8', '9', '+', '/'
}; };
size_t in_len = data.size(); const size_t in_len = data.size();
size_t out_len = 4 * ((in_len + 2) / 3); const size_t out_len = 4 * ((in_len + 2) / 3);
std::string ret(out_len, '\0'); std::string ret(out_len, '\0');
size_t i; size_t i;
char *p = const_cast<char *>(ret.c_str()); char *p = const_cast<char *>(ret.c_str());

View File

@ -369,8 +369,8 @@ std::string _sound_pick(const std::string &sound) {
void _sound_resolve_all() { void _sound_resolve_all() {
const std::string source = _sound_get_source_file(); const std::string source = _sound_get_source_file();
if (!source.empty()) { if (!source.empty()) {
for (auto &it : sound_repository) { for (const std::pair<const std::string, std::vector<std::string>> &it : sound_repository) {
for (std::string &name : it.second) { for (const std::string &name : it.second) {
// Zero Volume Prevents An OpenAL Source From Being Allocated While Still Resolving The Sound // Zero Volume Prevents An OpenAL Source From Being Allocated While Still Resolving The Sound
media_audio_play(source.c_str(), name.c_str(), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f); media_audio_play(source.c_str(), name.c_str(), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f);
} }

View File

@ -3,29 +3,29 @@
#include <mods/text-input-box/TextInputBox.h> #include <mods/text-input-box/TextInputBox.h>
#include <mods/input/input.h> #include <mods/input/input.h>
TextInputBox *TextInputBox::create(const std::string &placeholder, const std::string &text) { TextInputBox::TextInputBox(const std::string &placeholder, const std::string &text) {
// Construct // Construct
TextInputBox *self = new TextInputBox; this->component = GuiComponent::allocate();
self->super.constructor(); this->component->constructor();
// Setup // Setup
self->m_xPos = 0; this->m_xPos = 0;
self->m_yPos = 0; this->m_yPos = 0;
self->m_width = 0; this->m_width = 0;
self->m_height = 0; this->m_height = 0;
self->m_placeholder = placeholder; this->m_placeholder = placeholder;
self->m_text = text; this->m_text = text;
self->m_bFocused = false; this->m_bFocused = false;
self->m_bEnabled = true; this->m_bEnabled = true;
self->m_bCursorOn = true; this->m_bCursorOn = true;
self->m_insertHead = 0; this->m_insertHead = 0;
self->m_lastFlashed = 0; this->m_lastFlashed = 0;
self->m_pFont = nullptr; this->m_pFont = nullptr;
self->m_maxLength = -1; this->m_maxLength = -1;
self->m_scrollPos = 0; this->m_scrollPos = 0;
}
// Return TextInputBox::~TextInputBox() {
return self; component->destructor_deleting();
} }
void TextInputBox::setSize(const int x, const int y, const int width, const int height) { void TextInputBox::setSize(const int x, const int y, const int width, const int height) {
@ -139,7 +139,7 @@ void TextInputBox::setFocused(const bool b) {
} }
} }
void TextInputBox::onClick(int x, int y) { void TextInputBox::onClick(const int x, const int y) {
setFocused(clicked(x, y)); setFocused(clicked(x, y));
} }
@ -165,7 +165,7 @@ void TextInputBox::charPressed(const int k) {
recalculateScroll(); recalculateScroll();
} }
static std::string get_rendered_text(Font *font, const int width, const int scroll_pos, std::string text) { static std::string get_rendered_text(Font *font, const int width, const int scroll_pos, const std::string &text) {
std::string rendered_text = text.substr(scroll_pos); std::string rendered_text = text.substr(scroll_pos);
const int max_width = width - (PADDING * 2); const int max_width = width - (PADDING * 2);
while (font->width(rendered_text) > max_width) { while (font->width(rendered_text) > max_width) {
@ -177,8 +177,8 @@ static std::string get_rendered_text(Font *font, const int width, const int scro
static char CURSOR_CHAR = '_'; static char CURSOR_CHAR = '_';
void TextInputBox::render() { void TextInputBox::render() {
super.fill(m_xPos, m_yPos, m_xPos + m_width, m_yPos + m_height, 0xFFAAAAAA); component->fill(m_xPos, m_yPos, m_xPos + m_width, m_yPos + m_height, 0xFFAAAAAA);
super.fill(m_xPos + 1, m_yPos + 1, m_xPos + m_width - 1, m_yPos + m_height - 1, 0xFF000000); component->fill(m_xPos + 1, m_yPos + 1, m_xPos + m_width - 1, m_yPos + m_height - 1, 0xFF000000);
int text_color; int text_color;
int scroll_pos; int scroll_pos;
@ -195,7 +195,7 @@ void TextInputBox::render() {
rendered_text = get_rendered_text(m_pFont, m_width, scroll_pos, rendered_text); rendered_text = get_rendered_text(m_pFont, m_width, scroll_pos, rendered_text);
const int textYPos = (m_height - 8) / 2; const int textYPos = (m_height - 8) / 2;
super.drawString(m_pFont, rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color); component->drawString(m_pFont, rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color);
if (m_bCursorOn) { if (m_bCursorOn) {
const int cursor_pos = m_insertHead - m_scrollPos; const int cursor_pos = m_insertHead - m_scrollPos;
@ -205,7 +205,7 @@ void TextInputBox::render() {
std::string str; std::string str;
str += CURSOR_CHAR; str += CURSOR_CHAR;
super.drawString(m_pFont, str, m_xPos + xPos, m_yPos + textYPos + 2, 0xffffff); component->drawString(m_pFont, str, m_xPos + xPos, m_yPos + textYPos + 2, 0xffffff);
} }
} }
} }
@ -286,8 +286,8 @@ std::string TextInputBox::getText() const {
return m_text; return m_text;
} }
void TextInputBox::setText(std::string str) { void TextInputBox::setText(const std::string &text) {
m_text = str; m_text = text;
m_insertHead = int(m_text.size()); m_insertHead = int(m_text.size());
} }

View File

@ -1,54 +1,34 @@
#include <mods/text-input-box/TextInputScreen.h> #include <mods/text-input-box/TextInputScreen.h>
// VTable // VTable
void TextInputScreen::setup(Screen_vtable *vtable) { void TextInputScreen::keyPressed(const int key) const {
static Screen_keyPressed_t original_keyPressed = vtable->keyPressed; for (int i = 0; i < int(m_textInputs->size()); i++) {
vtable->keyPressed = [](Screen *super2, const int key) { TextInputBox *textInput = (*m_textInputs)[i];
original_keyPressed(super2, key);
TextInputScreen *self = (TextInputScreen *) super2;
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
TextInputBox *textInput = (*self->m_textInputs)[i];
textInput->keyPressed(key); textInput->keyPressed(key);
} }
}; }
static Screen_keyboardNewChar_t original_keyboardNewChar = vtable->keyboardNewChar; void TextInputScreen::keyboardNewChar(const char key) const {
vtable->keyboardNewChar = [](Screen *super2, const char key) { for (int i = 0; i < int(m_textInputs->size()); i++) {
original_keyboardNewChar(super2, key); TextInputBox *textInput = (*m_textInputs)[i];
TextInputScreen *self = (TextInputScreen *) super2;
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
TextInputBox *textInput = (*self->m_textInputs)[i];
textInput->charPressed(key); textInput->charPressed(key);
} }
}; }
static Screen_mouseClicked_t original_mouseClicked = vtable->mouseClicked; void TextInputScreen::mouseClicked(const int x, const int y, __attribute__((unused)) int param_1) const {
vtable->mouseClicked = [](Screen *super2, const int x, const int y, const int param_1) { for (int i = 0; i < int(m_textInputs->size()); i++) {
original_mouseClicked(super2, x, y, param_1); TextInputBox *textInput = (*m_textInputs)[i];
TextInputScreen *self = (TextInputScreen *) super2;
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
TextInputBox *textInput = (*self->m_textInputs)[i];
textInput->onClick(x, y); textInput->onClick(x, y);
} }
}; }
static Screen_render_t original_render = vtable->render; void TextInputScreen::render(__attribute__((unused)) int x, __attribute__((unused)) int y, __attribute__((unused)) float param_1) const {
vtable->render = [](Screen *super2, const int x, const int y, const float param_1) { for (int i = 0; i < int(m_textInputs->size()); i++) {
original_render(super2, x, y, param_1); TextInputBox *textInput = (*m_textInputs)[i];
TextInputScreen *self = (TextInputScreen *) super2;
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
TextInputBox *textInput = (*self->m_textInputs)[i];
textInput->tick(); textInput->tick();
textInput->render(); textInput->render();
} }
}; }
static Screen_init_t original_init = vtable->init; void TextInputScreen::init() {
vtable->init = [](Screen *super2) { m_textInputs = new std::vector<TextInputBox *>;
original_init(super2); }
TextInputScreen *self = (TextInputScreen *) super2; void TextInputScreen::removed() const {
self->m_textInputs = new std::vector<TextInputBox *>; delete m_textInputs;
};
static Screen_removed_t original_removed = vtable->removed;
vtable->removed = [](Screen *super2) {
original_removed(super2);
TextInputScreen *self = (TextInputScreen *) super2;
delete self->m_textInputs;
};
} }

View File

@ -9,17 +9,15 @@
// See: https://github.com/ReMinecraftPE/mcpe // See: https://github.com/ReMinecraftPE/mcpe
// Structures // Structures
struct LavaTexture { EXTEND_STRUCT(LavaTexture, DynamicTexture, struct {
DynamicTexture super;
int field_14; int field_14;
int field_18; int field_18;
float m_data1[256]; float m_data1[256];
float m_data2[256]; float m_data2[256];
float m_data3[256]; float m_data3[256];
float m_data4[256]; float m_data4[256];
}; });
struct LavaSideTexture { EXTEND_STRUCT(LavaSideTexture, DynamicTexture, struct {
DynamicTexture super;
int field_14; int field_14;
int field_18; int field_18;
int field_1C; int field_1C;
@ -27,13 +25,12 @@ struct LavaSideTexture {
float m_data2[256]; float m_data2[256];
float m_data3[256]; float m_data3[256];
float m_data4[256]; float m_data4[256];
}; });
struct FireTexture { EXTEND_STRUCT(FireTexture, DynamicTexture, struct {
DynamicTexture super;
float m_data1[320]; float m_data1[320];
float m_data2[320]; float m_data2[320];
Random m_random; Random *m_random;
}; });
// LavaTexture // LavaTexture
CUSTOM_VTABLE(lava_texture, DynamicTexture) { CUSTOM_VTABLE(lava_texture, DynamicTexture) {
@ -42,39 +39,39 @@ CUSTOM_VTABLE(lava_texture, DynamicTexture) {
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {
float f = 0.0F; float f = 0.0F;
int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f); const int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f);
int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f); const int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f);
for (int bx = x - 1; bx <= x + 1; bx++) { for (int bx = x - 1; bx <= x + 1; bx++) {
for (int by = y - 1; by <= y + 1; by++) { for (int by = y - 1; by <= y + 1; by++) {
int k2 = (bx + ay) & 0xf; const int k2 = (bx + ay) & 0xf;
int i3 = (by + ax) & 0xf; const int i3 = (by + ax) & 0xf;
f += self->m_data1[k2 + i3 * 16]; f += self->data.m_data1[k2 + i3 * 16];
} }
} }
self->m_data2[x + y * 16] = f / 10.0f + ((self->m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + self->m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f; self->data.m_data2[x + y * 16] = f / 10.0f + ((self->data.m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + self->data.m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + self->data.m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + self->data.m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f;
self->m_data3[x + y * 16] += self->m_data4[x + y * 16] * 0.01f; self->data.m_data3[x + y * 16] += self->data.m_data4[x + y * 16] * 0.01f;
if (self->m_data3[x + y * 16] < 0.0f) { if (self->data.m_data3[x + y * 16] < 0.0f) {
self->m_data3[x + y * 16] = 0.0f; self->data.m_data3[x + y * 16] = 0.0f;
} }
self->m_data4[x + y * 16] -= 0.06f; self->data.m_data4[x + y * 16] -= 0.06f;
if (Mth::random() < 0.005f) { if (Mth::random() < 0.005f) {
self->m_data4[x + y * 16] = 1.5f; self->data.m_data4[x + y * 16] = 1.5f;
} }
} }
} }
std::swap(self->m_data1, self->m_data2); std::swap(self->data.m_data1, self->data.m_data2);
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
float x1 = self->m_data1[i] * 2.0f; float x1 = self->data.m_data1[i] * 2.0f;
if (x1 > 1.0f) { if (x1 > 1.0f) {
x1 = 1.0f; x1 = 1.0f;
} }
if (x1 < 0.0f) { if (x1 < 0.0f) {
x1 = 0.0f; x1 = 0.0f;
} }
self->super.pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); self->super()->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
self->super.pixels[i * 4 + 1] = int(255.0f * x1 * x1); self->super()->pixels[i * 4 + 1] = int(255.0f * x1 * x1);
self->super.pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); self->super()->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
self->super.pixels[i * 4 + 3] = 255; self->super()->pixels[i * 4 + 3] = 255;
} }
}; };
} }
@ -82,17 +79,17 @@ static DynamicTexture *create_lava_texture() {
// Construct // Construct
LavaTexture *texture = new LavaTexture; LavaTexture *texture = new LavaTexture;
ALLOC_CHECK(texture); ALLOC_CHECK(texture);
texture->super.constructor(Tile::lava->texture); texture->super()->constructor(Tile::lava->texture);
// Set VTable // Set VTable
texture->super.vtable = get_lava_texture_vtable(); texture->super()->vtable = get_lava_texture_vtable();
// Setup // Setup
texture->field_14 = 0; texture->data.field_14 = 0;
texture->field_18 = 0; texture->data.field_18 = 0;
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
texture->m_data1[i] = 0.0f; texture->data.m_data1[i] = 0.0f;
texture->m_data2[i] = 0.0f; texture->data.m_data2[i] = 0.0f;
texture->m_data3[i] = 0.0f; texture->data.m_data3[i] = 0.0f;
texture->m_data4[i] = 0.0f; texture->data.m_data4[i] = 0.0f;
} }
// Return // Return
return (DynamicTexture *) texture; return (DynamicTexture *) texture;
@ -102,43 +99,43 @@ static DynamicTexture *create_lava_texture() {
CUSTOM_VTABLE(lava_side_texture, DynamicTexture) { CUSTOM_VTABLE(lava_side_texture, DynamicTexture) {
vtable->tick = [](DynamicTexture *super) { vtable->tick = [](DynamicTexture *super) {
LavaSideTexture *self = (LavaSideTexture *) super; LavaSideTexture *self = (LavaSideTexture *) super;
self->field_1C++; self->data.field_1C++;
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {
float f = 0.0F; float f = 0.0F;
int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f); const int ax = int(Mth::sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f);
int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f); const int ay = int(Mth::sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f);
for (int bx = x - 1; bx <= x + 1; bx++) { for (int bx = x - 1; bx <= x + 1; bx++) {
for (int by = y - 1; by <= y + 1; by++) { for (int by = y - 1; by <= y + 1; by++) {
int k2 = (bx + ay) & 0xf; const int k2 = (bx + ay) & 0xf;
int i3 = (by + ax) & 0xf; const int i3 = (by + ax) & 0xf;
f += self->m_data1[k2 + i3 * 16]; f += self->data.m_data1[k2 + i3 * 16];
} }
} }
self->m_data2[x + y * 16] = f / 10.0f + ((self->m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + self->m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f; self->data.m_data2[x + y * 16] = f / 10.0f + ((self->data.m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + self->data.m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + self->data.m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + self->data.m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f;
self->m_data3[x + y * 16] += self->m_data4[x + y * 16] * 0.01f; self->data.m_data3[x + y * 16] += self->data.m_data4[x + y * 16] * 0.01f;
if (self->m_data3[x + y * 16] < 0.0f) { if (self->data.m_data3[x + y * 16] < 0.0f) {
self->m_data3[x + y * 16] = 0.0f; self->data.m_data3[x + y * 16] = 0.0f;
} }
self->m_data4[x + y * 16] -= 0.06f; self->data.m_data4[x + y * 16] -= 0.06f;
if (Mth::random() < 0.005f) { if (Mth::random() < 0.005f) {
self->m_data4[x + y * 16] = 1.5f; self->data.m_data4[x + y * 16] = 1.5f;
} }
} }
} }
std::swap(self->m_data1, self->m_data2); std::swap(self->data.m_data1, self->data.m_data2);
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
float x1 = self->m_data1[(i - 16 * (self->field_1C / 3)) & 0xFF] * 2.0f; float x1 = self->data.m_data1[(i - 16 * (self->data.field_1C / 3)) & 0xFF] * 2.0f;
if (x1 > 1.0f) { if (x1 > 1.0f) {
x1 = 1.0f; x1 = 1.0f;
} }
if (x1 < 0.0f) { if (x1 < 0.0f) {
x1 = 0.0f; x1 = 0.0f;
} }
self->super.pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); self->super()->pixels[i * 4 + 0] = int(155.0f + 100.0f * x1);
self->super.pixels[i * 4 + 1] = int(255.0f * x1 * x1); self->super()->pixels[i * 4 + 1] = int(255.0f * x1 * x1);
self->super.pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); self->super()->pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1);
self->super.pixels[i * 4 + 3] = 255; self->super()->pixels[i * 4 + 3] = 255;
} }
}; };
} }
@ -146,19 +143,19 @@ static DynamicTexture *create_lava_side_texture() {
// Construct // Construct
LavaSideTexture *texture = new LavaSideTexture; LavaSideTexture *texture = new LavaSideTexture;
ALLOC_CHECK(texture); ALLOC_CHECK(texture);
texture->super.constructor(Tile::lava->texture + 1); texture->super()->constructor(Tile::lava->texture + 1);
// Set VTable // Set VTable
texture->super.vtable = get_lava_side_texture_vtable(); texture->super()->vtable = get_lava_side_texture_vtable();
// Setup // Setup
texture->field_14 = 0; texture->data.field_14 = 0;
texture->field_18 = 0; texture->data.field_18 = 0;
texture->field_1C = 0; texture->data.field_1C = 0;
texture->super.texture_size = 2; texture->super()->texture_size = 2;
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
texture->m_data1[i] = 0.0f; texture->data.m_data1[i] = 0.0f;
texture->m_data2[i] = 0.0f; texture->data.m_data2[i] = 0.0f;
texture->m_data3[i] = 0.0f; texture->data.m_data3[i] = 0.0f;
texture->m_data4[i] = 0.0f; texture->data.m_data4[i] = 0.0f;
} }
// Return // Return
return (DynamicTexture *) texture; return (DynamicTexture *) texture;
@ -171,61 +168,62 @@ CUSTOM_VTABLE(fire_texture, DynamicTexture) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 20; j++) { for (int j = 0; j < 20; j++) {
int l = 18; int l = 18;
float f1 = self->m_data1[i + ((j + 1) % 20) * 16] * l; float f1 = self->data.m_data1[i + ((j + 1) % 20) * 16] * l;
for (int i1 = i - 1; i1 <= i + 1; i1++) { for (int i1 = i - 1; i1 <= i + 1; i1++) {
for (int k1 = j; k1 <= j + 1; k1++) { for (int k1 = j; k1 <= j + 1; k1++) {
int i2 = i1; const int i2 = i1;
int k2 = k1; const int k2 = k1;
if (i2 >= 0 && k2 >= 0 && i2 < 16 && k2 < 20) if (i2 >= 0 && k2 >= 0 && i2 < 16 && k2 < 20)
{ {
f1 += self->m_data1[i2 + k2 * 16]; f1 += self->data.m_data1[i2 + k2 * 16];
} }
l++; l++;
} }
} }
self->m_data2[i + j * 16] = f1 / 25.2f; self->data.m_data2[i + j * 16] = f1 / 25.2f;
if (j >= 19) { if (j >= 19) {
union { union {
uint32_t x; uint32_t x;
uint8_t b[4]; uint8_t b[4];
} a; } a = {};
a.x = self->m_random.genrand_int32(); a.x = self->data.m_random->genrand_int32();
self->m_data2[i + j * 16] = 0.2f + (((a.b[3] / 256.0f) * 0.1f) + ((((a.b[0] / 256.0f) * (a.b[1] / 256.0f)) * (a.b[2] / 256.0f)) * 4.0f)); self->data.m_data2[i + j * 16] = 0.2f + (((a.b[3] / 256.0f) * 0.1f) + ((((a.b[0] / 256.0f) * (a.b[1] / 256.0f)) * (a.b[2] / 256.0f)) * 4.0f));
} }
} }
} }
std::swap(self->m_data1, self->m_data2); std::swap(self->data.m_data1, self->data.m_data2);
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
float x = self->m_data1[i] * 1.8f; float x = self->data.m_data1[i] * 1.8f;
if (x > 1.0f) { if (x > 1.0f) {
x = 1.0f; x = 1.0f;
} }
if (x < 0.0f) { if (x < 0.0f) {
x = 0.0f; x = 0.0f;
} }
self->super.pixels[4 * i + 0] = int(x * 155.0f + 100.0f); self->super()->pixels[4 * i + 0] = int(x * 155.0f + 100.0f);
self->super.pixels[4 * i + 1] = int(x * x * 255.0f); self->super()->pixels[4 * i + 1] = int(x * x * 255.0f);
self->super.pixels[4 * i + 2] = int(x * x * x * x * x * x * x * x * x * x * 255.0f); self->super()->pixels[4 * i + 2] = int(x * x * x * x * x * x * x * x * x * x * 255.0f);
self->super.pixels[4 * i + 3] = x >= 0.5f ? 255 : 0; self->super()->pixels[4 * i + 3] = x >= 0.5f ? 255 : 0;
} }
}; };
} }
static DynamicTexture *create_fire_texture(int a2) { static DynamicTexture *create_fire_texture(const int a2) {
// Construct // Construct
FireTexture *texture = new FireTexture; FireTexture *texture = new FireTexture;
ALLOC_CHECK(texture); ALLOC_CHECK(texture);
texture->super.constructor(Tile::fire->texture + (16 * a2)); texture->super()->constructor(Tile::fire->texture + (16 * a2));
// Set VTable // Set VTable
texture->super.vtable = get_fire_texture_vtable(); texture->super()->vtable = get_fire_texture_vtable();
// Setup Random // Setup Random
int seed = Common::getTimeMs(); texture->data.m_random = Random::allocate();
texture->m_random.seed = seed; const int seed = Common::getTimeMs();
texture->m_random.param_1 = 0x271; texture->data.m_random->seed = seed;
texture->m_random.param_2 = false; texture->data.m_random->param_1 = 0x271;
texture->m_random.param_3 = 0; texture->data.m_random->param_2 = false;
texture->data.m_random->param_3 = 0;
for (int i = 0; i < 320; i++) { for (int i = 0; i < 320; i++) {
texture->m_data1[i] = 0.0f; texture->data.m_data1[i] = 0.0f;
texture->m_data2[i] = 0.0f; texture->data.m_data2[i] = 0.0f;
} }
// Return // Return
return (DynamicTexture *) texture; return (DynamicTexture *) texture;
@ -253,7 +251,7 @@ static void Textures_addDynamicTexture_injection(Textures *textures, DynamicText
} }
// Init // Init
void _init_textures_lava(bool animated_water_param, bool animated_lava_param, bool animated_fire_param) { void _init_textures_lava(const bool animated_water_param, const bool animated_lava_param, const bool animated_fire_param) {
animated_water = animated_water_param; animated_water = animated_water_param;
animated_lava = animated_lava_param; animated_lava = animated_lava_param;
animated_fire = animated_fire_param; animated_fire = animated_fire_param;

View File

@ -16,7 +16,7 @@
#include "stb_image.h" #include "stb_image.h"
// Animated Water // Animated Water
static void Minecraft_tick_injection(Minecraft *minecraft) { static void Minecraft_tick_injection(const Minecraft *minecraft) {
// Tick Dynamic Textures // Tick Dynamic Textures
Textures *textures = minecraft->textures; Textures *textures = minecraft->textures;
if (textures != nullptr) { if (textures != nullptr) {
@ -36,7 +36,7 @@ static std::vector<texture_data> &get_texture_data() {
} }
HOOK(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)) { HOOK(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)) {
// Store // Store
texture_data data; texture_data data = {};
glGetIntegerv(GL_TEXTURE_BINDING_2D, &data.id); glGetIntegerv(GL_TEXTURE_BINDING_2D, &data.id);
data.width = width; data.width = width;
data.height = height; data.height = height;
@ -52,7 +52,7 @@ HOOK(glDeleteTextures, void, (GLsizei n, const GLuint *textures)) {
const GLint id = textures[i]; const GLint id = textures[i];
std::vector<texture_data>::iterator it = get_texture_data().begin(); std::vector<texture_data>::iterator it = get_texture_data().begin();
while (it != get_texture_data().end()) { while (it != get_texture_data().end()) {
texture_data data = *it; const texture_data data = *it;
if (data.id == id) { if (data.id == id) {
it = get_texture_data().erase(it); it = get_texture_data().erase(it);
} else { } else {
@ -69,7 +69,7 @@ static void get_texture_size(const GLint id, GLsizei *width, GLsizei *height) {
// Iterate // Iterate
std::vector<texture_data>::iterator it = get_texture_data().begin(); std::vector<texture_data>::iterator it = get_texture_data().begin();
while (it != get_texture_data().end()) { while (it != get_texture_data().end()) {
texture_data data = *it; const texture_data data = *it;
if (data.id == id) { if (data.id == id) {
// Found // Found
*width = data.width; *width = data.width;

View File

@ -16,7 +16,7 @@
// Improved Title Screen Background // Improved Title Screen Background
static void StartMenuScreen_render_Screen_renderBackground_injection(Screen *screen) { static void StartMenuScreen_render_Screen_renderBackground_injection(Screen *screen) {
// Draw // Draw
Minecraft *minecraft = screen->minecraft; const Minecraft *minecraft = screen->minecraft;
Textures *textures = minecraft->textures; Textures *textures = minecraft->textures;
std::string texture = "gui/titleBG.png"; std::string texture = "gui/titleBG.png";
textures->loadAndBindTexture(texture); textures->loadAndBindTexture(texture);
@ -93,8 +93,8 @@ static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x
const float multiplier = touch_gui ? 0.5f : 1.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_x = (float(screen->width) / 2.0f) + (94.0f * multiplier);
const float splash_y = 4.0f + (36.0f * multiplier); const float splash_y = 4.0f + (36.0f * multiplier);
const float max_width = 86; constexpr float max_width = 86;
const float max_scale = 2.0f; constexpr float max_scale = 2.0f;
// Draw (From https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/client/gui/screens/StartMenuScreen.cpp#L699-L718) // Draw (From https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/client/gui/screens/StartMenuScreen.cpp#L699-L718)
glPushMatrix(); glPushMatrix();
// Position // Position

View File

@ -30,7 +30,7 @@ static bool should_show_welcome() {
// Read Line // Read Line
std::string line; std::string line;
std::getline(stream, line); std::getline(stream, line);
bool invalid = line != MCPI_VERSION; const bool invalid = line != MCPI_VERSION;
// Close File // Close File
stream.close(); stream.close();
// Return // Return
@ -53,7 +53,7 @@ static Button *getting_started;
static Button *changelog; static Button *changelog;
static Button *proceed; static Button *proceed;
static int text_y; static int text_y;
static void position_screen(int width, int height) { static void position_screen(const int width, const int height) {
// Width/Height // Width/Height
getting_started->width = changelog->width = proceed->width = button_width; getting_started->width = changelog->width = proceed->width = button_width;
getting_started->height = changelog->height = proceed->height = button_height; getting_started->height = changelog->height = proceed->height = button_height;
@ -66,8 +66,8 @@ static void position_screen(int width, int height) {
getting_started->y = changelog->y = line_height + line_padding; getting_started->y = changelog->y = line_height + line_padding;
proceed->y = getting_started->y + button_height + (button_padding * 2); proceed->y = getting_started->y + button_height + (button_padding * 2);
// Center // Center
int content_height = proceed->y + proceed->height; const int content_height = proceed->y + proceed->height;
int y_offset = (height - content_height) / 2; const int y_offset = (height - content_height) / 2;
text_y += y_offset; text_y += y_offset;
getting_started->y += y_offset; getting_started->y += y_offset;
changelog->y += y_offset; changelog->y += y_offset;
@ -89,7 +89,7 @@ CUSTOM_VTABLE(welcome_screen, Screen) {
}; };
// Rendering // Rendering
static Screen_render_t original_render = vtable->render; static Screen_render_t original_render = vtable->render;
vtable->render = [](Screen *self, int x, int y, float param_1) { vtable->render = [](Screen *self, const int x, const int y, const float param_1) {
// Background // Background
self->renderBackground(); self->renderBackground();
// Call Original Method // Call Original Method
@ -121,7 +121,7 @@ CUSTOM_VTABLE(welcome_screen, Screen) {
} }
static Screen *create_welcome_screen() { static Screen *create_welcome_screen() {
// Allocate // Allocate
Screen *screen = new Screen; Screen *screen = Screen::allocate();
ALLOC_CHECK(screen); ALLOC_CHECK(screen);
screen->constructor(); screen->constructor();

View File

@ -45,12 +45,12 @@ static void LargeImageButton_render_GuiComponent_drawCenteredString_injection(Gu
int touch_gui = 0; int touch_gui = 0;
template <typename T> template <typename T>
static Button *create_button(int id, std::string text) { static Button *create_button(int id, std::string text) {
T *button = new T; T *button = T::allocate();
ALLOC_CHECK(button); ALLOC_CHECK(button);
button->constructor(id, text); button->constructor(id, text);
return (Button *) button; return (Button *) button;
} }
Button *touch_create_button(const int id, std::string text) { Button *touch_create_button(const int id, const std::string &text) {
if (touch_gui) { if (touch_gui) {
return create_button<Touch_TButton>(id, text); return create_button<Touch_TButton>(id, text);
} else { } else {

View File

@ -249,8 +249,6 @@ target_include_directories(
# Disable C++11 String ABI # Disable C++11 String ABI
target_compile_definitions(symbols PUBLIC -D_GLIBCXX_USE_CXX11_ABI=0) target_compile_definitions(symbols PUBLIC -D_GLIBCXX_USE_CXX11_ABI=0)
# Fix Warning
target_compile_options(symbols PUBLIC -Wno-missing-field-initializers)
# Install # Install
install(TARGETS symbols DESTINATION "${MCPI_LIB_DIR}") install(TARGETS symbols DESTINATION "${MCPI_LIB_DIR}")

View File

@ -3,3 +3,5 @@ size 0xc;
property uint sock = 0x0; property uint sock = 0x0;
property std::string str = 0x4; property std::string str = 0x4;
property int time = 0x8; property int time = 0x8;
mark-as-simple;

View File

@ -2,3 +2,5 @@ size 0x8;
property char *data = 0x0; property char *data = 0x0;
property int length = 0x4; property int length = 0x4;
mark-as-simple;

View File

@ -14,3 +14,5 @@ method bool isNull() = 0x999b0;
property int count = 0x0; property int count = 0x0;
property int id = 0x4; property int id = 0x4;
property int auxiliary = 0x8; property int auxiliary = 0x8;
mark-as-simple;

View File

@ -3,3 +3,5 @@ size 0x4;
property Mob *mob = 0x0; property Mob *mob = 0x0;
method bool compare(Chunk *param_1, Chunk *param_2) = 0x5118c; // Actually Called _ZN19DistanceChunkSorterclEPK5ChunkS2_ method bool compare(Chunk *param_1, Chunk *param_2) = 0x5118c; // Actually Called _ZN19DistanceChunkSorterclEPK5ChunkS2_
mark-as-simple;

View File

@ -2,3 +2,5 @@ size 0x8;
property int seed = 0x0; property int seed = 0x0;
property int game_type = 0x4; property int game_type = 0x4;
mark-as-simple;

View File

@ -5,3 +5,5 @@ property std::string name = 0x4;
property int seed = 0x8; property int seed = 0x8;
property int game_mode = 0xc; property int game_mode = 0xc;
property int param_5 = 0x10; property int param_5 = 0x10;
mark-as-simple;

View File

@ -6,3 +6,5 @@ property float z1 = 0x8;
property float x2 = 0xc; property float x2 = 0xc;
property float y2 = 0x10; property float y2 = 0x10;
property float z2 = 0x14; property float z2 = 0x14;
mark-as-simple;

View File

@ -8,3 +8,5 @@ property int side = 0x10;
property Vec3 exact = 0x14; property Vec3 exact = 0x14;
property Entity *entity = 0x20; property Entity *entity = 0x20;
property uchar unknown = 0x24; property uchar unknown = 0x24;
mark-as-simple;

View File

@ -3,3 +3,5 @@ size 0xc;
property float x = 0x0; property float x = 0x0;
property float y = 0x4; property float y = 0x4;
property float z = 0x8; property float z = 0x8;
mark-as-simple;

View File

@ -1 +1,6 @@
size 0xa; size 0x10;
property unsigned long long param_1 = 0x0;
property ushort param_2 = 0x8;
mark-as-simple;

View File

@ -1,3 +1,7 @@
size 0x14; size 0x14;
method char *ToString(bool print_delimiter, char delimiter) = 0xd6198; method char *ToString(bool print_delimiter, char delimiter) = 0xd6198;
property uchar data[0x14] = 0x0;
mark-as-simple;

View File

@ -4,3 +4,5 @@ property Item *item = 0x0;
property Tile *tile = 0x4; property Tile *tile = 0x4;
property ItemInstance instance = 0x8; property ItemInstance instance = 0x8;
property char letter = 0x14; property char letter = 0x14;
mark-as-simple;

View File

@ -8,3 +8,5 @@ property bool field4_0x10 = 0x10;
property bool field5_0x11 = 0x11; property bool field5_0x11 = 0x11;
property int field6_0x14 = 0x14; property int field6_0x14 = 0x14;
property int field7_0x18 = 0x18; property int field7_0x18 = 0x18;
mark-as-simple;