Some Fixes

This commit is contained in:
TheBrokenRail 2024-11-22 22:02:55 -05:00
parent 4e1476bcfd
commit 3d89fb691a
11 changed files with 49 additions and 41 deletions

View File

@ -60,7 +60,10 @@ string(CONCAT COMPILE_FLAGS_SETUP
"set(CMAKE_CXX_STANDARD 20)\n" "set(CMAKE_CXX_STANDARD 20)\n"
# Skip RPath # Skip RPath
"set(CMAKE_SKIP_BUILD_RPATH TRUE)" "set(CMAKE_SKIP_BUILD_RPATH TRUE)\n"
# Always Build Shared Libraries
"set(BUILD_SHARED_LIBS TRUE CACHE BOOL \"\" FORCE)"
) )
if(BUILD_ARM_COMPONENTS) if(BUILD_ARM_COMPONENTS)
string(CONCAT COMPILE_FLAGS_SETUP string(CONCAT COMPILE_FLAGS_SETUP
@ -122,7 +125,7 @@ endif()
# Install SDK # Install SDK
if(BUILD_ARM_COMPONENTS) if(BUILD_ARM_COMPONENTS)
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" FILE "sdk-targets.cmake" EXPORT_LINK_INTERFACE_LIBRARIES) install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" FILE "sdk-targets.cmake")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake" file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake"
# Sanity Check # Sanity Check
"${ARM_SANITY_CHECK}\n" "${ARM_SANITY_CHECK}\n"

View File

@ -6,7 +6,6 @@ add_compile_options(-w)
## GLFW ## GLFW
# Download # Download
set(BUILD_SHARED_LIBS TRUE CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES FALSE CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES FALSE CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS FALSE CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS FALSE CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS FALSE CACHE BOOL "" FORCE) set(GLFW_BUILD_DOCS FALSE CACHE BOOL "" FORCE)

View File

@ -20,7 +20,7 @@ setup_header_dirs(imgui
"${CMAKE_CURRENT_SOURCE_DIR}/src/backends" "${CMAKE_CURRENT_SOURCE_DIR}/src/backends"
"${CMAKE_CURRENT_SOURCE_DIR}/src/misc/cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/misc/cpp"
) )
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED QUIET)
target_link_libraries(imgui PUBLIC glfw OpenGL::GL) target_link_libraries(imgui PUBLIC glfw OpenGL::GL)
# Fonts # Fonts

View File

@ -5,7 +5,6 @@
#include <cstdio> #include <cstdio>
#include <csignal> #include <csignal>
#include <sys/stat.h> #include <sys/stat.h>
#include <ctime>
#include <string> #include <string>
#include <fcntl.h> #include <fcntl.h>
@ -38,17 +37,13 @@ static void setup_log_file() {
const std::string logs = get_logs_folder(); const std::string logs = get_logs_folder();
// Get Timestamp // Get Timestamp
time_t raw_time; std::string time = format_time("%Y-%m-%d");
time(&raw_time);
const tm *time_info = localtime(&raw_time);
char time[512];
strftime(time, 512, "%Y-%m-%d", time_info);
// Get Log Filename // Get Log Filename
std::string file; std::string file;
int num = 1; int num = 1;
do { do {
file = std::string(time) + '-' + std::to_string(num) + ".log"; file = time + '-' + std::to_string(num) + ".log";
log_filename = logs + '/' + file; log_filename = logs + '/' + file;
num++; num++;
} while (access(log_filename.c_str(), F_OK) != -1); } while (access(log_filename.c_str(), F_OK) != -1);

View File

@ -57,3 +57,7 @@ void safe_write(int fd, const void *buf, size_t size);
// Profile Directory // Profile Directory
std::string home_get(); std::string home_get();
// Format Time
std::string format_time(const char *fmt);
std::string format_time(const char *fmt, int time);

View File

@ -2,6 +2,7 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <cstring> #include <cstring>
#include <ctime>
#include <libreborn/util.h> #include <libreborn/util.h>
#include <libreborn/config.h> #include <libreborn/config.h>
@ -114,3 +115,23 @@ std::string home_get() {
} }
return std::string(home) + std::string(get_home_subdirectory_for_game_data()); return std::string(home) + std::string(get_home_subdirectory_for_game_data());
} }
// Format Time
static std::string _format_time(const char *fmt, const time_t raw_time) {
const tm *time_info = localtime(&raw_time);
if (time_info == nullptr) {
ERR("Unable To Determine Current Time: %s", strerror(errno));
}
char buf[512];
strftime(buf, sizeof(buf), fmt, time_info);
return std::string(buf);
}
std::string format_time(const char *fmt) {
time_t raw_time;
time(&raw_time);
return _format_time(fmt, raw_time);
}
std::string format_time(const char *fmt, const int time) {
// This Will Break In 2038
return _format_time(fmt, time);
}

View File

@ -11,6 +11,6 @@ if(BUILD_MEDIA_LAYER_CORE)
endif() endif()
# Add Trampoline # Add Trampoline
if(MCPI_USE_MEDIA_LAYER_TRAMPOLINE OR BUILD_ARM_COMPONENTS) if(MCPI_USE_MEDIA_LAYER_TRAMPOLINE)
add_subdirectory(trampoline) add_subdirectory(trampoline)
endif() endif()

View File

