Skip to content

Commit 951d581

Browse files
committed
Use SharedInfo + Add ConfigGenerator version check
1 parent d68bb01 commit 951d581

File tree

9 files changed

+73
-12
lines changed

9 files changed

+73
-12
lines changed

ArchiSteamFarm/ArchiSteamFarm.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<Compile Include="ObsoleteSteamGuardAccount.cs" />
115115
<Compile Include="Program.cs" />
116116
<Compile Include="Properties\AssemblyInfo.cs" />
117+
<Compile Include="SharedInfo.cs" />
117118
<Compile Include="Trading.cs" />
118119
<Compile Include="Utilities.cs" />
119120
<Compile Include="WCF.cs" />

ArchiSteamFarm/Bot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ private string ResponseHelp(ulong steamID) {
881881
return null;
882882
}
883883

884-
return "https://github.com/" + Program.GithubRepo + "/wiki/Commands";
884+
return "https://github.com/" + SharedInfo.GithubRepo + "/wiki/Commands";
885885
}
886886

887887
private async Task<string> ResponseRedeem(ulong steamID, string message, bool validate) {

ArchiSteamFarm/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ private enum EMode : byte {
6161
internal const string ConfigDirectory = "config";
6262
internal const string DebugDirectory = "debug";
6363
internal const string LogFile = "log.txt";
64-
internal const string GithubRepo = "JustArchi/ArchiSteamFarm";
6564

6665
private const string ASF = "ASF";
67-
private const string GithubReleaseURL = "https://api.github.com/repos/" + GithubRepo + "/releases"; // GitHub API is HTTPS only
66+
private const string GithubReleaseURL = "https://api.github.com/repos/" + SharedInfo.GithubRepo + "/releases"; // GitHub API is HTTPS only
6867
private const string GlobalConfigFile = ASF + ".json";
6968
private const string GlobalDatabaseFile = ASF + ".db";
7069

ArchiSteamFarm/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
3+
using ArchiSteamFarm;
34

45
// General Information about an assembly is controlled through the following
56
// set of attributes. Change these attribute values to modify the information
@@ -9,7 +10,7 @@
910
[assembly: AssemblyConfiguration("")]
1011
[assembly: AssemblyCompany("")]
1112
[assembly: AssemblyProduct("ArchiSteamFarm")]
12-
[assembly: AssemblyCopyright("Copyright © ArchiSteamFarm 2015-2016")]
13+
[assembly: AssemblyCopyright(SharedInfo.Copyright)]
1314
[assembly: AssemblyTrademark("")]
1415
[assembly: AssemblyCulture("")]
1516

@@ -31,5 +32,5 @@
3132
// You can specify all the values or you can default the Build and Revision Numbers
3233
// by using the '*' as shown below:
3334
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("2.1.1.2")]
35-
[assembly: AssemblyFileVersion("2.1.1.2")]
35+
[assembly: AssemblyVersion(SharedInfo.Version)]
36+
[assembly: AssemblyFileVersion(SharedInfo.Version)]

ArchiSteamFarm/SharedInfo.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
_ _ _ ____ _ _____
3+
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4+
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5+
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6+
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7+
8+
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
9+
10+
11+
Licensed under the Apache License, Version 2.0 (the "License");
12+
you may not use this file except in compliance with the License.
13+
You may obtain a copy of the License at
14+
15+
http://www.apache.org/licenses/LICENSE-2.0
16+
17+
Unless required by applicable law or agreed to in writing, software
18+
distributed under the License is distributed on an "AS IS" BASIS,
19+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
See the License for the specific language governing permissions and
21+
limitations under the License.
22+
23+
*/
24+
25+
namespace ArchiSteamFarm {
26+
internal static class SharedInfo {
27+
internal const string Copyright = "Copyright © ArchiSteamFarm 2015-2016";
28+
internal const string Version = "2.1.1.2";
29+
30+
internal const string GithubRepo = "JustArchi/ArchiSteamFarm";
31+
}
32+
}

ConfigGenerator/ConfigGenerator.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
<Reference Include="System.Windows.Forms" />
5050
</ItemGroup>
5151
<ItemGroup>
52+
<Compile Include="..\ArchiSteamFarm\SharedInfo.cs">
53+
<Link>SharedInfo.cs</Link>
54+
</Compile>
5255
<Compile Include="ASFConfig.cs" />
5356
<Compile Include="BotConfig.cs" />
5457
<Compile Include="DialogBox.cs" />

ConfigGenerator/MainForm.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ limitations under the License.
2929
using System.Linq;
3030
using System.Text.RegularExpressions;
3131
using System.Windows.Forms;
32+
using ArchiSteamFarm;
3233

3334
namespace ConfigGenerator {
3435
internal sealed partial class MainForm : Form {
@@ -196,7 +197,7 @@ private void MainForm_HelpButtonClicked(object sender, CancelEventArgs args) {
196197

197198
args.Cancel = true;
198199
Tutorial.OnAction(Tutorial.EPhase.Help);
199-
Process.Start("https://github.com/JustArchi/ArchiSteamFarm/wiki/Configuration");
200+
Process.Start("https://github.com/" + SharedInfo.GithubRepo + "/wiki/Configuration");
200201
Tutorial.OnAction(Tutorial.EPhase.HelpFinished);
201202
}
202203
}

ConfigGenerator/Program.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ limitations under the License.
2323
*/
2424

2525
using System;
26+
using System.Diagnostics;
2627
using System.IO;
2728
using System.Reflection;
2829
using System.Threading.Tasks;
2930
using System.Windows.Forms;
31+
using ArchiSteamFarm;
3032

3133
namespace ConfigGenerator {
3234
internal static class Program {
@@ -35,8 +37,10 @@ internal static class Program {
3537
internal const string GlobalConfigFile = ASF + ".json";
3638

3739
private const string ASFDirectory = "ArchiSteamFarm";
40+
private const string ASFExecutableFile = ASF + ".exe";
3841

3942
private static readonly string ExecutableDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
43+
private static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
4044

4145
/// <summary>
4246
/// The main entry point for the application.
@@ -75,11 +79,30 @@ private static void Init() {
7579
}
7680
}
7781

78-
if (Directory.Exists(ConfigDirectory)) {
82+
if (!Directory.Exists(ConfigDirectory)) {
83+
Logging.LogGenericErrorWithoutStacktrace("Config directory could not be found!");
84+
Environment.Exit(1);
85+
}
86+
87+
if (!File.Exists(ASFExecutableFile)) {
7988
return;
8089
}
8190

82-
Logging.LogGenericErrorWithoutStacktrace("Config directory could not be found!");
91+
FileVersionInfo asfVersionInfo = FileVersionInfo.GetVersionInfo(ASFExecutableFile);
92+
93+
Version asfVersion = new Version(asfVersionInfo.ProductVersion);
94+
if (Version == asfVersion) {
95+
return;
96+
}
97+
98+
Logging.LogGenericErrorWithoutStacktrace(
99+
"Version of ASF and ConfigGenerator doesn't match!" + Environment.NewLine +
100+
"ASF version: " + asfVersion + " | ConfigGenerator version: " + Version + Environment.NewLine +
101+
Environment.NewLine +
102+
"Please use ConfigGenerator from the same ASF release, I'll redirect you to appropriate ASF release..."
103+
);
104+
105+
Process.Start("https://github.com/" + SharedInfo.GithubRepo + "/releases/tag/" + asfVersion);
83106
Environment.Exit(1);
84107
}
85108

ConfigGenerator/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
3+
using ArchiSteamFarm;
34

45
// General Information about an assembly is controlled through the following
56
// set of attributes. Change these attribute values to modify the information
@@ -9,7 +10,7 @@
910
[assembly: AssemblyConfiguration("")]
1011
[assembly: AssemblyCompany("")]
1112
[assembly: AssemblyProduct("ConfigGenerator")]
12-
[assembly: AssemblyCopyright("Copyright © ArchiSteamFarm 2015-2016")]
13+
[assembly: AssemblyCopyright(SharedInfo.Copyright)]
1314
[assembly: AssemblyTrademark("")]
1415
[assembly: AssemblyCulture("")]
1516

@@ -31,5 +32,5 @@
3132
// You can specify all the values or you can default the Build and Revision Numbers
3233
// by using the '*' as shown below:
3334
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion(SharedInfo.Version)]
36+
[assembly: AssemblyFileVersion(SharedInfo.Version)]

0 commit comments

Comments
 (0)