-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathversion.inc
70 lines (57 loc) · 1.47 KB
/
version.inc
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
/**
* Stock functions for game version identification.
*/
#if defined __stocksoup_version_included
#endinput
#endif
#define __stocksoup_version_included
/**
* Returns a StringMap containing key-value entries from steam.inf.
*/
static stock StringMap GetSteamINFData() {
static StringMap s_VersionInfo;
if (!s_VersionInfo) {
s_VersionInfo = new StringMap();
File hSteam = OpenFile("steam.inf", "r");
char buffer[32];
while (hSteam.ReadLine(buffer, sizeof(buffer))) {
int assign = FindCharInString(buffer, '=');
if (assign != -1) {
// copy everything up to equals sign
char[] key = new char[assign + 1];
strcopy(key, assign + 1, buffer);
s_VersionInfo.SetString(key, buffer[assign + 1]);
}
}
delete hSteam;
}
return s_VersionInfo;
}
stock int GetNetworkPatchVersion() {
char buffer[16];
if (GetSteamINFData().GetString("PatchVersion", buffer, sizeof(buffer))) {
return StringToInt(buffer);
}
return 0;
}
stock int GetApplicationClientVersion() {
char buffer[16];
if (GetSteamINFData().GetString("ClientVersion", buffer, sizeof(buffer))) {
return StringToInt(buffer);
}
return 0;
}
stock int GetApplicationServerVersion() {
char buffer[16];
if (GetSteamINFData().GetString("ServerVersion", buffer, sizeof(buffer))) {
return StringToInt(buffer);
}
return 0;
}
stock int GetAppID() {
char buffer[16];
if (GetSteamINFData().GetString("appID", buffer, sizeof(buffer))) {
return StringToInt(buffer);
}
return 0;
}