Skip to content

Commit

Permalink
Version bump and fixed merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Jul 11, 2024
1 parent 8a632f4 commit c60268e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 36 deletions.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "BeatLeader",
"description": "beatleader.xyz | In-game leaderboards for custom and OST maps | Score replays | Clans, events, playlists and much more",
"author": "NSGolova",
"version": "0.7.1",
"version": "0.8.1",
"packageId": "com.beatgames.beatsaber",
"packageVersion": "1.28.0_4124311467",
"coverImage": "cover.png",
Expand Down
6 changes: 3 additions & 3 deletions qpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"info": {
"name": "BeatLeader",
"id": "BeatLeader",
"version": "0.7.1",
"version": "0.8.1",
"url": null,
"additionalData": {
"overrideSoName": "libbl.so"
Expand Down Expand Up @@ -47,7 +47,7 @@
},
{
"id": "libcurl",
"versionRange": "*",
"versionRange": "=8.5.0",
"additionalData": {}
},
{
Expand All @@ -67,7 +67,7 @@
},
{
"id": "conditional-dependencies",
"versionRange": "*",
"versionRange": "=0.1.0",
"additionalData": {}
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/PlaylistSynchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ void ActuallySyncPlaylist() {

for (string playlist : parts) {
DownloadPlaylist(WebUtils::API_URL + "playlist/" + playlist, playlist, true, [](auto songs) {
BSML::MainThreadScheduler::Schedule([] {
SongCore::API::Loading::RefreshLevelPacks();
QuestUI::MainThreadScheduler::Schedule([] {
RuntimeSongLoader::API::RefreshPacks(true);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ReplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ReplayManager::TryPostReplay(string name, PlayEndData status, int tryIndex,

WebUtils::PostFileAsync(WebUtils::API_URL + "replayoculus" + status.ToQueryString(), replayFile, (long)file_info.st_size, [name, tryIndex, finished, replayFile, replayPostStart, runCallback, status](long statusCode, string result, string headers) {
fclose(replayFile);
if (statusCode >= 450 && tryIndex < 2) {
if ((statusCode >= 450 || statusCode < 200) && tryIndex < 2) {
getLogger().info("%s", ("Retrying posting replay after " + to_string(statusCode) + " #" + to_string(tryIndex) + " " + std::string(result)).c_str());
if (statusCode == 100) {
result = "Timed out";
Expand Down
89 changes: 60 additions & 29 deletions src/Utils/WebUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
#include "Utils/WebUtils.hpp"
#include "Utils/ModConfig.hpp"

#include "UnityEngine/Application.hpp"

#include "libcurl/shared/curl.h"
#include "libcurl/shared/easy.h"

#include <filesystem>
#include <sstream>

#define TIMEOUT 60
#define USER_AGENT string(ID "/" VERSION " (BeatSaber/" + GameVersion + ") (Oculus)").c_str()

#define X_BSSB "X-BSSB: ✔"

namespace WebUtils {
string GameVersion = "1.24.0";

string API_URL = "";
string WEB_URL = "";
string USER_AGENT = "";

void refresh_urls() {
if (getModConfig().ServerType.GetValue() == "Test") {
Expand All @@ -26,6 +29,7 @@ namespace WebUtils {
API_URL = "https://api.beatleader.xyz/";
WEB_URL = "https://beatleader.xyz/";
}
USER_AGENT = "BeatLeader / " + modInfo.version + " (BeatSaber/" + (string)UnityEngine::Application::get_version() + ") (Oculus)";
}

//https://stackoverflow.com/a/55660581
Expand Down Expand Up @@ -162,7 +166,7 @@ namespace WebUtils {
long httpCode(0);

curl_easy_setopt(curl, CURLOPT_WRITEDATA, reinterpret_cast<void*>(&val));
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
Expand Down Expand Up @@ -237,19 +241,24 @@ namespace WebUtils {

long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

auto res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
long errorCode = static_cast<long>(res);
string errorValue = curl_easy_strerror(res);
getLogger().critical("curl_easy_perform() failed: %u: %s", errorCode, errorValue.c_str());
curl_easy_cleanup(curl);
finished(errorCode, errorValue);
} else {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
finished(httpCode, val);
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
finished(httpCode, val);
}
);
t.detach();
Expand Down Expand Up @@ -303,15 +312,24 @@ namespace WebUtils {
if (val) {
curl_easy_setopt(curl, CURLOPT_WRITEDATA, val);
}
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

auto res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
long errorCode = static_cast<long>(res);
string errorValue = curl_easy_strerror(res);

getLogger().critical("curl_easy_perform() failed: %u: %s", errorCode, errorValue.c_str());
if (val) {
fclose(val);
}
curl_easy_cleanup(curl);
finished(errorCode);
return;
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
if (val) {
Expand Down Expand Up @@ -368,7 +386,7 @@ namespace WebUtils {

long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
Expand All @@ -378,12 +396,16 @@ namespace WebUtils {
CURLcode res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
long errorCode = static_cast<long>(res);
string errorValue = curl_easy_strerror(res);
getLogger().critical("curl_easy_perform() failed: %u: %s", errorCode, errorValue.c_str());
curl_easy_cleanup(curl);
finished(errorCode, errorValue);
} else {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
finished(httpCode, val);
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
//curl_mime_free(form);
finished(httpCode, val);
}
);
t.detach();
Expand Down Expand Up @@ -441,21 +463,26 @@ namespace WebUtils {

long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

CURLcode res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
long errorCode = static_cast<long>(res);
string errorValue = curl_easy_strerror(res);
getLogger().critical("curl_easy_perform() failed: %u: %s", errorCode, errorValue.c_str());
curl_easy_cleanup(curl);
curl_formfree(formpost);
finished(errorCode, errorValue);
} else {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
curl_formfree(formpost);
//curl_mime_free(form);
finished(httpCode, val);
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
curl_formfree(formpost);
//curl_mime_free(form);
finished(httpCode, val);
}
);
t.detach();
Expand Down Expand Up @@ -538,7 +565,7 @@ namespace WebUtils {

long httpCode(0);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &val);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT);
curl_easy_setopt(curl, CURLOPT_USERAGENT, USER_AGENT.c_str());
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
Expand All @@ -556,12 +583,16 @@ namespace WebUtils {
CURLcode res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK) {
getLogger().critical("curl_easy_perform() failed: %u: %s", res, curl_easy_strerror(res));
long errorCode = static_cast<long>(res);
string errorValue = curl_easy_strerror(res);
getLogger().critical("curl_easy_perform() failed: %u: %s", errorCode, errorValue.c_str());
curl_easy_cleanup(curl);
finished(errorCode, errorValue, "");
} else {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
finished(httpCode, val, responseHeaders);
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
//curl_mime_free(form);
finished(httpCode, val, responseHeaders);
}
);
t.detach();
Expand Down

0 comments on commit c60268e

Please sign in to comment.