@@ -1810,14 +1810,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
1810
1810
if (datasize < 2 +1 +PLAYERNAME_SIZE)
1811
1811
return ;
1812
1812
1813
- verbosestream<<" Server: Got TOSERVER_INIT from "
1814
- <<peer_id<<std::endl;
1813
+ verbosestream<<" Server: Got TOSERVER_INIT from " <<addr_s<<std::endl;
1815
1814
1816
1815
// Do not allow multiple players in simple singleplayer mode.
1817
1816
// This isn't a perfect way to do it, but will suffice for now.
1818
1817
if (m_simple_singleplayer_mode && m_clients.size () > 1 ){
1819
- infostream<<" Server: Not allowing another client to connect in "
1820
- <<" simple singleplayer mode" <<std::endl;
1818
+ infostream<<" Server: Not allowing another client ( " <<addr_s
1819
+ <<" ) to connect in simple singleplayer mode" <<std::endl;
1821
1820
DenyAccess (peer_id, L" Running in simple singleplayer mode." );
1822
1821
return ;
1823
1822
}
@@ -1839,9 +1838,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
1839
1838
{
1840
1839
actionstream<<" Server: A mismatched client tried to connect from "
1841
1840
<<addr_s<<std::endl;
1842
- infostream<<" Server: Cannot negotiate "
1843
- " serialization version with peer "
1844
- <<peer_id<<std::endl;
1841
+ infostream<<" Server: Cannot negotiate serialization version with "
1842
+ <<addr_s<<std::endl;
1845
1843
DenyAccess (peer_id, std::wstring (
1846
1844
L" Your client's version is not supported.\n "
1847
1845
L" Server version is " )
@@ -1879,7 +1877,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
1879
1877
net_proto_version = max_net_proto_version;
1880
1878
}
1881
1879
1882
- verbosestream<<" Server: " <<peer_id <<" Protocol version: min: "
1880
+ verbosestream<<" Server: " <<addr_s <<" : Protocol version: min: "
1883
1881
<<min_net_proto_version<<" , max: " <<max_net_proto_version
1884
1882
<<" , chosen: " <<net_proto_version<<std::endl;
1885
1883
@@ -1888,8 +1886,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
1888
1886
if (net_proto_version < SERVER_PROTOCOL_VERSION_MIN ||
1889
1887
net_proto_version > SERVER_PROTOCOL_VERSION_MAX)
1890
1888
{
1891
- actionstream<<" Server: A mismatched client tried to connect from " <<addr_s
1892
- <<std::endl;
1889
+ actionstream<<" Server: A mismatched client tried to connect from "
1890
+ <<addr_s<< std::endl;
1893
1891
DenyAccess (peer_id, std::wstring (
1894
1892
L" Your client's version is not supported.\n "
1895
1893
L" Server version is " )
@@ -1957,14 +1955,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
1957
1955
1958
1956
if (!isSingleplayer () && strcasecmp (playername, " singleplayer" ) == 0 )
1959
1957
{
1960
- actionstream<<" Server: Player with an invalid name "
1958
+ actionstream<<" Server: Player with the name \" singleplayer \" "
1961
1959
<<" tried to connect from " <<addr_s<<std::endl;
1962
1960
DenyAccess (peer_id, L" Name is not allowed" );
1963
1961
return ;
1964
1962
}
1965
1963
1966
1964
infostream<<" Server: New connection: \" " <<playername<<" \" from "
1967
- <<m_con. GetPeerAddress (peer_id). serializeString () <<std::endl;
1965
+ <<addr_s<< " (peer_id= " <<peer_id<< " ) " <<std::endl;
1968
1966
1969
1967
// Get password
1970
1968
char given_password[PASSWORD_SIZE];
@@ -2041,9 +2039,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
2041
2039
}
2042
2040
2043
2041
if (given_password != checkpwd){
2044
- actionstream<<" Server: " <<playername<<" supplied invalid password"
2045
- <<" (peer_id= " <<peer_id<< " ) " << std::endl;
2046
- DenyAccess (peer_id, L" Invalid password" );
2042
+ actionstream<<" Server: " <<playername<<" supplied wrong password"
2043
+ <<std::endl;
2044
+ DenyAccess (peer_id, L" Wrong password" );
2047
2045
return ;
2048
2046
}
2049
2047
@@ -2053,10 +2051,19 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
2053
2051
// If failed, cancel
2054
2052
if (playersao == NULL )
2055
2053
{
2056
- errorstream<<" Server: peer_id=" <<peer_id
2057
- <<" : failed to emerge player" <<std::endl;
2058
- DenyAccess (peer_id, L" Could not allocate player. You"
2059
- " may need to wait for a timeout." );
2054
+ RemotePlayer *player =
2055
+ static_cast <RemotePlayer*>(m_env->getPlayer (playername));
2056
+ if (player && player->peer_id != 0 ){
2057
+ errorstream<<" Server: " <<playername<<" : Failed to emerge player"
2058
+ <<" (player allocated to an another client)" <<std::endl;
2059
+ DenyAccess (peer_id, L" Another client is connected with this "
2060
+ L" name. If your client closed unexpectedly, try again in "
2061
+ L" a minute." );
2062
+ } else {
2063
+ errorstream<<" Server: " <<playername<<" : Failed to emerge player"
2064
+ <<std::endl;
2065
+ DenyAccess (peer_id, L" Could not allocate player." );
2066
+ }
2060
2067
return ;
2061
2068
}
2062
2069
0 commit comments