Skip to content

Commit

Permalink
First attempt at fixing issues with the lobby (FAForever#5450)
Browse files Browse the repository at this point in the history
  • Loading branch information
4z0t authored Oct 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b764dd5 commit f0eeeb9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lua/ui/lobby/lobby.lua
Original file line number Diff line number Diff line change
@@ -5135,7 +5135,15 @@ local MessageHandlers = {
},

AddPlayer = {
Accept = AmHost,
Accept = function(data)
return data.PlayerOptions.OwnerID and
data.PlayerOptions.OwnerID == data.SenderID and
not FindNameForID(data.SenderID) and
lobbyComm:IsHost()
end,
Reject = function(data)
lobbyComm:EjectPeer(data.SenderID, "Invalid player data.")
end,
Handle = function(data)
-- try to reassign the same slot as in the last game if it's a rehosted game, otherwise give it an empty
-- slot or move it to observer
@@ -5510,6 +5518,8 @@ function InitLobbyComm(protocol, localPort, desiredPlayerName, localPlayerUID, n
-- No defined validator is taken to be always-accept.
if not MessageHandlers[data.Type].Accept or MessageHandlers[data.Type].Accept(data) then
MessageHandlers[data.Type].Handle(data)
elseif MessageHandlers[data.Type].Reject then
MessageHandlers[data.Type].Reject(data)
else
WARN("Rejected message of type " .. data.Type .. " from " .. FindNameForID(data.SenderID))
end

0 comments on commit f0eeeb9

Please sign in to comment.