Fix player assignments on map change (number of players may decrease, knocking assigned players out of a slot). Fixes #655

This was SVN commit r8534.
This commit is contained in:
historic_bruno 2010-11-04 20:34:29 +00:00
parent 4a9ae1de17
commit dbcd004844

View File

@ -162,16 +162,12 @@ function init(attribs)
getGUIObjectByName("startGame").enabled = false;
}
// Set up offline-only bits:
if (!g_IsNetworked)
{
getGUIObjectByName("chatPanel").hidden = true;
g_PlayerAssignments = { "local": { "name": "You", "player": 1, "civ": "", "team": -1} };
}
// Settings for all possible player slots
var boxSpacing = 32;
for (var i = 0; i < g_MaxPlayers; ++i)
@ -212,8 +208,6 @@ function init(attribs)
};
}
updatePlayerList();
getGUIObjectByName("chatInput").focus();
}
@ -516,6 +510,23 @@ function selectMap(name)
return;
}
// Reset player assignments on map change
if (!g_IsNetworked)
{ // Slot 1
g_PlayerAssignments = { "local": { "name": "You", "player": 1, "civ": "", "team": -1} };
updatePlayerList();
}
else
{
for (var guid in g_PlayerAssignments)
{ // Unassign extra players
var player = g_PlayerAssignments[guid].player;
if (player <= g_MaxPlayers && player > g_NumPlayers)
Engine.AssignNetworkPlayer(player, "");
}
}
if (g_IsNetworked)
Engine.SetNetworkGameAttributes(g_GameAttributes);
else