doom3-bfg/neo/sys/sys_lobby_backend_direct.cpp

265 lines
6.7 KiB
C++
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma hdrstop
#include "precompiled.h"
2012-11-26 18:58:24 +00:00
#include "sys_lobby_backend.h"
#include "sys_lobby_backend_direct.h"
extern idCVar net_port;
extern idCVar net_ip;
2012-11-26 18:58:24 +00:00
extern idLobbyToSessionCB* lobbyToSessionCB;
2012-11-26 18:58:24 +00:00
/*
========================
idLobbyBackendDirect::idLobbyBackendWin
========================
*/
idLobbyBackendDirect::idLobbyBackendDirect()
{
2012-11-26 18:58:24 +00:00
state = STATE_INVALID;
}
/*
========================
idLobbyBackendDirect::StartHosting
========================
*/
void idLobbyBackendDirect::StartHosting( const idMatchParameters& p, float skillLevel, lobbyBackendType_t type )
{
2012-11-26 18:58:24 +00:00
NET_VERBOSE_PRINT( "idLobbyBackendDirect::StartHosting\n" );
2012-11-26 18:58:24 +00:00
isLocal = MatchTypeIsLocal( p.matchFlags );
isHost = true;
2012-11-26 18:58:24 +00:00
state = STATE_READY;
isLocal = true;
}
/*
========================
idLobbyBackendDirect::StartFinding
========================
*/
void idLobbyBackendDirect::StartFinding( const idMatchParameters& p, int numPartyUsers, float skillLevel )
{
2012-11-26 18:58:24 +00:00
isLocal = MatchTypeIsLocal( p.matchFlags );
isHost = false;
if( lobbyToSessionCB->CanJoinLocalHost() )
{
2012-11-26 18:58:24 +00:00
state = STATE_READY;
}
else
{
2012-11-26 18:58:24 +00:00
state = STATE_FAILED;
}
}
/*
========================
idLobbyBackendDirect::GetSearchResults
========================
*/
void idLobbyBackendDirect::GetSearchResults( idList< lobbyConnectInfo_t >& searchResults )
{
2012-11-26 18:58:24 +00:00
lobbyConnectInfo_t fakeResult;
searchResults.Clear();
searchResults.Append( fakeResult );
}
/*
========================
idLobbyBackendDirect::JoinFromConnectInfo
========================
*/
void idLobbyBackendDirect::JoinFromConnectInfo( const lobbyConnectInfo_t& connectInfo )
{
if( lobbyToSessionCB->CanJoinLocalHost() )
{
// TODO: "CanJoinLocalHost" == *must* join LocalHost ?!
2012-11-26 18:58:24 +00:00
Sys_StringToNetAdr( "localhost", &address, true );
address.port = net_port.GetInteger();
NET_VERBOSE_PRINT( "NET: idLobbyBackendDirect::JoinFromConnectInfo(): canJoinLocalHost\n" );
}
else
{
2012-11-26 18:58:24 +00:00
address = connectInfo.netAddr;
NET_VERBOSE_PRINT( "NET: idLobbyBackendDirect::JoinFromConnectInfo(): %s\n", Sys_NetAdrToString( address ) );
2012-11-26 18:58:24 +00:00
}
2012-11-26 18:58:24 +00:00
state = STATE_READY;
isLocal = false;
isHost = false;
}
/*
========================
idLobbyBackendDirect::Shutdown
========================
*/
void idLobbyBackendDirect::Shutdown()
{
2012-11-26 18:58:24 +00:00
state = STATE_SHUTDOWN;
}
/*
========================
idLobbyBackendDirect::BecomeHost
========================
*/
void idLobbyBackendDirect::BecomeHost( int numInvites )
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::FinishBecomeHost
========================
*/
void idLobbyBackendDirect::FinishBecomeHost()
{
2012-11-26 18:58:24 +00:00
isHost = true;
}
/*
========================
idLobbyBackendDirect::GetOwnerAddress
========================
*/
void idLobbyBackendDirect::GetOwnerAddress( lobbyAddress_t& outAddr )
{
2012-11-26 18:58:24 +00:00
outAddr.netAddr = address;
state = STATE_READY;
}
/*
========================
idLobbyBackendDirect::SetIsJoinable
========================
*/
void idLobbyBackendDirect::SetIsJoinable( bool joinable )
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::GetConnectInfo
========================
*/
lobbyConnectInfo_t idLobbyBackendDirect::GetConnectInfo()
{
2012-11-26 18:58:24 +00:00
lobbyConnectInfo_t connectInfo;
2012-11-26 18:58:24 +00:00
// If we aren't the host, this lobby should have been joined through JoinFromConnectInfo
if( IsHost() )
{
2012-11-26 18:58:24 +00:00
// If we are the host, give them our ip address
// DG: always using the first IP doesn't work, because on linux that's 127.0.0.1
// and even if not, this causes trouble with NAT.
// So either use net_ip or, if it's not set ("localhost"), use 0.0.0.0 which is
// a special case the client will treat as "just use the IP I used for the lobby"
// (which is the right behavior for the Direct backend, I guess).
// the client special case is in idLobby::HandleReliableMsg
const char* ip = net_ip.GetString();
if( ip == NULL || idStr::Length( ip ) == 0 || idStr::Icmp( ip, "localhost" ) == 0 )
ip = "0.0.0.0";
// DG end
2012-11-26 18:58:24 +00:00
Sys_StringToNetAdr( ip, &address, false );
address.port = net_port.GetInteger();
}
2012-11-26 18:58:24 +00:00
connectInfo.netAddr = address;
2012-11-26 18:58:24 +00:00
return connectInfo;
}
/*
========================
idLobbyBackendDirect::IsOwnerOfConnectInfo
========================
*/
bool idLobbyBackendDirect::IsOwnerOfConnectInfo( const lobbyConnectInfo_t& connectInfo ) const
{
2012-11-26 18:58:24 +00:00
return Sys_CompareNetAdrBase( address, connectInfo.netAddr );
}
/*
========================
idLobbyBackendDirect::Pump
========================
*/
void idLobbyBackendDirect::Pump()
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::UpdateMatchParms
========================
*/
void idLobbyBackendDirect::UpdateMatchParms( const idMatchParameters& p )
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::UpdateLobbySkill
========================
*/
void idLobbyBackendDirect::UpdateLobbySkill( float lobbySkill )
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::SetInGame
========================
*/
void idLobbyBackendDirect::SetInGame( bool value )
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::RegisterUser
========================
*/
void idLobbyBackendDirect::RegisterUser( lobbyUser_t* user, bool isLocal )
{
2012-11-26 18:58:24 +00:00
}
/*
========================
idLobbyBackendDirect::UnregisterUser
========================
*/
void idLobbyBackendDirect::UnregisterUser( lobbyUser_t* user, bool isLocal )
{
2012-11-26 18:58:24 +00:00
}