Skip to content

Commit

Permalink
Fixed GameConfig parsing crash, added pre release versioning
Browse files Browse the repository at this point in the history
GameConfigs would fail to parse if they started with GameConfig.txt instead of Configs
  • Loading branch information
Exactol committed May 25, 2019
1 parent 49ab52c commit 423ce24
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CompilePalX/CompilePalX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
<Content Include="Compiling\errorstyle.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="version_prerelease.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Keys\materialkeys.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
10 changes: 9 additions & 1 deletion CompilePalX/GameConfiguration/GameConfigurationParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;

public static class sutil {
Expand Down Expand Up @@ -98,6 +99,13 @@ public class DataBlock {

return null;
}
public DataBlock GetFirstByName(string[] names) {
for (int i = 0; i < this.subBlocks.Count; i++)
if (names.Contains(this.subBlocks[i].name))
return this.subBlocks[i];

return null;
}

public List<DataBlock> GetAllByName(string _name) {
List<DataBlock> c = new List<DataBlock>();
Expand Down Expand Up @@ -140,7 +148,7 @@ class GameConfigurationParser {

KV.FileData data = new KV.FileData(filename);

foreach (KV.DataBlock gamedb in data.headnode.GetFirstByName("\"Configs\"").GetFirstByName("\"Games\"").subBlocks) {
foreach (KV.DataBlock gamedb in data.headnode.GetFirstByName(new []{"\"Configs\"", "\"GameConfig.txt\""}).GetFirstByName("\"Games\"").subBlocks) {
string binfolder = Path.GetDirectoryName(filename);
KV.DataBlock hdb = gamedb.GetFirstByName("\"Hammer\"");

Expand Down
13 changes: 10 additions & 3 deletions CompilePalX/Updating/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ static class UpdateManager
{
public static event UpdateFound OnUpdateFound;

public static int CurrentVersion;
public static int LatestVersion;
public static float CurrentVersion;
public static float CurrentPrereleaseVersion;
public static float LatestVersion;
public static float LatestPrereleaseVersion;

private const string UpdateURL = "https://raw.githubusercontent.com/ruarai/CompilePal/master/CompilePalX/version.txt";

public static void CheckVersion()
{
string currentVersion = File.ReadAllText(CompilePalPath.Directory + "version.txt");
CurrentVersion = int.Parse(currentVersion);
string currentPrereleaseVersion = File.ReadAllText(CompilePalPath.Directory + "version_prerelease.txt");
CurrentVersion = float.Parse(currentVersion);
CurrentPrereleaseVersion = float.Parse(currentPrereleaseVersion);

if (CurrentPrereleaseVersion > CurrentVersion)
CurrentVersion = CurrentPrereleaseVersion;

Thread updaterThread = new Thread(ThreadedCheck);
updaterThread.Start();
Expand Down
1 change: 1 addition & 0 deletions CompilePalX/version_prerelease.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
026.1

0 comments on commit 423ce24

Please sign in to comment.