Ticket #3607: t3607_assign_the_unassigned_v1.patch
File t3607_assign_the_unassigned_v1.patch, 1.6 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
function handleNetMessage(message) 455 455 var resetReady = false; 456 456 var newPlayer = ""; 457 457 // Find and report all joinings/leavings 458 458 for (var host in message.hosts) 459 459 { 460 if (!g_PlayerAssignments[host]) 460 if (g_PlayerAssignments[host]) 461 continue; 462 463 // If we have extra player slots and we are the controller, give the player an ID. 464 if (g_IsController && message.hosts[host].player === -1 && g_AssignedCount < g_GameAttributes.settings.PlayerData.length) 461 465 { 462 // If we have extra player slots and we are the controller, give the player an ID.463 if (g_IsController && message.hosts[host].player === -1 && g_AssignedCount < g_GameAttributes.settings.PlayerData.length)464 Engine.AssignNetworkPlayer(g_AssignedCount + 1, host);465 addChatMessage({ "type": "connect", "username": message.hosts[host].name });466 newPlayer = host;466 // Find an index of the playerdata array which is not assigned to any player 467 let freeSlot = 1 + g_GameAttributes.settings.PlayerData.findIndex((v,i) => 468 Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player != i + 1) 469 ); 470 Engine.AssignNetworkPlayer(freeSlot, host); 467 471 } 472 473 addChatMessage({ "type": "connect", "username": message.hosts[host].name }); 474 newPlayer = host; 468 475 } 469 476 470 477 for (var host in g_PlayerAssignments) 471 478 { 472 479 if (!message.hosts[host])