diff --git a/src/client/component/motd.cpp b/src/client/component/motd.cpp index 632a0a3c..0b8400c1 100644 --- a/src/client/component/motd.cpp +++ b/src/client/component/motd.cpp @@ -16,11 +16,11 @@ namespace motd { std::thread([] { - auto data = utils::http::get_data("https://h1.gg/data/motd.png"); - if (data.has_value()) - { - materials::add("motd_image", data.value().buffer); - } + //auto data = utils::http::get_data("https://h1.gg/data/motd.png"); + //if (data.has_value()) + //{ + // materials::add("motd_image", data.value().buffer); + //} }).detach(); } diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index 0d073289..5f536c72 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -410,7 +410,7 @@ namespace server_list scheduler::once([]() { // add dvars to change destination master server ip/port - master_server_ip = dvars::register_string("masterServerIP", "h1.fed0001.xyz", game::DVAR_FLAG_NONE, + master_server_ip = dvars::register_string("masterServerIP", "h1.fed.cat", game::DVAR_FLAG_NONE, "IP of the destination master server to connect to"); master_server_port = dvars::register_string("masterServerPort", "20810", game::DVAR_FLAG_NONE, "Port of the destination master server to connect to"); diff --git a/src/client/component/updater.cpp b/src/client/component/updater.cpp index dcb44584..7d56e769 100644 --- a/src/client/component/updater.cpp +++ b/src/client/component/updater.cpp @@ -14,13 +14,12 @@ #include #include -#include #include #include #include #include -#define MASTER "https://master.fed0001.xyz/h1-mod/" +#define MASTER "https://h1-mod.fed.cat/" #define FILES_PATH "files.json" #define FILES_PATH_DEV "files-dev.json" @@ -161,10 +160,17 @@ namespace updater { return utils::string::va("%i", uint32_t(time(nullptr))); } - - std::optional download_file(const std::string& name) + + std::optional download_data_file(const std::string& name) { - return utils::http::get_data(MASTER + select(DATA_PATH, DATA_PATH_DEV) + name + "?" + get_time_str()); + const auto file = std::format("{}{}?{}", select(DATA_PATH, DATA_PATH_DEV), name, get_time_str()); + return updater::get_server_file(file); + } + + std::optional download_file_list() + { + const auto file = std::format("{}?{}", select(FILES_PATH, FILES_PATH_DEV), get_time_str()); + return updater::get_server_file(file); } bool has_old_data_files() @@ -301,6 +307,34 @@ namespace updater } } + std::optional get_server_file(const std::string& endpoint) + { + static std::vector server_urls = + { + {"https://h1-mod.fed.cat/"}, + {"https://master.fed0001.xyz/h1-mod/"}, // remove this at some point + }; + + const auto try_url = [&](const std::string& base_url) + { + const auto url = base_url + endpoint; + console::debug("[HTTP] GET file \"%s\"\n", url.data()); + const auto result = utils::http::get_data(url); + return result; + }; + + for (const auto& url : server_urls) + { + const auto result = try_url(url); + if (result.has_value()) + { + return result; + } + } + + return {}; + } + void relaunch() { const auto mode = game::environment::is_mp() ? "-multiplayer" : "-singleplayer"; @@ -406,7 +440,7 @@ namespace updater scheduler::once([]() { - const auto files_data = utils::http::get_data(MASTER + select(FILES_PATH, FILES_PATH_DEV) + "?" + get_time_str()); + const auto files_data = download_file_list(); if (is_update_cancelled()) { @@ -546,7 +580,7 @@ namespace updater console::debug("[Updater] downloading file %s\n", file.data()); - const auto data = download_file(file); + const auto data = download_data_file(file); if (is_update_cancelled()) { diff --git a/src/client/component/updater.hpp b/src/client/component/updater.hpp index 0301a6c3..ba8039c2 100644 --- a/src/client/component/updater.hpp +++ b/src/client/component/updater.hpp @@ -2,8 +2,12 @@ #define CLIENT_DATA_FOLDER "cdata" +#include + namespace updater { + std::optional get_server_file(const std::string& endpoint); + void relaunch(); void set_has_tried_update(bool tried); diff --git a/src/client/game/demonware/services/bdMarketingComms.cpp b/src/client/game/demonware/services/bdMarketingComms.cpp index cee496b4..aa6ac61c 100644 --- a/src/client/game/demonware/services/bdMarketingComms.cpp +++ b/src/client/game/demonware/services/bdMarketingComms.cpp @@ -14,7 +14,7 @@ namespace demonware void bdMarketingComms::getMessages(service_server* server, byte_buffer* /*buffer*/) const { - auto reply = server->create_reply(this->task_id()); + /*auto reply = server->create_reply(this->task_id()); const int timeout = 7; // seconds @@ -73,6 +73,8 @@ namespace demonware reply->add(featured2); } + reply->send();*/ + auto reply = server->create_reply(this->task_id()); reply->send(); }