From 0bce0d17ac8af189bf196c36b2ccf3d9ec705d04 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Tue, 29 Jun 2021 16:19:02 -0400 Subject: [PATCH] Use Default Port In servers.txt If Not Specified --- VERSION | 2 +- docs/CHANGELOG.md | 3 +++ docs/MULTIPLAYER.md | 6 ++++-- libreborn/include/libreborn/minecraft.h | 2 +- mods/src/multiplayer/multiplayer.cpp | 21 ++++++++++++--------- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index f1547e6d..815e68dd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.7 +2.0.8 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f4b147e9..38e93371 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +**2.0.8** +* Use Default Port In ``servers.txt`` If Not Specified + **2.0.7** * Fix Sign Text Not Updating In Multiplayer When Exiting Editing UI Using Escape Button * Fix Item Dropping Not Working diff --git a/docs/MULTIPLAYER.md b/docs/MULTIPLAYER.md index 46786303..0fd62efe 100644 --- a/docs/MULTIPLAYER.md +++ b/docs/MULTIPLAYER.md @@ -9,6 +9,8 @@ Unlike vanilla MCPI, MCPI-Reborn allows you to natively join a server outside of ### Example ``~/.minecraft-pi/servers.txt`` ``` -# Comment -example.com:19132 +# Default Port Is 19132 +example.com +# Custom Port +example.com:19133 ``` diff --git a/libreborn/include/libreborn/minecraft.h b/libreborn/include/libreborn/minecraft.h index f689de50..8952e7e3 100644 --- a/libreborn/include/libreborn/minecraft.h +++ b/libreborn/include/libreborn/minecraft.h @@ -110,7 +110,7 @@ static Minecraft_grabMouse_t Minecraft_grabMouse = (Minecraft_grabMouse_t) 0x15d typedef void (*Minecraft_leaveGame_t)(unsigned char *minecraft, bool save_remote_level); static Minecraft_leaveGame_t Minecraft_leaveGame = (Minecraft_leaveGame_t) 0x15ea0; -typedef void (*Minecraft_handleBack_t)(unsigned char *minecraft, bool param_1); +typedef int (*Minecraft_handleBack_t)(unsigned char *minecraft, bool param_1); static uint32_t Minecraft_handleBack_vtable_offset = 0x34; static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t diff --git a/mods/src/multiplayer/multiplayer.cpp b/mods/src/multiplayer/multiplayer.cpp index 0fdee570..c2da8309 100644 --- a/mods/src/multiplayer/multiplayer.cpp +++ b/mods/src/multiplayer/multiplayer.cpp @@ -35,7 +35,7 @@ static void load_servers() { // Write Defaults std::ofstream server_list_file_output(file); server_list_file_output << "# External Servers File\n"; - server_list_file_output << "thebrokenrail.com:19132\n"; + server_list_file_output << "thebrokenrail.com\n"; server_list_file_output.close(); // Re-Open Stream server_list_file = std::ifstream(file); @@ -58,15 +58,18 @@ static void load_servers() { // Parse std::string address; std::string port_str; - // Loop + // Add Default Port If Needed size_t last_colon = line.find_last_of(':'); - if (last_colon != std::string::npos) { - for (std::string::size_type i = 0; i < line.length(); i++) { - if (i > last_colon) { - port_str.push_back(line[i]); - } else if (i < last_colon) { - address.push_back(line[i]); - } + if (last_colon == std::string::npos) { + line.append(":19132"); + last_colon = line.find_last_of(':'); + } + // Loop + for (std::string::size_type i = 0; i < line.length(); i++) { + if (i > last_colon) { + port_str.push_back(line[i]); + } else if (i < last_colon) { + address.push_back(line[i]); } } // Check Line