mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 04:53:12 +01:00
Refactor, remove temporary console logging
This commit is contained in:
@@ -87,7 +87,7 @@ private:
|
||||
uint16 _listeningPort = 0;
|
||||
SOCKET _socket = INVALID_SOCKET;
|
||||
|
||||
std::string _hostStr;
|
||||
std::string _hostName;
|
||||
|
||||
SDL_mutex * _connectMutex = nullptr;
|
||||
std::string _error;
|
||||
@@ -205,12 +205,20 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
char hoststr[NI_MAXHOST];
|
||||
int rc = getnameinfo((struct sockaddr *)&client_addr, client_len, hoststr, sizeof(hoststr), nullptr, 0, NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
char hostName[NI_MAXHOST];
|
||||
int rc = getnameinfo(
|
||||
(struct sockaddr *)&client_addr,
|
||||
client_len,
|
||||
hostName,
|
||||
sizeof(hostName),
|
||||
nullptr,
|
||||
0,
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
SetTCPNoDelay(socket, true);
|
||||
tcpSocket = new TcpSocket(socket);
|
||||
if (rc == 0)
|
||||
tcpSocket->SetHostStr(hoststr);
|
||||
if (rc == 0) {
|
||||
_hostName = std::string(hostName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tcpSocket;
|
||||
@@ -411,14 +419,9 @@ public:
|
||||
SDL_UnlockMutex(_connectMutex);
|
||||
}
|
||||
|
||||
const char * GetHostStr() override
|
||||
const char * GetHostName() const override
|
||||
{
|
||||
return _hostStr.empty() ? nullptr : _hostStr.c_str();
|
||||
}
|
||||
|
||||
void SetHostStr(const char * hostStr) override
|
||||
{
|
||||
_hostStr = std::string(hostStr);
|
||||
return _hostName.empty() ? nullptr : _hostName.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -59,8 +59,7 @@ public:
|
||||
virtual void Disconnect() abstract;
|
||||
virtual void Close() abstract;
|
||||
|
||||
virtual const char * GetHostStr() abstract;
|
||||
virtual void SetHostStr(const char * hostStr) abstract;
|
||||
virtual const char * GetHostName() const abstract;
|
||||
};
|
||||
|
||||
ITcpSocket * CreateTcpSocket();
|
||||
|
||||
@@ -1408,10 +1408,6 @@ void Network::Server_Client_Joined(const char* name, const std::string &keyhash,
|
||||
if (player) {
|
||||
char text[256];
|
||||
const char * player_name = (const char *) player->name.c_str();
|
||||
//Relay connection information to console
|
||||
auto hostStr = connection.Socket->GetHostStr();
|
||||
log_info("%s has joined from host: %s", player_name, hostStr);
|
||||
//Show join message in chat
|
||||
format_string(text, 256, STR_MULTIPLAYER_PLAYER_HAS_JOINED_THE_GAME, &player_name);
|
||||
chat_history_add(text);
|
||||
Server_Send_MAP(&connection);
|
||||
|
||||
Reference in New Issue
Block a user