Skip to content

Commit 6795542

Browse files
steampp: add goldsrc engine checker
1 parent fd7b11d commit 6795542

File tree

8 files changed

+69
-2
lines changed

8 files changed

+69
-2
lines changed

include/steampp/steampp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class Steam {
4242

4343
[[nodiscard]] std::string getAppStoreArtPath(AppID appID) const;
4444

45+
[[nodiscard]] bool isAppUsingGoldSrcEngine(AppID appID) const;
46+
4547
[[nodiscard]] bool isAppUsingSourceEngine(AppID appID) const;
4648

4749
[[nodiscard]] bool isAppUsingSource2Engine(AppID appID) const;

lang/c/include/steamppc/steampp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ SOURCEPP_API sourcepp_string_t steampp_get_app_box_art_path(steampp_steam_handle
5151
// REQUIRES MANUAL FREE: sourcepp_string_free
5252
SOURCEPP_API sourcepp_string_t steampp_get_app_store_art_path(steampp_steam_handle_t handle, AppID appID);
5353

54+
SOURCEPP_API bool steampp_is_app_using_goldsrc_engine(steampp_steam_handle_t handle, AppID appID);
55+
5456
SOURCEPP_API bool steampp_is_app_using_source_engine(steampp_steam_handle_t handle, AppID appID);
5557

5658
SOURCEPP_API bool steampp_is_app_using_source_2_engine(steampp_steam_handle_t handle, AppID appID);

lang/c/src/steamppc/steampp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ SOURCEPP_API sourcepp_string_t steampp_get_app_store_art_path(steampp_steam_hand
9898
return Convert::toString(Convert::steam(handle)->getAppStoreArtPath(appID));
9999
}
100100

101+
SOURCEPP_API bool steampp_is_app_using_goldsrc_engine(steampp_steam_handle_t handle, AppID appID) {
102+
SOURCEPP_EARLY_RETURN_VAL(handle, false);
103+
104+
return Convert::steam(handle)->isAppUsingGoldSrcEngine(appID);
105+
}
106+
101107
SOURCEPP_API bool steampp_is_app_using_source_engine(steampp_steam_handle_t handle, AppID appID) {
102108
SOURCEPP_EARLY_RETURN_VAL(handle, false);
103109

lang/python/src/steampp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ inline void register_python(py::module_& m) {
2828
.def("get_app_logo_path", &Steam::getAppLogoPath, py::arg("appID"))
2929
.def("get_app_box_art_path", &Steam::getAppBoxArtPath, py::arg("appID"))
3030
.def("get_app_store_art_path", &Steam::getAppStoreArtPath, py::arg("appID"))
31+
.def("is_app_using_goldsrc_engine", &Steam::isAppUsingGoldSrcEngine, py::arg("appID"))
3132
.def("is_app_using_source_engine", &Steam::isAppUsingSourceEngine, py::arg("appID"))
3233
.def("is_app_using_source_2_engine", &Steam::isAppUsingSource2Engine, py::arg("appID"))
3334
.def("__bool__", &Steam::operator bool, py::is_operator());
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
632730, // Base Defense
2+
10, // Counter-Strike
3+
273110, // Counter-Strike Nexon
4+
80, // Counter-Strike: Condition Zero
5+
100, // Counter-Strike: Condition Zero Deleted Scenes
6+
223710, // Cry of Fear
7+
30, // Day of Defeat
8+
40, // Deathmatch Classic
9+
1707900, // Delta Particles
10+
70, // Half-Life
11+
1889470, // Half-Life Decay: Solo Mission DEMO
12+
90, // Half-Life Dedicated Server
13+
812440, // Half-Life: Absolute Zero
14+
130, // Half-Life: Blue Shift
15+
679990, // Half-Life: Caged
16+
2842160, // Half-Life: ESCAPE 2.0
17+
1761270, // Half-Life: MMod
18+
50, // Half-Life: Opposing Force
19+
1283930, // Half-Life: Restored
20+
3368040, // Half-Life: The Classic Collection
21+
1908720, // Half-Life: VR Mod
22+
3416640, // Half-Life: Zombies Ate My Neighbours
23+
638360, // Half-Rats: Parasomnia
24+
644320, // Halfquake Trilogy
25+
850870, // Hard-Life
26+
354900, // Headcrab Frenzy!
27+
1961680, // Master Sword: Rebirth
28+
60, // Ricochet
29+
225840, // Sven Co-op
30+
276060, // Sven Co-op Dedicated Server
31+
20, // Team Fortress Classic

src/steampp/cache/EngineSource.inl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@
109109
747250, // Half-Life 2: Year Long Alarm
110110
360, // Half-Life Deathmatch: Source
111111
255470, // Half-Life Deathmatch: Source Dedicated server
112-
2296760, // Half-Life: Hadron
113112
280, // Half-Life: Source
114113
1219590, // HEAT REBORN
115114
1523440, // HEAT REBORN BETA
@@ -156,6 +155,7 @@
156155
1802710, // Momentum Mod Playtest
157156
244630, // NEOTOKYO
158157
313600, // NEOTOKYO Dedicated Server
158+
2954780, // Nightmare House: The Original Mod
159159
224260, // No More Room in Hell
160160
317670, // No More Room in Hell Dedicated Server
161161
17710, // Nuclear Dawn
@@ -167,15 +167,19 @@
167167
17575, // Pirates, Vikings, and Knights II Dedicated Server
168168
400, // Portal
169169
620, // Portal 2
170+
2615420, // Portal: Ambition
171+
2665240, // Portal Ambition Demo
170172
213630, // Portal 2 - Educational Version
171173
247120, // Portal 2 Sixense Perceptual Pack
172174
440000, // Portal 2: Community Edition
175+
1400890, // Portal 2: Community Edition SDK
173176
2716490, // Portal 2: Confinement
174177
1255980, // Portal Reloaded
175178
317400, // Portal Stories: Mel
176179
2012840, // Portal with RTX
177180
410, // Portal: First Slice
178181
1636310, // Portal: Forbidden Testing Tracks
182+
3043220, // Portal: Lost in Aperture
179183
2410180, // Portal: Prelude RTX
180184
601360, // Portal: Revolution
181185
2266250, // Portal: Revolution Authoring Tools
@@ -215,6 +219,7 @@
215219
1197420, // Team Fortress: Throwback Dedicated Server
216220
303210, // The Beginner's Guide
217221
1007090, // The Burton Equation
222+
3281900, // The Cleaning Game
218223
314280, // The Forgotten Ones
219224
2403, // The Ship Dedicated Server
220225
2430, // The Ship Tutorial
@@ -238,6 +243,7 @@
238243
313240, // Wilson Chronicles
239244
22200, // Zeno Clash
240245
22220, // Zeno Clash Demo
246+
22210, // Zeno Clash Press
241247
813990, // Zombie Master: Reborn
242248
17500, // Zombie Panic! Source
243249
17505, // Zombie Panic! Source Dedicated Server

src/steampp/cache/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Cache Generation Steps
22

33
1. Open the following URL in your browser:
4+
- GoldSrc:
5+
- https://steamdb.info/tech/Engine/GoldSource/?sort=name_asc
46
- Source:
57
- https://steamdb.info/tech/Engine/Source/?sort=name_asc
68
- Source 2:
@@ -15,4 +17,4 @@
1517
console.log(o);
1618
```
1719
4. Copy the given output and paste it into the relevant file.
18-
5. Trim entries manually which don't actually match the given engine. SteamDB isn't perfect and stuff slips through the system. (For example, as of May 26, 2024, Portal 2: Community Edition is listed as a game that uses Source 2.)
20+
5. Trim entries manually which don't actually match the given engine. SteamDB isn't perfect and stuff slips through the system.

src/steampp/steampp.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ using namespace steampp;
2525

2626
namespace {
2727

28+
bool isAppUsingGoldSrcEnginePredicate(std::string_view installDir) {
29+
std::filesystem::directory_iterator dirIterator{installDir, std::filesystem::directory_options::skip_permission_denied};
30+
std::error_code ec;
31+
return std::any_of(std::filesystem::begin(dirIterator), std::filesystem::end(dirIterator), [&ec](const auto& entry){
32+
return entry.is_directory(ec) && std::filesystem::exists(entry.path() / "liblist.gam", ec);
33+
});
34+
}
35+
2836
bool isAppUsingSourceEnginePredicate(std::string_view installDir) {
2937
std::filesystem::directory_iterator dirIterator{installDir, std::filesystem::directory_options::skip_permission_denied};
3038
std::error_code ec;
@@ -52,6 +60,11 @@ bool isAppUsingSource2EnginePredicate(std::string_view installDir) {
5260

5361
// Note: this can't be a template because gcc threw a fit. No idea why
5462
std::unordered_set<AppID> getAppsKnownToUseEngine(bool(*p)(std::string_view)) {
63+
if (p == &::isAppUsingGoldSrcEnginePredicate) {
64+
return {
65+
#include "cache/EngineGoldSrc.inl"
66+
};
67+
}
5568
if (p == &::isAppUsingSourceEnginePredicate) {
5669
return {
5770
#include "cache/EngineSource.inl"
@@ -321,6 +334,10 @@ std::string Steam::getAppStoreArtPath(AppID appID) const {
321334
return path;
322335
}
323336

337+
bool Steam::isAppUsingGoldSrcEngine(AppID appID) const {
338+
return ::isAppUsingEngine<::isAppUsingGoldSrcEnginePredicate>(this, appID);
339+
}
340+
324341
bool Steam::isAppUsingSourceEngine(AppID appID) const {
325342
return ::isAppUsingEngine<::isAppUsingSourceEnginePredicate>(this, appID);
326343
}

0 commit comments

Comments
 (0)