sys_lobby_backend_direct.cpp 5.9 KB

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