diff --git a/.travis.yml b/.travis.yml
index 68a01cbaf..2eb13e1fb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,4 @@
+sudo: false
language: csharp
solution: ArchiSteamFarm.sln
diff --git a/ConfigGenerator/ConfigGenerator.csproj b/ConfigGenerator/ConfigGenerator.csproj
index 2bf79bff0..d3b742478 100644
--- a/ConfigGenerator/ConfigGenerator.csproj
+++ b/ConfigGenerator/ConfigGenerator.csproj
@@ -48,7 +48,6 @@
-
diff --git a/ConfigGenerator/GlobalConfig.cs b/ConfigGenerator/GlobalConfig.cs
index 64b8fec37..4a319e2b5 100644
--- a/ConfigGenerator/GlobalConfig.cs
+++ b/ConfigGenerator/GlobalConfig.cs
@@ -36,6 +36,13 @@ namespace ConfigGenerator {
Experimental
}
+ private const byte DefaultMaxFarmingTime = 10;
+ private const byte DefaultFarmingDelay = 5;
+ private const byte DefaultHttpTimeout = 60;
+ private const ushort DefaultWCFPort = 1242;
+
+ private static readonly ProtocolType DefaultSteamProtocol = ProtocolType.Tcp;
+
// This is hardcoded blacklist which should not be possible to change
internal static readonly HashSet GlobalBlacklist = new HashSet { 267420, 303700, 335590, 368020, 425280 };
@@ -49,19 +56,19 @@ namespace ConfigGenerator {
public EUpdateChannel UpdateChannel { get; set; } = EUpdateChannel.Stable;
[JsonProperty(Required = Required.DisallowNull)]
- public ProtocolType SteamProtocol { get; set; } = ProtocolType.Tcp;
+ public ProtocolType SteamProtocol { get; set; } = DefaultSteamProtocol;
[JsonProperty(Required = Required.DisallowNull)]
public ulong SteamOwnerID { get; set; } = 0;
[JsonProperty(Required = Required.DisallowNull)]
- public byte MaxFarmingTime { get; set; } = 10;
+ public byte MaxFarmingTime { get; set; } = DefaultMaxFarmingTime;
[JsonProperty(Required = Required.DisallowNull)]
public byte IdleFarmingPeriod { get; set; } = 3;
[JsonProperty(Required = Required.DisallowNull)]
- public byte FarmingDelay { get; set; } = 5;
+ public byte FarmingDelay { get; set; } = DefaultFarmingDelay;
[JsonProperty(Required = Required.DisallowNull)]
public byte AccountPlayingDelay { get; set; } = 5;
@@ -76,13 +83,13 @@ namespace ConfigGenerator {
public bool ForceHttp { get; set; } = false;
[JsonProperty(Required = Required.DisallowNull)]
- public byte HttpTimeout { get; set; } = 60;
+ public byte HttpTimeout { get; set; } = DefaultHttpTimeout;
- [JsonProperty(Required = Required.DisallowNull)]
+ [JsonProperty]
public string WCFHostname { get; set; } = "localhost";
[JsonProperty(Required = Required.DisallowNull)]
- public ushort WCFPort { get; set; } = 1242;
+ public ushort WCFPort { get; set; } = DefaultWCFPort;
[JsonProperty(Required = Required.DisallowNull)]
public bool LogToFile { get; set; } = true;
@@ -111,23 +118,43 @@ namespace ConfigGenerator {
globalConfig = JsonConvert.DeserializeObject(File.ReadAllText(filePath));
} catch (Exception e) {
Logging.LogGenericException(e);
- return new GlobalConfig(filePath);
+ return null;
}
- globalConfig.FilePath = filePath;
-
// SK2 supports only TCP and UDP steam protocols
- // Make sure that user can't screw this up
+ // Ensure that user can't screw this up
switch (globalConfig.SteamProtocol) {
case ProtocolType.Tcp:
case ProtocolType.Udp:
break;
default:
- Logging.LogGenericWarning("Configured SteamProtocol is invalid: " + globalConfig.SteamProtocol + ", default TCP protocol will be used instead");
- globalConfig.SteamProtocol = ProtocolType.Tcp;
+ Logging.LogGenericWarning("Configured SteamProtocol is invalid: " + globalConfig.SteamProtocol + ". Value of " + DefaultSteamProtocol + " will be used instead");
+ globalConfig.SteamProtocol = DefaultSteamProtocol;
break;
}
+ // User might not know what he's doing
+ // Ensure that he can't screw core ASF variables
+ if (globalConfig.MaxFarmingTime == 0) {
+ Logging.LogGenericWarning("Configured MaxFarmingTime is invalid: " + globalConfig.MaxFarmingTime + ". Value of " + DefaultMaxFarmingTime + " will be used instead");
+ globalConfig.MaxFarmingTime = DefaultMaxFarmingTime;
+ }
+
+ if (globalConfig.FarmingDelay == 0) {
+ Logging.LogGenericWarning("Configured FarmingDelay is invalid: " + globalConfig.FarmingDelay + ". Value of " + DefaultFarmingDelay + " will be used instead");
+ globalConfig.FarmingDelay = DefaultFarmingDelay;
+ }
+
+ if (globalConfig.HttpTimeout == 0) {
+ Logging.LogGenericWarning("Configured HttpTimeout is invalid: " + globalConfig.HttpTimeout + ". Value of " + DefaultHttpTimeout + " will be used instead");
+ globalConfig.HttpTimeout = DefaultHttpTimeout;
+ }
+
+ if (globalConfig.WCFPort == 0) {
+ Logging.LogGenericWarning("Configured WCFPort is invalid: " + globalConfig.WCFPort + ". Value of " + DefaultWCFPort + " will be used instead");
+ globalConfig.WCFPort = DefaultWCFPort;
+ }
+
return globalConfig;
}