minecraft-pi-reborn/mods/src/version/version.cpp

38 lines
989 B
C++
Raw Permalink Normal View History

2021-06-28 20:00:52 +00:00
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2021-06-28 20:00:52 +00:00
2022-06-25 21:30:08 +00:00
#include <mods/version/version.h>
#include <mods/init/init.h>
2021-06-28 20:00:52 +00:00
// Get New Version
char *version_get() {
2024-04-02 23:22:01 +00:00
static char *version = nullptr;
2021-06-28 20:00:52 +00:00
// Load
2024-04-02 23:22:01 +00:00
if (version == nullptr) {
2024-01-07 07:59:04 +00:00
safe_asprintf(&version, "%s / Reborn v%s", Strings_minecraft_pi_version, reborn_get_version());
2021-06-28 20:00:52 +00:00
}
// Return
return version;
}
// Free
__attribute__((destructor)) static void _free_version() {
free(version_get());
}
// Injection For Touch GUI Version
2024-05-05 00:46:15 +00:00
static std::string Common_getGameVersionString_injection(__attribute__((unused)) std::string *version_suffix) {
2021-06-28 20:00:52 +00:00
// Set Version
return version_get();
}
// Init
void init_version() {
// Touch GUI
2024-05-05 00:46:15 +00:00
overwrite(Common_getGameVersionString, Common_getGameVersionString_injection);
2021-06-28 20:00:52 +00:00
// Normal GUI
2024-01-07 07:59:04 +00:00
patch_address((void *) Strings_minecraft_pi_version_pointer, version_get());
2021-11-14 04:29:48 +00:00
// Log
INFO("Starting Minecraft: Pi Edition (%s)", version_get());
2021-06-28 20:00:52 +00:00
}