Bug Fixes & Improvements
This commit is contained in:
parent
18b25486e7
commit
07f5e188f7
@ -77,3 +77,4 @@ TRUE Hide Crosshair In Third-Person
|
||||
TRUE Fix Camera Legs
|
||||
TRUE Implement Crafting Remainders
|
||||
TRUE Fix Door Duplication
|
||||
TRUE Fix Cobweb Lighting
|
@ -68,7 +68,7 @@ static void setup_log_file() {
|
||||
// Get Timestamp
|
||||
time_t raw_time;
|
||||
time(&raw_time);
|
||||
tm *time_info = localtime(&raw_time);
|
||||
const tm *time_info = localtime(&raw_time);
|
||||
char time[512];
|
||||
strftime(time, 512, "%Y-%m-%d", time_info);
|
||||
|
||||
|
@ -45,7 +45,13 @@ static void setup_environment(const options_t &options) {
|
||||
}
|
||||
|
||||
// Setup MCPI_HOME
|
||||
if (!reborn_is_server()) {
|
||||
if (const char *custom_profile_directory = getenv(MCPI_PROFILE_DIRECTORY_ENV); custom_profile_directory != nullptr) {
|
||||
// Custom Directory
|
||||
custom_profile_directory = realpath(custom_profile_directory, nullptr);
|
||||
ALLOC_CHECK(custom_profile_directory);
|
||||
set_and_print_env(_MCPI_HOME_ENV, custom_profile_directory);
|
||||
free((void *) custom_profile_directory);
|
||||
} else if (!reborn_is_server()) {
|
||||
// Ensure $HOME
|
||||
const char *home = getenv("HOME");
|
||||
if (home == nullptr) {
|
||||
|
@ -8,32 +8,58 @@
|
||||
#include "bootstrap.h"
|
||||
|
||||
// Get All Mods In Folder
|
||||
static void load(std::string &ld_preload, const std::string &folder) {
|
||||
static void load(std::string &ld_preload, const std::string &folder, int recursion_limit = 128);
|
||||
static void handle_file(std::string &ld_preload, const std::string &file, const int recursion_limit) {
|
||||
// Check Type
|
||||
struct stat file_stat = {};
|
||||
lstat(file.c_str(), &file_stat);
|
||||
if (S_ISDIR(file_stat.st_mode)) {
|
||||
// Recurse Into Directory
|
||||
load(ld_preload, std::string(file) + "/", recursion_limit - 1);
|
||||
} else if (S_ISLNK(file_stat.st_mode)) {
|
||||
// Resolve Symlink
|
||||
char *resolved_file = realpath(file.c_str(), nullptr);
|
||||
ALLOC_CHECK(resolved_file);
|
||||
handle_file(ld_preload, resolved_file, recursion_limit);
|
||||
free(resolved_file);
|
||||
} else if (S_ISREG(file_stat.st_mode)) {
|
||||
// Check If File Is Accessible
|
||||
const int result = access(file.c_str(), R_OK);
|
||||
if (result == 0) {
|
||||
// Add To LD_PRELOAD
|
||||
ld_preload += file + ":";
|
||||
} else if (result == -1 && errno != 0) {
|
||||
// Fail
|
||||
WARN("Unable To Access: %s: %s", file.c_str(), strerror(errno));
|
||||
errno = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
static void load(std::string &ld_preload, const std::string &folder, const int recursion_limit) {
|
||||
// Check Recursion
|
||||
if (recursion_limit <= 0) {
|
||||
ERR("Reached Recursion Limit While Loading Mods");
|
||||
}
|
||||
// Open Folder
|
||||
ensure_directory(folder.c_str());
|
||||
DIR *dp = opendir(folder.c_str());
|
||||
if (dp != nullptr) {
|
||||
if (dp == nullptr) {
|
||||
// Unable To Open Folder
|
||||
ERR("Error Opening Directory: %s: %s", folder.c_str(), strerror(errno));
|
||||
}
|
||||
// Loop Through Folder
|
||||
while (true) {
|
||||
errno = 0;
|
||||
dirent *entry = readdir(dp);
|
||||
const dirent *entry = readdir(dp);
|
||||
if (entry != nullptr) {
|
||||
// Check If File Is Regular
|
||||
if (entry->d_type == DT_REG) {
|
||||
// Block Pseudo-Directories
|
||||
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
|
||||
continue;
|
||||
}
|
||||
// Get Full Name
|
||||
std::string name = folder + entry->d_name;
|
||||
|
||||
// Check If File Is Accessible
|
||||
int result = access(name.c_str(), R_OK);
|
||||
if (result == 0) {
|
||||
// Add To LD_PRELOAD
|
||||
ld_preload += name + ":";
|
||||
} else if (result == -1 && errno != 0) {
|
||||
// Fail
|
||||
WARN("Unable To Access: %s: %s", name.c_str(), strerror(errno));
|
||||
errno = 0;
|
||||
}
|
||||
}
|
||||
// Handle
|
||||
handle_file(ld_preload, name, recursion_limit);
|
||||
} else if (errno != 0) {
|
||||
// Error Reading Contents Of Folder
|
||||
ERR("Error Reading Directory: %s: %s", folder.c_str(), strerror(errno));
|
||||
@ -44,10 +70,6 @@ static void load(std::string &ld_preload, const std::string &folder) {
|
||||
}
|
||||
// Close Folder
|
||||
closedir(dp);
|
||||
} else {
|
||||
// Unable To Open Folder
|
||||
ERR("Error Opening Directory: %s: %s", folder.c_str(), strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
// Bootstrap Mods
|
||||
@ -59,7 +81,7 @@ std::string bootstrap_mods(const std::string &binary_directory) {
|
||||
// ~/.minecraft-pi/mods
|
||||
{
|
||||
// Get Mods Folder
|
||||
std::string mods_folder = std::string(getenv(_MCPI_HOME_ENV)) + get_home_subdirectory_for_game_data() + SUBDIRECTORY_FOR_MODS;
|
||||
const std::string mods_folder = std::string(getenv(_MCPI_HOME_ENV)) + get_home_subdirectory_for_game_data() + SUBDIRECTORY_FOR_MODS;
|
||||
// Load Mods From ./mods
|
||||
load(preload, mods_folder);
|
||||
}
|
||||
@ -67,7 +89,7 @@ std::string bootstrap_mods(const std::string &binary_directory) {
|
||||
// Built-In Mods
|
||||
{
|
||||
// Get Mods Folder
|
||||
std::string mods_folder = binary_directory + SUBDIRECTORY_FOR_MODS;
|
||||
const std::string mods_folder = binary_directory + SUBDIRECTORY_FOR_MODS;
|
||||
// Load Mods From ./mods
|
||||
load(preload, mods_folder);
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ void copy_sdk(const std::string &binary_directory, const bool log_with_debug) {
|
||||
}
|
||||
|
||||
// Lock File
|
||||
std::string lock_file_path = sdk_path + "/.lock";
|
||||
int lock_file_fd = lock_file(lock_file_path.c_str());
|
||||
const std::string lock_file_path = sdk_path + "/.lock";
|
||||
const int lock_file_fd = lock_file(lock_file_path.c_str());
|
||||
|
||||
// Output Directory
|
||||
std::string output = sdk_path + "/" MCPI_SDK_DIR;
|
||||
const std::string output = sdk_path + "/" MCPI_SDK_DIR;
|
||||
// Source Directory
|
||||
std::string source = binary_directory + "/sdk/.";
|
||||
const std::string source = binary_directory + "/sdk/.";
|
||||
|
||||
// Clean
|
||||
{
|
||||
|
@ -22,3 +22,4 @@ ENV(MCPI_BLOCK_OUTLINE_WIDTH, "Custom Width For Block Outline (In Pixels)")
|
||||
ENV(MCPI_GUI_SCALE, "Custom GUI Scale")
|
||||
// $HOME
|
||||
ENV(_MCPI_HOME, "")
|
||||
ENV(MCPI_PROFILE_DIRECTORY, "Custom Profile Directory")
|
@ -40,7 +40,7 @@ int lock_file(const char *file) {
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
void unlock_file(const char *file, int fd) {
|
||||
void unlock_file(const char *file, const int fd) {
|
||||
if (flock(fd, LOCK_UN) == -1) {
|
||||
ERR("Unable To Unlock File: %s: %s", file, strerror(errno));
|
||||
}
|
||||
@ -84,7 +84,10 @@ void reborn_check_display() {
|
||||
|
||||
// Home Subdirectory
|
||||
const char *get_home_subdirectory_for_game_data() {
|
||||
if (!reborn_is_server()) {
|
||||
if (getenv(MCPI_PROFILE_DIRECTORY_ENV) != NULL) {
|
||||
// No Subdirectory When Using Custom Profile Directory
|
||||
return "";
|
||||
} else if (!reborn_is_server()) {
|
||||
// Store Game Data In "~/.minecraft-pi" Instead Of "~/.minecraft" To Avoid Conflicts
|
||||
return "/.minecraft-pi";
|
||||
} else {
|
||||
|
@ -781,6 +781,11 @@ static void DoorTile_neighborChanged_Tile_spawnResources_injection(DoorTile *sel
|
||||
self->spawnResources(level, x, y, z, data2, 1);
|
||||
}
|
||||
|
||||
// Fix Cobweb Lighting
|
||||
static Tile *Tile_initTiles_WebTile_setLightBlock_injection(Tile *self, __attribute__((unused)) int strength) {
|
||||
return self;
|
||||
}
|
||||
|
||||
// Init
|
||||
template <typename... Args>
|
||||
static void nop(__attribute__((unused)) Args... args) {
|
||||
@ -1055,6 +1060,11 @@ void init_misc() {
|
||||
overwrite_call((void *) 0xbe110, (void *) DoorTile_neighborChanged_Tile_spawnResources_injection);
|
||||
}
|
||||
|
||||
// Fix Cobweb Lighting
|
||||
if (feature_has("Fix Cobweb Lighting", server_enabled)) {
|
||||
overwrite_call((void *) 0xc444c, (void *) Tile_initTiles_WebTile_setLightBlock_injection);
|
||||
}
|
||||
|
||||
// Init Logging
|
||||
_init_misc_logging();
|
||||
_init_misc_api();
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <symbols/minecraft.h>
|
||||
#include <GLES/gl.h>
|
||||
|
||||
#include <mods/home/home.h>
|
||||
#include <mods/touch/touch.h>
|
||||
#include <mods/misc/misc.h>
|
||||
#include <mods/options/info.h>
|
||||
@ -45,11 +46,19 @@ static std::string profile_directory_suffix =
|
||||
std::string(get_home_subdirectory_for_game_data())
|
||||
;
|
||||
static std::string get_profile_directory_url() {
|
||||
std::string directory;
|
||||
if (getenv(MCPI_PROFILE_DIRECTORY_ENV) != nullptr) {
|
||||
// Using Custom Directory
|
||||
directory = home_get();
|
||||
} else {
|
||||
// Determine Proper Directory
|
||||
const char *home = getenv("HOME");
|
||||
if (home == nullptr) {
|
||||
IMPOSSIBLE();
|
||||
}
|
||||
return std::string("file://") + home + profile_directory_suffix;
|
||||
directory = home + profile_directory_suffix;
|
||||
}
|
||||
return std::string("file://") + directory;
|
||||
}
|
||||
|
||||
// Info Data
|
||||
|
@ -55,6 +55,7 @@ virtual-method Tile *setLightEmission(float light) = 0xf0;
|
||||
virtual-method Tile *setExplodeable(float explodeable) = 0xf4;
|
||||
virtual-method Tile *setDestroyTime(float destroy_time) = 0xf8;
|
||||
virtual-method void spawnResources(Level *level, int x, int y, int z, int data, float chance) = 0x80;
|
||||
virtual-method Tile *setLightBlock(int strength) = 0xec;
|
||||
|
||||
property int texture = 0x4;
|
||||
property int id = 0x8;
|
||||
|
Loading…
Reference in New Issue
Block a user