Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 788 Lines • ▼ Show 20 Lines | |||||
function onClientJoin(newGUID, newAssignments) | function onClientJoin(newGUID, newAssignments) | ||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
"type": "connect", | "type": "connect", | ||||
"guid": newGUID, | "guid": newGUID, | ||||
"username": newAssignments[newGUID].name | "username": newAssignments[newGUID].name | ||||
}); | }); | ||||
// Assign joining observers to unused player numbers | |||||
if (!g_IsController || newAssignments[newGUID].player != -1) | |||||
return; | |||||
let freeSlot = g_GameAttributes.settings.PlayerData.findIndex((v,i) => | let freeSlot = g_GameAttributes.settings.PlayerData.findIndex((v,i) => | ||||
Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player != i+1) | Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player != i+1) | ||||
); | ); | ||||
if (freeSlot == -1) | // Client is not and cannot assigned as player | ||||
if (newAssignments[newGUID].player == -1 && freeSlot == -1) | |||||
return; | return; | ||||
// Assign the joining client to the free slot | |||||
if (g_IsController && newAssignments[newGUID].player == -1) | |||||
Engine.AssignNetworkPlayer(freeSlot + 1, newGUID); | Engine.AssignNetworkPlayer(freeSlot + 1, newGUID); | ||||
resetReadyData(); | resetReadyData(); | ||||
} | } | ||||
function onClientLeave(guid) | function onClientLeave(guid) | ||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
"type": "disconnect", | "type": "disconnect", | ||||
"guid": guid | "guid": guid | ||||
▲ Show 20 Lines • Show All 1,203 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator