Updater uses a core.cfg specified URL now.
Updater uses a core.cfg specified URL now.
1.1 --- a/configs/core.cfg Tue Feb 17 16:19:11 2009 -0500
1.2 +++ b/configs/core.cfg Tue Feb 17 16:39:02 2009 -0500
1.3 @@ -97,6 +97,12 @@
1.4 "ForceRestartAfterUpdate" "no"
1.5
1.6 /**
1.7 + * URL to use for retrieving update information.
1.8 + * SSL is not yet supported.
1.9 + */
1.10 + "AutoUpdateURL" "http://www.sourcemod.net/update/"
1.11 +
1.12 + /**
1.13 * Whether to show debug spew.
1.14 * Currently this will log details about the gamedata updating process.
1.15 */
2.1 --- a/extensions/updater/Updater.cpp Tue Feb 17 16:19:11 2009 -0500
2.2 +++ b/extensions/updater/Updater.cpp Tue Feb 17 16:39:02 2009 -0500
2.3 @@ -34,8 +34,6 @@
2.4 #include "Updater.h"
2.5 #include "md5.h"
2.6
2.7 -#define UPDATE_URL "http://www.sourcemod.net/update/"
2.8 -
2.9 #define USTATE_NONE 0
2.10 #define USTATE_FOLDERS 1
2.11 #define USTATE_CHANGED 2
2.12 @@ -125,7 +123,7 @@
2.13 }
2.14 else if (strcmp(key, "location") == 0)
2.15 {
2.16 - url.assign(UPDATE_URL);
2.17 + url.assign(update_url);
2.18 url.append(value);
2.19 }
2.20 break;
2.21 @@ -330,18 +328,18 @@
2.22 libsys->CloseDirectory(dir);
2.23 }
2.24
2.25 -void UpdateReader::PerformUpdate()
2.26 +void UpdateReader::PerformUpdate(const char *url)
2.27 {
2.28 IWebForm *form;
2.29 MemoryDownloader master;
2.30 SMCStates states = {0, 0};
2.31
2.32 + update_url = url;
2.33 +
2.34 form = webternet->CreateForm();
2.35 xfer = webternet->CreateSession();
2.36 xfer->SetFailOnHTTPError(true);
2.37
2.38 - const char *root_url = UPDATE_URL "gamedata.php";
2.39 -
2.40 form->AddString("version", SVN_FULL_VERSION);
2.41 form->AddString("build", SM_BUILD_UNIQUEID);
2.42
2.43 @@ -352,9 +350,9 @@
2.44 smutils->Format(temp, sizeof(temp), "%d", num_files);
2.45 form->AddString("files", temp);
2.46
2.47 - if (!xfer->PostAndDownload(root_url, form, &master, NULL))
2.48 + if (!xfer->PostAndDownload(url, form, &master, NULL))
2.49 {
2.50 - AddUpdateError("Could not download \"%s\"", root_url);
2.51 + AddUpdateError("Could not download \"%s\"", url);
2.52 AddUpdateError("Error: %s", xfer->LastErrorMessage());
2.53 goto cleanup;
2.54 }
3.1 --- a/extensions/updater/Updater.h Tue Feb 17 16:19:11 2009 -0500
3.2 +++ b/extensions/updater/Updater.h Tue Feb 17 16:39:02 2009 -0500
3.3 @@ -59,7 +59,7 @@
3.4 SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
3.5 SMCResult ReadSMC_LeavingSection(const SMCStates *states);
3.6 public:
3.7 - void PerformUpdate();
3.8 + void PerformUpdate(const char *url);
3.9 UpdatePart *DetachParts();
3.10 private:
3.11 void HandleFile();
3.12 @@ -75,6 +75,7 @@
3.13 char checksum[33];
3.14 UpdatePart *partFirst;
3.15 UpdatePart *partLast;
3.16 + const char *update_url;
3.17 };
3.18 }
3.19
4.1 --- a/extensions/updater/extension.cpp Tue Feb 17 16:19:11 2009 -0500
4.2 +++ b/extensions/updater/extension.cpp Tue Feb 17 16:39:02 2009 -0500
4.3 @@ -38,6 +38,8 @@
4.4 #include <sh_list.h>
4.5 #include <sh_string.h>
4.6
4.7 +#define DEFAULT_UPDATE_URL "http://www.sourcemod.net/update/"
4.8 +
4.9 using namespace SourceHook;
4.10
4.11 SmUpdater g_Updater; /**< Global singleton for extension's main interface */
4.12 @@ -46,6 +48,7 @@
4.13 IWebternet *webternet;
4.14 static List<String *> update_errors;
4.15 static IThreadHandle *update_thread;
4.16 +static String update_url;
4.17
4.18 bool SmUpdater::SDK_OnLoad(char *error, size_t maxlength, bool late)
4.19 {
4.20 @@ -64,6 +67,13 @@
4.21 return false;
4.22 }
4.23
4.24 + const char *url = smutils->GetCoreConfigValue("AutoUpdateURL");
4.25 + if (url == NULL)
4.26 + {
4.27 + url = DEFAULT_UPDATE_URL;
4.28 + }
4.29 + update_url.assign(url);
4.30 +
4.31 return true;
4.32 }
4.33
4.34 @@ -175,7 +185,7 @@
4.35 {
4.36 UpdateReader ur;
4.37
4.38 - ur.PerformUpdate();
4.39 + ur.PerformUpdate(update_url.c_str());
4.40
4.41 smutils->AddFrameAction(PumpUpdate, ur.DetachParts());
4.42 }