Show Reborn Version In Start Screen
minecraft-pi-reborn/pipeline/head This commit looks good Details

remotes/1694384457978408539/master 2.0.5
TheBrokenRail 2021-06-28 16:00:52 -04:00
parent 2b0d1d55ff
commit 053bf4aa5f
18 changed files with 88 additions and 13 deletions

View File

@ -94,6 +94,10 @@ if(MCPI_SERVER_MODE)
add_definitions(-DMCPI_SERVER_MODE)
endif()
# Version
file(STRINGS VERSION VERSION)
add_definitions(-DVERSION="${VERSION}")
# Build libreborn
add_subdirectory(libreborn)

View File

@ -1,6 +1,7 @@
# Changelog
**2.0.5**
* Show Reborn Version In Start Screen
* External Server Support
**2.0.4**

View File

@ -3,7 +3,7 @@ Name=Minecraft: Pi Edition: Reborn
Comment=Fun with Blocks
Icon=/usr/share/pixmaps/minecraft-pi-reborn-client.png
StartupNotify=false
StartupWMClass=Minecraft - Pi edition
StartupWMClass=Minecraft: Pi Edition: Reborn
Exec=/usr/bin/minecraft-pi-reborn-client
Terminal=false
Type=Application

View File

@ -106,7 +106,7 @@ static void run_zenity_and_set_env(const char *env_name, std::vector<std::string
std::vector<std::string> full_command;
full_command.push_back("zenity");
full_command.push_back("--class");
full_command.push_back("Minecraft - Pi edition");
full_command.push_back("Minecraft: Pi Edition: Reborn");
full_command.insert(full_command.end(), command.begin(), command.end());
// Convert To C Array
const char *full_command_array[full_command.size() + 1];

View File

@ -17,6 +17,7 @@ static renderCursor_t renderCursor = (renderCursor_t) 0x480c4;
static char **default_path = (char **) 0xe264; // /.minecraft/
static char **default_username = (char **) 0x18fd4; // StevePi
static char **minecraft_pi_version = (char **) 0x39d94; // v0.1.1 alpha
static unsigned char **Item_flintAndSteel = (unsigned char **) 0x17ba70;
static unsigned char **Item_snowball = (unsigned char **) 0x17bbb0;
@ -477,6 +478,11 @@ static SelectWorldScreen_getUniqueLevelName_t SelectWorldScreen_getUniqueLevelNa
static SelectWorldScreen_getUniqueLevelName_t Touch_SelectWorldScreen_getUniqueLevelName = (SelectWorldScreen_getUniqueLevelName_t) 0x3d82c;
// Common
typedef std::string (*Common_getGameVersionString_t)(std::string const& version_suffix);
static Common_getGameVersionString_t Common_getGameVersionString = (Common_getGameVersionString_t) 0x15068;
#endif
#pragma GCC diagnostic pop

View File

@ -15,9 +15,12 @@ add_library(readdir SHARED src/readdir/readdir.c)
add_library(feature SHARED src/feature/feature.c)
target_link_libraries(feature reborn)
add_library(version SHARED src/version/version.cpp)
target_link_libraries(version reborn)
if(MCPI_SERVER_MODE)
add_library(server SHARED src/server/server.cpp src/server/server_properties.cpp)
target_link_libraries(server reborn feature home compat dl media-layer-core pthread)
target_link_libraries(server reborn feature home compat version dl media-layer-core pthread)
else()
add_library(multiplayer SHARED src/multiplayer/multiplayer.cpp)
target_link_libraries(multiplayer reborn home)
@ -60,7 +63,7 @@ add_library(test SHARED src/test/test.c)
target_link_libraries(test reborn home)
add_library(init SHARED src/init/init.c)
target_link_libraries(init compat game_mode camera input misc death options touch textures chat home test)
target_link_libraries(init compat game_mode camera input misc death options touch textures chat home version test)
if(MCPI_SERVER_MODE)
target_link_libraries(init server)
else()
@ -68,7 +71,7 @@ else()
endif()
## Install Mods
install(TARGETS init compat readdir feature override game_mode camera input misc death options touch textures chat home test DESTINATION "${MCPI_INSTALL_DIR}/mods")
install(TARGETS init compat readdir feature override game_mode camera input misc death options touch textures chat home version test DESTINATION "${MCPI_INSTALL_DIR}/mods")
if(MCPI_SERVER_MODE)
install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods")
else()

View File

@ -42,7 +42,7 @@ unsigned int chat_get_counter() {
static void *chat_thread(__attribute__((unused)) void *nop) {
// Open
int return_code;
char *output = run_command("zenity --title \"Chat\" --class \"Minecraft - Pi edition\" --entry --text \"Enter Chat Message:\"", &return_code);
char *output = run_command("zenity --title 'Chat' --class 'Minecraft: Pi Edition: Reborn' --entry --text 'Enter Chat Message:'", &return_code);
// Handle Message
if (output != NULL) {
// Check Return Code

View File

@ -12,6 +12,12 @@
#include "../init/init.h"
#include "compat.h"
// Custom Title
HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) {
ensure_SDL_WM_SetCaption();
(*real_SDL_WM_SetCaption)("Minecraft: Pi Edition: Reborn", icon);
}
// Mouse Cursor Is Always Invisible In Vanilla MCPI
// Because In Vanilla MCPI, The GPU Overlay Covered The Normal Mouse Cursor
HOOK(SDL_ShowCursor, int, (int toggle)) {

View File

@ -31,10 +31,18 @@ HOOK(getenv, char *, (const char *name)) {
// Get MCPI Home Directory
char *home_get() {
char *dir = NULL;
safe_asprintf(&dir, "%s/" NEW_PATH, getenv("HOME"));
static char *dir = NULL;
// Load
if (dir == NULL) {
safe_asprintf(&dir, "%s/" NEW_PATH, getenv("HOME"));
}
// Return
return dir;
}
// Free
__attribute__((destructor)) static void _free_home() {
free(home_get());
}
// Init
void init_home() {

View File

@ -4,7 +4,7 @@
extern "C" {
#endif
char *home_get(); // Remember To free()
char *home_get();
#ifdef __cplusplus
}

View File

@ -18,4 +18,5 @@ __attribute__((constructor)) static void init() {
init_textures();
init_chat();
init_home();
init_version();
}

View File

@ -21,6 +21,7 @@ void init_touch();
void init_textures();
void init_chat();
void init_home();
void init_version();
#ifdef __cplusplus
}

View File

@ -20,8 +20,6 @@ static char *get_override_path(const char *filename) {
// Get Asset Override Path
char *overrides = NULL;
safe_asprintf(&overrides, "%s/overrides", home_path);
// Free Home Path
free(home_path);
// Get Data Path
char *data = NULL;
char *cwd = getcwd(NULL, 0);

View File

@ -23,6 +23,7 @@
#include "../init/init.h"
#include "../home/home.h"
#include "../compat/compat.h"
#include "../version/version.h"
#include <libreborn/minecraft.h>
@ -65,7 +66,7 @@ static std::string get_world_name() {
// Create/Start World
static void start_world(unsigned char *minecraft) {
INFO("%s", "Starting Minecraft: Pi Edition Dedicated Server");
INFO("Starting Minecraft: Pi Edition: Dedicated Server (%s)", version_get());
// Specify Level Settings
LevelSettings settings;

View File

@ -13,7 +13,6 @@ void run_tests() {
char *path = home_get();
int exists = access(path, F_OK) == 0;
int can_write = exists ? access(path, R_OK | W_OK) == 0 : 1;
free(path);
if (!can_write) {
// Failure

View File

@ -0,0 +1,2 @@
# ``version`` Mod
This mod adds the MCPI-Reborn version to the start screen.

View File

@ -0,0 +1,34 @@
#include <libreborn/libreborn.h>
#include <libreborn/minecraft.h>
#include "version.h"
#include "../init/init.h"
// Get New Version
char *version_get() {
static char *version = NULL;
// Load
if (version == NULL) {
safe_asprintf(&version, "%s / Reborn v" VERSION, *minecraft_pi_version);
}
// Return
return version;
}
// Free
__attribute__((destructor)) static void _free_version() {
free(version_get());
}
// Injection For Touch GUI Version
static std::string Common_getGameVersionString_injection(__attribute__((unused)) std::string const& version_suffix) {
// Set Version
return version_get();
}
// Init
void init_version() {
// Touch GUI
overwrite((void *) Common_getGameVersionString, (void *) Common_getGameVersionString_injection);
// Normal GUI
patch_address((void *) minecraft_pi_version, version_get());
}

View File

@ -0,0 +1,11 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
char *version_get();
#ifdef __cplusplus
}
#endif