mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 10:34:01 +00:00
Prevent GameSettings from setting more players than the map supports
This commit is contained in:
committed by
wraitii
parent
3a94cb0bfe
commit
fed028a386
@@ -3,6 +3,7 @@ GameSettings.prototype.Attributes.PlayerCount = class PlayerCount extends GameSe
|
||||
init()
|
||||
{
|
||||
this.nbPlayers = 1;
|
||||
this.maxPlayers = g_MaxPlayers;
|
||||
this.settings.map.watch(() => this.onMapTypeChange(), ["type"]);
|
||||
this.settings.map.watch(() => this.onMapChange(), ["map"]);
|
||||
}
|
||||
@@ -25,6 +26,8 @@ GameSettings.prototype.Attributes.PlayerCount = class PlayerCount extends GameSe
|
||||
{
|
||||
if (this.settings.map.type == "random" && old != "random")
|
||||
this.nbPlayers = 2;
|
||||
if (this.settings.map.type === "random")
|
||||
this.maxPlayers = g_MaxPlayers;
|
||||
}
|
||||
|
||||
onMapChange()
|
||||
@@ -35,6 +38,7 @@ GameSettings.prototype.Attributes.PlayerCount = class PlayerCount extends GameSe
|
||||
!this.settings.map.data.settings.PlayerData)
|
||||
return;
|
||||
this.nbPlayers = this.settings.map.data.settings.PlayerData.length;
|
||||
this.maxPlayers = this.settings.map.data.settings.PlayerData.length;
|
||||
}
|
||||
|
||||
reloadFromLegacy(data)
|
||||
@@ -60,6 +64,6 @@ GameSettings.prototype.Attributes.PlayerCount = class PlayerCount extends GameSe
|
||||
|
||||
setNb(nb)
|
||||
{
|
||||
this.nbPlayers = Math.max(1, Math.min(g_MaxPlayers, nb));
|
||||
this.nbPlayers = Math.max(1, Math.min(this.maxPlayers, nb));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user