mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-02 08:51:57 +00:00
rewrote posix_net.cpp based on win_net.cpp
And suddenly hosting a server on linux works at least locally (with client and server on the same machine). Even though there are still strange bugs (massive lags in one direction, doesn't work in LAN), at least it works at all now.
This commit is contained in:
parent
5001b49841
commit
e8c8a04c07
6 changed files with 768 additions and 360 deletions
File diff suppressed because it is too large
Load diff
|
@ -402,7 +402,7 @@ void idSessionLocalWin::Connect_f( const idCmdArgs& args )
|
|||
lobbyConnectInfo_t connectInfo;
|
||||
|
||||
Sys_StringToNetAdr( args.Argv( 1 ), &connectInfo.netAddr, true );
|
||||
connectInfo.netAddr.port = net_port.GetInteger();
|
||||
connectInfo.netAddr.port = net_port.GetInteger(); // FIXME: really? what if it was specified in the connect cmd?
|
||||
|
||||
ConnectAndMoveToLobby( GetPartyLobby(), connectInfo, false );
|
||||
}
|
||||
|
@ -600,6 +600,7 @@ idSessionLocalWin::EnsurePort
|
|||
*/
|
||||
void idSessionLocalWin::EnsurePort()
|
||||
{
|
||||
// XXX: fucked up?
|
||||
// Init the port using reqular windows sockets
|
||||
if( port.IsOpen() )
|
||||
{
|
||||
|
|
|
@ -339,6 +339,7 @@ void idLobby::Shutdown( bool retainMigrationInfo, bool skipGoodbye )
|
|||
idLobby::HandlePacket
|
||||
========================
|
||||
*/
|
||||
// FIXME: remoteAddress const?
|
||||
void idLobby::HandlePacket( lobbyAddress_t& remoteAddress, idBitMsg fragMsg, idPacketProcessor::sessionId_t sessionID )
|
||||
{
|
||||
SCOPED_PROFILE_EVENT( "HandlePacket" );
|
||||
|
@ -1857,7 +1858,7 @@ int idLobby::HandleInitialPeerConnection( idBitMsg& msg, const lobbyAddress_t& p
|
|||
|
||||
if( !IsHost() )
|
||||
{
|
||||
NET_VERBOSE_PRINT( "NET: Got connectionless hello from peer %s on session, and we are not a host\n", peerAddress.ToString() );
|
||||
NET_VERBOSE_PRINT( "NET: Got connectionless hello from peer %s (num %i) on session, and we are not a host\n", peerAddress.ToString(), peerNum );
|
||||
SendGoodbye( peerAddress );
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -103,10 +103,12 @@ void idLobbyBackendDirect::JoinFromConnectInfo( const lobbyConnectInfo_t& connec
|
|||
{
|
||||
Sys_StringToNetAdr( "localhost", &address, true );
|
||||
address.port = net_port.GetInteger();
|
||||
NET_VERBOSE_PRINT( "NET: idLobbyBackendDirect::JoinFromConnectInfo(): canJoinLocalHost\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
address = connectInfo.netAddr;
|
||||
NET_VERBOSE_PRINT( "NET: idLobbyBackendDirect::JoinFromConnectInfo(): %s\n", Sys_NetAdrToString( address ) );
|
||||
}
|
||||
|
||||
state = STATE_READY;
|
||||
|
@ -176,7 +178,7 @@ lobbyConnectInfo_t idLobbyBackendDirect::GetConnectInfo()
|
|||
if( IsHost() )
|
||||
{
|
||||
// If we are the host, give them our ip address
|
||||
const char* ip = Sys_GetLocalIP( 0 );
|
||||
const char* ip = Sys_GetLocalIP( 0 ); // XXX: ohweiha.
|
||||
Sys_StringToNetAdr( ip, &address, false );
|
||||
address.port = net_port.GetInteger();
|
||||
}
|
||||
|
|
|
@ -1128,6 +1128,7 @@ bool idSessionLocal::State_Create_And_Move_To_Game_Lobby()
|
|||
|
||||
// Now that we've created our game lobby, send our own party users to it
|
||||
// NOTE - We pass in false to wait on party members since we are the host, and we know they can connect to us
|
||||
// TODO: special handling of ourselves here?
|
||||
GetPartyLobby().SendMembersToLobby( GetGameLobby(), false );
|
||||
return true;
|
||||
}
|
||||
|
@ -1591,7 +1592,7 @@ idSession::~idSession()
|
|||
dedicatedServerSearch = NULL;
|
||||
}
|
||||
|
||||
idCVar net_verbose( "net_verbose", "0", CVAR_BOOL, "Print a bunch of message about the network session" );
|
||||
idCVar net_verbose( "net_verbose", "0", CVAR_BOOL | CVAR_NOCHEAT, "Print a bunch of message about the network session" );
|
||||
idCVar net_verboseResource( "net_verboseResource", "0", CVAR_BOOL, "Prints a bunch of message about network resources" );
|
||||
idCVar net_verboseReliable( "net_verboseReliable", "0", CVAR_BOOL, "Prints the more spammy messages about reliable network msgs" );
|
||||
idCVar si_splitscreen( "si_splitscreen", "0", CVAR_INTEGER, "force splitscreen" );
|
||||
|
|
|
@ -61,7 +61,7 @@ idCVar net_socksPort( "net_socksPort", "1080", CVAR_ARCHIVE | CVAR_INTEGER, "" )
|
|||
idCVar net_socksUsername( "net_socksUsername", "", CVAR_ARCHIVE, "" );
|
||||
idCVar net_socksPassword( "net_socksPassword", "", CVAR_ARCHIVE, "" );
|
||||
|
||||
idCVar net_ip( "net_ip", "localhost", 0, "local IP address" );
|
||||
idCVar net_ip( "net_ip", "localhost", CVAR_NOCHEAT, "local IP address" );
|
||||
|
||||
static struct sockaddr_in socksRelayAddr;
|
||||
|
||||
|
@ -684,7 +684,9 @@ bool Net_GetUDPPacket( int netSocket, netadr_t& net_from, char* data, int& size,
|
|||
idLib::Printf( buf );
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// DG: ip_socket is never initialized, so this is dead code
|
||||
// - and if netSocket is 0 (so this would be true) recvfrom above will already fail
|
||||
if( static_cast<unsigned int>( netSocket ) == ip_socket )
|
||||
{
|
||||
memset( from.sin_zero, 0, sizeof( from.sin_zero ) );
|
||||
|
@ -706,8 +708,12 @@ bool Net_GetUDPPacket( int netSocket, netadr_t& net_from, char* data, int& size,
|
|||
}
|
||||
else
|
||||
{
|
||||
#endif // 0
|
||||
|
||||
Net_SockadrToNetadr( &from, &net_from );
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ret > maxSize )
|
||||
{
|
||||
|
@ -1177,3 +1183,4 @@ void idUDP::SendPacket( const netadr_t to, const void* data, int size )
|
|||
|
||||
Net_SendUDPPacket( netSocket, size, data, to );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue