From 0ccc05ad9013049f6fa6f35b96dafb71ddc6e594 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Wed, 27 Jan 2021 16:26:19 -0500 Subject: [PATCH] Fixes --- Dockerfile.server | 2 +- MODDING.md | 4 +- README.md | 12 ++--- build/build-mods.sh | 20 ++++--- core/CMakeLists.txt | 15 ------ .../minecraft-pi/client/docker-compose.yml | 2 +- .../minecraft-pi/client/docker-compose.yml | 2 +- .../minecraft-pi/server/docker-compose.yml | 2 +- launcher/CMakeLists.txt | 10 ++++ {core => launcher}/src/launcher.c | 6 +-- libreborn/CMakeLists.txt | 13 +++++ .../include/libreborn/libreborn.h | 6 +-- .../core/core.c => libreborn/src/libreborn.c | 2 +- mods/CMakeLists.txt | 52 +++++++++++++------ mods/src/camera/camera.cpp | 2 +- mods/src/compat/compat.c | 9 ++-- mods/src/compat/compat.h | 3 ++ mods/src/feature/feature.c | 2 +- mods/src/feature/feature.h | 6 +-- mods/src/game_mode/game_mode.c | 2 +- mods/src/game_mode/game_mode.cpp | 2 +- mods/src/game_mode/game_mode.h | 6 +-- mods/src/init/init.h | 6 +-- mods/src/input/input.c | 2 +- mods/src/input/input.cpp | 2 +- mods/src/input/input.h | 6 +-- mods/src/minecraft.h | 8 +-- mods/src/misc/misc.c | 2 +- mods/src/misc/misc.cpp | 2 +- mods/src/misc/misc.h | 6 +-- mods/src/options/options.c | 2 +- mods/src/override/override.c | 2 +- mods/src/{compat => readdir}/readdir.c | 0 mods/src/screenshot/screenshot.c | 2 +- mods/src/screenshot/screenshot.h | 6 +-- mods/src/server/server.cpp | 3 +- mods/src/server/server.h | 15 ------ mods/src/server/server_internal.h | 8 +-- mods/src/server/server_properties.h | 8 +-- {core => mods}/src/stubs/EGL.c | 5 ++ {core => mods}/src/stubs/GLESv2.c | 0 {core => mods}/src/stubs/bcm_host.c | 0 mods/src/test/test.c | 2 +- mods/src/textures/textures.cpp | 2 +- scripts/package.sh | 6 +-- 45 files changed, 126 insertions(+), 149 deletions(-) delete mode 100644 core/CMakeLists.txt create mode 100644 launcher/CMakeLists.txt rename {core => launcher}/src/launcher.c (97%) create mode 100644 libreborn/CMakeLists.txt rename mods/include/libcore/libcore.h => libreborn/include/libreborn/libreborn.h (97%) rename mods/src/core/core.c => libreborn/src/libreborn.c (99%) create mode 100644 mods/src/compat/compat.h rename mods/src/{compat => readdir}/readdir.c (100%) delete mode 100644 mods/src/server/server.h rename {core => mods}/src/stubs/EGL.c (95%) rename {core => mods}/src/stubs/GLESv2.c (100%) rename {core => mods}/src/stubs/bcm_host.c (100%) diff --git a/Dockerfile.server b/Dockerfile.server index 2c83a65..d245b19 100644 --- a/Dockerfile.server +++ b/Dockerfile.server @@ -1,3 +1,3 @@ -FROM thebrokenrail/minecraft-pi:client +FROM thebrokenrail/minecraft-pi-reborn:client ENV MCPI_MODE=server diff --git a/MODDING.md b/MODDING.md index 006a8b8..7830d4c 100644 --- a/MODDING.md +++ b/MODDING.md @@ -1,5 +1,5 @@ # Modding -Modding Minecraft: Pi Edition is possible by patching the binary at runtime. To make this easier ``minecraft-pi-reborn`` includes a library called ``libcore.so`` which provides several functions to help you patch the game. +Modding Minecraft: Pi Edition is possible by patching the binary at runtime. To make this easier ``minecraft-pi-reborn`` includes a library called ``libreborn.so`` which provides several functions to help you patch the game. ## Hex Addresses Minecraft: Pi Edition has no symbols so you must patch the hex address of an instruction instead of using a function name. Hex addresses can be found using tools like [Ghidra](https://ghidra-sre.org) or [RetDec](https://retdec.com). To find out what a function does, you can find its equivalent in Minecraft: Pocket Edition 0.6.1 and use its name for reference because Minecraft: Pocket Edition 0.6.1 includes symbols. @@ -10,7 +10,7 @@ Minecraft: Pi Edition has no symbols so you must patch the hex address of an ins ## 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 +## ``libreborn.so`` API Header files and the shared library can be download from [Jenkins](https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/lib). ### ``void overwrite(void *start, void *target)`` diff --git a/README.md b/README.md index 8ae807b..a719774 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Minecraft: Pi Edition: Reborn Minecraft: Pi Edition Modding Project -## Setup +## Getting Started 1. Remove Old Minecraft: Pi Edition Package If Installed (``sudo apt remove minecraft-pi``) -2. Download Appropriate Package (See Table Below) From [Here](https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/deb/) +2. Download Appropriate Package From [Here](https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/deb/) (See Table Below) 3. Install With ``sudo apt install ./`` +4. Have Fun! ### Packages | Package | Description | @@ -18,9 +19,7 @@ Minecraft: Pi Edition Modding Project #### Docker Versions While the distribution-provided version of Docker is fine for most systems, in rare cases it can be outdated and cause bugs. Before reporting a bug, try using the official builds of Docker. These can be installed by following your distribution's instructions at https://docs.docker.com/engine/install. -### Specific Notes - -#### Debian/Raspbian Buster +#### Debian/Raspbian Buster And ``libseccomp2`` By default Raspbian Buster ships an older version of the package ``libseccomp2``. This package is used to block certain dangerous system calls from running inside Docker containers. The included version accidentally blocks the system call ``clock_gettime64``, this causes bugs inside Minecraft: Pi Edition. However, the Debian ``buster-backports`` repo includes an updated version. You can enable the ``buster-backports`` repo and update ``libseccomp2`` by running: ```sh @@ -35,9 +34,6 @@ sudo apt update sudo apt install -t buster-backports libseccomp2 ``` -### PinePhone (Mobian) -This supports running on a PinePhone using Mobian. However, you will need to attach a keyboard and mouse because Minecraft: Pi Edition does not have touch support. - ## Troubleshooting Crashes Game logs are located in ``/tmp/minecraft-pi``. diff --git a/build/build-mods.sh b/build/build-mods.sh index cb89857..91442a5 100755 --- a/build/build-mods.sh +++ b/build/build-mods.sh @@ -2,6 +2,17 @@ set -e +cd launcher + +mkdir build +cd build + +cmake .. +make -j$(nproc) +make install DESTDIR=../../minecraft-pi + +cd ../../ + cd mods mkdir build @@ -9,11 +20,6 @@ cd build cmake .. make -j$(nproc) +make install DESTDIR=../../minecraft-pi -cd ../../ - -mkdir minecraft-pi/mods -cp mods/build/lib*.so minecraft-pi/mods - -cp mods/build/core/lib*.so minecraft-pi -cp mods/build/core/launcher minecraft-pi +cd ../../ \ No newline at end of file diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt deleted file mode 100644 index cf546a1..0000000 --- a/core/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.1.0) - -project(core) - -add_compile_options(-Wall -Wextra -Werror) - -add_library(bcm_host SHARED src/stubs/bcm_host.c) -add_library(EGL SHARED src/stubs/EGL.c) - -# MCPI Links Against GLESv2 But Requires GLESv1_CM -add_library(GLESv2 SHARED src/stubs/GLESv2.c) -target_link_libraries(GLESv2 GLESv1_CM) -target_link_options(GLESv2 PRIVATE "-Wl,--no-as-needed") - -add_executable(launcher src/launcher.c) diff --git a/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml b/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml index 2962469..639d0d5 100644 --- a/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml +++ b/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: minecraft-pi: - image: 'thebrokenrail/minecraft-pi:client' + image: 'thebrokenrail/minecraft-pi-reborn:client' network_mode: 'host' volumes: - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static diff --git a/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml b/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml index ad743b5..5c8e301 100644 --- a/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml +++ b/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: minecraft-pi: - image: 'thebrokenrail/minecraft-pi:client' + image: 'thebrokenrail/minecraft-pi-reborn:client' network_mode: 'host' volumes: - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static diff --git a/debian/server/usr/share/minecraft-pi/server/docker-compose.yml b/debian/server/usr/share/minecraft-pi/server/docker-compose.yml index 962370d..ba080d3 100644 --- a/debian/server/usr/share/minecraft-pi/server/docker-compose.yml +++ b/debian/server/usr/share/minecraft-pi/server/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: minecraft-pi-server: - image: 'thebrokenrail/minecraft-pi:server' + image: 'thebrokenrail/minecraft-pi-reborn:server' network_mode: 'host' volumes: - /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt new file mode 100644 index 0000000..5a4b6d4 --- /dev/null +++ b/launcher/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.0) + +project(launcher) + +add_compile_options(-Wall -Wextra -Werror) + +add_executable(launcher src/launcher.c) + +# Install +install(TARGETS launcher DESTINATION /) diff --git a/core/src/launcher.c b/launcher/src/launcher.c similarity index 97% rename from core/src/launcher.c rename to launcher/src/launcher.c index f9dde29..6e78e76 100644 --- a/core/src/launcher.c +++ b/launcher/src/launcher.c @@ -111,9 +111,7 @@ int main(__attribute__((unused)) int argc, char *argv[]) { char *ld_path = NULL; // Start Configuring LD_LIBRARY_PATH - char *cwd = getcwd(NULL, 0); - asprintf(&ld_path, "%s:/usr/arm-linux-gnueabihf/lib", cwd); - free(cwd); + asprintf(&ld_path, "/usr/arm-linux-gnueabihf/lib"); // Start Configuring LD_PRELOAD char *ld_preload = NULL; @@ -127,7 +125,7 @@ int main(__attribute__((unused)) int argc, char *argv[]) { asprintf(&home_mods, "%s/.minecraft/mods/", getenv("HOME")); load(&ld_path, &ld_preload, home_mods); free(home_mods); - + // Add Existing LD_LIBRARY_PATH asprintf(&ld_path, "%s:%s", ld_path, get_env_safe("LD_LIBRARY_PATH")); diff --git a/libreborn/CMakeLists.txt b/libreborn/CMakeLists.txt new file mode 100644 index 0000000..f39f04a --- /dev/null +++ b/libreborn/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.13.0) + +project(libreborn) + +add_compile_options(-Wall -Wextra -Werror) +add_link_options(-Wl,--no-undefined) + +add_library(reborn SHARED src/libreborn.c) +target_link_libraries(reborn dl) +target_include_directories(reborn PUBLIC include) + +# Install +install(TARGETS reborn DESTINATION /mods) \ No newline at end of file diff --git a/mods/include/libcore/libcore.h b/libreborn/include/libreborn/libreborn.h similarity index 97% rename from mods/include/libcore/libcore.h rename to libreborn/include/libreborn/libreborn.h index fc4acb2..0f84247 100644 --- a/mods/include/libcore/libcore.h +++ b/libreborn/include/libreborn/libreborn.h @@ -1,6 +1,4 @@ -#ifndef LIBLOADER_H - -#define LIBLOADER_H +#pragma once #ifdef __cplusplus extern "C" { @@ -47,5 +45,3 @@ void _patch_address(const char *file, int line, void *start, void *target); #ifdef __cplusplus } #endif - -#endif diff --git a/mods/src/core/core.c b/libreborn/src/libreborn.c similarity index 99% rename from mods/src/core/core.c rename to libreborn/src/libreborn.c index a643fc4..5a7cd65 100644 --- a/mods/src/core/core.c +++ b/libreborn/src/libreborn.c @@ -7,7 +7,7 @@ #include #include -#include +#include // Find And Iterate Over All .text Sections In Current Binary typedef void (*text_section_callback)(void *section, Elf32_Word size, void *data); diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index f6d54e0..a10ec87 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -2,60 +2,78 @@ cmake_minimum_required(VERSION 3.13.0) project(mods) +## Setup + add_compile_options(-Wall -Wextra -Werror) add_link_options(-Wl,--no-undefined) # Disable C++11 String ABI add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) -add_subdirectory(../core core) +# Add libreborn +add_subdirectory(../libreborn libreborn) # Include Libraries Exported To Runtime Environment include_directories(/app/export/include) -# Include Headers -include_directories(include) - # Find GLFW find_package(glfw3 3.3 REQUIRED) +## Mods + add_library(compat SHARED src/compat/compat.c) target_link_libraries(compat feature input screenshot SDL GLESv1_CM X11 dl glfw Xfixes) -add_library(readdir SHARED src/compat/readdir.c) - -add_library(core SHARED src/core/core.c) -target_link_libraries(core dl) +add_library(readdir SHARED src/readdir/readdir.c) add_library(feature SHARED src/feature/feature.c) +target_link_libraries(feature reborn) add_library(server SHARED src/server/server.cpp src/server/server_properties.cpp) -target_link_libraries(server core feature dl SDL pthread) +target_link_libraries(server reborn feature dl SDL pthread) add_library(screenshot SHARED src/screenshot/screenshot.c) -target_link_libraries(screenshot GLESv1_CM freeimage) +target_link_libraries(screenshot reborn GLESv1_CM freeimage) add_library(camera SHARED src/camera/camera.cpp) -target_link_libraries(camera core screenshot) +target_link_libraries(camera reborn screenshot) add_library(game_mode SHARED src/game_mode/game_mode.c src/game_mode/game_mode.cpp) -target_link_libraries(game_mode core) +target_link_libraries(game_mode reborn) add_library(input SHARED src/input/input.c src/input/input.cpp) -target_link_libraries(input core feature SDL) +target_link_libraries(input reborn feature SDL) add_library(misc SHARED src/misc/misc.c src/misc/misc.cpp) -target_link_libraries(misc core feature util) +target_link_libraries(misc reborn feature util) add_library(options SHARED src/options/options.c) -target_link_libraries(options core feature) +target_link_libraries(options reborn feature) add_library(override SHARED src/override/override.c) -target_link_libraries(override dl) +target_link_libraries(override reborn dl) add_library(textures SHARED src/textures/textures.cpp) -target_link_libraries(textures core feature GLESv1_CM) +target_link_libraries(textures reborn feature GLESv1_CM) add_library(test SHARED src/test/test.c) +target_link_libraries(test reborn) add_library(init SHARED src/init/init.c) target_link_libraries(init compat server game_mode camera input misc options textures test) + +## Stubs + +# Stub RPI-Specific Graphics +add_library(bcm_host SHARED src/stubs/bcm_host.c) + +# Stub EGL +add_library(EGL SHARED src/stubs/EGL.c) +target_link_libraries(EGL compat) + +# MCPI Links Against GLESv2 But Uses GLESv1_CM +add_library(GLESv2 SHARED src/stubs/GLESv2.c) +target_link_libraries(GLESv2 GLESv1_CM) +target_link_options(GLESv2 PRIVATE "-Wl,--no-as-needed") + +## Install +install(TARGETS init compat readdir feature screenshot override server game_mode camera input misc options textures test bcm_host EGL GLESv2 DESTINATION /mods) \ No newline at end of file diff --git a/mods/src/camera/camera.cpp b/mods/src/camera/camera.cpp index 44b85b3..81b8da8 100644 --- a/mods/src/camera/camera.cpp +++ b/mods/src/camera/camera.cpp @@ -1,4 +1,4 @@ -#include +#include #include "../screenshot/screenshot.h" #include "../init/init.h" diff --git a/mods/src/compat/compat.c b/mods/src/compat/compat.c index d3ac0eb..68e2070 100644 --- a/mods/src/compat/compat.c +++ b/mods/src/compat/compat.c @@ -14,13 +14,15 @@ #include #include -#include +#include #include "../feature/feature.h" #include "../input/input.h" #include "../screenshot/screenshot.h" #include "../init/init.h" +#include "compat.h" + static GLFWwindow *glfw_window; static int is_server = 0; @@ -202,14 +204,11 @@ HOOK(SDL_WM_SetCaption, void, (const char *title, __attribute__((unused)) const } } -#include -HOOK(eglSwapBuffers, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface surface)) { +void compat_eglSwapBuffers() { if (!is_server) { // Don't Swap Buffers In A Context-Less Window glfwSwapBuffers(glfw_window); } - - return EGL_TRUE; } static int is_fullscreen = 0; diff --git a/mods/src/compat/compat.h b/mods/src/compat/compat.h new file mode 100644 index 0000000..8311d8b --- /dev/null +++ b/mods/src/compat/compat.h @@ -0,0 +1,3 @@ +#pragma once + +void compat_eglSwapBuffers(); \ No newline at end of file diff --git a/mods/src/feature/feature.c b/mods/src/feature/feature.c index e832131..1f7f78c 100644 --- a/mods/src/feature/feature.c +++ b/mods/src/feature/feature.c @@ -1,7 +1,7 @@ #include #include -#include +#include #include "feature.h" diff --git a/mods/src/feature/feature.h b/mods/src/feature/feature.h index 1315300..a945fbd 100644 --- a/mods/src/feature/feature.h +++ b/mods/src/feature/feature.h @@ -1,6 +1,4 @@ -#ifndef FEATURE_H - -#define FEATURE_H +#pragma once #ifdef __cplusplus extern "C" { @@ -12,5 +10,3 @@ int feature_get_mode(); #ifdef __cplusplus } #endif - -#endif diff --git a/mods/src/game_mode/game_mode.c b/mods/src/game_mode/game_mode.c index 4d4962f..1efa0f5 100644 --- a/mods/src/game_mode/game_mode.c +++ b/mods/src/game_mode/game_mode.c @@ -1,4 +1,4 @@ -#include +#include #include "game_mode.h" #include "../init/init.h" diff --git a/mods/src/game_mode/game_mode.cpp b/mods/src/game_mode/game_mode.cpp index ef06f27..3c07c7e 100644 --- a/mods/src/game_mode/game_mode.cpp +++ b/mods/src/game_mode/game_mode.cpp @@ -1,4 +1,4 @@ -#include +#include #include "game_mode.h" diff --git a/mods/src/game_mode/game_mode.h b/mods/src/game_mode/game_mode.h index 911891a..0e89d2b 100644 --- a/mods/src/game_mode/game_mode.h +++ b/mods/src/game_mode/game_mode.h @@ -1,6 +1,4 @@ -#ifndef GAME_MODE_H - -#define GAME_MODE_H +#pragma once #ifdef __cplusplus extern "C" { @@ -10,6 +8,4 @@ void init_game_mode_cpp(); #ifdef __cplusplus } -#endif - #endif \ No newline at end of file diff --git a/mods/src/init/init.h b/mods/src/init/init.h index 4da5fe3..d986e7c 100644 --- a/mods/src/init/init.h +++ b/mods/src/init/init.h @@ -1,6 +1,4 @@ -#ifndef INIT_H - -#define INIT_H +#pragma once #ifdef __cplusplus extern "C" { @@ -18,6 +16,4 @@ void init_textures(); #ifdef __cplusplus } -#endif - #endif \ No newline at end of file diff --git a/mods/src/input/input.c b/mods/src/input/input.c index dace1d7..537a00a 100644 --- a/mods/src/input/input.c +++ b/mods/src/input/input.c @@ -1,4 +1,4 @@ -#include +#include #include "../feature/feature.h" #include "input.h" diff --git a/mods/src/input/input.cpp b/mods/src/input/input.cpp index fcf301c..a2c2fa1 100644 --- a/mods/src/input/input.cpp +++ b/mods/src/input/input.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include "../feature/feature.h" #include "input.h" diff --git a/mods/src/input/input.h b/mods/src/input/input.h index ff08737..9a29f37 100644 --- a/mods/src/input/input.h +++ b/mods/src/input/input.h @@ -1,6 +1,4 @@ -#ifndef INPUT_H - -#define INPUT_H +#pragma once #ifdef __cplusplus extern "C" { @@ -20,5 +18,3 @@ void init_input_cpp(); #ifdef __cplusplus } #endif - -#endif diff --git a/mods/src/minecraft.h b/mods/src/minecraft.h index 3b980ba..fee6a44 100644 --- a/mods/src/minecraft.h +++ b/mods/src/minecraft.h @@ -1,6 +1,4 @@ -#ifndef MINECRAFT_H - -#define MINECRAFT_H +#pragma once #include @@ -367,6 +365,4 @@ static SelectWorldScreen_getUniqueLevelName_t Touch_SelectWorldScreen_getUniqueL #endif -#pragma GCC diagnostic pop - -#endif \ No newline at end of file +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 8101e57..28ecfb1 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -1,4 +1,4 @@ -#include +#include #include "../feature/feature.h" #include "misc.h" diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index b9b169d..4feb258 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include "../feature/feature.h" #include "misc.h" diff --git a/mods/src/misc/misc.h b/mods/src/misc/misc.h index dee63ac..7252f8e 100644 --- a/mods/src/misc/misc.h +++ b/mods/src/misc/misc.h @@ -1,6 +1,4 @@ -#ifndef MISC_H - -#define MISC_H +#pragma once #ifdef __cplusplus extern "C" { @@ -10,6 +8,4 @@ void init_misc_cpp(); #ifdef __cplusplus } -#endif - #endif \ No newline at end of file diff --git a/mods/src/options/options.c b/mods/src/options/options.c index 281c321..f309a0d 100644 --- a/mods/src/options/options.c +++ b/mods/src/options/options.c @@ -1,6 +1,6 @@ #include -#include +#include #include "../feature/feature.h" #include "../init/init.h" diff --git a/mods/src/override/override.c b/mods/src/override/override.c index 48590ae..320d8cf 100644 --- a/mods/src/override/override.c +++ b/mods/src/override/override.c @@ -8,7 +8,7 @@ #include #include -#include +#include static int starts_with(const char *s, const char *t) { return strncmp(s, t, strlen(t)) == 0; diff --git a/mods/src/compat/readdir.c b/mods/src/readdir/readdir.c similarity index 100% rename from mods/src/compat/readdir.c rename to mods/src/readdir/readdir.c diff --git a/mods/src/screenshot/screenshot.c b/mods/src/screenshot/screenshot.c index cf77f24..8a6abc6 100644 --- a/mods/src/screenshot/screenshot.c +++ b/mods/src/screenshot/screenshot.c @@ -9,7 +9,7 @@ #include -#include +#include #include "screenshot.h" diff --git a/mods/src/screenshot/screenshot.h b/mods/src/screenshot/screenshot.h index 45773a3..27a76c9 100644 --- a/mods/src/screenshot/screenshot.h +++ b/mods/src/screenshot/screenshot.h @@ -1,6 +1,4 @@ -#ifndef SCREENSHOT_H - -#define SCREENSHOT_H +#pragma once #ifdef __cplusplus extern "C" { @@ -10,6 +8,4 @@ void take_screenshot(); #ifdef __cplusplus } -#endif - #endif \ No newline at end of file diff --git a/mods/src/server/server.cpp b/mods/src/server/server.cpp index 3d60339..a365f33 100644 --- a/mods/src/server/server.cpp +++ b/mods/src/server/server.cpp @@ -12,9 +12,8 @@ #include -#include +#include -#include "server.h" #include "server_internal.h" #include "server_properties.h" diff --git a/mods/src/server/server.h b/mods/src/server/server.h deleted file mode 100644 index 67c1f58..0000000 --- a/mods/src/server/server.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SERVER_H - -#define SERVER_H - -#ifdef __cplusplus -extern "C" { -#endif\ - -const char *server_get_motd(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mods/src/server/server_internal.h b/mods/src/server/server_internal.h index 3f9a81f..4ed49dd 100644 --- a/mods/src/server/server_internal.h +++ b/mods/src/server/server_internal.h @@ -1,6 +1,4 @@ -#ifndef SERVER_INTERNAL_H - -#define SERVER_INTERNAL_H +#pragma once #include #include @@ -9,6 +7,4 @@ std::string server_internal_get_world_name(); unsigned char *server_internal_get_level(unsigned char *minecraft); std::vector server_internal_get_players(unsigned char *level); std::string server_internal_get_player_username(unsigned char *player); -unsigned char *server_internal_get_minecraft(unsigned char *player); - -#endif \ No newline at end of file +unsigned char *server_internal_get_minecraft(unsigned char *player); \ No newline at end of file diff --git a/mods/src/server/server_properties.h b/mods/src/server/server_properties.h index e3ffdd1..041817a 100644 --- a/mods/src/server/server_properties.h +++ b/mods/src/server/server_properties.h @@ -1,6 +1,4 @@ -#ifndef SERVER_PROPERTIES_H - -#define SERVER_PROPERTIES_H +#pragma once #include #include @@ -17,6 +15,4 @@ public: std::string get_string(std::string const& name, std::string const& def); int get_int(std::string const& name, std::string const& def); bool get_bool(std::string const& name, std::string const& def); -}; - -#endif +}; \ No newline at end of file diff --git a/core/src/stubs/EGL.c b/mods/src/stubs/EGL.c similarity index 95% rename from core/src/stubs/EGL.c rename to mods/src/stubs/EGL.c index af7cf52..3b2fba9 100644 --- a/core/src/stubs/EGL.c +++ b/mods/src/stubs/EGL.c @@ -1,5 +1,7 @@ #include +#include "../compat/compat.h" + // EGL/SDL Is Replaced With GLFW EGLDisplay eglGetDisplay(__attribute__((unused)) NativeDisplayType native_display) { @@ -32,6 +34,9 @@ EGLBoolean eglDestroyContext(__attribute__((unused)) EGLDisplay display, __attri EGLBoolean eglTerminate(__attribute__((unused)) EGLDisplay display) { return EGL_TRUE; } + +// Send Buffer Swap Request To GLFW EGLBoolean eglSwapBuffers(__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface surface) { + compat_eglSwapBuffers(); return EGL_TRUE; } \ No newline at end of file diff --git a/core/src/stubs/GLESv2.c b/mods/src/stubs/GLESv2.c similarity index 100% rename from core/src/stubs/GLESv2.c rename to mods/src/stubs/GLESv2.c diff --git a/core/src/stubs/bcm_host.c b/mods/src/stubs/bcm_host.c similarity index 100% rename from core/src/stubs/bcm_host.c rename to mods/src/stubs/bcm_host.c diff --git a/mods/src/test/test.c b/mods/src/test/test.c index 57fb110..d75df58 100644 --- a/mods/src/test/test.c +++ b/mods/src/test/test.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include "../init/init.h" diff --git a/mods/src/textures/textures.cpp b/mods/src/textures/textures.cpp index cf2e643..0c53f01 100644 --- a/mods/src/textures/textures.cpp +++ b/mods/src/textures/textures.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include "../feature/feature.h" #include "../init/init.h" diff --git a/scripts/package.sh b/scripts/package.sh index 2427004..7573605 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -30,7 +30,7 @@ prepare_control() { } # Package Client DEBs -docker save thebrokenrail/minecraft-pi:client | gzip > debian/tmp/client-image.tar.gz +docker save thebrokenrail/minecraft-pi-reborn:client | gzip > debian/tmp/client-image.tar.gz package_client() { # Clean rm -rf "debian/tmp/$1" @@ -46,7 +46,7 @@ package_client virgl package_client native # Package Server DEB -docker save thebrokenrail/minecraft-pi:server | gzip > debian/tmp/server-image.tar.gz +docker save thebrokenrail/minecraft-pi-reborn:server | gzip > debian/tmp/server-image.tar.gz package_server() { # Clean rm -rf debian/tmp/server @@ -69,7 +69,7 @@ mkdir -p out/lib cp -r mods/include out/lib/include # Copy Shared Library -IMG_ID="$(docker create thebrokenrail/minecraft-pi:client)" +IMG_ID="$(docker create thebrokenrail/minecraft-pi-reborn:client)" docker cp "${IMG_ID}":/app/minecraft-pi/mods/. ./out/lib/. || : RET="$?" docker rm -v "${IMG_ID}"