File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55#include < winhttp.h>
66
77#include " logger.h"
8+ #include " game_type.h"
89
910Version GetLatestJAPIVersion () {
1011 std::vector<uint8_t > buffer = DownloadFile (" raw.githubusercontent.com/Kapilarny/JAPI/master/version.txt" );
@@ -261,7 +262,7 @@ void DownloadJAPI(Version version) {
261262void CreateSteamAppID () {
262263 // Create steam_appid.txt
263264 std::ofstream steam_appid (" steam_appid.txt" , std::ios::out | std::ios::trunc);
264- steam_appid << " 1372110 " ;
265+ steam_appid << GetGameData (). steam_appid ;
265266 steam_appid.close ();
266267
267268 JINFO (" Created steam_appid.txt" );
Original file line number Diff line number Diff line change 1+ #include " game_type.h"
2+
3+ #include < filesystem>
4+
5+ #include " logger.h"
6+
7+ GameData::GameData () {
8+ if (std::filesystem::exists (" ASBR.exe" )) {
9+ JINFO (" Detected ASBR.exe, assuming ASBR" );
10+
11+ this ->game_type = GameType::ASBR;
12+ this ->game_file = " ASBR.exe" ;
13+ this ->steam_appid = " 1372110" ;
14+ } else if (std::filesystem::exists (" NSUNSC.exe" )) {
15+ JINFO (" Detected NSUNSC.exe, assuming Connections" );
16+
17+ this ->game_type = GameType::CONNECTIONS;
18+ this ->game_file = " NSUNSC.exe" ;
19+ this ->steam_appid = " 1020790" ;
20+ } else {
21+ JFATAL (" Could not detect game type" );
22+ exit (1 );
23+ }
24+ }
25+
26+ static GameData game_data;
27+
28+ GameData& GetGameData () {
29+ if (game_data.game_type == GameType::NONE) {
30+ game_data = GameData ();
31+ }
32+
33+ return game_data;
34+ }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < string>
4+ #include < stdint.h>
5+
6+ enum class GameType {
7+ NONE = -1 ,
8+ ASBR = 0 ,
9+ CONNECTIONS = 1
10+ };
11+
12+ typedef struct GameData {
13+ GameData ();
14+
15+ GameType game_type;
16+ std::string game_file;
17+ std::string steam_appid;
18+ } GameData;
19+
20+ GameData& GetGameData ();
Original file line number Diff line number Diff line change 77
88#define JAPI_UPDATER_MAJOR 1
99#define JAPI_UPDATER_MINOR 1
10- #define JAPI_UPDATER_PATCH 1
10+ #define JAPI_UPDATER_PATCH 2
1111
1212typedef struct Version {
1313 uint32_t major;
Original file line number Diff line number Diff line change 99#include " utils.h"
1010#include " logger.h"
1111
12- #include " updater .h"
12+ #include " game_type .h"
1313
1414void SaveConfig (toml::table& config) {
1515 std::ofstream config_file (" japi/config/updater.cfg" , std::ios::out | std::ios::trunc);
1616 config_file << config;
1717}
1818
1919int UpdaterMain () {
20+ if (GetGameData ().game_type == GameType::NONE) {
21+ JFATAL (" Could not detect game type" );
22+ return 1 ;
23+ }
24+
2025 // Check if japi/ exists
2126 if (!std::filesystem::exists (" japi" )) {
2227 std::filesystem::create_directory (" japi" );
Original file line number Diff line number Diff line change 44#include < stdio.h>
55
66#include " logger.h"
7+ #include " game_type.h"
78
89void LaunchGame () {
910 // Run ASBR.exe
@@ -19,7 +20,8 @@ void LaunchGame() {
1920 GetCurrentDirectoryA (MAX_PATH, current_directory);
2021
2122 // Append the ASBR.exe path
22- strcat (current_directory, " \\ ASBR.exe" );
23+ std::string str = " \\ " + GetGameData ().game_file ;
24+ strcat (current_directory, str.c_str ());
2325
2426 JINFO (current_directory);
2527
You can’t perform that action at this time.
0 commit comments