Merge branch 'master' of https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn
This commit is contained in:
commit
a3e49a8e79
@ -23,18 +23,13 @@ jobs:
|
|||||||
- ARMHF
|
- ARMHF
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: node:16-buster
|
container: node:lts-bullseye
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
# Dependencies
|
# Dependencies
|
||||||
- name: Install CMake
|
|
||||||
run: |
|
|
||||||
echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list
|
|
||||||
apt-get update
|
|
||||||
apt-get install --no-install-recommends -y -t buster-backports cmake
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: ./scripts/install-dependencies.sh ${{ matrix.arch }}
|
run: ./scripts/install-dependencies.sh ${{ matrix.arch }}
|
||||||
# Build
|
# Build
|
||||||
@ -55,18 +50,13 @@ jobs:
|
|||||||
- Server
|
- Server
|
||||||
name: Test
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: node:16-buster
|
container: node:lts-bullseye
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
# Dependencies
|
# Dependencies
|
||||||
- name: Install CMake
|
|
||||||
run: |
|
|
||||||
echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list
|
|
||||||
apt-get update
|
|
||||||
apt-get install --no-install-recommends -y -t buster-backports cmake
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: ./scripts/install-dependencies.sh
|
run: ./scripts/install-dependencies.sh
|
||||||
- name: Install ARM Toolchain
|
- name: Install ARM Toolchain
|
||||||
@ -81,7 +71,7 @@ jobs:
|
|||||||
needs: build
|
needs: build
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: node:16-buster
|
container: node:lts-bullseye
|
||||||
steps:
|
steps:
|
||||||
# Dependencies
|
# Dependencies
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
@ -97,7 +87,7 @@ jobs:
|
|||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: https://gitea.com/actions/release-action@main
|
uses: https://gitea.com/actions/release-action@main
|
||||||
with:
|
with:
|
||||||
files: ./out
|
files: ./out
|
||||||
api_key: ${{ secrets.RELEASE_TOKEN }}
|
api_key: ${{ secrets.RELEASE_TOKEN }}
|
||||||
title: v${{ github.ref_name }}
|
title: v${{ github.ref_name }}
|
||||||
body: "[View Changelog](https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/src/branch/master/docs/CHANGELOG.md)"
|
body: "[View Changelog](https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/src/branch/master/docs/CHANGELOG.md)"
|
||||||
|
@ -70,7 +70,7 @@ add_compile_options(-ffast-math)
|
|||||||
|
|
||||||
# Warnings
|
# Warnings
|
||||||
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
|
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
# Prevents False Positives
|
# Prevents False Positives
|
||||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.0)
|
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.0)
|
||||||
add_compile_options(-Wno-stringop-overflow)
|
add_compile_options(-Wno-stringop-overflow)
|
||||||
|
2
dependencies/glfw/src
vendored
2
dependencies/glfw/src
vendored
@ -1 +1 @@
|
|||||||
Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1
|
Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada
|
@ -8,6 +8,9 @@ If you run MCPI-Reborn with ``--version`` it will print its version to ``stdout`
|
|||||||
### ``--debug``
|
### ``--debug``
|
||||||
This sets ``MCPI_DEBUG``.
|
This sets ``MCPI_DEBUG``.
|
||||||
|
|
||||||
|
### ``--copy-sdk``
|
||||||
|
This extracts the modding SDK and immediately exits. (This allows the SDK to be extracted without starting the game.)
|
||||||
|
|
||||||
### Client Mode Only
|
### Client Mode Only
|
||||||
|
|
||||||
#### ``--print-available-feature-flags``
|
#### ``--print-available-feature-flags``
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Download packages [here](https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/releases).
|
Download packages [here](https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/releases).
|
||||||
|
|
||||||
### System Requirements
|
### System Requirements
|
||||||
* Debian Buster/Ubuntu 18.04 Or Higher
|
* Debian Bullseye/Ubuntu 20.04 Or Higher
|
||||||
* FUSE 2
|
* FUSE 2
|
||||||
* Debian/Ubuntu: ``sudo apt install libfuse2``
|
* Debian/Ubuntu: ``sudo apt install libfuse2``
|
||||||
* Arch: ``sudo pacman -S fuse2``
|
* Arch: ``sudo pacman -S fuse2``
|
||||||
|
@ -14,4 +14,4 @@ include("$ENV{HOME}/.minecraft-pi/sdk/lib/minecraft-pi-reborn-client/sdk/sdk.cma
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
add_library(chat-commands SHARED chat-commands.cpp)
|
add_library(chat-commands SHARED chat-commands.cpp)
|
||||||
target_link_libraries(chat-commands mods-headers reborn-patch symbols chat misc)
|
target_link_libraries(chat-commands mods reborn-patch symbols)
|
||||||
|
@ -14,4 +14,4 @@ include("$ENV{HOME}/.minecraft-pi/sdk/lib/minecraft-pi-reborn-client/sdk/sdk.cma
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
add_library(expanded-creative SHARED expanded-creative.cpp)
|
add_library(expanded-creative SHARED expanded-creative.cpp)
|
||||||
target_link_libraries(expanded-creative mods-headers reborn-patch symbols misc)
|
target_link_libraries(expanded-creative mods reborn-patch symbols)
|
||||||
|
@ -14,4 +14,4 @@ include("$ENV{HOME}/.minecraft-pi/sdk/lib/minecraft-pi-reborn-client/sdk/sdk.cma
|
|||||||
|
|
||||||
# Build
|
# Build
|
||||||
add_library(recipes SHARED recipes.cpp)
|
add_library(recipes SHARED recipes.cpp)
|
||||||
target_link_libraries(recipes mods-headers reborn-util symbols misc)
|
target_link_libraries(recipes mods reborn-util symbols)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
project(launcher)
|
project(launcher)
|
||||||
|
|
||||||
# Launcher
|
# Launcher
|
||||||
add_executable(launcher src/bootstrap.c src/patchelf.cpp src/util.c src/crash-report.c)
|
add_executable(launcher src/bootstrap.c src/patchelf.cpp src/util.c src/crash-report.c src/sdk.c src/mods.c)
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
target_sources(launcher PRIVATE src/server/launcher.c)
|
target_sources(launcher PRIVATE src/server/launcher.c)
|
||||||
else()
|
else()
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -15,77 +7,6 @@
|
|||||||
#include "patchelf.h"
|
#include "patchelf.h"
|
||||||
#include "crash-report.h"
|
#include "crash-report.h"
|
||||||
|
|
||||||
// Get All Mods In Folder
|
|
||||||
static void load(char **ld_preload, char *folder) {
|
|
||||||
int folder_name_length = strlen(folder);
|
|
||||||
// Retry Until Successful
|
|
||||||
while (1) {
|
|
||||||
// Open Folder
|
|
||||||
DIR *dp = opendir(folder);
|
|
||||||
if (dp != NULL) {
|
|
||||||
// Loop Through Folder
|
|
||||||
struct dirent *entry = NULL;
|
|
||||||
errno = 0;
|
|
||||||
while (1) {
|
|
||||||
errno = 0;
|
|
||||||
entry = readdir(dp);
|
|
||||||
if (entry != NULL) {
|
|
||||||
// Check If File Is Regular
|
|
||||||
if (entry->d_type == DT_REG) {
|
|
||||||
// Get Full Name
|
|
||||||
int name_length = strlen(entry->d_name);
|
|
||||||
int total_length = folder_name_length + name_length;
|
|
||||||
char name[total_length + 1];
|
|
||||||
|
|
||||||
// Concatenate Folder Name And File Name
|
|
||||||
for (int i = 0; i < folder_name_length; i++) {
|
|
||||||
name[i] = folder[i];
|
|
||||||
}
|
|
||||||
for (int i = 0; i < name_length; i++) {
|
|
||||||
name[folder_name_length + i] = entry->d_name[i];
|
|
||||||
}
|
|
||||||
// Add Terminator
|
|
||||||
name[total_length] = '\0';
|
|
||||||
|
|
||||||
// Check If File Is Accessible
|
|
||||||
int result = access(name, R_OK);
|
|
||||||
if (result == 0) {
|
|
||||||
// Add To LD_PRELOAD
|
|
||||||
string_append(ld_preload, "%s%s", *ld_preload == NULL ? "" : ":", name);
|
|
||||||
} else if (result == -1 && errno != 0) {
|
|
||||||
// Fail
|
|
||||||
WARN("Unable To Access: %s: %s", name, strerror(errno));
|
|
||||||
errno = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (errno != 0) {
|
|
||||||
// Error Reading Contents Of Folder
|
|
||||||
ERR("Error Reading Directory: %s: %s", folder, strerror(errno));
|
|
||||||
} else {
|
|
||||||
// Done!
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Close Folder
|
|
||||||
closedir(dp);
|
|
||||||
|
|
||||||
// Exit Function
|
|
||||||
return;
|
|
||||||
} else if (errno == ENOENT) {
|
|
||||||
// Folder Doesn't Exists, Attempt Creation
|
|
||||||
int ret = mkdir(folder, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
|
||||||
if (ret != 0) {
|
|
||||||
// Unable To Create Folder
|
|
||||||
ERR("Error Creating Directory: %s: %s", folder, strerror(errno));
|
|
||||||
}
|
|
||||||
// Continue Retrying
|
|
||||||
} else {
|
|
||||||
// Unable To Open Folder
|
|
||||||
ERR("Error Opening Directory: %s: %s", folder, strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MCPI_BINARY "minecraft-pi"
|
#define MCPI_BINARY "minecraft-pi"
|
||||||
#define QEMU_BINARY "qemu-arm"
|
#define QEMU_BINARY "qemu-arm"
|
||||||
|
|
||||||
@ -182,11 +103,11 @@ void pre_bootstrap(int argc, char *argv[]) {
|
|||||||
set_and_print_env("GTK_THEME", "Adwaita:dark");
|
set_and_print_env("GTK_THEME", "Adwaita:dark");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get Binary Directory
|
|
||||||
char *binary_directory = get_binary_directory();
|
|
||||||
|
|
||||||
// Configure PATH
|
// Configure PATH
|
||||||
{
|
{
|
||||||
|
// Get Binary Directory
|
||||||
|
char *binary_directory = get_binary_directory();
|
||||||
|
|
||||||
// Add Library Directory
|
// Add Library Directory
|
||||||
char *new_path = NULL;
|
char *new_path = NULL;
|
||||||
safe_asprintf(&new_path, "%s/bin", binary_directory);
|
safe_asprintf(&new_path, "%s/bin", binary_directory);
|
||||||
@ -200,10 +121,21 @@ void pre_bootstrap(int argc, char *argv[]) {
|
|||||||
// Set And Free
|
// Set And Free
|
||||||
set_and_print_env("PATH", new_path);
|
set_and_print_env("PATH", new_path);
|
||||||
free(new_path);
|
free(new_path);
|
||||||
|
|
||||||
|
// Free Binary Directory
|
||||||
|
free(binary_directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free Binary Directory
|
// --copy-sdk
|
||||||
free(binary_directory);
|
for (int i = 1; i < argc; i++) {
|
||||||
|
if (strcmp(argv[i], "--copy-sdk") == 0) {
|
||||||
|
char *binary_directory = get_binary_directory();
|
||||||
|
copy_sdk(binary_directory, 0);
|
||||||
|
free(binary_directory);
|
||||||
|
fflush(stdout);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup Crash Reports
|
// Setup Crash Reports
|
||||||
setup_crash_report();
|
setup_crash_report();
|
||||||
@ -242,56 +174,6 @@ void pre_bootstrap(int argc, char *argv[]) {
|
|||||||
print_debug_information();
|
print_debug_information();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy SDK Into ~/.minecraft-pi
|
|
||||||
#define HOME_SUBDIRECTORY_FOR_SDK HOME_SUBDIRECTORY_FOR_GAME_DATA "/sdk"
|
|
||||||
static void copy_sdk(char *binary_directory) {
|
|
||||||
// Ensure SDK Directory
|
|
||||||
{
|
|
||||||
char *sdk_path = NULL;
|
|
||||||
safe_asprintf(&sdk_path, "%s" HOME_SUBDIRECTORY_FOR_SDK, getenv("HOME"));
|
|
||||||
const char *const command[] = {"mkdir", "-p", sdk_path, NULL};
|
|
||||||
run_simple_command(command, "Unable To Create SDK Directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock File
|
|
||||||
char *lock_file_path = NULL;
|
|
||||||
safe_asprintf(&lock_file_path, "%s" HOME_SUBDIRECTORY_FOR_SDK "/.lock", getenv("HOME"));
|
|
||||||
int lock_file_fd = lock_file(lock_file_path);
|
|
||||||
|
|
||||||
// Output Directory
|
|
||||||
char *output = NULL;
|
|
||||||
safe_asprintf(&output, "%s" HOME_SUBDIRECTORY_FOR_SDK "/" MCPI_SDK_DIR, getenv("HOME"));
|
|
||||||
// Source Directory
|
|
||||||
char *source = NULL;
|
|
||||||
safe_asprintf(&source, "%s/sdk/.", binary_directory);
|
|
||||||
|
|
||||||
// Clean
|
|
||||||
{
|
|
||||||
const char *const command[] = {"rm", "-rf", output, NULL};
|
|
||||||
run_simple_command(command, "Unable To Clean SDK Output Directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make Directory
|
|
||||||
{
|
|
||||||
const char *const command[] = {"mkdir", "-p", output, NULL};
|
|
||||||
run_simple_command(command, "Unable To Create SDK Output Directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy
|
|
||||||
{
|
|
||||||
const char *const command[] = {"cp", "-ar", source, output, NULL};
|
|
||||||
run_simple_command(command, "Unable To Copy SDK");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Free
|
|
||||||
free(output);
|
|
||||||
free(source);
|
|
||||||
|
|
||||||
// Unlock File
|
|
||||||
unlock_file(lock_file_path, lock_file_fd);
|
|
||||||
free(lock_file_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bootstrap
|
// Bootstrap
|
||||||
void bootstrap(int argc, char *argv[]) {
|
void bootstrap(int argc, char *argv[]) {
|
||||||
INFO("Configuring Game...");
|
INFO("Configuring Game...");
|
||||||
@ -301,7 +183,7 @@ void bootstrap(int argc, char *argv[]) {
|
|||||||
DEBUG("Binary Directory: %s", binary_directory);
|
DEBUG("Binary Directory: %s", binary_directory);
|
||||||
|
|
||||||
// Copy SDK
|
// Copy SDK
|
||||||
copy_sdk(binary_directory);
|
copy_sdk(binary_directory, 1);
|
||||||
|
|
||||||
// Set MCPI_REBORN_ASSETS_PATH
|
// Set MCPI_REBORN_ASSETS_PATH
|
||||||
{
|
{
|
||||||
@ -432,44 +314,7 @@ void bootstrap(int argc, char *argv[]) {
|
|||||||
set_and_print_env("MCPI_NATIVE_LD_PRELOAD", host_ld_preload);
|
set_and_print_env("MCPI_NATIVE_LD_PRELOAD", host_ld_preload);
|
||||||
|
|
||||||
// ARM Components
|
// ARM Components
|
||||||
{
|
bootstrap_mods(binary_directory);
|
||||||
// Prepare
|
|
||||||
char *preload = NULL;
|
|
||||||
|
|
||||||
// ~/.minecraft-pi/mods
|
|
||||||
{
|
|
||||||
// Get Mods Folder
|
|
||||||
char *mods_folder = NULL;
|
|
||||||
safe_asprintf(&mods_folder, "%s" HOME_SUBDIRECTORY_FOR_GAME_DATA "/mods/", getenv("HOME"));
|
|
||||||
// Load Mods From ./mods
|
|
||||||
load(&preload, mods_folder);
|
|
||||||
// Free Mods Folder
|
|
||||||
free(mods_folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Built-In Mods
|
|
||||||
{
|
|
||||||
// Get Mods Folder
|
|
||||||
char *mods_folder = NULL;
|
|
||||||
safe_asprintf(&mods_folder, "%s/mods/", binary_directory);
|
|
||||||
// Load Mods From ./mods
|
|
||||||
load(&preload, mods_folder);
|
|
||||||
// Free Mods Folder
|
|
||||||
free(mods_folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add LD_PRELOAD
|
|
||||||
{
|
|
||||||
char *value = getenv("LD_PRELOAD");
|
|
||||||
if (value != NULL && strlen(value) > 0) {
|
|
||||||
string_append(&preload, ":%s", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set
|
|
||||||
set_and_print_env("MCPI_ARM_LD_PRELOAD", preload);
|
|
||||||
free(preload);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free Binary Directory
|
// Free Binary Directory
|
||||||
|
@ -6,6 +6,8 @@ extern "C" {
|
|||||||
|
|
||||||
void pre_bootstrap(int argc, char *argv[]);
|
void pre_bootstrap(int argc, char *argv[]);
|
||||||
void bootstrap(int argc, char *argv[]);
|
void bootstrap(int argc, char *argv[]);
|
||||||
|
void copy_sdk(char *binary_directory, int log_with_debug);
|
||||||
|
void bootstrap_mods(char *binary_directory);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
110
launcher/src/mods.c
Normal file
110
launcher/src/mods.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <libreborn/libreborn.h>
|
||||||
|
|
||||||
|
#include "bootstrap.h"
|
||||||
|
|
||||||
|
// Get All Mods In Folder
|
||||||
|
static void load(char **ld_preload, const char *folder) {
|
||||||
|
int folder_name_length = strlen(folder);
|
||||||
|
// Open Folder
|
||||||
|
DIR *dp = opendir(folder);
|
||||||
|
if (dp != NULL) {
|
||||||
|
// Loop Through Folder
|
||||||
|
struct dirent *entry = NULL;
|
||||||
|
errno = 0;
|
||||||
|
while (1) {
|
||||||
|
errno = 0;
|
||||||
|
entry = readdir(dp);
|
||||||
|
if (entry != NULL) {
|
||||||
|
// Check If File Is Regular
|
||||||
|
if (entry->d_type == DT_REG) {
|
||||||
|
// Get Full Name
|
||||||
|
int name_length = strlen(entry->d_name);
|
||||||
|
int total_length = folder_name_length + name_length;
|
||||||
|
char name[total_length + 1];
|
||||||
|
|
||||||
|
// Concatenate Folder Name And File Name
|
||||||
|
for (int i = 0; i < folder_name_length; i++) {
|
||||||
|
name[i] = folder[i];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < name_length; i++) {
|
||||||
|
name[folder_name_length + i] = entry->d_name[i];
|
||||||
|
}
|
||||||
|
// Add Terminator
|
||||||
|
name[total_length] = '\0';
|
||||||
|
|
||||||
|
// Check If File Is Accessible
|
||||||
|
int result = access(name, R_OK);
|
||||||
|
if (result == 0) {
|
||||||
|
// Add To LD_PRELOAD
|
||||||
|
string_append(ld_preload, "%s%s", *ld_preload == NULL ? "" : ":", name);
|
||||||
|
} else if (result == -1 && errno != 0) {
|
||||||
|
// Fail
|
||||||
|
WARN("Unable To Access: %s: %s", name, strerror(errno));
|
||||||
|
errno = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (errno != 0) {
|
||||||
|
// Error Reading Contents Of Folder
|
||||||
|
ERR("Error Reading Directory: %s: %s", folder, strerror(errno));
|
||||||
|
} else {
|
||||||
|
// Done!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Close Folder
|
||||||
|
closedir(dp);
|
||||||
|
} else if (errno == ENOENT) {
|
||||||
|
// Folder Doesn't Exist
|
||||||
|
} else {
|
||||||
|
// Unable To Open Folder
|
||||||
|
ERR("Error Opening Directory: %s: %s", folder, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bootstrap Mods
|
||||||
|
void bootstrap_mods(char *binary_directory) {
|
||||||
|
// Prepare
|
||||||
|
char *preload = NULL;
|
||||||
|
|
||||||
|
// ~/.minecraft-pi/mods
|
||||||
|
{
|
||||||
|
// Get Mods Folder
|
||||||
|
char *mods_folder = NULL;
|
||||||
|
safe_asprintf(&mods_folder, "%s" HOME_SUBDIRECTORY_FOR_GAME_DATA "/mods/", getenv("HOME"));
|
||||||
|
// Load Mods From ./mods
|
||||||
|
load(&preload, mods_folder);
|
||||||
|
// Free Mods Folder
|
||||||
|
free(mods_folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Built-In Mods
|
||||||
|
{
|
||||||
|
// Get Mods Folder
|
||||||
|
char *mods_folder = NULL;
|
||||||
|
safe_asprintf(&mods_folder, "%s/mods/", binary_directory);
|
||||||
|
// Load Mods From ./mods
|
||||||
|
load(&preload, mods_folder);
|
||||||
|
// Free Mods Folder
|
||||||
|
free(mods_folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add LD_PRELOAD
|
||||||
|
{
|
||||||
|
char *value = getenv("LD_PRELOAD");
|
||||||
|
if (value != NULL && strlen(value) > 0) {
|
||||||
|
string_append(&preload, ":%s", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set
|
||||||
|
set_and_print_env("MCPI_ARM_LD_PRELOAD", preload);
|
||||||
|
free(preload);
|
||||||
|
}
|
67
launcher/src/sdk.c
Normal file
67
launcher/src/sdk.c
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#include <libreborn/libreborn.h>
|
||||||
|
|
||||||
|
#include "bootstrap.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
// Log
|
||||||
|
#define LOG(is_debug, ...) \
|
||||||
|
{ \
|
||||||
|
if (is_debug) { \
|
||||||
|
DEBUG(__VA_ARGS__); \
|
||||||
|
} else { \
|
||||||
|
INFO(__VA_ARGS__); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy SDK Into ~/.minecraft-pi
|
||||||
|
#define HOME_SUBDIRECTORY_FOR_SDK HOME_SUBDIRECTORY_FOR_GAME_DATA "/sdk"
|
||||||
|
void copy_sdk(char *binary_directory, int log_with_debug) {
|
||||||
|
// Ensure SDK Directory
|
||||||
|
{
|
||||||
|
char *sdk_path = NULL;
|
||||||
|
safe_asprintf(&sdk_path, "%s" HOME_SUBDIRECTORY_FOR_SDK, getenv("HOME"));
|
||||||
|
const char *const command[] = {"mkdir", "-p", sdk_path, NULL};
|
||||||
|
run_simple_command(command, "Unable To Create SDK Directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock File
|
||||||
|
char *lock_file_path = NULL;
|
||||||
|
safe_asprintf(&lock_file_path, "%s" HOME_SUBDIRECTORY_FOR_SDK "/.lock", getenv("HOME"));
|
||||||
|
int lock_file_fd = lock_file(lock_file_path);
|
||||||
|
|
||||||
|
// Output Directory
|
||||||
|
char *output = NULL;
|
||||||
|
safe_asprintf(&output, "%s" HOME_SUBDIRECTORY_FOR_SDK "/" MCPI_SDK_DIR, getenv("HOME"));
|
||||||
|
// Source Directory
|
||||||
|
char *source = NULL;
|
||||||
|
safe_asprintf(&source, "%s/sdk/.", binary_directory);
|
||||||
|
|
||||||
|
// Clean
|
||||||
|
{
|
||||||
|
const char *const command[] = {"rm", "-rf", output, NULL};
|
||||||
|
run_simple_command(command, "Unable To Clean SDK Output Directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make Directory
|
||||||
|
{
|
||||||
|
const char *const command[] = {"mkdir", "-p", output, NULL};
|
||||||
|
run_simple_command(command, "Unable To Create SDK Output Directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy
|
||||||
|
{
|
||||||
|
const char *const command[] = {"cp", "-ar", source, output, NULL};
|
||||||
|
run_simple_command(command, "Unable To Copy SDK");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log
|
||||||
|
LOG(log_with_debug, "Copied SDK To: %s", output);
|
||||||
|
|
||||||
|
// Free
|
||||||
|
free(output);
|
||||||
|
free(source);
|
||||||
|
|
||||||
|
// Unlock File
|
||||||
|
unlock_file(lock_file_path, lock_file_fd);
|
||||||
|
free(lock_file_path);
|
||||||
|
}
|
@ -1,102 +1,109 @@
|
|||||||
project(mods)
|
project(mods)
|
||||||
|
|
||||||
## Headers
|
# Common Sources
|
||||||
add_library(mods-headers INTERFACE)
|
set(SRC
|
||||||
target_include_directories(
|
# compat
|
||||||
mods-headers
|
src/compat/compat.c
|
||||||
INTERFACE
|
src/compat/egl.c
|
||||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
src/compat/x11.c
|
||||||
"$<INSTALL_INTERFACE:${MCPI_SDK_INCLUDE_DIR}/mods>"
|
src/compat/bcm_host.c
|
||||||
|
# readdir
|
||||||
|
src/readdir/readdir.c
|
||||||
|
# feature
|
||||||
|
src/feature/feature.c
|
||||||
|
# version
|
||||||
|
src/version/version.cpp
|
||||||
|
# chat
|
||||||
|
src/chat/chat.cpp
|
||||||
|
src/chat/ui.c
|
||||||
|
# creative
|
||||||
|
src/creative/creative.cpp
|
||||||
|
# game-mode
|
||||||
|
src/game-mode/game-mode.c
|
||||||
|
src/game-mode/ui.cpp
|
||||||
|
# override
|
||||||
|
src/override/override.c
|
||||||
|
# death
|
||||||
|
src/death/death.cpp
|
||||||
|
# misc
|
||||||
|
src/misc/misc.c
|
||||||
|
src/misc/misc.cpp
|
||||||
|
src/misc/logging.cpp
|
||||||
|
src/misc/api.cpp
|
||||||
|
# options
|
||||||
|
src/options/options.c
|
||||||
|
src/options/options.cpp
|
||||||
|
# bucket
|
||||||
|
src/bucket/bucket.cpp
|
||||||
|
# cake
|
||||||
|
src/cake/cake.cpp
|
||||||
|
# home
|
||||||
|
src/home/home.c
|
||||||
|
# test
|
||||||
|
src/test/test.c
|
||||||
|
# init
|
||||||
|
src/init/init.c
|
||||||
)
|
)
|
||||||
target_link_libraries(mods-headers INTERFACE symbols)
|
|
||||||
# SDK
|
|
||||||
install(TARGETS mods-headers EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
|
||||||
install(DIRECTORY "include/" DESTINATION "${MCPI_SDK_INCLUDE_DIR}/mods")
|
|
||||||
|
|
||||||
## Mods
|
|
||||||
|
|
||||||
add_library(compat SHARED src/compat/compat.c src/compat/egl.c src/compat/x11.c src/compat/bcm_host.c)
|
|
||||||
target_link_libraries(compat mods-headers reborn-patch media-layer-core)
|
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
|
||||||
target_link_libraries(compat screenshot input sign chat home dl)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(readdir SHARED src/readdir/readdir.c)
|
|
||||||
|
|
||||||
add_library(feature SHARED src/feature/feature.c)
|
|
||||||
target_link_libraries(feature mods-headers reborn-patch)
|
|
||||||
|
|
||||||
add_library(version SHARED src/version/version.cpp)
|
|
||||||
target_link_libraries(version mods-headers reborn-patch symbols)
|
|
||||||
|
|
||||||
add_library(chat SHARED src/chat/chat.cpp src/chat/ui.c)
|
|
||||||
target_link_libraries(chat mods-headers reborn-patch symbols feature)
|
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
|
||||||
target_link_libraries(chat input media-layer-core pthread)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(creative SHARED src/creative/creative.cpp)
|
|
||||||
target_link_libraries(creative mods-headers reborn-patch symbols feature misc)
|
|
||||||
|
|
||||||
add_library(game-mode SHARED src/game-mode/game-mode.c src/game-mode/ui.cpp)
|
|
||||||
target_link_libraries(game-mode mods-headers reborn-patch symbols feature)
|
|
||||||
if(NOT MCPI_SERVER_MODE)
|
|
||||||
target_link_libraries(game-mode pthread media-layer-core)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
# Server-Only Sources
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
add_library(server SHARED src/server/server.cpp src/server/server_properties.cpp)
|
list(APPEND SRC
|
||||||
target_link_libraries(server mods-headers reborn-patch symbols feature home misc compat dl media-layer-core pthread)
|
# server
|
||||||
|
src/server/server.cpp
|
||||||
|
src/server/server_properties.cpp
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
add_library(multiplayer SHARED src/multiplayer/multiplayer.cpp)
|
list(APPEND SRC
|
||||||
target_link_libraries(multiplayer mods-headers reborn-patch symbols home feature)
|
# multiplayer
|
||||||
|
src/multiplayer/multiplayer.cpp
|
||||||
add_library(benchmark SHARED src/benchmark/benchmark.cpp)
|
# benchmark
|
||||||
target_link_libraries(benchmark mods-headers reborn-patch symbols compat misc media-layer-core)
|
src/benchmark/benchmark.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
# Headless-Only Sources
|
||||||
add_library(sound SHARED src/sound/sound.cpp src/sound/repository.cpp)
|
if(MCPI_HEADLESS_MODE)
|
||||||
target_link_libraries(sound mods-headers reborn-patch symbols feature override media-layer-core)
|
list(APPEND SRC
|
||||||
|
# textures
|
||||||
add_library(camera SHARED src/camera/camera.cpp)
|
src/textures/headless.cpp
|
||||||
target_link_libraries(camera mods-headers reborn-patch symbols feature home screenshot)
|
)
|
||||||
|
|
||||||
add_library(input SHARED src/input/input.cpp src/input/bow.c src/input/attack.c src/input/toggle.c src/input/misc.c src/input/drop.cpp src/input/crafting.cpp)
|
|
||||||
target_link_libraries(input mods-headers reborn-patch symbols creative feature misc media-layer-core)
|
|
||||||
|
|
||||||
add_library(sign SHARED src/sign/sign.cpp)
|
|
||||||
target_link_libraries(sign mods-headers reborn-patch symbols feature input media-layer-core)
|
|
||||||
|
|
||||||
add_library(touch SHARED src/touch/touch.cpp)
|
|
||||||
target_link_libraries(touch mods-headers reborn-patch symbols feature)
|
|
||||||
|
|
||||||
add_library(atlas SHARED src/atlas/atlas.cpp)
|
|
||||||
target_link_libraries(atlas mods-headers reborn-patch symbols feature media-layer-core)
|
|
||||||
|
|
||||||
add_library(title-screen SHARED src/title-screen/title-screen.cpp)
|
|
||||||
target_link_libraries(title-screen mods-headers reborn-patch symbols feature compat)
|
|
||||||
|
|
||||||
add_library(skin SHARED src/skin/skin.cpp src/skin/loader.cpp)
|
|
||||||
target_link_libraries(skin mods-headers reborn-patch symbols feature misc textures media-layer-core stb_image)
|
|
||||||
|
|
||||||
add_library(screenshot SHARED src/screenshot/screenshot.c)
|
|
||||||
target_link_libraries(screenshot mods-headers reborn-util media-layer-core stb_image)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
|
||||||
add_library(textures SHARED src/textures/textures.cpp)
|
|
||||||
else()
|
else()
|
||||||
add_library(textures SHARED src/textures/headless.cpp)
|
list(APPEND SRC
|
||||||
endif()
|
# sound
|
||||||
target_link_libraries(textures mods-headers reborn-patch symbols)
|
src/sound/sound.cpp
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
src/sound/repository.cpp
|
||||||
target_link_libraries(textures media-layer-core feature misc stb_image)
|
# camera
|
||||||
|
src/camera/camera.cpp
|
||||||
|
# input
|
||||||
|
src/input/input.cpp
|
||||||
|
src/input/bow.c
|
||||||
|
src/input/attack.c
|
||||||
|
src/input/toggle.c
|
||||||
|
src/input/misc.c
|
||||||
|
src/input/drop.cpp
|
||||||
|
src/input/crafting.cpp
|
||||||
|
# sign
|
||||||
|
src/sign/sign.cpp
|
||||||
|
# touch
|
||||||
|
src/touch/touch.cpp
|
||||||
|
# atlas
|
||||||
|
src/atlas/atlas.cpp
|
||||||
|
# title-screen
|
||||||
|
src/title-screen/title-screen.cpp
|
||||||
|
# skin
|
||||||
|
src/skin/skin.cpp
|
||||||
|
src/skin/loader.cpp
|
||||||
|
# screenshot
|
||||||
|
src/screenshot/screenshot.c
|
||||||
|
# textures
|
||||||
|
src/textures/textures.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(override SHARED src/override/override.c)
|
# Build
|
||||||
target_link_libraries(override mods-headers reborn-patch symbols dl home)
|
add_library(mods SHARED ${SRC})
|
||||||
|
|
||||||
|
==== BASE ====
|
||||||
add_library(death SHARED src/death/death.cpp)
|
add_library(death SHARED src/death/death.cpp)
|
||||||
target_link_libraries(death mods-headers reborn-patch symbols feature)
|
target_link_libraries(death mods-headers reborn-patch symbols feature)
|
||||||
|
|
||||||
@ -109,28 +116,29 @@ target_link_libraries(options mods-headers reborn-patch symbols feature home)
|
|||||||
add_library(bucket SHARED src/bucket/bucket.cpp)
|
add_library(bucket SHARED src/bucket/bucket.cpp)
|
||||||
target_link_libraries(bucket mods-headers reborn-patch symbols feature misc)
|
target_link_libraries(bucket mods-headers reborn-patch symbols feature misc)
|
||||||
|
|
||||||
add_library(cake SHARED src/cake/cake.cpp)
|
|
||||||
target_link_libraries(cake mods-headers reborn-patch symbols feature misc)
|
|
||||||
|
|
||||||
add_library(home SHARED src/home/home.c)
|
add_library(home SHARED src/home/home.c)
|
||||||
target_link_libraries(home mods-headers reborn-patch symbols)
|
target_link_libraries(home mods-headers reborn-patch symbols)
|
||||||
|
|
||||||
add_library(test SHARED src/test/test.c)
|
add_library(test SHARED src/test/test.c)
|
||||||
target_link_libraries(test mods-headers reborn-patch home)
|
target_link_libraries(test mods-headers reborn-patch home)
|
||||||
|
==== BASE ====
|
||||||
|
|
||||||
|
==== BASE ====
|
||||||
add_library(init SHARED src/init/init.c)
|
add_library(init SHARED src/init/init.c)
|
||||||
target_link_libraries(init symbols mods-headers reborn-util compat game-mode misc death options chat creative bucket cake textures home version test media-layer-core)
|
target_link_libraries(init symbols mods-headers reborn-util compat game-mode misc death options chat creative bucket textures home version test media-layer-core)
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
target_link_libraries(init server)
|
target_link_libraries(init server)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(init multiplayer benchmark)
|
target_link_libraries(init multiplayer benchmark)
|
||||||
endif()
|
endif()
|
||||||
|
==== BASE ====
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
target_link_libraries(init sound camera input sign touch atlas title-screen skin)
|
target_link_libraries(mods stb_image)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
==== BASE ====
|
||||||
## Install Mods
|
## Install Mods
|
||||||
set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket cake textures home version test)
|
set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket textures home version test)
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
list(APPEND MODS_TO_INSTALL server)
|
list(APPEND MODS_TO_INSTALL server)
|
||||||
else()
|
else()
|
||||||
@ -140,5 +148,6 @@ if(NOT MCPI_HEADLESS_MODE)
|
|||||||
list(APPEND MODS_TO_INSTALL sound camera input sign touch atlas title-screen skin screenshot)
|
list(APPEND MODS_TO_INSTALL sound camera input sign touch atlas title-screen skin screenshot)
|
||||||
endif()
|
endif()
|
||||||
install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
||||||
|
==== BASE ====
|
||||||
# SDK
|
# SDK
|
||||||
install(TARGETS ${MODS_TO_INSTALL} EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
install(DIRECTORY "include/" DESTINATION "${MCPI_SDK_INCLUDE_DIR}/mods")
|
||||||
|
@ -13,7 +13,7 @@ void init_compat();
|
|||||||
void init_server();
|
void init_server();
|
||||||
#else
|
#else
|
||||||
void init_multiplayer();
|
void init_multiplayer();
|
||||||
void init_benchmark();
|
void init_benchmark(int argc, char *argv[]);
|
||||||
#endif
|
#endif
|
||||||
#ifndef MCPI_HEADLESS_MODE
|
#ifndef MCPI_HEADLESS_MODE
|
||||||
void init_sound();
|
void init_sound();
|
||||||
|
5
mods/include/mods/server/server.h
Normal file
5
mods/include/mods/server/server.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "server_properties.h"
|
||||||
|
|
||||||
|
ServerProperties &get_server_properties();
|
6
mods/include/mods/sound/sound.h
Normal file
6
mods/include/mods/sound/sound.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
extern std::unordered_map<std::string, std::vector<std::string>> sound_repository;
|
@ -10,20 +10,6 @@
|
|||||||
#include <mods/compat/compat.h>
|
#include <mods/compat/compat.h>
|
||||||
#include <mods/misc/misc.h>
|
#include <mods/misc/misc.h>
|
||||||
|
|
||||||
// --benchmark: Activate Benchmark
|
|
||||||
static bool active = false;
|
|
||||||
__attribute__((constructor)) static void _init_active(int argc, char *argv[]) {
|
|
||||||
// Iterate Arguments
|
|
||||||
for (int i = 1; i < argc; i++) {
|
|
||||||
// Check Argument
|
|
||||||
if (strcmp(argv[i], "--benchmark") == 0) {
|
|
||||||
// Enabled
|
|
||||||
active = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
#define NANOSECONDS_IN_SECOND 1000000000ll
|
#define NANOSECONDS_IN_SECOND 1000000000ll
|
||||||
|
|
||||||
@ -172,7 +158,17 @@ static void Minecraft_update_injection(Minecraft *minecraft) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init Benchmark
|
// Init Benchmark
|
||||||
void init_benchmark() {
|
void init_benchmark(int argc, char *argv[]) {
|
||||||
|
// --benchmark: Activate Benchmark
|
||||||
|
bool active = false;
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
|
// Check Argument
|
||||||
|
if (strcmp(argv[i], "--benchmark") == 0) {
|
||||||
|
// Enabled
|
||||||
|
active = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (active) {
|
if (active) {
|
||||||
misc_run_on_update(Minecraft_update_injection);
|
misc_run_on_update(Minecraft_update_injection);
|
||||||
// Track Ticks
|
// Track Ticks
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <mods/misc/misc.h>
|
#include <mods/misc/misc.h>
|
||||||
|
|
||||||
// Items
|
// Items
|
||||||
FoodItem *bucket = NULL;
|
static FoodItem *bucket = NULL;
|
||||||
|
|
||||||
// Description And Texture
|
// Description And Texture
|
||||||
static std::string BucketItem_getDescriptionId(__attribute__((unused)) FoodItem *item, ItemInstance *item_instance) {
|
static std::string BucketItem_getDescriptionId(__attribute__((unused)) FoodItem *item, ItemInstance *item_instance) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <media-layer/core.h>
|
#include <media-layer/core.h>
|
||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
__attribute__((constructor)) static void init() {
|
__attribute__((constructor)) static void init(int argc, char *argv[]) {
|
||||||
media_ensure_loaded();
|
media_ensure_loaded();
|
||||||
run_tests();
|
run_tests();
|
||||||
init_symbols();
|
init_symbols();
|
||||||
@ -35,6 +35,9 @@ __attribute__((constructor)) static void init() {
|
|||||||
init_cake();
|
init_cake();
|
||||||
init_home();
|
init_home();
|
||||||
#ifndef MCPI_SERVER_MODE
|
#ifndef MCPI_SERVER_MODE
|
||||||
init_benchmark();
|
init_benchmark(argc, argv);
|
||||||
|
#else
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
#include <mods/server/server_properties.h>
|
#include <mods/server/server.h>
|
||||||
|
|
||||||
#include <mods/feature/feature.h>
|
#include <mods/feature/feature.h>
|
||||||
#include <mods/init/init.h>
|
#include <mods/init/init.h>
|
||||||
@ -44,7 +44,7 @@ __attribute__((constructor)) static void _init_only_generate(int argc, char *arg
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Server Properties
|
// Server Properties
|
||||||
static ServerProperties &get_server_properties() {
|
ServerProperties &get_server_properties() {
|
||||||
static ServerProperties properties;
|
static ServerProperties properties;
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
@ -8,9 +6,10 @@
|
|||||||
#include <media-layer/audio.h>
|
#include <media-layer/audio.h>
|
||||||
|
|
||||||
#include "sound-internal.h"
|
#include "sound-internal.h"
|
||||||
|
#include <mods/sound/sound.h>
|
||||||
|
|
||||||
// Sound Repository Extracted From MCPE 0.6.1 APK
|
// Sound Repository Extracted From MCPE 0.6.1 APK
|
||||||
static std::unordered_map<std::string, std::vector<std::string>> repository = {
|
std::unordered_map<std::string, std::vector<std::string>> sound_repository = {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"step.cloth",
|
"step.cloth",
|
||||||
@ -355,9 +354,9 @@ __attribute__((constructor)) static void init_rand_seed() {
|
|||||||
}
|
}
|
||||||
// Pick Sound
|
// Pick Sound
|
||||||
std::string _sound_pick(std::string sound) {
|
std::string _sound_pick(std::string sound) {
|
||||||
if (repository.count(sound) > 0) {
|
if (sound_repository.count(sound) > 0) {
|
||||||
// Sound Exists
|
// Sound Exists
|
||||||
std::vector<std::string> &options = repository[sound];
|
std::vector<std::string> &options = sound_repository[sound];
|
||||||
return options[rand() % options.size()];
|
return options[rand() % options.size()];
|
||||||
} else {
|
} else {
|
||||||
// Invalid Sound
|
// Invalid Sound
|
||||||
@ -370,7 +369,7 @@ std::string _sound_pick(std::string sound) {
|
|||||||
void _sound_resolve_all() {
|
void _sound_resolve_all() {
|
||||||
std::string source = _sound_get_source_file();
|
std::string source = _sound_get_source_file();
|
||||||
if (source.size() > 0) {
|
if (source.size() > 0) {
|
||||||
for (auto &it : repository) {
|
for (auto &it : sound_repository) {
|
||||||
for (std::string &name : it.second) {
|
for (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);
|
||||||
|
@ -20,9 +20,6 @@ run() {
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get dist-upgrade -y
|
sudo apt-get dist-upgrade -y
|
||||||
|
|
||||||
# Architecture Detection
|
|
||||||
sudo apt-get install --no-install-recommends -y dpkg-dev
|
|
||||||
|
|
||||||
# Install Everything In One Go
|
# Install Everything In One Go
|
||||||
PKG_QUEUE=''
|
PKG_QUEUE=''
|
||||||
queue_pkg() {
|
queue_pkg() {
|
||||||
@ -44,22 +41,7 @@ run() {
|
|||||||
# Architecture-Specific Dependencies
|
# Architecture-Specific Dependencies
|
||||||
architecture_specific_pkg() {
|
architecture_specific_pkg() {
|
||||||
# Compiler
|
# Compiler
|
||||||
if [ "$(dpkg-architecture -qDEB_BUILD_ARCH)" = "$1" ]; then
|
queue_pkg crossbuild-essential-$1
|
||||||
queue_pkg \
|
|
||||||
gcc \
|
|
||||||
g++
|
|
||||||
else
|
|
||||||
case "$1" in
|
|
||||||
'armhf') GCC_TARGET='arm-linux-gnueabihf';;
|
|
||||||
'arm64') GCC_TARGET='aarch64-linux-gnu';;
|
|
||||||
'i386') GCC_TARGET='i686-linux-gnu';;
|
|
||||||
'amd64') GCC_TARGET='x86-64-linux-gnu';;
|
|
||||||
esac
|
|
||||||
queue_pkg \
|
|
||||||
"gcc-${GCC_TARGET}" \
|
|
||||||
libc6-dev-$1-cross \
|
|
||||||
"g++-${GCC_TARGET}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
queue_pkg \
|
queue_pkg \
|
||||||
|
Loading…
Reference in New Issue
Block a user