From 49f56bd90db8a9991d98436eaccbc470255f3771 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Tue, 23 Jan 2024 23:00:22 -0500 Subject: [PATCH] Fix Benchmark --- mods/include/mods/init/init.h | 2 +- mods/src/benchmark/benchmark.cpp | 26 +++++++++++--------------- mods/src/init/init.c | 7 +++++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/mods/include/mods/init/init.h b/mods/include/mods/init/init.h index ea7b95204a..2809dd517e 100644 --- a/mods/include/mods/init/init.h +++ b/mods/include/mods/init/init.h @@ -13,7 +13,7 @@ void init_compat(); void init_server(); #else void init_multiplayer(); -void init_benchmark(); +void init_benchmark(int argc, char *argv[]); #endif #ifndef MCPI_HEADLESS_MODE void init_sound(); diff --git a/mods/src/benchmark/benchmark.cpp b/mods/src/benchmark/benchmark.cpp index 3d8ca1040e..3c708c4ace 100644 --- a/mods/src/benchmark/benchmark.cpp +++ b/mods/src/benchmark/benchmark.cpp @@ -10,20 +10,6 @@ #include #include -// --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 #define NANOSECONDS_IN_SECOND 1000000000ll @@ -172,7 +158,17 @@ static void Minecraft_update_injection(Minecraft *minecraft) { } // 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) { misc_run_on_update(Minecraft_update_injection); // Track Ticks diff --git a/mods/src/init/init.c b/mods/src/init/init.c index 5823111b15..100512bb1d 100644 --- a/mods/src/init/init.c +++ b/mods/src/init/init.c @@ -3,7 +3,7 @@ #include #include -__attribute__((constructor)) static void init() { +__attribute__((constructor)) static void init(int argc, char *argv[]) { media_ensure_loaded(); run_tests(); init_symbols(); @@ -34,6 +34,9 @@ __attribute__((constructor)) static void init() { init_bucket(); init_home(); #ifndef MCPI_SERVER_MODE - init_benchmark(); + init_benchmark(argc, argv); +#else + (void) argc; + (void) argv; #endif }