Browse Source

Improve Handling When MCPI-Reborn Directory != MCPI Directory

pull/36/head 2.2.9-flatpak
TheBrokenRail 9 months ago
parent
commit
b36df1d8ff
  1. 19
      launcher/src/bootstrap.c
  2. 2
      media-layer/proxy/src/server/server.cpp
  3. 7
      mods/src/home/home.c

19
launcher/src/bootstrap.c

@ -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...");

2
media-layer/proxy/src/server/server.cpp

@ -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;

7
mods/src/home/home.c

@ -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);
}

Loading…
Cancel
Save