gg.easy.airship 0.1.1521 → 0.1.1522
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,7 +37,10 @@ namespace Code.Player {
|
|
|
37
37
|
[SerializeField] public AgonesBetaSdk agones;
|
|
38
38
|
private static string AGONES_PLAYERS_LIST_NAME = "players";
|
|
39
39
|
private static string AGONES_RESERVATIONS_LIST_NAME = "reservations";
|
|
40
|
+
// To implement max players, we fill in fake reservations for slots we never want to fill. This is the prefix for the fake reservations we should ignore.
|
|
41
|
+
private static string AGONES_RESERVATION_FILL_PREFIX = "::";
|
|
40
42
|
private static double MAX_RESERVATION_TIME_SEC = 60 * 5;
|
|
43
|
+
|
|
41
44
|
private Dictionary<string, DateTime> agonesReservationMap = new();
|
|
42
45
|
|
|
43
46
|
private ServerBootstrap serverBootstrap;
|
|
@@ -87,6 +90,7 @@ namespace Code.Player {
|
|
|
87
90
|
var reservedList = await this.agones.GetListValues(AGONES_RESERVATIONS_LIST_NAME);
|
|
88
91
|
reservedList.ForEach((reservation) =>
|
|
89
92
|
{
|
|
93
|
+
if (reservation.StartsWith(AGONES_RESERVATION_FILL_PREFIX)) return;
|
|
90
94
|
agonesReservationMap.TryAdd(reservation, DateTime.Now);
|
|
91
95
|
});
|
|
92
96
|
});
|
|
@@ -113,6 +117,7 @@ namespace Code.Player {
|
|
|
113
117
|
var toRemove = new List<string>();
|
|
114
118
|
foreach (var entry in agonesReservationMap)
|
|
115
119
|
{
|
|
120
|
+
if (entry.Key.StartsWith(AGONES_RESERVATION_FILL_PREFIX)) continue; // Fake reservations should never show up, but we check just in case.
|
|
116
121
|
double seconds = DateTime.Now.Subtract(entry.Value).TotalSeconds;
|
|
117
122
|
if (seconds < MAX_RESERVATION_TIME_SEC || players.Find((info) => $"{info.userId}" == entry.Key)) continue;
|
|
118
123
|
await this.agones.DeleteListValue(AGONES_RESERVATIONS_LIST_NAME, entry.Key);
|