Prevent players and AIs being assigned to the same slot simultaneously in SP and MP if persist-match-settings were enabled

following the wrong move of this clearance from updatePlayerList to
handlePlayerAssignmentMessage.

Differential Revision: https://code.wildfiregames.com/D434
Reviewed By: Imarok
This was SVN commit r19602.
This commit is contained in:
elexis 2017-05-17 22:01:23 +00:00
parent 4bacd6f38e
commit 5302e3e1f7

View file

@ -1207,6 +1207,7 @@ function handlePlayerAssignmentMessage(message)
g_PlayerAssignments = message.newAssignments;
sanitizePlayerData(g_GameAttributes.settings.PlayerData);
updateGUIObjects();
sendRegisterGameStanza();
}
@ -1231,9 +1232,6 @@ function onClientJoin(newGUID, newAssignments)
if (g_IsController && newAssignments[newGUID].player == -1)
Engine.AssignNetworkPlayer(freeSlot + 1, newGUID);
g_GameAttributes.settings.PlayerData[freeSlot].AI = "";
g_GameAttributes.settings.PlayerData[freeSlot].AIDiff = g_DefaultPlayerData[freeSlot].AIDiff;
resetReadyData();
}
@ -1424,6 +1422,10 @@ function sanitizePlayerData(playerData)
let smallestDistance = colorDistances.find(distance => colorDistances.every(distance2 => (distance2 >= distance)));
pData.Color = g_PlayerColorPickerList.find(color => colorDistance(color, pData.Color) == smallestDistance);
}
// If there is a player in that slot, then there can't be an AI
if (Object.keys(g_PlayerAssignments).some(guid => g_PlayerAssignments[guid].player == index + 1))
pData.AI = "";
});
ensureUniquePlayerColors(playerData);