11#nullable enable
22using System . Text . Json ;
3+ using LBPUnion . ProjectLighthouse . Configuration ;
34using LBPUnion . ProjectLighthouse . Database ;
45using LBPUnion . ProjectLighthouse . Extensions ;
56using LBPUnion . ProjectLighthouse . Helpers ;
@@ -42,6 +43,11 @@ public async Task<IActionResult> Match()
4243 UserEntity ? user = await this . database . UserFromGameToken ( token ) ;
4344 if ( user == null ) return this . Forbid ( ) ;
4445
46+ await LastContactHelper . SetLastContact ( this . database , user , token . GameVersion , token . Platform ) ;
47+
48+ // Do not allow matchmaking if it has been disabled
49+ if ( ! ServerConfiguration . Instance . Matchmaking . MatchmakingEnabled ) return this . BadRequest ( ) ;
50+
4551 #region Parse match data
4652
4753 // Example POST /match: [UpdateMyPlayerData,["Player":"FireGamer9872"]]
@@ -75,35 +81,26 @@ public async Task<IActionResult> Match()
7581
7682 #endregion
7783
78- await LastContactHelper . SetLastContact ( this . database , user , token . GameVersion , token . Platform ) ;
79-
8084 #region Process match data
8185
8286 switch ( matchData )
8387 {
8488 case UpdateMyPlayerData playerData :
8589 {
86- MatchHelper . SetUserLocation ( user . UserId , token . UserLocation ) ;
8790 Room ? room = RoomHelper . FindRoomByUser ( user . UserId , token . GameVersion , token . Platform , true ) ;
8891
8992 if ( playerData . RoomState != null )
9093 if ( room != null && Equals ( room . HostId , user . UserId ) )
9194 room . State = ( RoomState ) playerData . RoomState ;
9295 break ;
9396 }
94- // Check how many people are online in release builds, disabled for debug for ..well debugging.
95- #if DEBUG
9697 case FindBestRoom diveInData :
97- #else
98- case FindBestRoom diveInData when MatchHelper . UserLocations . Count > 1 :
99- #endif
10098 {
10199 FindBestRoomResponse ? response = RoomHelper . FindBestRoom ( this . database ,
102100 user ,
103101 token . GameVersion ,
104102 diveInData . RoomSlot ,
105- token . Platform ,
106- token . UserLocation ) ;
103+ token . Platform ) ;
107104
108105 if ( response == null ) return this . NotFound ( ) ;
109106
@@ -113,7 +110,7 @@ public async Task<IActionResult> Match()
113110
114111 return this . Ok ( $ "[{{\" StatusCode\" :200}},{ serialized } ]") ;
115112 }
116- case CreateRoom createRoom when ! MatchHelper . UserLocations . IsEmpty :
113+ case CreateRoom createRoom :
117114 {
118115 List < int > users = new ( ) ;
119116 foreach ( string playerUsername in createRoom . Players )
0 commit comments