@ -1,7 +1,7 @@
project(media-layer-core) project(media-layer-core)
# Build # Build
add_library(media-layer-core-real SHARED add_library(media-layer-core SHARED
src/base.cpp src/base.cpp
src/window/media.cpp src/window/media.cpp
src/window/cursor.cpp src/window/cursor.cpp
@ -14,18 +14,12 @@ add_library(media-layer-core-real SHARED
src/audio/file.cpp src/audio/file.cpp
) )
# Set Name
set_target_properties(media-layer-core-real PROPERTIES OUTPUT_NAME "media-layer-core")
if(BUILD_NATIVE_COMPONENTS)
add_library(media-layer-core ALIAS media-layer-core-real)
endif()
# Install # Install
setup_library(media-layer-core-real TRUE FALSE) setup_library(media-layer-core TRUE TRUE)
# Link # Link
find_library(OPENAL_LIBRARY NAMES openal REQUIRED) find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
target_link_libraries(media-layer-core-real target_link_libraries(media-layer-core
PUBLIC PUBLIC
media-layer-headers media-layer-headers
reborn-util reborn-util

View File

@ -7,7 +7,11 @@ set(MEDIA_LAYER_TRAMPOLINE_SRC src/media-layer-core.cpp src/GLESv1_CM.cpp)
if(BUILD_NATIVE_COMPONENTS) if(BUILD_NATIVE_COMPONENTS)
# Host Component # Host Component
add_library(media-layer-trampoline src/host/host.cpp ${MEDIA_LAYER_TRAMPOLINE_SRC}) add_library(media-layer-trampoline src/host/host.cpp ${MEDIA_LAYER_TRAMPOLINE_SRC})
target_link_libraries(media-layer-trampoline reborn-util media-layer-core trampoline-headers) target_link_libraries(media-layer-trampoline
reborn-util
media-layer-core
trampoline-headers
)
target_compile_definitions(media-layer-trampoline PRIVATE MEDIA_LAYER_TRAMPOLINE_HOST) target_compile_definitions(media-layer-trampoline PRIVATE MEDIA_LAYER_TRAMPOLINE_HOST)
# Install # Install
setup_library(media-layer-trampoline TRUE TRUE) setup_library(media-layer-trampoline TRUE TRUE)
@ -20,9 +24,8 @@ elseif(BUILD_ARM_COMPONENTS)
PRIVATE PRIVATE
reborn-util reborn-util
trampoline-headers trampoline-headers
rt
) )
target_compile_definitions(media-layer-core PRIVATE MEDIA_LAYER_TRAMPOLINE_GUEST) target_compile_definitions(media-layer-core PRIVATE MEDIA_LAYER_TRAMPOLINE_GUEST)
# Install # Install
setup_library(media-layer-core "${MCPI_USE_MEDIA_LAYER_TRAMPOLINE}" TRUE) setup_library(media-layer-core TRUE TRUE)
endif() endif()

View File

@ -46,7 +46,7 @@ static void LoginPacket_read_injection(LoginPacket_read_t original, LoginPacket
// Fix RakNet::RakString Security Bug // Fix RakNet::RakString Security Bug
// //
// RakNet::RakString's format constructor is often given unsanitized user input and is never used for formatting, // RakNet::RakString's format constructor is often given un-sanitized user input and is never used for formatting,
// this is a massive security risk, allowing clients to run arbitrary format specifiers, this disables the // this is a massive security risk, allowing clients to run arbitrary format specifiers, this disables the
// formatting functionality. // formatting functionality.
RakNet_RakString_constructor_2_t RakNet_RakString_constructor_2 = (RakNet_RakString_constructor_2_t) 0xea5cc; RakNet_RakString_constructor_2_t RakNet_RakString_constructor_2 = (RakNet_RakString_constructor_2_t) 0xea5cc;
@ -259,12 +259,7 @@ static ItemInstance *Item_getCraftingRemainingItem_injection(__attribute__((unus
// Display Date In Select World Screen // Display Date In Select World Screen
static std::string AppPlatform_linux_getDateString_injection(__attribute__((unused)) AppPlatform_linux *app_platform, const int time) { static std::string AppPlatform_linux_getDateString_injection(__attribute__((unused)) AppPlatform_linux *app_platform, const int time) {
// From https://github.com/ReMinecraftPE/mcpe/blob/56e51027b1c2e67fe5a0e8a091cefe51d4d11926/platforms/sdl/base/AppPlatform_sdl_base.cpp#L68-L84 // From https://github.com/ReMinecraftPE/mcpe/blob/56e51027b1c2e67fe5a0e8a091cefe51d4d11926/platforms/sdl/base/AppPlatform_sdl_base.cpp#L68-L84
const time_t tt = time; return format_time("%b %d %Y %H:%M:%S", time);
tm t = {};
gmtime_r(&tt, &t);
char buf[2048];
strftime(buf, sizeof buf, "%b %d %Y %H:%M:%S", &t);
return std::string(buf);
} }
// Missing Strings // Missing Strings

View File

@ -1,8 +1,6 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <unistd.h> #include <unistd.h>
#include <ctime>
#include <sys/stat.h>
#include "stb_image.h" #include "stb_image.h"
#include "stb_image_write.h" #include "stb_image_write.h"
@ -45,17 +43,13 @@ void screenshot_take(Gui *gui) {
} }
// Get Timestamp // Get Timestamp
time_t raw_time; std::string time = format_time("%Y-%m-%d_%H.%M.%S");
time(&raw_time);
const tm *time_info = localtime(&raw_time);
char time[512];
strftime(time, 512, "%Y-%m-%d_%H.%M.%S", time_info);
// Prevent Overwriting Screenshots // Prevent Overwriting Screenshots
int num = 0; int num = 0;
std::string filename; std::string filename;
do { do {
filename = std::string(time); filename = time;
if (num > 0) { if (num > 0) {
filename += '-' + std::to_string(num); filename += '-' + std::to_string(num);
} }