Fix Build On Ubuntu 22.04 & Bug Fixes

This commit is contained in:
TheBrokenRail 2022-05-11 18:24:03 -04:00
parent 524a390921
commit b59c580f6a
15 changed files with 105 additions and 32 deletions

View File

@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.13.0)
# Specify Options # Specify Options
option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE) option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE)
if(MCPI_IS_MIXED_BUILD)
option(MCPI_BUNDLE_ARMHF_SYSROOT "Whether To Include An ARMHF Sysroot" TRUE)
endif()
option(MCPI_SERVER_MODE "Server Mode" FALSE) option(MCPI_SERVER_MODE "Server Mode" FALSE)
option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE}) option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE})
if(NOT MCPI_HEADLESS_MODE) if(NOT MCPI_HEADLESS_MODE)
@ -55,6 +58,11 @@ endif()
# Start Project # Start Project
project(minecraft-pi-reborn) project(minecraft-pi-reborn)
# Sanity Check
if(BUILD_NATIVE_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT MCPI_IS_MIXED_BUILD)
message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
endif()
# Require ARM Compilation # Require ARM Compilation
if(USE_ARM32_TOOLCHAIN AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") if(USE_ARM32_TOOLCHAIN AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
message(FATAL_ERROR "ARM-Targeting Compiler Required") message(FATAL_ERROR "ARM-Targeting Compiler Required")
@ -88,6 +96,10 @@ add_subdirectory(dependencies)
# 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_CXX_COMPILER_VERSION VERSION_GREATER 10.0)
# Prevents False Positives
add_compile_options(-Wno-stringop-overflow)
endif()
add_link_options(-Wl,--no-undefined) add_link_options(-Wl,--no-undefined)
add_definitions(-D_GNU_SOURCE) add_definitions(-D_GNU_SOURCE)
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
@ -103,6 +115,9 @@ endif()
if(MCPI_IS_APPIMAGE_BUILD) if(MCPI_IS_APPIMAGE_BUILD)
add_definitions(-DMCPI_IS_APPIMAGE_BUILD) add_definitions(-DMCPI_IS_APPIMAGE_BUILD)
endif() endif()
if(MCPI_BUNDLE_ARMHF_SYSROOT)
add_definitions(-DMCPI_BUNDLE_ARMHF_SYSROOT)
endif()
# Version # Version
set_property( set_property(

View File

@ -21,6 +21,6 @@ if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_HEADLESS_MODE)
add_subdirectory(zenity) add_subdirectory(zenity)
endif() endif()
# Sysroot # Sysroot
if(BUILD_ARM_COMPONENTS AND MCPI_IS_MIXED_BUILD) if(BUILD_ARM_COMPONENTS AND MCPI_BUNDLE_ARMHF_SYSROOT)
add_subdirectory(armhf-sysroot) add_subdirectory(armhf-sysroot)
endif() endif()

View File

@ -9,20 +9,10 @@ else()
# Download From APT # Download From APT
set(APT_PACKAGES "libc6" "libstdc++6") set(APT_PACKAGES "libc6" "libstdc++6")
# Reconfigure CMake If APT Data Is Changed
file(GLOB_RECURSE APT_FILES "apt/*")
foreach(APT_FILE IN LISTS APT_FILES)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS "${APT_FILE}"
)
endforeach()
# Copy To Binary Directory # Copy To Binary Directory
set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt-build") set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt")
file(REMOVE_RECURSE "${APT_DIR}") file(REMOVE_RECURSE "${APT_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/apt/." DESTINATION "${APT_DIR}") file(MAKE_DIRECTORY "${APT_DIR}")
# Make Directories # Make Directories
file(MAKE_DIRECTORY "${APT_DIR}/apt.conf.d") file(MAKE_DIRECTORY "${APT_DIR}/apt.conf.d")
file(MAKE_DIRECTORY "${APT_DIR}/preferences.d") file(MAKE_DIRECTORY "${APT_DIR}/preferences.d")
@ -30,6 +20,18 @@ else()
file(MAKE_DIRECTORY "${APT_DIR}/dpkg") file(MAKE_DIRECTORY "${APT_DIR}/dpkg")
file(TOUCH "${APT_DIR}/dpkg/status") file(TOUCH "${APT_DIR}/dpkg/status")
# Create APT Sources
execute_process(
COMMAND "${CMAKE_SOURCE_DIR}/scripts/tools/get-apt-sources.sh"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE APT_SOURCES
RESULT_VARIABLE APT_SOURCES_RESULT
)
if(NOT APT_SOURCES_RESULT EQUAL 0)
message(FATAL_ERROR "Unable To Get APT Sources For ARMHF Sysroot")
endif()
file(WRITE "${APT_DIR}/sources.list" "${APT_SOURCES}")
# Create APT Config # Create APT Config
string(CONCAT APT_CONFIG string(CONCAT APT_CONFIG
"Dir \"${APT_DIR}\";\n" "Dir \"${APT_DIR}\";\n"

View File

@ -1 +0,0 @@
deb https://deb.debian.org/debian/ sid main

@ -1 +1 @@
Subproject commit 7dfd84c458dfa12b351c932b8281b13faf7b50b9 Subproject commit 62e175ef9fae75335575964c845a302447c012c7

View File

@ -29,7 +29,7 @@ TRUE Close Current Screen On Death
FALSE Disable Raw Mouse Motion (Not Recommended) FALSE Disable Raw Mouse Motion (Not Recommended)
TRUE Fix Furnace Not Checking Item Auxiliary TRUE Fix Furnace Not Checking Item Auxiliary
TRUE Improved Cursor Rendering TRUE Improved Cursor Rendering
FALSE Disable V-Sync TRUE Disable V-Sync
TRUE Fix Options Screen TRUE Fix Options Screen
TRUE Force Touch GUI Inventory TRUE Force Touch GUI Inventory
TRUE Fix Pause Menu TRUE Fix Pause Menu

View File

@ -227,7 +227,7 @@ void bootstrap(int argc, char *argv[]) {
// Find Linker // Find Linker
char *linker = NULL; char *linker = NULL;
// Select Linker // Select Linker
#ifndef __arm__ #ifdef MCPI_BUNDLE_ARMHF_SYSROOT
// Use ARM Sysroot Linker // Use ARM Sysroot Linker
safe_asprintf(&linker, "%s/sysroot/lib/ld-linux-armhf.so.3", binary_directory); safe_asprintf(&linker, "%s/sysroot/lib/ld-linux-armhf.so.3", binary_directory);
#else #else
@ -264,9 +264,9 @@ void bootstrap(int argc, char *argv[]) {
// Add Library Directory // Add Library Directory
safe_asprintf(&new_ld_path, "%s/lib", binary_directory); safe_asprintf(&new_ld_path, "%s/lib", binary_directory);
// Add ARM Sysroot Libraries (Ensure Priority) (Ignroe On Actual ARM System) // Add ARM Sysroot Libraries (Ensure Priority) (Ignore On Actual ARM System)
#ifndef __arm__ #ifdef MCPI_BUNDLE_ARMHF_SYSROOT
string_append(&new_ld_path, ":%s/sysroot/lib/arm-linux-gnueabihf:%s/sysroot/usr/lib/arm-linux-gnueabihf", binary_directory, binary_directory); string_append(&new_ld_path, ":%s/sysroot/lib:%s/sysroot/lib/arm-linux-gnueabihf:%s/sysroot/usr/lib:%s/sysroot/usr/lib/arm-linux-gnueabihf", binary_directory, binary_directory, binary_directory, binary_directory);
#endif #endif
// Add LD_LIBRARY_PATH // Add LD_LIBRARY_PATH

View File

@ -192,6 +192,8 @@ static void GameRenderer_render_injection(unsigned char *game_renderer, float pa
// Check If Cursor Should Render // Check If Cursor Should Render
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) { if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
// Fix GL Mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Get X And Y // Get X And Y
float x = (*Mouse_getX)() * (*InvGuiScale); float x = (*Mouse_getX)() * (*InvGuiScale);
float y = (*Mouse_getY)() * (*InvGuiScale); float y = (*Mouse_getY)() * (*InvGuiScale);

View File

@ -51,8 +51,10 @@ static void Options_initDefaultValue_injection(unsigned char *options) {
(*Options_initDefaultValue)(options); (*Options_initDefaultValue)(options);
// Default Graphics Settings // Default Graphics Settings
#ifndef MCPI_SERVER_MODE
*(options + Options_fancy_graphics_property_offset) = 1; *(options + Options_fancy_graphics_property_offset) = 1;
*(options + Options_ambient_occlusion_property_offset) = 1; *(options + Options_ambient_occlusion_property_offset) = 1;
#endif
// Store // Store
stored_options = options; stored_options = options;

View File

@ -91,7 +91,7 @@ static char *get_new_options_txt_path() {
#endif #endif
// Modify Option Toggles // Modify Option Toggles
static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char *options_pane, unsigned char *unknown_object, std::string const& name, unsigned char *option) { static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char *options_pane, uint32_t group_id, std::string const& name, unsigned char *option) {
// Modify // Modify
std::string new_name = name; std::string new_name = name;
if (name == "Fancy Graphics") { if (name == "Fancy Graphics") {
@ -116,7 +116,7 @@ static void OptionsPane_unknown_toggle_creating_function_injection(unsigned char
} }
// Call Original Method // Call Original Method
(*OptionsPane_unknown_toggle_creating_function)(options_pane, unknown_object, new_name, option); (*OptionsPane_unknown_toggle_creating_function)(options_pane, group_id, new_name, option);
} }
// Add Missing Options To Options::getBooleanValue // Add Missing Options To Options::getBooleanValue

View File

@ -54,6 +54,7 @@ static ServerProperties &get_server_properties() {
#define DEFAULT_PORT "19132" #define DEFAULT_PORT "19132"
#define DEFAULT_SEED "" #define DEFAULT_SEED ""
#define DEFAULT_FORCE_MOB_SPAWNING "false" #define DEFAULT_FORCE_MOB_SPAWNING "false"
#define DEFAULT_PEACEFUL_MODE "false"
#define DEFAULT_WORLD_NAME "world" #define DEFAULT_WORLD_NAME "world"
#define DEFAULT_MAX_PLAYERS "4" #define DEFAULT_MAX_PLAYERS "4"
#define DEFAULT_WHITELIST "false" #define DEFAULT_WHITELIST "false"
@ -72,6 +73,10 @@ static void start_world(unsigned char *minecraft) {
// Log // Log
INFO("Loading World: %s", world_name.c_str()); INFO("Loading World: %s", world_name.c_str());
// Peaceful Mode
unsigned char *options = minecraft + Minecraft_options_property_offset;
*(int32_t *) (options + Options_game_difficulty_property_offset) = get_server_properties().get_bool("peaceful-mode", DEFAULT_PEACEFUL_MODE) ? 0 : 2;
// Specify Level Settings // Specify Level Settings
LevelSettings settings; LevelSettings settings;
settings.game_type = get_server_properties().get_int("game-mode", DEFAULT_GAME_MODE); settings.game_type = get_server_properties().get_int("game-mode", DEFAULT_GAME_MODE);
@ -461,6 +466,8 @@ static void server_init() {
properties_file_output << "seed=" DEFAULT_SEED "\n"; properties_file_output << "seed=" DEFAULT_SEED "\n";
properties_file_output << "# Force Mob Spawning (false = Disabled, true = Enabled)\n"; properties_file_output << "# Force Mob Spawning (false = Disabled, true = Enabled)\n";
properties_file_output << "force-mob-spawning=" DEFAULT_FORCE_MOB_SPAWNING "\n"; properties_file_output << "force-mob-spawning=" DEFAULT_FORCE_MOB_SPAWNING "\n";
properties_file_output << "# Peaceful Mode (false = Disabled, true = Enabled)\n";
properties_file_output << "peaceful-mode=" DEFAULT_PEACEFUL_MODE "\n";
properties_file_output << "# World To Select\n"; properties_file_output << "# World To Select\n";
properties_file_output << "world-name=" DEFAULT_WORLD_NAME "\n"; properties_file_output << "world-name=" DEFAULT_WORLD_NAME "\n";
properties_file_output << "# Maximum Player Count\n"; properties_file_output << "# Maximum Player Count\n";

View File

@ -3,7 +3,7 @@
set -e set -e
# Generate # Generate
./scripts/generate-appimage-builder-yaml.js "$1" "$2" ./scripts/tools/generate-appimage-builder-yaml.js "$1" "$2"
# Build/Package # Build/Package
appimage-builder --recipe AppImageBuilder.yml appimage-builder --recipe AppImageBuilder.yml

View File

@ -1,5 +1,8 @@
#!/usr/bin/env node #!/usr/bin/env node
// Child Process
const child_process = require('child_process');
// Arguments // Arguments
if (process.argv.length < 4) { if (process.argv.length < 4) {
throw new Error('Invalid Arguments'); throw new Error('Invalid Arguments');
@ -12,8 +15,12 @@ const id = `com.thebrokenrail.MCPIReborn${mode === 'server' ? 'Server' : 'Client
const name = `minecraft-pi-reborn-${mode}`; const name = `minecraft-pi-reborn-${mode}`;
const updateURL = `https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/${name}-latest-${arch}.AppImage.zsync`; const updateURL = `https://jenkins.thebrokenrail.com/job/minecraft-pi-reborn/job/master/lastSuccessfulBuild/artifact/out/${name}-latest-${arch}.AppImage.zsync`;
// APT Data // APT Sources
const apt_distribution = 'sid'; const apt_sources = child_process.execFileSync('./scripts/tools/get-apt-sources.sh', [], {encoding: 'utf-8'}).trim().split('\n');
const apt_sources_formatted = [];
for (const apt_source of apt_sources) {
apt_sources_formatted.push({sourceline: apt_source});
}
// Version // Version
const fs = require('fs'); const fs = require('fs');
@ -58,11 +65,7 @@ const packageExclusions = [
// APT // APT
const apt = { const apt = {
arch: arch, arch: arch,
sources: [ sources: apt_sources_formatted,
{
sourceline: `deb [arch=${arch}] https://deb.debian.org/debian/ ${apt_distribution} main`
}
],
allow_unauthenticated: true, allow_unauthenticated: true,
include: packages, include: packages,
exclude: packageExclusions exclude: packageExclusions
@ -113,7 +116,7 @@ const runtime = {
GTK_PATH: `\${APPDIR}/usr/lib/${triplet}/gtk-3.0`, GTK_PATH: `\${APPDIR}/usr/lib/${triplet}/gtk-3.0`,
GTK_DATA_PREFIX: '${APPDIR}', GTK_DATA_PREFIX: '${APPDIR}',
GTK_THEME: 'Default', GTK_THEME: 'Default',
XDG_DATA_DIRS: '${APPDIR}/share:${APPDIR}/usr/share', XDG_DATA_DIRS: '${APPDIR}/share:${APPDIR}/usr/share:/share:/usr/share',
APPDIR_LIBRARY_PATH: `\${APPDIR}/usr/lib/${triplet}:\${APPDIR}/usr/${triplet}/lib:\${APPDIR}/lib/${triplet}:\${APPDIR}/usr/lib:\${APPDIR}/usr/lib/${triplet}/gdk-pixbuf-2.0/2.10.0/loaders`, APPDIR_LIBRARY_PATH: `\${APPDIR}/usr/lib/${triplet}:\${APPDIR}/usr/${triplet}/lib:\${APPDIR}/lib/${triplet}:\${APPDIR}/usr/lib:\${APPDIR}/usr/lib/${triplet}/gdk-pixbuf-2.0/2.10.0/loaders`,
APPDIR_MODULE_DIR: '/tmp/.minecraft-pi-tmp' APPDIR_MODULE_DIR: '/tmp/.minecraft-pi-tmp'
} : undefined, } : undefined,

View File

@ -0,0 +1,43 @@
#!/bin/sh
set -e
if [ ! -z "${MCPI_CUSTOM_APT_REPO}" ]; then
echo "${MCPI_CUSTOM_APT_REPO}"
exit 0
fi
ID="$(sed -n -e 's/^ID=//p' /etc/os-release)"
ID_LIKE="$(sed -n -e 's/^ID_LIKE=//p' /etc/os-release)"
VERSION_CODENAME="$(sed -n -e 's/^VERSION_CODENAME=//p' /etc/os-release)"
OUT=""
get_apt_sources() {
if [ "${1}" = "ubuntu" ]; then
OUT="deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME} main restricted
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME}-updates main restricted
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME} universe
deb [arch=i386,amd64] http://archive.ubuntu.com/ubuntu/ ${VERSION_CODENAME}-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME} main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME}-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME} universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports/ ${VERSION_CODENAME}-updates universe"
elif [ "${1}" = "debian" ]; then
OUT="deb https://deb.debian.org/debian/ ${VERSION_CODENAME} main"
if [ "${VERSION_CODENAME}" != "sid" ] && [ "${VERSION_CODENAME}" != "unstable" ] && [ "${VERSION_CODENAME}" != "experimental" ]; then
OUT="${OUT}
deb https://deb.debian.org/debian/ ${VERSION_CODENAME}-updates main"
fi
fi
}
get_apt_sources "${ID}"
if [ -z "${OUT}" ]; then
get_apt_sources "${ID_LIKE}"
fi
if [ ! -z "${OUT}" ]; then
echo "${OUT}"
else
echo "Unsupported Distribution: ${ID}" 1>&2
exit 1
fi

View File

@ -835,7 +835,7 @@ static uint32_t OptionsFile_options_txt_path_property_offset = 0x0; // std::stri
// OptionsPane // OptionsPane
typedef void (*OptionsPane_unknown_toggle_creating_function_t)(unsigned char *options_pane, unsigned char *unknown_object, std::string const& name, unsigned char *option); typedef void (*OptionsPane_unknown_toggle_creating_function_t)(unsigned char *options_pane, uint32_t group_id, std::string const& name, unsigned char *option);
static OptionsPane_unknown_toggle_creating_function_t OptionsPane_unknown_toggle_creating_function = (OptionsPane_unknown_toggle_creating_function_t) 0x24470; static OptionsPane_unknown_toggle_creating_function_t OptionsPane_unknown_toggle_creating_function = (OptionsPane_unknown_toggle_creating_function_t) 0x24470;
// Textures // Textures