-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGameVersion.cs
More file actions
155 lines (136 loc) · 5.48 KB
/
GameVersion.cs
File metadata and controls
155 lines (136 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
using System.IO;
namespace ModAPI.Common
{
public enum GameVersionType
{
/// <summary>3.0.0.2818 (July 2009) installed from disc, with patch 5.1</summary>
Disc,
/// <summary>3.1.0.22 (March 2017) installed from Origin, requires ModAPI Fix</summary>
Origin_March2017,
/// <summary>3.1.0.29 (October 2024) installed from EA App or Origin, requires ModAPI Fix</summary>
EA_October2024,
/// <summary>3.1.0.22 (March 2017) installed from GOG or Steam</summary>
Steam_March2017,
/// <summary>3.1.0.29 (October 2024) installed from GOG</summary>
GOG_October2024,
/// <summary>3.1.0.29 (October 2024) installed from Steam, has steamstub DRM</summary>
Steam_October2024,
None
}
public static class GameVersion
{
private static readonly int[] ExecutableSizes = {
24909584, // Disc
24898224, // Origin_March2017
24906040, // EA_October2024
24885248, // Steam_March2017
24895536, // GoG_October2024
25066744 // Steam_October2024
};
public static bool RequiresModAPIFix(GameVersionType versionType)
{
return versionType == GameVersionType.Origin_March2017 ||
versionType == GameVersionType.EA_October2024;
}
public static GameVersionType DetectVersion(string path)
{
if (!string.IsNullOrEmpty(path))
{
var length = new FileInfo(path).Length;
for (int i = 0; i < ExecutableSizes.Length; i++)
{
if (length == ExecutableSizes[i])
{
return (GameVersionType)i;
}
}
}
return GameVersionType.None;
}
public static string GetVersionName(GameVersionType type)
{
switch (type)
{
case GameVersionType.Disc:
return "disk";
case GameVersionType.Origin_March2017:
case GameVersionType.EA_October2024:
case GameVersionType.Steam_March2017:
case GameVersionType.GOG_October2024:
case GameVersionType.Steam_October2024:
return "steam_patched";
default:
return null;
}
}
public static string GetExecutableFileName(GameVersionType type)
{
switch (type)
{
case GameVersionType.Disc:
case GameVersionType.Steam_March2017:
case GameVersionType.GOG_October2024:
case GameVersionType.Steam_October2024:
return "SporeApp.exe";
// Origin and EA App have extra DRM
// which requires the ModAPIFix executable
case GameVersionType.Origin_March2017:
case GameVersionType.EA_October2024:
return "SporeApp_ModAPIFix.exe";
default:
return null;
}
}
public static string GetNewDLLName(GameVersionType type)
{
switch (type)
{
case GameVersionType.Disc:
return "SporeModAPI.disk.dll";
case GameVersionType.Origin_March2017:
case GameVersionType.EA_October2024:
case GameVersionType.Steam_March2017:
case GameVersionType.GOG_October2024:
case GameVersionType.Steam_October2024:
return "SporeModAPI.march2017.dll";
default:
return null;
}
}
public static string GetFriendlyVersionName(GameVersionType type)
{
switch (type)
{
case GameVersionType.Disc:
return "Disc + Patch 5.1, July 2009";
case GameVersionType.Origin_March2017:
return "Origin, March 2017";
case GameVersionType.EA_October2024:
return "EA App, October 2024";
case GameVersionType.Steam_March2017:
return "GOG/Steam, March 2017";
case GameVersionType.GOG_October2024:
return "GOG, October 2024";
case GameVersionType.Steam_October2024:
return "Steam, October 2024";
default:
return "Unknown";
}
}
/// <summary>
/// Returns true if this version type is compatible with LAA (Large Address Aware, aka 4GB patch).
/// </summary>
public static bool IsLAACompatible(GameVersionType type)
{
switch (type)
{
// Steam_October2024 has steamstub DRM which prevents modification of the exe, thus preventing the game from running if LAA is set in PE header
case GameVersionType.Steam_October2024:
return false;
// No known issues with any other versions
default:
return true;
}
}
}
}