diff --git a/launcher/src/bootstrap/bootstrap.cpp b/launcher/src/bootstrap/bootstrap.cpp index 4e8a403480..9508b89c64 100644 --- a/launcher/src/bootstrap/bootstrap.cpp +++ b/launcher/src/bootstrap/bootstrap.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include "../util/util.h" diff --git a/launcher/src/bootstrap/mods.cpp b/launcher/src/bootstrap/mods.cpp index 3ab6075ecd..9f925231e5 100644 --- a/launcher/src/bootstrap/mods.cpp +++ b/launcher/src/bootstrap/mods.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/launcher/src/client/configuration.cpp b/launcher/src/client/configuration.cpp index adfe354da3..05bcabbdf8 100644 --- a/launcher/src/client/configuration.cpp +++ b/launcher/src/client/configuration.cpp @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include #include "../util/util.h" diff --git a/launcher/src/logger/logger.cpp b/launcher/src/logger/logger.cpp index be1ab4a4b9..de2b5e1574 100644 --- a/launcher/src/logger/logger.cpp +++ b/launcher/src/logger/logger.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -13,6 +12,7 @@ #include #include #include +#include #include "logger.h" diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp index 28037821d8..c24a0cf790 100644 --- a/launcher/src/main.cpp +++ b/launcher/src/main.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "bootstrap/bootstrap.h" #include "options/parser.h" diff --git a/launcher/src/options/parser.cpp b/launcher/src/options/parser.cpp index a0315ba872..9d24602b48 100644 --- a/launcher/src/options/parser.cpp +++ b/launcher/src/options/parser.cpp @@ -3,6 +3,7 @@ #include #include #include + #include "parser.h" // Globals diff --git a/libreborn/CMakeLists.txt b/libreborn/CMakeLists.txt index 9ffbc1aafe..2e8e0ccb5a 100644 --- a/libreborn/CMakeLists.txt +++ b/libreborn/CMakeLists.txt @@ -12,6 +12,7 @@ add_library(reborn-util SHARED src/util/log.cpp src/util/cp437.cpp src/util/env.cpp + src/util/config.cpp src/util/flags/node.cpp src/util/flags/flags.cpp src/util/flags/available-feature-flags # Show In IDE diff --git a/libreborn/include/libreborn/config.h.in b/libreborn/include/libreborn/config.h.in index 3382cc042d..6013be8674 100644 --- a/libreborn/include/libreborn/config.h.in +++ b/libreborn/include/libreborn/config.h.in @@ -11,3 +11,8 @@ #cmakedefine MCPI_SKIN_SERVER "@MCPI_SKIN_SERVER@" #cmakedefine MCPI_DISCORD_INVITE "@MCPI_DISCORD_INVITE@" #cmakedefine MCPI_DOCUMENTATION "@MCPI_DOCUMENTATION@" + +// Access Configuration At Runtime +const char *reborn_get_version(); +bool reborn_is_headless(); +bool reborn_is_server(); \ No newline at end of file diff --git a/libreborn/include/libreborn/exec.h b/libreborn/include/libreborn/exec.h index 64a6ad1939..1fc6977d28 100644 --- a/libreborn/include/libreborn/exec.h +++ b/libreborn/include/libreborn/exec.h @@ -20,9 +20,6 @@ void poll_fds(const std::vector &fds, const std::function *run_command(const char *const command[], int *exit_status); bool is_exit_status_success(int status); diff --git a/libreborn/include/libreborn/util.h b/libreborn/include/libreborn/util.h index 958cfa5d31..f5a3934fb6 100644 --- a/libreborn/include/libreborn/util.h +++ b/libreborn/include/libreborn/util.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -27,7 +26,7 @@ }) // Hook Library Function -#define EXTERNAL_FUNC(name, return_type, args) \ +#define HOOK(name, return_type, args) \ typedef return_type (*real_##name##_t)args; \ __attribute__((__unused__)) static real_##name##_t real_##name() { \ static real_##name##_t func = NULL; \ @@ -39,9 +38,7 @@ } \ } \ return func; \ - } -#define HOOK(name, return_type, args) \ - EXTERNAL_FUNC(name, return_type, args) \ + } \ extern "C" __attribute__((__used__)) return_type name args // Safe Version Of pipe() @@ -50,6 +47,7 @@ struct Pipe { const int read; const int write; }; + // Check If Two Percentages Are Different Enough To Be Logged bool is_progress_difference_significant(int32_t new_val, int32_t old_val); @@ -57,11 +55,6 @@ bool is_progress_difference_significant(int32_t new_val, int32_t old_val); int lock_file(const char *file); void unlock_file(const char *file, int fd); -// Access Configuration At Runtime -const char *reborn_get_version(); -bool reborn_is_headless(); -bool reborn_is_server(); - // Check $DISPLAY void reborn_check_display(); diff --git a/libreborn/src/patch/code-block.cpp b/libreborn/src/patch/code-block.cpp index 20d2ef1d77..c7927b14d1 100644 --- a/libreborn/src/patch/code-block.cpp +++ b/libreborn/src/patch/code-block.cpp @@ -1,6 +1,8 @@ #include +#include +#include -#include +#include #include "patch-internal.h" // Limit Amount Of overwrite_calls() Calls diff --git a/libreborn/src/patch/instruction.cpp b/libreborn/src/patch/instruction.cpp index 5e231c6b31..0749021a07 100644 --- a/libreborn/src/patch/instruction.cpp +++ b/libreborn/src/patch/instruction.cpp @@ -1,4 +1,4 @@ -#include +#include #include "patch-internal.h" // Check Instruction diff --git a/libreborn/src/patch/patch.cpp b/libreborn/src/patch/patch.cpp index a450687da5..a2e77e150c 100644 --- a/libreborn/src/patch/patch.cpp +++ b/libreborn/src/patch/patch.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include "patch-internal.h" // Overwrite Specific B(L) Instruction diff --git a/libreborn/src/patch/segments.cpp b/libreborn/src/patch/segments.cpp index 0f100f5144..dfafa43ecf 100644 --- a/libreborn/src/patch/segments.cpp +++ b/libreborn/src/patch/segments.cpp @@ -1,10 +1,11 @@ #include +#include #include #include #include -#include +#include #include "patch-internal.h" // Track Segments diff --git a/libreborn/src/util/config.cpp b/libreborn/src/util/config.cpp new file mode 100644 index 0000000000..6014a6b423 --- /dev/null +++ b/libreborn/src/util/config.cpp @@ -0,0 +1,32 @@ +#include + +#include +#include + +// Access Configuration At Runtime +const char *reborn_get_version() { + return MCPI_VERSION; +} +bool reborn_is_headless() { + static bool ret; + static bool is_set = false; + if (!is_set) { + ret = reborn_is_server(); + if (getenv(_MCPI_FORCE_HEADLESS_ENV)) { + ret = true; + } else if (getenv(_MCPI_FORCE_NON_HEADLESS_ENV)) { + ret = false; + } + is_set = true; + } + return ret; +} +bool reborn_is_server() { + static int ret; + static bool is_set = false; + if (!is_set) { + ret = getenv(_MCPI_SERVER_MODE_ENV) != nullptr; + is_set = true; + } + return ret; +} \ No newline at end of file diff --git a/libreborn/src/util/exec.cpp b/libreborn/src/util/exec.cpp index 6bba724d82..07fc5250c2 100644 --- a/libreborn/src/util/exec.cpp +++ b/libreborn/src/util/exec.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -133,6 +134,7 @@ __attribute__((noreturn)) void safe_execvpe(const char *const argv[], const char } // Run Command And Get Output +#define CHILD_PROCESS_TAG "(Child Process) " std::vector *run_command(const char *const command[], int *exit_status) { // Run const std::optional child = fork_with_stdio(); diff --git a/libreborn/src/util/util.cpp b/libreborn/src/util/util.cpp index edacace142..29b9bb26af 100644 --- a/libreborn/src/util/util.cpp +++ b/libreborn/src/util/util.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -50,34 +51,6 @@ void unlock_file(const char *file, const int fd) { close(fd); } -// Access Configuration At Runtime -const char *reborn_get_version() { - return MCPI_VERSION; -} -bool reborn_is_headless() { - static bool ret; - static bool is_set = false; - if (!is_set) { - ret = reborn_is_server(); - if (getenv(_MCPI_FORCE_HEADLESS_ENV)) { - ret = true; - } else if (getenv(_MCPI_FORCE_NON_HEADLESS_ENV)) { - ret = false; - } - is_set = true; - } - return ret; -} -bool reborn_is_server() { - static int ret; - static int is_set = 0; - if (!is_set) { - ret = getenv(_MCPI_SERVER_MODE_ENV) != nullptr; - is_set = 1; - } - return ret; -} - // Check $DISPLAY void reborn_check_display() { if (!getenv("DISPLAY") && !getenv("WAYLAND_DISPLAY")) { diff --git a/media-layer/core/src/audio/api.cpp b/media-layer/core/src/audio/api.cpp index 6d44ca7e0e..1e9a557868 100644 --- a/media-layer/core/src/audio/api.cpp +++ b/media-layer/core/src/audio/api.cpp @@ -4,11 +4,9 @@ #include #include -#include +#include -#include "file.h" -#include "engine.h" -#include "api.h" +#include "audio.h" // Store Audio Sources static std::vector sources; @@ -18,7 +16,6 @@ static std::vector sources; static std::vector idle_sources; // Error Checking -#define AL_ERROR_CHECK() AL_ERROR_CHECK_MANUAL(alGetError()) #define AL_ERROR_CHECK_MANUAL(val) \ { \ ALenum __err = val; \ @@ -26,6 +23,7 @@ static std::vector idle_sources; ERR("OpenAL Error: %s", alGetString(__err)); \ } \ } +#define AL_ERROR_CHECK() AL_ERROR_CHECK_MANUAL(alGetError()) // Delete Sources void _media_audio_delete_sources() { diff --git a/media-layer/core/src/audio/api.h b/media-layer/core/src/audio/api.h deleted file mode 100644 index dd90975f35..0000000000 --- a/media-layer/core/src/audio/api.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -__attribute__((visibility("internal"))) void _media_audio_delete_sources(); diff --git a/media-layer/core/src/audio/audio.h b/media-layer/core/src/audio/audio.h new file mode 100644 index 0000000000..416fb0795d --- /dev/null +++ b/media-layer/core/src/audio/audio.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +__attribute__((visibility("internal"))) void _media_audio_delete_sources(); + +__attribute__((visibility("internal"))) void _media_audio_init(); +__attribute__((visibility("internal"))) void _media_audio_cleanup(); +__attribute__((visibility("internal"))) int _media_audio_is_loaded(); + +__attribute__((visibility("internal"))) ALuint _media_audio_get_buffer(const char *source, const char *name); +__attribute__((visibility("internal"))) void _media_audio_delete_buffers(); \ No newline at end of file diff --git a/media-layer/core/src/audio/engine.cpp b/media-layer/core/src/audio/engine.cpp index fd4cdd6807..ddfbdc97a0 100644 --- a/media-layer/core/src/audio/engine.cpp +++ b/media-layer/core/src/audio/engine.cpp @@ -2,11 +2,9 @@ #include #include -#include +#include -#include "engine.h" -#include "file.h" -#include "api.h" +#include "audio.h" // Store Device static ALCdevice *device = nullptr; diff --git a/media-layer/core/src/audio/engine.h b/media-layer/core/src/audio/engine.h deleted file mode 100644 index 1aba3c26b3..0000000000 --- a/media-layer/core/src/audio/engine.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -__attribute__((visibility("internal"))) void _media_audio_init(); -__attribute__((visibility("internal"))) void _media_audio_cleanup(); -__attribute__((visibility("internal"))) int _media_audio_is_loaded(); \ No newline at end of file diff --git a/media-layer/core/src/audio/file.cpp b/media-layer/core/src/audio/file.cpp index ae2643311f..1d606f8d0f 100644 --- a/media-layer/core/src/audio/file.cpp +++ b/media-layer/core/src/audio/file.cpp @@ -6,10 +6,9 @@ #include -#include +#include -#include "file.h" -#include "engine.h" +#include "audio.h" // Load Symbol From ELF File static void load_symbol(const char *source, const char *name, std::function callback) { @@ -53,7 +52,7 @@ static ALuint load_sound(const char *source, const char *name) { WARN("Symbol Too Small To Contain Audio Metadata: %s", name); return; } - audio_metadata *meta = (audio_metadata *) symbol; + const audio_metadata *meta = (audio_metadata *) symbol; // Check Frame Size if (meta->frame_size != 1 && meta->frame_size != 2) { @@ -73,7 +72,7 @@ static ALuint load_sound(const char *source, const char *name) { } // Load Data - const int remaining_size = size - sizeof (audio_metadata); + const int remaining_size = int(size - sizeof (audio_metadata)); const int data_size = meta->channels * meta->frames * meta->frame_size; if (remaining_size < data_size) { WARN("Symbol Too Small To Contain Specified Audio Data: %s", name); @@ -107,7 +106,7 @@ static std::unordered_map buffers; ALuint _media_audio_get_buffer(const char *source, const char *name) { // Check if (_media_audio_is_loaded()) { - if (buffers.count(name) > 0) { + if (buffers.contains(name)) { // Return return buffers[name]; } else { diff --git a/media-layer/core/src/audio/file.h b/media-layer/core/src/audio/file.h deleted file mode 100644 index 63d9366c0a..0000000000 --- a/media-layer/core/src/audio/file.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -__attribute__((visibility("internal"))) ALuint _media_audio_get_buffer(const char *source, const char *name); -__attribute__((visibility("internal"))) void _media_audio_delete_buffers(); diff --git a/media-layer/core/src/base.cpp b/media-layer/core/src/base.cpp index 196948eb5f..2be4af6b95 100644 --- a/media-layer/core/src/base.cpp +++ b/media-layer/core/src/base.cpp @@ -2,8 +2,6 @@ #include -#include - #include "window/media.h" // SDL Is Replaced With GLFW diff --git a/media-layer/core/src/window/gles.cpp b/media-layer/core/src/window/gles.cpp index 9bfe023ae6..e45bd83032 100644 --- a/media-layer/core/src/window/gles.cpp +++ b/media-layer/core/src/window/gles.cpp @@ -2,7 +2,7 @@ #define GLFW_INCLUDE_NONE #include -#include +#include #include "media.h" diff --git a/media-layer/core/src/window/media.cpp b/media-layer/core/src/window/media.cpp index ea799b59f9..1d4d0db5ce 100644 --- a/media-layer/core/src/window/media.cpp +++ b/media-layer/core/src/window/media.cpp @@ -2,7 +2,7 @@ #include #include "media.h" -#include "../audio/engine.h" +#include "../audio/audio.h" // Window GLFWwindow *glfw_window = nullptr; diff --git a/media-layer/core/src/window/media.h b/media-layer/core/src/window/media.h index 4ea346ef18..fd88272fa6 100644 --- a/media-layer/core/src/window/media.h +++ b/media-layer/core/src/window/media.h @@ -4,7 +4,10 @@ #include #include -#include +#include +#include +#include +#include #include diff --git a/media-layer/include/media-layer/core.h b/media-layer/include/media-layer/core.h index d82a3c9a85..667109a4d0 100644 --- a/media-layer/include/media-layer/core.h +++ b/media-layer/include/media-layer/core.h @@ -16,7 +16,7 @@ void media_toggle_fullscreen(); void media_swap_buffers(); void media_cleanup(); void media_get_framebuffer_size(int *width, int *height); -void media_set_interactable(int is_interactable); +void media_set_interactable(int toggle); void media_disable_vsync(); void media_set_raw_mouse_motion_enabled(int enabled); int media_has_extension(const char *name); diff --git a/media-layer/trampoline/src/GLESv1_CM.cpp b/media-layer/trampoline/src/GLESv1_CM.cpp index 8af084ec18..62e1e7a4dc 100644 --- a/media-layer/trampoline/src/GLESv1_CM.cpp +++ b/media-layer/trampoline/src/GLESv1_CM.cpp @@ -1,7 +1,8 @@ #include #include -#include +#include +#include #include "common/common.h" diff --git a/media-layer/trampoline/src/guest/guest.cpp b/media-layer/trampoline/src/guest/guest.cpp index cc1d324944..5ba76b2d90 100644 --- a/media-layer/trampoline/src/guest/guest.cpp +++ b/media-layer/trampoline/src/guest/guest.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/media-layer/trampoline/src/host/host.cpp b/media-layer/trampoline/src/host/host.cpp index 9f7d2377d8..d7196562af 100644 --- a/media-layer/trampoline/src/host/host.cpp +++ b/media-layer/trampoline/src/host/host.cpp @@ -1,4 +1,4 @@ -#include +#include #include "host.h" diff --git a/media-layer/trampoline/src/media-layer-core.cpp b/media-layer/trampoline/src/media-layer-core.cpp index 48ebc0197d..17226725ab 100644 --- a/media-layer/trampoline/src/media-layer-core.cpp +++ b/media-layer/trampoline/src/media-layer-core.cpp @@ -7,8 +7,6 @@ #include "common/common.h" -#include - // SDL Functions CALL(0, media_SDL_Init, int, (uint32_t flags)) diff --git a/mods/src/feature/feature.cpp b/mods/src/feature/feature.cpp index dc20a9b000..05cefd93e2 100644 --- a/mods/src/feature/feature.cpp +++ b/mods/src/feature/feature.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include