Updater uses a core.cfg specified URL now.
This commit is contained in:
parent
9e445a5adf
commit
3d7b0db114
@ -96,6 +96,12 @@
|
|||||||
*/
|
*/
|
||||||
"ForceRestartAfterUpdate" "no"
|
"ForceRestartAfterUpdate" "no"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL to use for retrieving update information.
|
||||||
|
* SSL is not yet supported.
|
||||||
|
*/
|
||||||
|
"AutoUpdateURL" "http://www.sourcemod.net/update/"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to show debug spew.
|
* Whether to show debug spew.
|
||||||
* Currently this will log details about the gamedata updating process.
|
* Currently this will log details about the gamedata updating process.
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
#include "Updater.h"
|
#include "Updater.h"
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
|
|
||||||
#define UPDATE_URL "http://www.sourcemod.net/update/"
|
|
||||||
|
|
||||||
#define USTATE_NONE 0
|
#define USTATE_NONE 0
|
||||||
#define USTATE_FOLDERS 1
|
#define USTATE_FOLDERS 1
|
||||||
#define USTATE_CHANGED 2
|
#define USTATE_CHANGED 2
|
||||||
@ -125,7 +123,7 @@ SMCResult UpdateReader::ReadSMC_KeyValue(const SMCStates *states,
|
|||||||
}
|
}
|
||||||
else if (strcmp(key, "location") == 0)
|
else if (strcmp(key, "location") == 0)
|
||||||
{
|
{
|
||||||
url.assign(UPDATE_URL);
|
url.assign(update_url);
|
||||||
url.append(value);
|
url.append(value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -330,18 +328,18 @@ static void add_folders(IWebForm *form, const char *root, unsigned int &num_file
|
|||||||
libsys->CloseDirectory(dir);
|
libsys->CloseDirectory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateReader::PerformUpdate()
|
void UpdateReader::PerformUpdate(const char *url)
|
||||||
{
|
{
|
||||||
IWebForm *form;
|
IWebForm *form;
|
||||||
MemoryDownloader master;
|
MemoryDownloader master;
|
||||||
SMCStates states = {0, 0};
|
SMCStates states = {0, 0};
|
||||||
|
|
||||||
|
update_url = url;
|
||||||
|
|
||||||
form = webternet->CreateForm();
|
form = webternet->CreateForm();
|
||||||
xfer = webternet->CreateSession();
|
xfer = webternet->CreateSession();
|
||||||
xfer->SetFailOnHTTPError(true);
|
xfer->SetFailOnHTTPError(true);
|
||||||
|
|
||||||
const char *root_url = UPDATE_URL "gamedata.php";
|
|
||||||
|
|
||||||
form->AddString("version", SVN_FULL_VERSION);
|
form->AddString("version", SVN_FULL_VERSION);
|
||||||
form->AddString("build", SM_BUILD_UNIQUEID);
|
form->AddString("build", SM_BUILD_UNIQUEID);
|
||||||
|
|
||||||
@ -352,9 +350,9 @@ void UpdateReader::PerformUpdate()
|
|||||||
smutils->Format(temp, sizeof(temp), "%d", num_files);
|
smutils->Format(temp, sizeof(temp), "%d", num_files);
|
||||||
form->AddString("files", temp);
|
form->AddString("files", temp);
|
||||||
|
|
||||||
if (!xfer->PostAndDownload(root_url, form, &master, NULL))
|
if (!xfer->PostAndDownload(url, form, &master, NULL))
|
||||||
{
|
{
|
||||||
AddUpdateError("Could not download \"%s\"", root_url);
|
AddUpdateError("Could not download \"%s\"", url);
|
||||||
AddUpdateError("Error: %s", xfer->LastErrorMessage());
|
AddUpdateError("Error: %s", xfer->LastErrorMessage());
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace SourceMod
|
|||||||
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
||||||
SMCResult ReadSMC_LeavingSection(const SMCStates *states);
|
SMCResult ReadSMC_LeavingSection(const SMCStates *states);
|
||||||
public:
|
public:
|
||||||
void PerformUpdate();
|
void PerformUpdate(const char *url);
|
||||||
UpdatePart *DetachParts();
|
UpdatePart *DetachParts();
|
||||||
private:
|
private:
|
||||||
void HandleFile();
|
void HandleFile();
|
||||||
@ -75,6 +75,7 @@ namespace SourceMod
|
|||||||
char checksum[33];
|
char checksum[33];
|
||||||
UpdatePart *partFirst;
|
UpdatePart *partFirst;
|
||||||
UpdatePart *partLast;
|
UpdatePart *partLast;
|
||||||
|
const char *update_url;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
#include <sh_string.h>
|
#include <sh_string.h>
|
||||||
|
|
||||||
|
#define DEFAULT_UPDATE_URL "http://www.sourcemod.net/update/"
|
||||||
|
|
||||||
using namespace SourceHook;
|
using namespace SourceHook;
|
||||||
|
|
||||||
SmUpdater g_Updater; /**< Global singleton for extension's main interface */
|
SmUpdater g_Updater; /**< Global singleton for extension's main interface */
|
||||||
@ -46,6 +48,7 @@ SMEXT_LINK(&g_Updater);
|
|||||||
IWebternet *webternet;
|
IWebternet *webternet;
|
||||||
static List<String *> update_errors;
|
static List<String *> update_errors;
|
||||||
static IThreadHandle *update_thread;
|
static IThreadHandle *update_thread;
|
||||||
|
static String update_url;
|
||||||
|
|
||||||
bool SmUpdater::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
bool SmUpdater::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||||
{
|
{
|
||||||
@ -64,6 +67,13 @@ bool SmUpdater::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *url = smutils->GetCoreConfigValue("AutoUpdateURL");
|
||||||
|
if (url == NULL)
|
||||||
|
{
|
||||||
|
url = DEFAULT_UPDATE_URL;
|
||||||
|
}
|
||||||
|
update_url.assign(url);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +185,7 @@ void SmUpdater::RunThread(IThreadHandle *pHandle)
|
|||||||
{
|
{
|
||||||
UpdateReader ur;
|
UpdateReader ur;
|
||||||
|
|
||||||
ur.PerformUpdate();
|
ur.PerformUpdate(update_url.c_str());
|
||||||
|
|
||||||
smutils->AddFrameAction(PumpUpdate, ur.DetachParts());
|
smutils->AddFrameAction(PumpUpdate, ur.DetachParts());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user