This commit is contained in:
TheBrokenRail 2021-07-04 21:23:12 -04:00
parent e8ae2a9230
commit 665fe30a5f
11 changed files with 25 additions and 19 deletions

View File

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

View File

@ -28,7 +28,7 @@
ERR("Error Resolving Symbol: "#name": %s", dlerror()); \
} \
} \
}; \
} \
\
__attribute__((__used__)) return_type name args

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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