mirror of
https://github.com/Dingo-Shenanigans/ReSkate.git
synced 2026-10-27 06:07:09 +01:00
Multiplayer: dedicated servers require plugins, and players get them and the map on one card
A server lists Thunderstore packages in plugins.required ("Owner-Name", or "Owner-Name-1.2.3"
for at least that version, at most 16). It checks each on Thunderstore as it starts and leaves
out one not listed as a plugin, and sends the rest with its map offer (protocol 55).
A joining player's game checks them before the server's map loads. Those missing, switched off
or too old go on one card with the map when that is missing too, so the player is asked once.
GET ALL downloads and installs each, switches on any that were off, runs one live merge when
any brings game data, and joins; CANCEL leaves. The game fetches a package only when
Thunderstore lists it as a plugin and it installs as one (a reskate-plugin.json naming Luau
code), whatever a server asks; anything else is taken out again, so a cosmetic can never be
required.
map_download handles a list of packages instead of one map, and the Thunderstore chooser takes
the category it needs. A map alone keeps its card as it was.
This commit is contained in:
1 parent
e2d12a701d
commit
55a7342dc6
26 files changed
+1051
-255
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#include "server_map_update.h"
|
||||
#include "Engine/Core/Json/json.h"
|
||||
#include "Engine/Vfs/thunderstore_package.h"
|
||||
#include "Extension/Multiplayer/Net/protocol.h"
|
||||
#ifdef _WIN32
|
||||
#include "Engine/Vfs/https_download.h"
|
||||
#else
|
||||
@@ -102,6 +103,59 @@ void set_map_version(const fs::path &mod, const std::string &version) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string required_plugin_problem(const std::string &package_name, bool &reached) {
|
||||
reached = false;
|
||||
const auto name = package::parse_name(package_name);
|
||||
if (!name) return "it is not a Thunderstore package (Owner-Name, or Owner-Name-1.2.3)";
|
||||
auto bare = *name;
|
||||
bare.version.clear();
|
||||
std::string answer;
|
||||
try {
|
||||
answer = get_text(package::details_url(bare));
|
||||
} catch (const std::exception &failure) {
|
||||
return std::string("Thunderstore could not be asked about it (") + failure.what() + ")";
|
||||
}
|
||||
reached = true;
|
||||
const auto choice = package::choose(answer, bare, community, package::Kind::plugin);
|
||||
if (!choice.ok) return choice.reason.empty() ? "Thunderstore does not list it as a plugin" : choice.reason;
|
||||
if (!name->version.empty() && multiplayer::map_version_newer(name->version, choice.newest))
|
||||
return "Thunderstore's newest version is " + choice.newest + ", older than " + name->version;
|
||||
return {};
|
||||
}
|
||||
|
||||
RequiredPluginCheck::Done RequiredPluginCheck::tick(const std::vector<std::string> &required) {
|
||||
Done done;
|
||||
if (work_.valid()) {
|
||||
if (work_.wait_for(std::chrono::seconds(0)) != std::future_status::ready) return done;
|
||||
done = work_.get();
|
||||
done.finished = true;
|
||||
}
|
||||
if (!work_.valid() && (!started_ || required != checked_)) {
|
||||
started_ = true;
|
||||
checked_ = required;
|
||||
if (required.empty()) return done;
|
||||
work_ = std::async(std::launch::async, [required] {
|
||||
Done result;
|
||||
for (const auto &plugin : required) {
|
||||
bool reached{};
|
||||
auto problem = required_plugin_problem(plugin, reached);
|
||||
if (problem.empty()) continue;
|
||||
if (problem.ends_with('.')) problem.pop_back();
|
||||
if (reached) {
|
||||
result.refused.insert(plugin);
|
||||
result.lines.push_back("Required plugin " + plugin + " is left out: " + problem + ". Players are only asked for plugins.");
|
||||
} else {
|
||||
result.lines.push_back("Required plugin " + plugin + " could not be checked: " + problem + ". Players' games check it themselves.");
|
||||
}
|
||||
}
|
||||
if (result.lines.empty())
|
||||
result.lines.push_back("Required plugins: " + std::to_string(required.size()) + " checked on Thunderstore; players without them are offered them as they join.");
|
||||
return result;
|
||||
});
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
std::vector<MapUpdate> update_maps(const fs::path &mods, const std::string &in_play) {
|
||||
std::vector<MapUpdate> result;
|
||||
std::error_code error;
|
||||
|
||||
Reference in new issue
Block a user