protected override ushort ServerReadValueWithRange() { var description = this.DescriptionForConfigFile + Environment.NewLine + SharedGetAllowedRangeString(this.ValueMin.ToString(), this.ValueMax.ToString()); var settingValue = ServerRatesApi.Get(this.Id, this.ValueDefault, description); var clampedValue = MathHelper.Clamp(settingValue, this.ValueMin, this.ValueMax); // ReSharper disable once CompareOfFloatsByEqualityOperator if (settingValue == clampedValue) { return((ushort)settingValue); } Api.Logger.Error( string.Format( "Server rate value is out of range and was reset: Name={0}. Current value={1}. Allowed range: from {2} to {3}", this.Id, settingValue, this.ValueMin, this.ValueMax)); ServerRatesApi.Reset(this.Id, this.ValueDefault, description); return(this.ValueDefault); }
protected override bool ServerReadValue() { var defaultValue = this.ValueDefault ? 1 : 0; var settingValue = ServerRatesApi.Get(this.Id, defaultValue, this.DescriptionForConfigFile); var clampedValue = MathHelper.Clamp(settingValue, 0, 1); // ReSharper disable once CompareOfFloatsByEqualityOperator if (settingValue == clampedValue) { return(settingValue == 1); } Api.Logger.Error( string.Format( "Server rate value is out of range and was reset: Name={0}. Current value={1}. Allowed range: from {2} to {3}", this.Id, settingValue, 0, 1)); ServerRatesApi.Reset(this.Id, defaultValue, this.DescriptionForConfigFile); return(this.ValueDefault); }
protected override string ServerReadValue() { var currentValue = ServerRatesApi.Get(this.Id, this.ValueDefault, this.Description); if (string.IsNullOrEmpty(currentValue) || currentValue == "0") { // most server owners will likely configure this setting to empty string or simple "0" // with intent to disable the time gates currentValue = ValueNoTimeGates; } try { sharedTimeGateDurations = ParseTimeGating(currentValue); } catch { Api.Logger.Error($"Incorrect format for server rate: {this.Id} current value {currentValue}"); ServerRatesApi.Reset(this.Id, this.ValueDefault, this.Description); currentValue = this.ValueDefault; sharedTimeGateDurations = ParseTimeGating(currentValue); } return(currentValue); }
protected override string ServerReadValue() { var currentValue = ServerRatesApi.Get(this.Id, this.ValueDefault, this.Description); try { SharedFactionUpgradeCosts = ParseFactionUpgradeCosts(currentValue); } catch { Api.Logger.Error( $"Incorrect format for server rate: {this.Id} current value {currentValue}. Please note that the values must be separated by comma and each value must be NOT higher than 65535."); ServerRatesApi.Reset(this.Id, this.ValueDefault, this.Description); currentValue = this.ValueDefault; SharedFactionUpgradeCosts = ParseFactionUpgradeCosts(currentValue); } return(currentValue); }