Improve Handling When MCPI-Reborn Directory != MCPI Directory

This commit is contained in:
TheBrokenRail 2021-12-19 18:24:59 -05:00
parent bf58129164
commit b36df1d8ff
3 changed files with 26 additions and 2 deletions

View File

@ -149,7 +149,7 @@ void bootstrap(int argc, char *argv[]) {
// Add Library Directory
char *new_ld_path;
safe_asprintf(&new_ld_path, "%s/lib", binary_directory);
// Add Existing LD_LIBRAR_PATH
// Add Existing LD_LIBRARY_PATH
{
char *value = get_env_safe("LD_LIBRARY_PATH");
if (strlen(value) > 0) {
@ -194,6 +194,23 @@ void bootstrap(int argc, char *argv[]) {
free(new_ld_preload);
}
// Configure PATH
{
// Add Library Directory
char *new_path;
safe_asprintf(&new_path, "%s/lib", binary_directory);
// Add Existing PATH
{
char *value = get_env_safe("PATH");
if (strlen(value) > 0) {
string_append(&new_path, ":%s", value);
}
}
// Set And Free
set_and_print_env("PATH", new_path);
free(new_path);
}
// Start Game
INFO("%s", "Starting Game...");

View File

@ -79,7 +79,7 @@ static void start_media_layer_proxy_client(int read, int write) {
char *argv[] = {NULL /* Updated By safe_execvpe() */, read_str, write_str, NULL};
// Run
safe_execvpe_relative_to_binary("lib/media-layer-proxy-client", argv, environ);
safe_execvpe("media-layer-proxy-client", argv, environ);
} else {
// Parent Process
_client_pid = ret;

View File

@ -54,4 +54,11 @@ __attribute__((destructor)) static void _free_home() {
void init_home() {
// Store Data In ~/.minecraft-pi Instead Of ~/.minecraft
patch_address((void *) default_path, (void *) NEW_PATH);
// Change Directory To Binary Directory Manually
unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
patch((void *) 0xe0ac, nop_patch);
char *binary_directory = get_binary_directory();
chdir(binary_directory);
free(binary_directory);
}