Commit 3e9c6036 authored by nanahira's avatar nanahira

finish

parent 454d04b4
Pipeline #16755 failed with stages
in 4 minutes and 9 seconds
......@@ -4361,11 +4361,11 @@ unsigned int DuelClient::LookupHost(char *host) {
if (status != 0) {
return 0;
}
evutil_freeaddrinfo(answer);
sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr);
char ip[20];
evutil_inet_ntop(AF_INET, &(sin->sin_addr), ip, 20);
remote_addr = htonl(inet_addr(ip));
evutil_freeaddrinfo(answer);
}
return remote_addr;
}
......@@ -4411,7 +4411,6 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
rnd.reset((unsigned int)time(nullptr));
rnd.shuffle_vector(records);
auto record = records.front();
printf("Result: %s:%d\n", record.host, record.port);
memcpy(resolved, record.host, 100);
result->port = record.port;
#endif
......@@ -4431,7 +4430,9 @@ HostResult DuelClient::ParseHost(char *hostname) {
}
} else {
char host[100];
strncpy(host, hostname, trySplitter - hostname);
auto hostLength = trySplitter - hostname;
strncpy(host, hostname, hostLength);
host[hostLength] = '\0';
result.host = LookupHost(host);
result.port = atoi(trySplitter + 1);
}
......
......@@ -69,6 +69,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
const wchar_t* pstr = mainGame->ebJoinHost->getText();
BufferIO::CopyWStr(pstr, hostname, 100);
HostResult remote = DuelClient::ParseHost(hostname);
==
if(!remote.isValid()) {
mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment