MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / JoinServer

Function JoinServer

src/openrct2-ui/windows/ServerList.cpp:552–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550 }
551
552 void JoinServer(std::string address)
553 {
554 int32_t port = Network::kDefaultPort;
555 auto endBracketIndex = address.find(']');
556 auto colonIndex = address.find_last_of(':');
557 if (colonIndex != std::string::npos)
558 {
559 if (auto dotIndex = address.find('.'); endBracketIndex != std::string::npos || dotIndex != std::string::npos)
560 {
561 auto ret = std::sscanf(&address[colonIndex + 1], "%d", &port);
562 assert(ret);
563 if (ret > 0)
564 {
565 address = address.substr(0, colonIndex);
566 }
567 }
568 }
569
570 if (auto beginBracketIndex = address.find('[');
571 beginBracketIndex != std::string::npos && endBracketIndex != std::string::npos)
572 {
573 address = address.substr(beginBracketIndex + 1, endBracketIndex - beginBracketIndex - 1);
574 }
575
576 if (!Network::BeginClient(address, port))
577 {
578 ContextShowError(STR_UNABLE_TO_CONNECT_TO_SERVER, kStringIdNone, {});
579 }
580 }
581} // namespace OpenRCT2::Ui::Windows
582#endif

Callers 2

onMouseUpMethod · 0.85
onDropdownMethod · 0.85

Calls 3

BeginClientFunction · 0.85
ContextShowErrorFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected