From 665fe30a5f1484e10a53b3948fec524edb5a6bec Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Sun, 4 Jul 2021 21:23:12 -0400 Subject: [PATCH] Hotfix --- CMakeLists.txt | 4 +++- libreborn/include/libreborn/util.h | 2 +- libreborn/src/libreborn.c | 2 +- media-layer/proxy/src/common/common.c | 6 +++--- media-layer/stubs/CMakeLists.txt | 1 + mods/src/compat/compat.c | 6 +++--- mods/src/game-mode/game-mode.c | 2 +- mods/src/misc/misc.cpp | 8 ++++---- mods/src/options/options.c | 4 ++-- mods/src/server/server.cpp | 7 +++++-- mods/src/touch/touch.c | 2 +- 11 files changed, 25 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4c3de2..9d8dc2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,9 +85,11 @@ if(BUILD_ARM_COMPONENTS) endif() # Warnings -add_compile_options(-Wall -Wextra -Werror) +add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference) add_link_options(-Wl,--no-undefined) add_definitions(-D_GNU_SOURCE) +set(CMAKE_C_STANDARD 99) +set(CMAKE_CXX_STANDARD 11) # Specify Constants if(MCPI_SERVER_MODE) diff --git a/libreborn/include/libreborn/util.h b/libreborn/include/libreborn/util.h index 563d8a3..760e7e7 100644 --- a/libreborn/include/libreborn/util.h +++ b/libreborn/include/libreborn/util.h @@ -28,7 +28,7 @@ ERR("Error Resolving Symbol: "#name": %s", dlerror()); \ } \ } \ - }; \ + } \ \ __attribute__((__used__)) return_type name args diff --git a/libreborn/src/libreborn.c b/libreborn/src/libreborn.c index fcc60c9..e9a0471 100644 --- a/libreborn/src/libreborn.c +++ b/libreborn/src/libreborn.c @@ -131,7 +131,7 @@ void _overwrite(const char *file, int line, void *start, void *target) { unsigned char patch_data[4] = {0x04, 0xf0, 0x1f, 0xe5}; // "ldr pc, [pc, #-0x4]" _patch(file, line, start, patch_data); - _patch_address(file, line, start + 4, target); + _patch_address(file, line, (void *) (((unsigned char *) start) + 4), target); } // Print Patch Debug Data diff --git a/media-layer/proxy/src/common/common.c b/media-layer/proxy/src/common/common.c index 3b3dd67..28b7176 100644 --- a/media-layer/proxy/src/common/common.c +++ b/media-layer/proxy/src/common/common.c @@ -25,7 +25,7 @@ void safe_read(void *buf, size_t len) { size_t to_read = len; while (to_read > 0) { CHECK_CONNECTION(); - ssize_t x = read(get_connection_read(), buf + (len - to_read), to_read); + ssize_t x = read(get_connection_read(), (void *) (((unsigned char *) buf) + (len - to_read)), to_read); if (x == -1 && errno != EINTR) { PROXY_ERR("Failed Reading Data To Connection: %s", strerror(errno)); } @@ -57,7 +57,7 @@ void safe_write(void *buf, size_t len) { } ALLOC_CHECK(_write_cache); // Copy Data - memcpy(_write_cache + _write_cache_position, buf, len); + memcpy((void *) (((unsigned char *) _write_cache) + _write_cache_position), buf, len); // Advance Position _write_cache_position += len; } @@ -77,7 +77,7 @@ void flush_write_cache() { size_t to_write = _write_cache_position; while (to_write > 0) { CHECK_CONNECTION(); - ssize_t x = write(get_connection_write(), _write_cache + (_write_cache_position - to_write), to_write); + ssize_t x = write(get_connection_write(), (void *) (((unsigned char *) _write_cache) + (_write_cache_position - to_write)), to_write); if (x == -1 && errno != EINTR) { PROXY_ERR("Failed Writing Data To Connection: %s", strerror(errno)); } diff --git a/media-layer/stubs/CMakeLists.txt b/media-layer/stubs/CMakeLists.txt index 5ba3db8..f5f029e 100644 --- a/media-layer/stubs/CMakeLists.txt +++ b/media-layer/stubs/CMakeLists.txt @@ -32,6 +32,7 @@ if(BUILD_ARM_COMPONENTS) # Add NOP GLESv2 That Dpends On Actual GLESv1_CM (This Cannot Be A Symlink Because The Location Of GLESv1_CM Is Dynamic) add_library(GLESv2 SHARED src/nop.c) + target_compile_options(GLESv2 PRIVATE -w) target_link_libraries(GLESv2 GLESv1_CM) # Force Link target_link_options(GLESv2 PRIVATE "-Wl,--no-as-needed") diff --git a/mods/src/compat/compat.c b/mods/src/compat/compat.c index 00a3cf9..bcc555a 100644 --- a/mods/src/compat/compat.c +++ b/mods/src/compat/compat.c @@ -32,9 +32,9 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) { // Check If Exit Is Requested if (compat_check_exit_requested()) { // Send SDL_QUIT - SDL_Event event; - event.type = SDL_QUIT; - SDL_PushEvent(&event); + SDL_Event new_event; + new_event.type = SDL_QUIT; + SDL_PushEvent(&new_event); } #endif // #ifndef MCPI_SERVER_MODE diff --git a/mods/src/game-mode/game-mode.c b/mods/src/game-mode/game-mode.c index f61024d..7682c01 100644 --- a/mods/src/game-mode/game-mode.c +++ b/mods/src/game-mode/game-mode.c @@ -40,7 +40,7 @@ void init_game_mode() { if (feature_has("Implement Game-Mode Switching", 1)) { // Dynamic Game Mode Switching set_is_survival(1); - overwrite_calls((void *) Minecraft_setIsCreativeMode, Minecraft_setIsCreativeMode_injection); + overwrite_calls((void *) Minecraft_setIsCreativeMode, (void *) Minecraft_setIsCreativeMode_injection); // Replace CreatorLevel With ServerLevel (This Fixes Beds And Mob Spawning) unsigned char level_patch[4] = {0x68, 0x7e, 0x01, 0xeb}; // "bl 0x7692c" diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index 5fc9094..8fdc971 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -48,10 +48,10 @@ static int32_t Inventory_setupDefault_FillingContainer_addItem_call_injection(un // Bonemeal Is Already In The Creative Inventory continue; } - ItemInstance *item_instance = new ItemInstance; - ALLOC_CHECK(item_instance); - item_instance = (*ItemInstance_constructor_item_extra)(item_instance, *Item_dye_powder, 1, i); - (*FillingContainer_addItem)(filling_container, item_instance); + ItemInstance *new_item_instance = new ItemInstance; + ALLOC_CHECK(new_item_instance); + new_item_instance = (*ItemInstance_constructor_item_extra)(new_item_instance, *Item_dye_powder, 1, i); + (*FillingContainer_addItem)(filling_container, new_item_instance); } inventory_add_item(filling_container, *Item_camera, false); // Add Tiles diff --git a/mods/src/options/options.c b/mods/src/options/options.c index 5160daa..852d96c 100644 --- a/mods/src/options/options.c +++ b/mods/src/options/options.c @@ -70,7 +70,7 @@ static void Minecraft_init_injection(unsigned char *this) { void init_options() { // Force Mob Spawning if (feature_has("Force Mob Spawning", -1)) { - overwrite((void *) LevelData_getSpawnMobs, LevelData_getSpawnMobs_injection); + overwrite((void *) LevelData_getSpawnMobs, (void *) LevelData_getSpawnMobs_injection); } // Enable Fancy Graphics @@ -88,7 +88,7 @@ void init_options() { #endif // #ifndef MCPI_SERVER_MODE // Set Options - overwrite_calls((void *) Minecraft_init, Minecraft_init_injection); + overwrite_calls((void *) Minecraft_init, (void *) Minecraft_init_injection); // Change Username const char *username = get_username(); diff --git a/mods/src/server/server.cpp b/mods/src/server/server.cpp index c56fddd..ba881ec 100644 --- a/mods/src/server/server.cpp +++ b/mods/src/server/server.cpp @@ -230,8 +230,8 @@ static void ban_callback(unsigned char *minecraft, std::string username, unsigne // Kill Player static void kill_callback(__attribute__((unused)) unsigned char *minecraft, __attribute__((unused)) std::string username, unsigned char *player) { unsigned char *player_vtable = *(unsigned char **) player; - Mob_actuallyHurt_t Mob_actuallyHurt = *(Mob_actuallyHurt_t *) (player_vtable + Mob_actuallyHurt_vtable_offset); - (*Mob_actuallyHurt)(player, INT32_MAX); + Mob_actuallyHurt_t Player_actuallyHurt = *(Mob_actuallyHurt_t *) (player_vtable + Mob_actuallyHurt_vtable_offset); + (*Player_actuallyHurt)(player, INT32_MAX); INFO("Killed: %s", username.c_str()); } @@ -437,6 +437,9 @@ static const char *get_features() { if (get_server_properties().get_bool("peaceful-mode", DEFAULT_PEACEFUL_MODE)) { features += "Peaceful Mode|"; } + if (get_server_properties().get_bool("force-mob-spawning", DEFAULT_FORCE_MOB_SPAWNING)) { + features += "Force Mob Spawning|"; + } } return features.c_str(); } diff --git a/mods/src/touch/touch.c b/mods/src/touch/touch.c index 0c75710..bc136df 100644 --- a/mods/src/touch/touch.c +++ b/mods/src/touch/touch.c @@ -34,7 +34,7 @@ void init_touch() { int touch_gui = feature_has("Touch GUI", 0); if (touch_gui) { // Main UI - overwrite((void *) Minecraft_isTouchscreen, Minecraft_isTouchscreen_injection); + overwrite((void *) Minecraft_isTouchscreen, (void *) Minecraft_isTouchscreen_injection); // Disable Normal Cursor Rendering unsigned char disable_cursor_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"