99#include " steam_api.h"
1010#include " synchapi.h"
1111#include " shared/logger.h"
12+ #include < curl/curl.h>
1213
1314namespace SteamWorkshop {
1415
@@ -19,6 +20,12 @@ const PublishedFileId_t REPENTOGON_WORKSHOP_ID = 3643104060;
1920bool WaitForWorkshopDownload (PublishedFileId_t fileId, uint32 timeoutMs = 60000 ) {
2021 Logger::Info (" Checking download for steam workshop item %llu...\n " , fileId);
2122
23+
24+ if (!CanReachSteamWorkshop ()) {
25+ Logger::Error (" Cannot connect to the workshop!.\n " );
26+ return false ;
27+ }
28+
2229 uint32 elapsed = 0 ;
2330 const uint32 step = 100 ;
2431
@@ -51,6 +58,8 @@ bool SubscribeAndDownload(PublishedFileId_t workshopId, std::string& outPath) {
5158 Logger::Error (" Steam is not available.\n " );
5259 return false ;
5360 }
61+
62+
5463 SteamUGC ()->SubscribeItem (workshopId);
5564 if (!WaitForWorkshopDownload (workshopId)) {
5665 Logger::Error (" Failure waiting for workshop download.\n " );
@@ -96,6 +105,29 @@ bool SubscribeDownloadAndGetFile(PublishedFileId_t workshopId, const std::string
96105 return true ;
97106}
98107
108+
109+ bool CanReachSteamWorkshop ()
110+ {
111+ CURL * curl = curl_easy_init ();
112+ if (!curl)
113+ return false ;
114+
115+ curl_easy_setopt (curl, CURLOPT_URL , " https://steamcommunity.com/" );
116+ curl_easy_setopt (curl, CURLOPT_NOBODY , 1L );
117+ curl_easy_setopt (curl, CURLOPT_TIMEOUT , 5L ); // 5sec timeout
118+ curl_easy_setopt (curl, CURLOPT_CONNECTTIMEOUT , 5L );
119+ curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION , 1L );
120+
121+ CURLcode res = curl_easy_perform (curl);
122+
123+ long response_code = 0 ;
124+ if (res == CURLE_OK )
125+ curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE , &response_code);
126+
127+ curl_easy_cleanup (curl);
128+ return (res == CURLE_OK && response_code >= 200 && response_code < 400 );
129+ }
130+
99131// this is mainly for the updater to find later kind of hacky, but its the only way I could think of where the updater can use the steam entry when available without the steamapi (wont be able to make it available if it isnt tho)
100132bool CreateSteamEntryDirFile () {
101133 std::string installPath;
0 commit comments