mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 16:45:48 -04:00
Launcher: Assume port 25565 in Direct Connect when no port is given, instead of erroring
This commit is contained in:
parent
cacb52b595
commit
607e14a087
@ -563,6 +563,7 @@ static void DirectConnectScreen_Load(struct DirectConnectScreen* s) {
|
||||
|
||||
static void DirectConnectScreen_StartClient(void* w, int idx) {
|
||||
static const cc_string defMppass = String_FromConst("(none)");
|
||||
static const cc_string defPort = String_FromConst("25565");
|
||||
const cc_string* user = &DirectConnectScreen_Instance.iptUsername.text;
|
||||
const cc_string* addr = &DirectConnectScreen_Instance.iptAddress.text;
|
||||
const cc_string* mppass = &DirectConnectScreen_Instance.iptMppass.text;
|
||||
@ -571,12 +572,18 @@ static void DirectConnectScreen_StartClient(void* w, int idx) {
|
||||
cc_uint16 raw_port;
|
||||
|
||||
int index = String_LastIndexOf(addr, ':');
|
||||
if (index <= 0 || index == addr->length - 1) {
|
||||
if (index == 0 || index == addr->length - 1) {
|
||||
DirectConnectScreen_SetStatus("&eInvalid address"); return;
|
||||
}
|
||||
|
||||
ip = String_UNSAFE_Substring(addr, 0, index);
|
||||
port = String_UNSAFE_SubstringAt(addr, index + 1);
|
||||
/* support either "[IP]" or "[IP]:[PORT]" */
|
||||
if (index == -1) {
|
||||
ip = *addr;
|
||||
port = defPort;
|
||||
} else {
|
||||
ip = String_UNSAFE_Substring(addr, 0, index);
|
||||
port = String_UNSAFE_SubstringAt(addr, index + 1);
|
||||
}
|
||||
|
||||
if (!user->length) {
|
||||
DirectConnectScreen_SetStatus("&eUsername required"); return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user