Skip to content

Commit 508107e

Browse files
committed
Merge branch 'main' into recent-activity
2 parents 03bfe54 + 5283001 commit 508107e

File tree

16 files changed

+60
-76
lines changed

16 files changed

+60
-76
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Normalize shell scripts to have LF line endings
2+
*.sh text eol=lf

ProjectLighthouse.Servers.GameServer/Controllers/Login/LoginController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task<IActionResult> Login()
7272
switch (npTicket.Platform)
7373
{
7474
case Platform.RPCS3:
75-
user = await this.database.Users.FirstOrDefaultAsync(u => u.LinkedRpcnId == npTicket.UserId);
75+
user = await this.database.Users.FirstOrDefaultAsync(u => u.LinkedRpcnId == npTicket.UserId);
7676
break;
7777
case Platform.PS3:
7878
case Platform.Vita:
@@ -88,7 +88,7 @@ public async Task<IActionResult> Login()
8888
// If this user id hasn't been linked to any accounts
8989
if (user == null)
9090
{
91-
// Check if there is an account with that username already
91+
// Check if there is an account with that username already
9292
UserEntity? targetUsername = await this.database.Users.FirstOrDefaultAsync(u => u.Username == npTicket.Username);
9393
if (targetUsername != null)
9494
{
@@ -175,7 +175,7 @@ public async Task<IActionResult> Login()
175175
}
176176

177177
GameTokenEntity? token = await this.database.GameTokens.Include(t => t.User)
178-
.FirstOrDefaultAsync(t => t.UserLocation == ipAddress && t.User.Username == npTicket.Username && t.TicketHash == npTicket.TicketHash);
178+
.FirstOrDefaultAsync(t => t.User.Username == npTicket.Username && t.TicketHash == npTicket.TicketHash);
179179

180180
if (token != null)
181181
{

ProjectLighthouse.Servers.GameServer/Controllers/Matching/MatchController.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#nullable enable
22
using System.Text.Json;
3+
using LBPUnion.ProjectLighthouse.Configuration;
34
using LBPUnion.ProjectLighthouse.Database;
45
using LBPUnion.ProjectLighthouse.Extensions;
56
using 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)

ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public async Task<IActionResult> Announce()
6262
#if DEBUG
6363
announceText.Append("\n\n---DEBUG INFO---\n" +
6464
$"user.UserId: {token.UserId}\n" +
65-
$"token.UserLocation: {token.UserLocation}\n" +
6665
$"token.GameVersion: {token.GameVersion}\n" +
6766
$"token.TicketHash: {token.TicketHash}\n" +
6867
$"token.ExpiresAt: {token.ExpiresAt.ToString()}\n" +

ProjectLighthouse.Servers.Website/Controllers/Debug/RoomVisualizerController.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using LBPUnion.ProjectLighthouse.Database;
2-
using LBPUnion.ProjectLighthouse.Helpers;
3-
using LBPUnion.ProjectLighthouse.Types.Users;
42
using Microsoft.AspNetCore.Mvc;
5-
using Microsoft.EntityFrameworkCore;
63

74
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Debug;
85

@@ -27,10 +24,6 @@ public async Task<IActionResult> CreateFakeRoom()
2724
List<int> users = await this.database.Users.OrderByDescending(_ => EF.Functions.Random()).Take(2).Select(u => u.UserId).ToListAsync();
2825
RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2, Platform.PS3);
2926

30-
foreach (int user in users)
31-
{
32-
MatchHelper.SetUserLocation(user, "127.0.0.1");
33-
}
3427
return this.Redirect("/debug/roomVisualizer");
3528
#endif
3629
}

ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717

1818
<script>
1919
let shouldRefresh = true;
20-
20+
2121
setTimeout(() => {
2222
if (shouldRefresh) window.location.reload();
2323
}, @(refreshSeconds * 1000));
24-
24+
2525
function stopRefreshing() {
2626
shouldRefresh = false;
2727
console.log("Stopped refresh");
28-
28+
2929
const stopRefreshButton = document.getElementById("stop-refresh-button");
3030
stopRefreshButton.parentElement.removeChild(stopRefreshButton);
3131
console.log("Removed stop refresh button");
@@ -61,7 +61,7 @@
6161
#nullable enable
6262
if (version == GameVersion.LittleBigPlanet1 || version == GameVersion.LittleBigPlanetPSP || version == GameVersion.Unknown) continue;
6363

64-
FindBestRoomResponse? response = RoomHelper.FindBestRoom(Database, null, version, null, null, null);
64+
FindBestRoomResponse? response = RoomHelper.FindBestRoom(Database, null, version, null, null);
6565
string text = response == null ? "No room found." : "Room " + response.RoomId;
6666

6767
<p><b>Best room for @version.ToPrettyString()</b>: @text</p>

ProjectLighthouse.Tests/Helpers/MockHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static GameTokenEntity GetUnitTestToken() =>
3737
UserId = 1,
3838
ExpiresAt = DateTime.MaxValue,
3939
TokenId = 1,
40-
UserLocation = "127.0.0.1",
4140
UserToken = "unittest",
4241
};
4342

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
2+
3+
public class MatchmakingConfiguration
4+
{
5+
public bool MatchmakingEnabled { get; set; } = true;
6+
}

ProjectLighthouse/Configuration/ServerConfiguration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class ServerConfiguration : ConfigurationBase<ServerConfiguration>
1111
// This is so Lighthouse can properly identify outdated configurations and update them with newer settings accordingly.
1212
// If you are modifying anything here, this value MUST be incremented.
1313
// Thanks for listening~
14-
public override int ConfigVersion { get; set; } = 24;
14+
public override int ConfigVersion { get; set; } = 25;
1515

1616
public override string ConfigName { get; set; } = "lighthouse.yml";
1717
public string WebsiteListenUrl { get; set; } = "http://localhost:10060";
@@ -35,6 +35,7 @@ public class ServerConfiguration : ConfigurationBase<ServerConfiguration>
3535
public AuthenticationConfiguration Authentication { get; set; } = new();
3636
public CaptchaConfiguration Captcha { get; set; } = new();
3737
public DigestKeyConfiguration DigestKey { get; set; } = new();
38+
public MatchmakingConfiguration Matchmaking { get; set; } = new();
3839
public GoogleAnalyticsConfiguration GoogleAnalytics { get; set; } = new();
3940
public MailConfiguration Mail { get; set; } = new();
4041
public UserGeneratedContentLimitConfiguration UserGeneratedContentLimits { get; set; } = new();

ProjectLighthouse/Database/DatabaseContext.Utils.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public async Task<int> UserIdFromUsername(string? username)
6767
UserToken = CryptoHelper.GenerateAuthToken(),
6868
User = user,
6969
UserId = user.UserId,
70-
UserLocation = userLocation,
7170
GameVersion = npTicket.GameVersion,
7271
Platform = npTicket.Platform,
7372
TicketHash = npTicket.TicketHash,

0 commit comments

Comments
 (0)