From 19e2ded9bf702497733cf19854d8f2e59c1e9626 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Mon, 26 Oct 2020 15:58:28 -0400 Subject: [PATCH] Improve Comments --- .dockerignore | 16 +++++++++------- MODDING.md | 3 +++ README.md | 7 +++++++ mods/CMakeLists.txt | 3 ++- mods/include/libcore/libcore.h | 3 +++ mods/src/compat.c | 3 +-- mods/src/core.c | 1 + mods/src/extra.c | 9 ++++++--- mods/src/readdir.c | 2 ++ mods/src/server/server.cpp | 5 +---- 10 files changed, 35 insertions(+), 17 deletions(-) diff --git a/.dockerignore b/.dockerignore index 19b11d079..3b7dc5d05 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,9 @@ -.git -.gitignore -Dockerfile -README.md -data -install.sh -build.sh +/.git +/.gitignore +/Dockerfile* +/Jenkinsfile +/out +/LICENSE +*.md +/debian +/scripts diff --git a/MODDING.md b/MODDING.md index 40c765b12..64d24f14a 100644 --- a/MODDING.md +++ b/MODDING.md @@ -7,6 +7,9 @@ Minecraft: Pi Edition has no symbols so you must patch the hex address of an ins ## Loading Directories ``minecraft-pi-docker`` loads mods from two locations, ``/app/minecraft-pi/mods``, and ``~/.minecraft/mods``. The first location only exists in the Docker container and is immutable, so you should place your mods in ``~/.minecraft/mods`` which is mounted on the host as ``~/.minecraft-pi/mods``. +## C++ Strings +Minecraft: Pi Edition was compiled with an old version of GCC, so when interacting with C++ strings, make sure you set ``-D_GLIBCXX_USE_CXX11_ABI=0``. + ## ``libcore.so`` API Header files and the shared library can be download from [Jenkins](https://jenkins.thebrokenrail.com/job/minecraft-pi-docker/job/master/lastSuccessfulBuild/artifact/out/lib). diff --git a/README.md b/README.md index 00b74f851..674057eb0 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,12 @@ This is a project allowing Minecraft: Pi Edition to be run without a Raspberry P ## Setup [View Binaries](https://jenkins.thebrokenrail.com/job/minecraft-pi-docker/job/master/lastSuccessfulBuild/artifact/out/) +### Packages +| Package | Description | +| --- | --- | +| ``minecraft-pi-server`` | Dedicated Server | +| ``minecraft-pi-virgl`` | Minecraft Pi Edition Using VirGL For Hardware Acceleration (Recommended For Desktop) | +| ``minecraft-pi-native`` | Minecraft: Pi Edition Using Docker Device Mounting For GPU Acceleration (Recommended For Raspberry Pi) | + ## Modding [View Modding](MODDING.md) diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index 8f99dafb2..26062167b 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -1,8 +1,9 @@ -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 3.13.0) project(mods) add_compile_options(-Wall -Wextra -Werror) +add_link_options(-Wl,--no-undefined) add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) add_subdirectory(../core core) diff --git a/mods/include/libcore/libcore.h b/mods/include/libcore/libcore.h index 6eb66e963..8015d1393 100644 --- a/mods/include/libcore/libcore.h +++ b/mods/include/libcore/libcore.h @@ -27,6 +27,9 @@ extern "C" { \ __attribute__((__used__)) return_type name args +#define INFO(msg, ...) fprintf(stderr, "[INFO]: " msg "\n", __VA_ARGS__); +#define ERR(msg, ...) fprintf(stderr, "[ERR]: " msg "\n", __VA_ARGS__); exit(1); + void *_overwrite(const char *file, int line, void *start, void *target); #define overwrite(start, target) _overwrite(__FILE__, __LINE__, start, target); diff --git a/mods/src/compat.c b/mods/src/compat.c index 992ff93b2..e1b30a034 100644 --- a/mods/src/compat.c +++ b/mods/src/compat.c @@ -41,8 +41,7 @@ static void store_x11_window() { // Handle GLFW Error static void glfw_error(__attribute__((unused)) int error, const char *description) { - fprintf(stderr, "[ERR] GLFW Error: %s\n", description); - exit(1); + ERR("GLFW Error: %s", description); } // Convert GLFW Key To SDL Key diff --git a/mods/src/core.c b/mods/src/core.c index e9b051d40..b101706fc 100644 --- a/mods/src/core.c +++ b/mods/src/core.c @@ -70,6 +70,7 @@ void _patch(const char *file, int line, void *start, unsigned char patch[]) { mprotect((void *) page_start, end - page_start, PROT_READ | PROT_EXEC); + // Clear ARM Instruction Cache __clear_cache(start, (void *) end); } diff --git a/mods/src/extra.c b/mods/src/extra.c index 64436e46b..92f09e38b 100644 --- a/mods/src/extra.c +++ b/mods/src/extra.c @@ -163,8 +163,7 @@ int extra_get_mode() { } else if (strcmp("server", mode) == 0) { return 2; } else { - fprintf(stderr, "[ERR] Inavlid MCPI_MODE: %s\n", mode); - exit(1); + ERR("Inavlid MCPI_MODE: %s", mode); } } @@ -249,7 +248,11 @@ __attribute__((constructor)) static void init() { username = get_username(); fprintf(stderr, "Setting Username: %s\n", username); } - patch_address((void *) 0x18fd4, (void *) username); + char **default_username = (char **) 0x18fd4; + if (strcmp(*default_username, "StevePi") != 0) { + ERR("%s", "Default Username Is Invalid"); + } + patch_address((void *) default_username, (void *) username); if (extra_has_feature("Disable Autojump By Default")) { // Disable Autojump By Default diff --git a/mods/src/readdir.c b/mods/src/readdir.c index 84668b2cd..79b033c65 100644 --- a/mods/src/readdir.c +++ b/mods/src/readdir.c @@ -7,6 +7,8 @@ #include +// Minecraft: Pi Edition Was Not Compiled With 64-Bit Filesystem Support, So This Shims readdir() To Read Directories Properly + #define FILENAME_SIZE 256 HOOK(readdir, struct dirent *, (DIR *dirp)) { diff --git a/mods/src/server/server.cpp b/mods/src/server/server.cpp index 28637daa0..3b7acdd4a 100644 --- a/mods/src/server/server.cpp +++ b/mods/src/server/server.cpp @@ -35,8 +35,6 @@ static ProgressScreen_t ProgressScreen = (ProgressScreen_t) 0x37044; typedef void (*Minecraft_setScreen_t)(unsigned char *minecraft, unsigned char *screen); static Minecraft_setScreen_t Minecraft_setScreen = (Minecraft_setScreen_t) 0x15d6c; -#define INFO(msg, ...) fprintf(stderr, "[INFO]: " msg "\n", __VA_ARGS__); - // Store Minecraft For Exit static unsigned char *stored_minecraft = NULL; @@ -233,8 +231,7 @@ void server_init() { } if (!properties_file.is_open()) { - fprintf(stderr, "[ERR]: Unable To Open server.properties\n"); - exit(1); + ERR("%s", "Unable To Open server.properties"); } // Load Properties