Use Default Port In servers.txt If Not Specified

This commit is contained in:
TheBrokenRail 2021-06-29 16:19:02 -04:00
parent 0c0a61cd23
commit 0bce0d17ac
5 changed files with 21 additions and 13 deletions

View File

@ -1 +1 @@
2.0.7 2.0.8

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
**2.0.8**
* Use Default Port In ``servers.txt`` If Not Specified
**2.0.7** **2.0.7**
* Fix Sign Text Not Updating In Multiplayer When Exiting Editing UI Using Escape Button * Fix Sign Text Not Updating In Multiplayer When Exiting Editing UI Using Escape Button
* Fix Item Dropping Not Working * Fix Item Dropping Not Working

View File

@ -9,6 +9,8 @@ Unlike vanilla MCPI, MCPI-Reborn allows you to natively join a server outside of
### Example ``~/.minecraft-pi/servers.txt`` ### Example ``~/.minecraft-pi/servers.txt``
``` ```
# Comment # Default Port Is 19132
example.com:19132 example.com
# Custom Port
example.com:19133
``` ```

View File

@ -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); typedef void (*Minecraft_leaveGame_t)(unsigned char *minecraft, bool save_remote_level);
static Minecraft_leaveGame_t Minecraft_leaveGame = (Minecraft_leaveGame_t) 0x15ea0; 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_handleBack_vtable_offset = 0x34;
static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t

View File

@ -35,7 +35,7 @@ static void load_servers() {
// Write Defaults // Write Defaults
std::ofstream server_list_file_output(file); std::ofstream server_list_file_output(file);
server_list_file_output << "# External Servers File\n"; 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(); server_list_file_output.close();
// Re-Open Stream // Re-Open Stream
server_list_file = std::ifstream(file); server_list_file = std::ifstream(file);
@ -58,15 +58,18 @@ static void load_servers() {
// Parse // Parse
std::string address; std::string address;
std::string port_str; std::string port_str;
// Loop // Add Default Port If Needed
size_t last_colon = line.find_last_of(':'); size_t last_colon = line.find_last_of(':');
if (last_colon != std::string::npos) { if (last_colon == std::string::npos) {
for (std::string::size_type i = 0; i < line.length(); i++) { line.append(":19132");
if (i > last_colon) { last_colon = line.find_last_of(':');
port_str.push_back(line[i]); }
} else if (i < last_colon) { // Loop
address.push_back(line[i]); 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 // Check Line