Index: binaries/data/config/default.cfg
===================================================================
--- binaries/data/config/default.cfg
+++ binaries/data/config/default.cfg
@@ -332,6 +332,7 @@
[gui.gamesetup]
enabletips = true ; Enable/Disable tips during gamesetup (for newcomers)
+assignplayers = everyone ; Whether to assign joining clients to free playerslots. Possible values: everyone, buddies, noone.
[gui.session]
camerajump.threshold = 40 ; How close do we have to be to the actual location in order to jump back to the previous one?
Index: binaries/data/mods/public/gui/gamesetup/gamesetup.js
===================================================================
--- binaries/data/mods/public/gui/gamesetup/gamesetup.js
+++ binaries/data/mods/public/gui/gamesetup/gamesetup.js
@@ -1279,22 +1279,35 @@
function onClientJoin(newGUID, newAssignments)
{
+ let playername = newAssignments[newGUID].name;
+
addChatMessage({
"type": "connect",
"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) =>
Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player != i+1)
);
// Client is not and cannot become assigned as player
- if (newAssignments[newGUID].player == -1 && freeSlot == -1)
+ if (!isRejoiningPlayer && freeSlot == -1)
return;
// Assign the joining client to the free slot
- if (g_IsController && newAssignments[newGUID].player == -1)
+ if (g_IsController && !isRejoiningPlayer)
Engine.AssignNetworkPlayer(freeSlot + 1, newGUID);
resetReadyData();
Index: binaries/data/mods/public/gui/options/options.json
===================================================================
--- binaries/data/mods/public/gui/options/options.json
+++ binaries/data/mods/public/gui/options/options.json
@@ -80,6 +80,19 @@
"parameters": { "config": "persistmatchsettings" }
},
{
+ "type": "dropdown",
+ "label": "Assign Players",
+ "tooltip": "Whether to assign joining clients to free playerslots in the gamesetup.",
+ "parameters": {
+ "config": "gui.gamesetup.assignplayers",
+ "list": [
+ { "value": "noone", "label": "Noone" },
+ { "value": "buddies", "label": "Buddies" },
+ { "value": "everyone", "label": "Everyone" }
+ ]
+ }
+ },
+ {
"type": "boolean",
"label": "Late Observer Joins",
"tooltip": "Allow observers to join the game after it started",
Index: binaries/data/mods/public/gui/options/options.xml
===================================================================
--- binaries/data/mods/public/gui/options/options.xml
+++ binaries/data/mods/public/gui/options/options.xml
@@ -13,11 +13,11 @@
-