sys_lobby_backend_direct.cpp (6015B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 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. 23 24 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. 25 26 =========================================================================== 27 */ 28 #pragma hdrstop 29 #include "../idlib/precompiled.h" 30 #include "sys_lobby_backend.h" 31 #include "sys_lobby_backend_direct.h" 32 33 extern idCVar net_port; 34 35 extern idLobbyToSessionCB * lobbyToSessionCB; 36 37 /* 38 ======================== 39 idLobbyBackendDirect::idLobbyBackendWin 40 ======================== 41 */ 42 idLobbyBackendDirect::idLobbyBackendDirect() { 43 state = STATE_INVALID; 44 } 45 46 /* 47 ======================== 48 idLobbyBackendDirect::StartHosting 49 ======================== 50 */ 51 void idLobbyBackendDirect::StartHosting( const idMatchParameters & p, float skillLevel, lobbyBackendType_t type ) { 52 NET_VERBOSE_PRINT( "idLobbyBackendDirect::StartHosting\n" ); 53 54 isLocal = MatchTypeIsLocal( p.matchFlags ); 55 isHost = true; 56 57 state = STATE_READY; 58 isLocal = true; 59 } 60 61 /* 62 ======================== 63 idLobbyBackendDirect::StartFinding 64 ======================== 65 */ 66 void idLobbyBackendDirect::StartFinding( const idMatchParameters & p, int numPartyUsers, float skillLevel ) { 67 isLocal = MatchTypeIsLocal( p.matchFlags ); 68 isHost = false; 69 70 if ( lobbyToSessionCB->CanJoinLocalHost() ) { 71 state = STATE_READY; 72 } else { 73 state = STATE_FAILED; 74 } 75 } 76 77 /* 78 ======================== 79 idLobbyBackendDirect::GetSearchResults 80 ======================== 81 */ 82 void idLobbyBackendDirect::GetSearchResults( idList< lobbyConnectInfo_t > & searchResults ) { 83 lobbyConnectInfo_t fakeResult; 84 searchResults.Clear(); 85 searchResults.Append( fakeResult ); 86 } 87 88 /* 89 ======================== 90 idLobbyBackendDirect::JoinFromConnectInfo 91 ======================== 92 */ 93 void idLobbyBackendDirect::JoinFromConnectInfo( const lobbyConnectInfo_t & connectInfo ) { 94 if ( lobbyToSessionCB->CanJoinLocalHost() ) { 95 Sys_StringToNetAdr( "localhost", &address, true ); 96 address.port = net_port.GetInteger(); 97 } else { 98 address = connectInfo.netAddr; 99 } 100 101 state = STATE_READY; 102 isLocal = false; 103 isHost = false; 104 } 105 106 /* 107 ======================== 108 idLobbyBackendDirect::Shutdown 109 ======================== 110 */ 111 void idLobbyBackendDirect::Shutdown() { 112 state = STATE_SHUTDOWN; 113 } 114 115 /* 116 ======================== 117 idLobbyBackendDirect::BecomeHost 118 ======================== 119 */ 120 void idLobbyBackendDirect::BecomeHost( int numInvites ) { 121 } 122 123 /* 124 ======================== 125 idLobbyBackendDirect::FinishBecomeHost 126 ======================== 127 */ 128 void idLobbyBackendDirect::FinishBecomeHost() { 129 isHost = true; 130 } 131 132 /* 133 ======================== 134 idLobbyBackendDirect::GetOwnerAddress 135 ======================== 136 */ 137 void idLobbyBackendDirect::GetOwnerAddress( lobbyAddress_t & outAddr ) { 138 outAddr.netAddr = address; 139 state = STATE_READY; 140 } 141 142 /* 143 ======================== 144 idLobbyBackendDirect::SetIsJoinable 145 ======================== 146 */ 147 void idLobbyBackendDirect::SetIsJoinable( bool joinable ) { 148 } 149 150 /* 151 ======================== 152 idLobbyBackendDirect::GetConnectInfo 153 ======================== 154 */ 155 lobbyConnectInfo_t idLobbyBackendDirect::GetConnectInfo() { 156 lobbyConnectInfo_t connectInfo; 157 158 // If we aren't the host, this lobby should have been joined through JoinFromConnectInfo 159 if ( IsHost() ) { 160 // If we are the host, give them our ip address 161 const char * ip = Sys_GetLocalIP( 0 ); 162 Sys_StringToNetAdr( ip, &address, false ); 163 address.port = net_port.GetInteger(); 164 } 165 166 connectInfo.netAddr = address; 167 168 return connectInfo; 169 } 170 171 /* 172 ======================== 173 idLobbyBackendDirect::IsOwnerOfConnectInfo 174 ======================== 175 */ 176 bool idLobbyBackendDirect::IsOwnerOfConnectInfo( const lobbyConnectInfo_t & connectInfo ) const { 177 return Sys_CompareNetAdrBase( address, connectInfo.netAddr ); 178 } 179 180 /* 181 ======================== 182 idLobbyBackendDirect::Pump 183 ======================== 184 */ 185 void idLobbyBackendDirect::Pump() { 186 } 187 188 /* 189 ======================== 190 idLobbyBackendDirect::UpdateMatchParms 191 ======================== 192 */ 193 void idLobbyBackendDirect::UpdateMatchParms( const idMatchParameters & p ) { 194 } 195 196 /* 197 ======================== 198 idLobbyBackendDirect::UpdateLobbySkill 199 ======================== 200 */ 201 void idLobbyBackendDirect::UpdateLobbySkill( float lobbySkill ) { 202 } 203 204 /* 205 ======================== 206 idLobbyBackendDirect::SetInGame 207 ======================== 208 */ 209 void idLobbyBackendDirect::SetInGame( bool value ) { 210 } 211 212 /* 213 ======================== 214 idLobbyBackendDirect::RegisterUser 215 ======================== 216 */ 217 void idLobbyBackendDirect::RegisterUser( lobbyUser_t * user, bool isLocal ) { 218 } 219 220 /* 221 ======================== 222 idLobbyBackendDirect::UnregisterUser 223 ======================== 224 */ 225 void idLobbyBackendDirect::UnregisterUser( lobbyUser_t * user, bool isLocal ) { 226 }