@@ -24,6 +24,27 @@ local maxPlayers = GlobalState.MaxPlayers
24
24
local playerPositions = {}
25
25
local queueSize = 0
26
26
27
+ --- @param license string
28
+ local function enqueue (license )
29
+ queueSize += 1
30
+ playerPositions [license ] = queueSize
31
+ end
32
+
33
+ --- @param license string
34
+ local function dequeue (license )
35
+ local pos = playerPositions [license ]
36
+
37
+ queueSize -= 1
38
+ playerPositions [license ] = nil
39
+
40
+ -- decrease the positions of players who are after the current player in queue
41
+ for k , v in pairs (playerPositions ) do
42
+ if v > pos then
43
+ playerPositions [k ] -= 1
44
+ end
45
+ end
46
+ end
47
+
27
48
--- Map of player licenses that passed the queue and are downloading server content.
28
49
--- Needs to be saved because these players won't be part of regular player counts such as `GetNumPlayerIndices`.
29
50
--- @type table<string , true>
@@ -46,27 +67,6 @@ local function removePlayerJoining(license)
46
67
joiningPlayers [license ] = nil
47
68
end
48
69
49
- --- @param license string
50
- local function enqueue (license )
51
- queueSize += 1
52
- playerPositions [license ] = queueSize
53
- end
54
-
55
- --- @param license string
56
- local function dequeue (license )
57
- local pos = playerPositions [license ]
58
-
59
- queueSize -= 1
60
- playerPositions [license ] = nil
61
-
62
- -- decrease the positions of players who are after the current player in queue
63
- for k , v in pairs (playerPositions ) do
64
- if v > pos then
65
- playerPositions [k ] -= 1
66
- end
67
- end
68
- end
69
-
70
70
--- @param source Source
71
71
--- @param license string
72
72
--- @param deferrals Deferrals
0 commit comments