From f08afbf654436b3c70ec57b19c571340543b6205 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 5 Jul 2024 03:24:27 -0400 Subject: [PATCH] Allow Skipping Page-Size Check --- launcher/src/bootstrap.cpp | 6 ++---- launcher/src/bootstrap.h | 4 +++- launcher/src/main.cpp | 2 +- launcher/src/options/option-list.h | 3 ++- libreborn/include/libreborn/log.h | 8 ++++++++ mods/src/misc/misc.cpp | 8 -------- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/launcher/src/bootstrap.cpp b/launcher/src/bootstrap.cpp index ea428c5388..1a7850e439 100644 --- a/launcher/src/bootstrap.cpp +++ b/launcher/src/bootstrap.cpp @@ -56,17 +56,15 @@ static void print_debug_information() { } // Bootstrap -void bootstrap() { +void bootstrap(const options_t &options) { // Debug Information print_debug_information(); // Check Page Size (Not Needed When Using QEMU) -#ifndef MCPI_RUNTIME_IS_QEMU long page_size = sysconf(_SC_PAGESIZE); if (page_size != REQUIRED_PAGE_SIZE) { - ERR("Invalid page size! A page size of %ld bytes is required, but the system size is %ld bytes.", (long) REQUIRED_PAGE_SIZE, page_size); + CONDITIONAL_ERR(!options.skip_pagesize_check, "Invalid page size! A page size of %ld bytes is required, but the system size is %ld bytes.", (long) REQUIRED_PAGE_SIZE, page_size); } -#endif // Get Binary Directory const std::string binary_directory = get_binary_directory(); diff --git a/launcher/src/bootstrap.h b/launcher/src/bootstrap.h index db58f0ae1f..452fa7847a 100644 --- a/launcher/src/bootstrap.h +++ b/launcher/src/bootstrap.h @@ -2,6 +2,8 @@ #include -void bootstrap(); +#include "options/parser.h" + +void bootstrap(const options_t &options); void copy_sdk(const std::string &binary_directory, bool log_with_debug); std::string bootstrap_mods(const std::string &binary_directory); diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index 0d4653c0d5..e642bd6105 100644 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -90,7 +90,7 @@ static void start_game(const options_t &options) { } // Bootstrap - bootstrap(); + bootstrap(options); } // Main diff --git a/launcher/src/options/option-list.h b/launcher/src/options/option-list.h index 19fc58ef46..52329aba14 100644 --- a/launcher/src/options/option-list.h +++ b/launcher/src/options/option-list.h @@ -9,4 +9,5 @@ OPTION(benchmark, "benchmark", -7, "Run Client-Mode Benchmark") OPTION(only_generate, "only-generate", -8, "Generate World And Exit (Server-Mode Only)") OPTION(force_headless, "force-headless", -9, "Force Disable Game Rendering") OPTION(force_non_headless, "force-non-headless", -10, "Force Enable Game Rendering") -OPTION(server_mode, "server", -11, "Run In Server-Mode") \ No newline at end of file +OPTION(server_mode, "server", -11, "Run In Server-Mode") +OPTION(skip_pagesize_check, "skip-pagesize-check", -12, "Skip Page-Size Check (Not Recommended)") \ No newline at end of file diff --git a/libreborn/include/libreborn/log.h b/libreborn/include/libreborn/log.h index cdc99ce5e3..47419a02a8 100644 --- a/libreborn/include/libreborn/log.h +++ b/libreborn/include/libreborn/log.h @@ -21,6 +21,14 @@ int reborn_get_debug_fd(); #define DEBUG(format, ...) RAW_DEBUG(reborn_debug_tag, format, ##__VA_ARGS__) #define ERR(format, ...) { fprintf(stderr, "[ERR]: (%s:%i): " format "\n", __FILE__, __LINE__, ##__VA_ARGS__); exit(EXIT_FAILURE); } #define IMPOSSIBLE() ERR("This Should Never Be Called") +#define CONDITIONAL_ERR(is_error, ...) \ + { \ + if ((is_error)) { \ + ERR(__VA_ARGS__); \ + } else { \ + WARN(__VA_ARGS__); \ + } \ + } #ifdef __cplusplus } diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index 9036560ba0..29a35a78e6 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -251,14 +251,6 @@ static const char *RAKNET_ERROR_NAMES[] = { "Couldn't Generate GUID", "Unknown" }; -#define CONDITIONAL_ERR(is_error, ...) \ - { \ - if ((is_error)) { \ - ERR(__VA_ARGS__); \ - } else { \ - WARN(__VA_ARGS__); \ - } \ - } static RakNet_StartupResult RakNetInstance_host_RakNet_RakPeer_Startup_injection(RakNet_RakPeer *rak_peer, unsigned short maxConnections, unsigned char *socketDescriptors, uint32_t socketDescriptorCount, int32_t threadPriority) { // Call Original Method RakNet_StartupResult result = rak_peer->Startup(maxConnections, socketDescriptors, socketDescriptorCount, threadPriority);