Update server url + remove motd stuff
This commit is contained in:
parent
f5a6233a76
commit
4de1f4f9c7
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -14,13 +14,12 @@
|
||||
|
||||
#include <utils/concurrency.hpp>
|
||||
#include <utils/cryptography.hpp>
|
||||
#include <utils/http.hpp>
|
||||
#include <utils/io.hpp>
|
||||
#include <utils/nt.hpp>
|
||||
#include <utils/properties.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
#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"
|
||||
@ -162,9 +161,16 @@ namespace updater
|
||||
return utils::string::va("%i", uint32_t(time(nullptr)));
|
||||
}
|
||||
|
||||
std::optional<utils::http::result> download_file(const std::string& name)
|
||||
std::optional<utils::http::result> 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<utils::http::result> 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<utils::http::result> get_server_file(const std::string& endpoint)
|
||||
{
|
||||
static std::vector<std::string> 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())
|
||||
{
|
||||
|
@ -2,8 +2,12 @@
|
||||
|
||||
#define CLIENT_DATA_FOLDER "cdata"
|
||||
|
||||
#include <utils/http.hpp>
|
||||
|
||||
namespace updater
|
||||
{
|
||||
std::optional<utils::http::result> get_server_file(const std::string& endpoint);
|
||||
|
||||
void relaunch();
|
||||
|
||||
void set_has_tried_update(bool tried);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user