diff --git a/VERSION b/VERSION index e30309f..f041bc6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.4.7 +2.4.8 diff --git a/dependencies/LIEF/src b/dependencies/LIEF/src index 2169578..966a66c 160000 --- a/dependencies/LIEF/src +++ b/dependencies/LIEF/src @@ -1 +1 @@ -Subproject commit 2169578d46934c973fdbfa2fae23b192e3cac8a0 +Subproject commit 966a66c78a498ed694f28a25b350853852612c4d diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 90dfa9d..5238f9e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +**2.4.8** +* Fix Bug In ``extract_from_bl_instruction`` +* Update LIEF And GLFW +* Allow Mods To Access The Original GLFW Keycode For Key Events (But Better) +* More Accurate Sound + **2.4.7** * Improve Server Performance * Add ``Add Biome Colors To Grass`` Feature Flag (Disabled By Default) diff --git a/images/start.png b/images/start.png index e8e2b77..d6e4091 100644 Binary files a/images/start.png and b/images/start.png differ diff --git a/libreborn/src/patch/patch.c b/libreborn/src/patch/patch.c index cd678b5..21093da 100644 --- a/libreborn/src/patch/patch.c +++ b/libreborn/src/patch/patch.c @@ -18,6 +18,10 @@ // Generate A BL Instruction static uint32_t generate_bl_instruction(void *from, void *to, int use_b_instruction) { + if (abs(((int32_t) to) - ((int32_t) from)) > 32000000) { + IMPOSSIBLE(); + } + uint32_t instruction; unsigned char *instruction_array = (unsigned char *) &instruction; @@ -140,11 +144,8 @@ void _overwrite_calls(const char *file, int line, void *start, void *target) { void *extract_from_bl_instruction(unsigned char *from) { unsigned char *pc = ((unsigned char *) from) + 8; - int32_t target = 0; - unsigned char *target_array = (unsigned char *) ⌖ - target_array[0] = from[0]; - target_array[1] = from[1]; - target_array[2] = from[2]; + int32_t target = *(int32_t *) from; + target = (target << 8) >> 8; int32_t offset = target << 2; diff --git a/media-layer/core/dependencies/glfw/CMakeLists.txt b/media-layer/core/dependencies/glfw/CMakeLists.txt index 1a03909..3d9aa60 100644 --- a/media-layer/core/dependencies/glfw/CMakeLists.txt +++ b/media-layer/core/dependencies/glfw/CMakeLists.txt @@ -21,15 +21,6 @@ add_subdirectory(src EXCLUDE_FROM_ALL) # Ensure Build add_custom_target(glfw-build ALL DEPENDS glfw) -# Remove When glfw/glfw#2192 Is Merged -target_compile_definitions(glfw PRIVATE -D_GLFW_LINUX_JOYSTICK) -# Remove When glfw/glfw#2198 Is Merged -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicize-glfw-symbol.h" - "#pragma once\n" - "extern __attribute__((visibility(\"default\"))) void _glfwDetectJoystickConnectionLinux(void);\n" -) -target_compile_options(glfw PRIVATE -include PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/publicize-glfw-symbol.h") - # Install install(TARGETS glfw DESTINATION "${MCPI_LIB_DIR}") if(BUILD_ARM_COMPONENTS) diff --git a/media-layer/core/dependencies/glfw/src b/media-layer/core/dependencies/glfw/src index dd8a678..3fa2360 160000 --- a/media-layer/core/dependencies/glfw/src +++ b/media-layer/core/dependencies/glfw/src @@ -1 +1 @@ -Subproject commit dd8a678a66f1967372e5a5e3deac41ebf65ee127 +Subproject commit 3fa2360720eeba1964df3c0ecf4b5df8648a8e52 diff --git a/media-layer/core/src/audio/api.cpp b/media-layer/core/src/audio/api.cpp index a755d76..3d2655d 100644 --- a/media-layer/core/src/audio/api.cpp +++ b/media-layer/core/src/audio/api.cpp @@ -140,11 +140,11 @@ void media_audio_play(const char *source, const char *name, float x, float y, fl // Set Attenuation alSourcei(al_source, AL_DISTANCE_MODEL, AL_LINEAR_DISTANCE_CLAMPED); AL_ERROR_CHECK(); - alSourcef(al_source, AL_MAX_DISTANCE, 22.0f); + alSourcef(al_source, AL_MAX_DISTANCE, 16.0f); AL_ERROR_CHECK(); - alSourcef(al_source, AL_ROLLOFF_FACTOR, 1.0f); + alSourcef(al_source, AL_ROLLOFF_FACTOR, 6.0f); AL_ERROR_CHECK(); - alSourcef(al_source, AL_REFERENCE_DISTANCE, 2.0f); + alSourcef(al_source, AL_REFERENCE_DISTANCE, 5.0f); AL_ERROR_CHECK(); // Set Buffer diff --git a/media-layer/core/src/audio/file.cpp b/media-layer/core/src/audio/file.cpp index c5e76af..34de48c 100644 --- a/media-layer/core/src/audio/file.cpp +++ b/media-layer/core/src/audio/file.cpp @@ -12,14 +12,14 @@ #include "engine.h" // Load Symbol From ELF File -static void load_symbol(const char *source, const char *name, std::function callback) { +static void load_symbol(const char *source, const char *name, std::function callback) { static std::unique_ptr binary = NULL; if (binary == NULL) { binary = LIEF::ELF::Parser::parse(source); } const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name); if (symbol != NULL) { - std::vector data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA); + LIEF::span data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA); callback(data.data(), data.size()); } else { WARN("Unable To Find Symbol: %s", name); @@ -45,7 +45,7 @@ static ALuint load_sound(const char *source, const char *name) { ALuint buffer = 0; // Load Symbol - load_symbol(source, name, [name, &buffer](unsigned char *symbol, uint32_t size) { + load_symbol(source, name, [name, &buffer](const unsigned char *symbol, uint32_t size) { // Load Metadata if (size < sizeof (audio_metadata)) { WARN("Symbol Too Small To Contain Audio Metadata: %s", name); @@ -77,7 +77,7 @@ static ALuint load_sound(const char *source, const char *name) { WARN("Symbol Too Small To Contain Specified Audio Data: %s", name); return; } - unsigned char *data = symbol + sizeof (audio_metadata); + const unsigned char *data = symbol + sizeof (audio_metadata); // Create Buffer alGenBuffers(1, &buffer); diff --git a/media-layer/core/src/media.c b/media-layer/core/src/media.c index ff0bfa7..df00d05 100644 --- a/media-layer/core/src/media.c +++ b/media-layer/core/src/media.c @@ -55,7 +55,8 @@ static void character_event(char c) { // SDL_UserEvent Is Never Used In MCPI, So It Is Repurposed For Character Events SDL_Event event; event.type = SDL_USEREVENT; - event.user.code = (int) c; + event.user.code = USER_EVENT_CHARACTER; + event.user.data1 = (int) c; SDL_PushEvent(&event); } @@ -166,15 +167,22 @@ static SDLMod glfw_modifier_to_sdl_modifier(int mods) { } // Pass Key Presses To SDL -static void glfw_key_raw(int key, __attribute__((unused)) int scancode, int action, int mods) { - SDL_Event event; +static void glfw_key_raw(int key, int scancode, int action, int mods) { + SDL_Event event1; int up = action == GLFW_RELEASE; - event.type = up ? SDL_KEYUP : SDL_KEYDOWN; - event.key.state = up ? SDL_RELEASED : SDL_PRESSED; - event.key.keysym.scancode = key; // Allow MCPI To Access Original GLFW Keycode - event.key.keysym.mod = glfw_modifier_to_sdl_modifier(mods); - event.key.keysym.sym = glfw_key_to_sdl_key(key); - SDL_PushEvent(&event); + event1.type = up ? SDL_KEYUP : SDL_KEYDOWN; + event1.key.state = up ? SDL_RELEASED : SDL_PRESSED; + event1.key.keysym.scancode = scancode; + event1.key.keysym.mod = glfw_modifier_to_sdl_modifier(mods); + event1.key.keysym.sym = glfw_key_to_sdl_key(key); + SDL_PushEvent(&event1); + // Allow MCPI To Access Original GLFW Keycode + SDL_Event event2; + event2.type = SDL_USEREVENT; + event2.user.code = USER_EVENT_REAL_KEY; + event2.user.data1 = event1.key.state; + event2.user.data2 = key; + SDL_PushEvent(&event2); } static void glfw_key(__attribute__((unused)) GLFWwindow *window, int key, int scancode, int action, int mods) { if (is_interactable) { @@ -679,12 +687,6 @@ void _media_handle_SDL_PollEvent() { // Process GLFW Events glfwPollEvents(); - // Fix Joystick Detection While Running (Remove When glfw/glfw#2198 Is Merged) - extern void _glfwDetectJoystickConnectionLinux(void); - if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) { - _glfwDetectJoystickConnectionLinux(); - } - // Controller update_controller_state(); diff --git a/media-layer/include/media-layer/core.h b/media-layer/include/media-layer/core.h index edc6118..2ef93af 100644 --- a/media-layer/include/media-layer/core.h +++ b/media-layer/include/media-layer/core.h @@ -8,6 +8,10 @@ extern "C" { #define DEFAULT_WIDTH 840 #define DEFAULT_HEIGHT 480 +// SDL User Events +#define USER_EVENT_CHARACTER 0 // data1 = 8-Bit Character +#define USER_EVENT_REAL_KEY 1 // data1 = SDL_RELEASED/PRESSED, data2 = GLFW Key Code + void media_ensure_loaded(); void media_toggle_fullscreen(); diff --git a/mods/src/compat/compat.c b/mods/src/compat/compat.c index 06ccd57..d575e5a 100644 --- a/mods/src/compat/compat.c +++ b/mods/src/compat/compat.c @@ -103,8 +103,10 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) { } case SDL_USEREVENT: { // SDL_UserEvent Is Never Used In MCPI, So It Is Repurposed For Character Events - sign_key_press((char) event->user.code); - handled = 1; + if (event->user.code == USER_EVENT_CHARACTER) { + sign_key_press((char) event->user.data1); + handled = 1; + } break; } } diff --git a/mods/src/sound/sound.cpp b/mods/src/sound/sound.cpp index b99f963..c0bfe71 100644 --- a/mods/src/sound/sound.cpp +++ b/mods/src/sound/sound.cpp @@ -59,10 +59,8 @@ std::string _sound_get_source_file() { static void play(std::string name, float x, float y, float z, float volume, float pitch, bool is_ui) { std::string source = _sound_get_source_file(); std::string resolved_name = _sound_pick(name); - if (pitch < 0.5f) { - pitch = 0.5f; - } else if (pitch > 2.0f) { - pitch = 2.0f; + if (pitch < 0.01f) { + pitch = 1; } if (source.size() > 0 && resolved_name.size() > 0) { media_audio_play(source.c_str(), resolved_name.c_str(), x, y, z, pitch, volume, is_ui);