Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js
Show First 20 Lines • Show All 1,273 Lines • ▼ Show 20 Lines | function handlePlayerAssignmentMessage(message) | ||||
if (playerChange) | if (playerChange) | ||||
sendRegisterGameStanzaImmediate(); | sendRegisterGameStanzaImmediate(); | ||||
else | else | ||||
sendRegisterGameStanza(); | sendRegisterGameStanza(); | ||||
} | } | ||||
function onClientJoin(newGUID, newAssignments) | function onClientJoin(newGUID, newAssignments) | ||||
{ | { | ||||
let playername = newAssignments[newGUID].name; | |||||
addChatMessage({ | addChatMessage({ | ||||
"type": "connect", | "type": "connect", | ||||
"guid": newGUID, | "guid": newGUID, | ||||
"username": newAssignments[newGUID].name | "username": playername | ||||
}); | }); | ||||
let isRejoiningPlayer = newAssignments[newGUID].player != -1; | |||||
// Assign the client (or only buddies if prefered) to an unused playerslot and rejoining players to their old slot | |||||
if (!isRejoiningPlayer && playername != newAssignments[Engine.GetPlayerGUID()].name) | |||||
{ | |||||
let assignOption = Engine.ConfigDB_GetValue("user", "gui.gamesetup.assignplayers"); | |||||
if (assignOption == "noone" || | |||||
assignOption == "buddies" && g_Buddies.indexOf(splitRatingFromNick(playername)[0]) == -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) | ||||
); | ); | ||||
// Client is not and cannot become assigned as player | // Client is not and cannot become assigned as player | ||||
if (newAssignments[newGUID].player == -1 && freeSlot == -1) | if (!isRejoiningPlayer && freeSlot == -1) | ||||
return; | return; | ||||
// Assign the joining client to the free slot | // Assign the joining client to the free slot | ||||
if (g_IsController && newAssignments[newGUID].player == -1) | if (g_IsController && !isRejoiningPlayer) | ||||
Engine.AssignNetworkPlayer(freeSlot + 1, newGUID); | Engine.AssignNetworkPlayer(freeSlot + 1, newGUID); | ||||
resetReadyData(); | resetReadyData(); | ||||
} | } | ||||
function onClientLeave(guid) | function onClientLeave(guid) | ||||
{ | { | ||||
addChatMessage({ | addChatMessage({ | ||||
▲ Show 20 Lines • Show All 960 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator