Add option to customise skin server

This commit is contained in:
UnknownShadow200 2021-11-18 22:20:11 +11:00
parent 15330c620d
commit 762660d7c6
4 changed files with 12 additions and 4 deletions

View File

@ -113,7 +113,7 @@ static void HttpBackend_Add(struct HttpRequest* req, cc_bool priority) {
*-----------------------------------------------------Http component------------------------------------------------------*
*#########################################################################################################################*/
static void Http_Init(void) {
ScheduledTask_Add(30, Http_CleanCacheTask);
Http_InitCommon();
/* If this webpage is https://, browsers deny any http:// downloading */
httpsOnly = interop_IsHttpsOnly();

View File

@ -902,8 +902,7 @@ static void WorkerLoop(void) {
*-----------------------------------------------------Http component------------------------------------------------------*
*#########################################################################################################################*/
static void Http_Init(void) {
httpOnly = Options_GetBool(OPT_HTTP_ONLY, false);
ScheduledTask_Add(30, Http_CleanCacheTask);
Http_InitCommon();
/* Http component gets initialised multiple times on Android */
if (workerThread) return;

View File

@ -71,6 +71,7 @@
#define OPT_TOUCH_BUTTONS "gui-touchbuttons"
#define OPT_TOUCH_SCALE "gui-touchscale"
#define OPT_HTTP_ONLY "http-no-https"
#define OPT_SKIN_SERVER "http-skinserver"
#define OPT_RAW_INPUT "win-raw-input"
#define LOPT_SESSION "launcher-session"

View File

@ -9,6 +9,9 @@
#include "Options.h"
static cc_bool httpsOnly, httpOnly;
static char skinServer_buffer[128];
static cc_string skinServer = String_FromArray(skinServer_buffer);
/* Frees data from a HTTP request. */
static void HttpRequest_Free(struct HttpRequest* request) {
Mem_Free(request->data);
@ -212,7 +215,7 @@ int Http_AsyncGetSkin(const cc_string* skinName) {
if (Utils_IsUrlPrefix(skinName)) {
String_Copy(&url, skinName);
} else {
String_Format1(&url, SKINS_SERVER "/%s.png", skinName);
String_Format2(&url, "%s/%s.png", &skinServer, skinName);
}
return Http_AsyncGetData(&url, false);
}
@ -263,6 +266,11 @@ void Http_UrlEncodeUtf8(cc_string* dst, const cc_string* src) {
/*########################################################################################################################*
*-----------------------------------------------------Http component------------------------------------------------------*
*#########################################################################################################################*/
static void Http_InitCommon(void) {
httpOnly = Options_GetBool(OPT_HTTP_ONLY, false);
Options_Get(OPT_SKIN_SERVER, &skinServer, SKINS_SERVER);
ScheduledTask_Add(30, Http_CleanCacheTask);
}
static void Http_Init(void);
struct IGameComponent Http_Component = {