minecraft-pi-reborn/mods/src/home/home.c

32 lines
712 B
C
Raw Normal View History

#include <errno.h>
2021-06-17 21:32:24 +00:00
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2021-06-17 21:32:24 +00:00
2022-06-25 21:30:08 +00:00
#include <mods/home/home.h>
#include <mods/init/init.h>
2021-06-17 21:32:24 +00:00
// Get MCPI Home Directory
char *home_get() {
2021-06-28 20:00:52 +00:00
static char *dir = NULL;
// Load
if (dir == NULL) {
safe_asprintf(&dir, "%s" HOME_SUBDIRECTORY_FOR_GAME_DATA, getenv("HOME"));
2021-06-28 20:00:52 +00:00
}
// Return
2021-06-17 21:32:24 +00:00
return dir;
}
2021-06-28 20:00:52 +00:00
// Free
__attribute__((destructor)) static void _free_home() {
free(home_get());
}
2021-06-17 21:32:24 +00:00
// Init
void init_home() {
// Store Data In ~/.minecraft-pi Instead Of ~/.minecraft
2021-12-01 02:25:04 +00:00
patch_address((void *) full_data_path, (void *) home_get());
2022-04-22 23:38:15 +00:00
// The override code resolves assets manually,
// making changing directory redundant.
2021-06-17 21:32:24 +00:00
}