mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Remove check invalid setting (no needed) (#606)
This commit is contained in:
1 parent
89de63729b
commit
1c9a229f69
6 files changed
+16
-95
No files matched your search
@@ -19,7 +19,7 @@ public abstract class GameOptionsSender
|
||||
|
||||
private Il2CppStructArray<byte> BuildOptionArray()
|
||||
{
|
||||
IGameOptions opt = BuildSendableGameOptions();
|
||||
IGameOptions opt = BuildGameOptions();
|
||||
var currentGameMode = AprilFoolsMode.IsAprilFoolsModeToggledOn ? opt.AprilFoolsOnMode : opt.GameMode;
|
||||
|
||||
// option => byte[]
|
||||
@@ -109,59 +109,6 @@ public abstract class GameOptionsSender
|
||||
}
|
||||
|
||||
public abstract IGameOptions BuildGameOptions();
|
||||
|
||||
protected IGameOptions BuildSendableGameOptions()
|
||||
{
|
||||
return SanitizeForOfficialServer(BuildGameOptions());
|
||||
}
|
||||
|
||||
protected static IGameOptions SanitizeForOfficialServer(IGameOptions opt)
|
||||
{
|
||||
if (CurrentServerType != ServerType.Vanilla || opt == null || !opt.TryCast(out NormalGameOptionsV10 normalOpt))
|
||||
return opt;
|
||||
|
||||
int originalMaxPlayers = normalOpt.MaxPlayers;
|
||||
int originalImpostors = normalOpt.NumImpostors;
|
||||
int originalKillDistance = normalOpt.KillDistance;
|
||||
float originalPlayerSpeed = normalOpt.PlayerSpeedMod;
|
||||
bool changed = false;
|
||||
|
||||
if (normalOpt.MaxPlayers > 15)
|
||||
{
|
||||
normalOpt.SetInt(Int32OptionNames.MaxPlayers, 15);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
int impostors = Mathf.Clamp(normalOpt.NumImpostors, 1, 3);
|
||||
if (impostors != normalOpt.NumImpostors)
|
||||
{
|
||||
normalOpt.SetInt(Int32OptionNames.NumImpostors, impostors);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
int killDistance = Mathf.Clamp(normalOpt.KillDistance, 0, 2);
|
||||
if (killDistance != normalOpt.KillDistance)
|
||||
{
|
||||
normalOpt.SetInt(Int32OptionNames.KillDistance, killDistance);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
float playerSpeed = Mathf.Clamp(normalOpt.PlayerSpeedMod, Main.MinSpeed, 3f);
|
||||
if (!Mathf.Approximately(playerSpeed, normalOpt.PlayerSpeedMod))
|
||||
{
|
||||
normalOpt.SetFloat(FloatOptionNames.PlayerSpeedMod, playerSpeed);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
Logger.Warn(
|
||||
$"Clamped outgoing official game options: MaxPlayers={originalMaxPlayers}->{normalOpt.MaxPlayers}, NumImpostors={originalImpostors}->{normalOpt.NumImpostors}, KillDistance={originalKillDistance}->{normalOpt.KillDistance}, PlayerSpeedMod={originalPlayerSpeed:0.###}->{normalOpt.PlayerSpeedMod:0.###}",
|
||||
nameof(GameOptionsSender));
|
||||
}
|
||||
|
||||
return normalOpt.CastFast<IGameOptions>();
|
||||
}
|
||||
|
||||
protected virtual bool AmValid()
|
||||
{
|
||||
|
||||
@@ -110,7 +110,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
|
||||
{
|
||||
if (player.AmOwner)
|
||||
{
|
||||
IGameOptions opt = BuildSendableGameOptions();
|
||||
IGameOptions opt = BuildGameOptions();
|
||||
|
||||
if (GameManager.Instance?.LogicComponents != null)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
|
||||
{
|
||||
if (player.AmOwner)
|
||||
{
|
||||
IGameOptions opt = BuildSendableGameOptions();
|
||||
IGameOptions opt = BuildGameOptions();
|
||||
|
||||
if (GameManager.Instance?.LogicComponents != null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user