This commit is contained in:
parent
e0ab968fa3
commit
c3fda82642
2
dependencies/LIEF/src
vendored
2
dependencies/LIEF/src
vendored
@ -1 +1 @@
|
||||
Subproject commit 2169578d46934c973fdbfa2fae23b192e3cac8a0
|
||||
Subproject commit 966a66c78a498ed694f28a25b350853852612c4d
|
@ -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)
|
||||
|
BIN
images/start.png
BIN
images/start.png
Binary file not shown.
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 155 KiB |
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit dd8a678a66f1967372e5a5e3deac41ebf65ee127
|
||||
Subproject commit 3fa2360720eeba1964df3c0ecf4b5df8648a8e52
|
@ -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
|
||||
|
@ -12,14 +12,14 @@
|
||||
#include "engine.h"
|
||||
|
||||
// Load Symbol From ELF File
|
||||
static void load_symbol(const char *source, const char *name, std::function<void(unsigned char *, uint32_t)> callback) {
|
||||
static void load_symbol(const char *source, const char *name, std::function<void(const unsigned char *, uint32_t)> callback) {
|
||||
static std::unique_ptr<LIEF::ELF::Binary> 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<uint8_t> data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA);
|
||||
LIEF::span<const uint8_t> 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);
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user