Skip to content

Commit 260e898

Browse files
committed
feat: infer game path from compile target
1 parent ee4cd52 commit 260e898

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/main/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ file(GLOB_RECURSE HEADERS_LIST
66
"*.h"
77
)
88

9-
function(BUILD_GAME GAME)
9+
function(BUILD_GAME GAME GAME_PATH)
1010
add_executable(DumpSource2-${GAME} ${SOURCES_LIST} ${HEADERS_LIST})
1111

1212
target_link_libraries(DumpSource2-${GAME} PRIVATE
@@ -15,11 +15,11 @@ function(BUILD_GAME GAME)
1515
${CMAKE_DL_LIBS}
1616
)
1717

18-
target_compile_definitions(DumpSource2-${GAME} PRIVATE GAME_${GAME})
18+
target_compile_definitions(DumpSource2-${GAME} PRIVATE GAME_${GAME} GAME_PATH="${GAME_PATH}")
1919
endfunction()
2020

21-
build_game(CS2)
22-
build_game(DOTA)
21+
build_game(CS2 csgo)
22+
build_game(DOTA dota)
2323

2424
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Source Files" FILES ${SOURCES_LIST})
2525
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Header Files" FILES ${HEADERS_LIST})

src/main/appframework.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,25 @@ void InitializeAppSystems()
138138
{
139139
for (const auto& appSystem : g_appSystems)
140140
{
141-
if ((appSystem.flags & CS2_ONLY) != 0 && Globals::modName != "csgo")
141+
#ifndef GAME_CS2
142+
if ((appSystem.flags & CS2_ONLY) != 0)
142143
continue;
144+
#endif // !GAME_CS2
143145

144-
std::string path = appSystem.gameBin ? fmt::format("../../{}/bin/{}", Globals::modName.c_str(), PLATFORM_FOLDER) : "";
146+
std::string path = appSystem.gameBin ? fmt::format("../../{}/bin/{}", GAME_PATH, PLATFORM_FOLDER) : "";
145147

146148
CModule module(path.c_str(), appSystem.moduleName);
147149

148150
auto interface = module.FindInterface<IAppSystem*>(appSystem.interfaceVersion.c_str());
149151

150152
g_factoryMap[appSystem.interfaceVersion] = interface;
151-
152-
if (appSystem.connect && Globals::modName == "csgo")
153+
if (appSystem.connect)
153154
{
155+
// TEMP: dota and deadlock is broken rn
156+
#ifdef GAME_CS2
154157
interface->Connect(&AppSystemFactory);
155158
interface->Init();
159+
#endif
156160
}
157161
else
158162
{

src/main/globalvariables.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
namespace Globals {
2626

27-
inline std::string modName;
2827
inline std::filesystem::path outputPath;
2928
inline std::ofstream stringsIgnoreStream;
3029

src/main/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
void Usage()
3030
{
31-
printf("Usage: DumpSource2 <mod name> <output path>\n");
31+
printf("Usage: DumpSource2 <output path>\n");
3232
}
3333

3434
int main(int argc, char** argv)
@@ -39,8 +39,7 @@ int main(int argc, char** argv)
3939
return 0;
4040
}
4141

42-
Globals::modName = argv[1];
43-
Globals::outputPath = argv[2];
42+
Globals::outputPath = argv[1];
4443

4544
if (!std::filesystem::is_directory(Globals::outputPath))
4645
{
@@ -56,8 +55,9 @@ int main(int argc, char** argv)
5655
printf("Dumping\n");
5756

5857
// TEMP: cs2 and dota/deadlock sdks are mismatched in ICvar vtable right now
59-
if(Globals::modName == "csgo")
58+
#ifdef GAME_CS2
6059
Dumpers::ConCommands::Dump();
60+
#endif
6161

6262
Dumpers::Schemas::Dump();
6363
}

0 commit comments

Comments
 (0)