mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-25 12:46:53 +01:00
Allow editing the cheats URL via the config file
This commit is contained in:
parent
34149ea92c
commit
f0fef6fe56
@ -1459,11 +1459,14 @@ int CodeDownload(const char *id)
|
||||
char txtpath[250];
|
||||
int txtLen = snprintf(txtpath, sizeof(txtpath), "%s%s.txt", Settings.TxtCheatcodespath, id);
|
||||
|
||||
char codeurl[80];
|
||||
snprintf(codeurl, sizeof(codeurl), "https://codes.rc24.xyz/txt.php?txt=%s", id);
|
||||
|
||||
char codeurl[300];
|
||||
struct download file = {};
|
||||
downloadfile(codeurl, &file);
|
||||
std::string url(Settings.URL_Cheats);
|
||||
if(url.find("{gameid}") != url.npos)
|
||||
{
|
||||
url.replace(url.find("{gameid}"), 8, id);
|
||||
downloadfile(url.c_str(), &file);
|
||||
}
|
||||
if (file.size <= 0) {
|
||||
gprintf("Trying backup...\n");
|
||||
snprintf(codeurl, sizeof(codeurl), "https://web.archive.org/web/202009if_/geckocodes.org/txt.php?txt=%s", id);
|
||||
|
@ -88,6 +88,7 @@ void CSettings::SetDefault()
|
||||
strlcpy(URL_Discs, "https://art.gametdb.com/wii/disc/", sizeof(URL_Discs));
|
||||
strlcpy(URL_DiscsCustom, "https://art.gametdb.com/wii/disccustom/", sizeof(URL_DiscsCustom));
|
||||
strlcpy(URL_GameTDB, "https://www.gametdb.com/wiitdb.zip", sizeof(URL_GameTDB));
|
||||
strlcpy(URL_Cheats, "https://codes.rc24.xyz/txt.php?txt={gameid}", sizeof(URL_Cheats));
|
||||
ProxyUsername[0] = 0;
|
||||
ProxyPassword[0] = 0;
|
||||
ProxyAddress[0] = 0;
|
||||
@ -508,6 +509,7 @@ bool CSettings::Save()
|
||||
fprintf(file, "URL_Discs = %s\n", URL_Discs);
|
||||
fprintf(file, "URL_DiscsCustom = %s\n", URL_DiscsCustom);
|
||||
fprintf(file, "URL_GameTDB = %s\n", URL_GameTDB);
|
||||
fprintf(file, "URL_Cheats = %s\n", URL_Cheats);
|
||||
fprintf(file, "ProxyUseSystem = %d\n", ProxyUseSystem);
|
||||
fprintf(file, "ProxyUsername = %s\n", ProxyUsername);
|
||||
fprintf(file, "ProxyPassword = %s\n", ProxyPassword);
|
||||
@ -518,15 +520,22 @@ bool CSettings::Save()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSettings::ValidateURL(char *value, bool zip)
|
||||
bool CSettings::ValidateURL(char *value, int type)
|
||||
{
|
||||
if (strlen(value) >= 12 && (strncmp(value, "https://", 8) == 0 || strncmp(value, "http://", 7) == 0))
|
||||
{
|
||||
if (zip)
|
||||
// GameTDB
|
||||
if (type == 1)
|
||||
{
|
||||
if (strncmp(value + strlen(value) -4, ".zip", 4) == 0) // The URL must end with .zip to be valid
|
||||
return true;
|
||||
}
|
||||
// Cheats
|
||||
else if (type == 2)
|
||||
{
|
||||
if (strstr(value, "{gameid}") != NULL)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strncmp(value + strlen(value) -1, "/", 1) == 0) // The URL must end with / to be valid
|
||||
@ -1346,10 +1355,16 @@ bool CSettings::SetSetting(char *name, char *value)
|
||||
}
|
||||
else if (strcmp(name, "URL_GameTDB") == 0)
|
||||
{
|
||||
if (ValidateURL(value, true))
|
||||
if (ValidateURL(value, 1))
|
||||
strlcpy(URL_GameTDB, value, sizeof(URL_GameTDB));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "URL_Cheats") == 0)
|
||||
{
|
||||
if (ValidateURL(value, 2))
|
||||
strlcpy(URL_Cheats, value, sizeof(URL_Cheats));
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "ProxyUseSystem") == 0)
|
||||
{
|
||||
ProxyUseSystem = atoi(value);
|
||||
|
@ -99,6 +99,7 @@ class CSettings
|
||||
char URL_Discs[300];
|
||||
char URL_DiscsCustom[300];
|
||||
char URL_GameTDB[300];
|
||||
char URL_Cheats[300];
|
||||
char ProxyUsername[33];
|
||||
char ProxyPassword[33];
|
||||
char ProxyAddress[256];
|
||||
@ -242,7 +243,7 @@ class CSettings
|
||||
bool FirstTimeRun;
|
||||
protected:
|
||||
bool ValidVersion(FILE * file);
|
||||
bool ValidateURL(char *value, bool zip = false);
|
||||
bool ValidateURL(char *value, int type = 0);
|
||||
bool SetSetting(char *name, char *value);
|
||||
//!Find the config file in the default paths
|
||||
bool FindConfig();
|
||||
|
Loading…
Reference in New Issue
Block a user