1
0
forked from 0ad/0ad

Ensure rated game and cheat won't be enabled at the same time.

Reported by: Freagarach
Differential Revision: https://code.wildfiregames.com/D3943
This was SVN commit r25418.
This commit is contained in:
wraitii 2021-05-10 07:49:30 +00:00
parent 5fbdbaa3bc
commit ad62707eef

View File

@ -4,6 +4,7 @@ GameSettings.prototype.Attributes.Rating = class Rating extends GameSetting
{ {
this.hasXmppClient = Engine.HasXmppClient(); this.hasXmppClient = Engine.HasXmppClient();
this.settings.playerCount.watch(() => this.maybeUpdate(), ["nbPlayers"]); this.settings.playerCount.watch(() => this.maybeUpdate(), ["nbPlayers"]);
this.settings.cheats.watch(() => this.maybeUpdate(), ["enabled"]);
this.maybeUpdate(); this.maybeUpdate();
} }
@ -30,7 +31,9 @@ GameSettings.prototype.Attributes.Rating = class Rating extends GameSetting
maybeUpdate() maybeUpdate()
{ {
// This setting is activated by default if it's possible. // This setting is activated by default if it's possible.
this.available = this.hasXmppClient && this.settings.playerCount.nbPlayers === 2; this.available = this.hasXmppClient &&
this.settings.playerCount.nbPlayers === 2 &&
!this.settings.cheats.enabled;
this.enabled = this.available; this.enabled = this.available;
} }
}; };