Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:LiteLDev/LiteLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Mar 12, 2021
2 parents ed8e2f7 + 6e6f5f7 commit c4faa91
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
44 changes: 24 additions & 20 deletions LiteLoader/CheckUpdate.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "pch.h"

void updateCheck()

int updateCheck()
{
std::thread t([] {
LPCTSTR lpszAgent = L"WinInetGet/0.1";
HINTERNET hInternet = InternetOpen(lpszAgent,
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
DWORD rec_timeout = 300 * 1000;
DWORD rec_timeout = 500 * 1000;
InternetSetOption(hInternet, INTERNET_OPTION_RECEIVE_TIMEOUT, &rec_timeout, sizeof(rec_timeout));
LPCTSTR lpszServerName = L"gitee.com";
INTERNET_PORT nServerPort = INTERNET_DEFAULT_HTTPS_PORT;
Expand All @@ -20,7 +21,7 @@ void updateCheck()
INTERNET_SERVICE_HTTP,
dwConnectFlags, dwConnectContext);
LPCTSTR lpszVerb = L"GET";
LPCTSTR lpszObjectName = L"/dreamguxiang/llupdate_pages/raw/master/update.json";
LPCTSTR lpszObjectName = L"/dreamguxiang/LLessentials/raw/master/llupdate.json";
LPCTSTR lpszVersion = NULL;
LPCTSTR lpszReferrer = NULL;
LPCTSTR* lplpszAcceptTypes = NULL;
Expand Down Expand Up @@ -57,24 +58,27 @@ void updateCheck()
}
pMessageBody[dwBytesRead];
std::string res = (char*)pMessageBody;
rapidjson::Document json;
json.Parse(res.c_str());;
if (json.HasParseError()) {
std::cout << "[BDSLiteloader] Failed to get updates(1)\n";
return;
}
auto arr = json.GetArray();
std::string LatestRelease = arr[arr.Size() - 1]["name"].GetString();
int latestVersionNum = arr[arr.Size() - 1]["versionNum"].GetInt();
if (latestVersionNum < LiteLoaderVersionNum) {
std::cout << "[BDSLiteloader] Found a new version: " << LatestRelease << "\n";
return;
rapidjson::Document json;
json.Parse(res.c_str());
if (json.HasParseError()) {
std::cout << "[BDSLiteloader] Failed to get updates(1)\n";
break;
}
auto arr = json.GetArray();
std::string LatestRelease = arr[arr.Size() - 1]["name"].GetString();
int latestVersionNum = arr[arr.Size() - 1]["versionNum"].GetInt();
if (latestVersionNum < LiteLoaderVersionNum) {
std::cout << "[BDSLiteloader] Found a new version: " << LatestRelease << "\n";
break;
}
if (latestVersionNum == LiteLoaderVersionNum) {
break;
}
if (latestVersionNum > LiteLoaderVersionNum) {
std::cout << "[BDSLiteloader] Using preview version: " << LatestRelease << "\n";
break;
}
}
if (latestVersionNum > LiteLoaderVersionNum) {
std::cout << "[BDSLiteloader] Using preview version: " << LatestRelease << "\n";
return;
}
}
});
t.detach();
}
2 changes: 1 addition & 1 deletion LiteLoader/LiteLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void FixUpCWD() {

void startWBThread();
bool versionCommand(CommandOrigin const& ori, CommandOutput& outp);
void updateCheck();
int updateCheck();

static void entry(bool fixcwd) {
if (fixcwd)
Expand Down
3 changes: 2 additions & 1 deletion LiteLoader/ServerCommands.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "pch.h"

int updateCheck();
bool versionCommand(CommandOrigin const& ori, CommandOutput& outp) {
updateCheck();
outp.success("The server is running Bedrock Dedicated Server with BDSLiteLoader " + (string)LiteLoaderVersion);
}

0 comments on commit c4faa91

Please sign in to comment.