Files
ReSkate/Server/server_plugins.h
T
Robin MoellerandClaude Opus 5.5 0706730e79 Plugins: mods.content and read_content read the server's Mods on a dedicated server
A server plugin with mods.read could call reskate.mods.content, but the
server's game had no content of its own, so it got nil and "not
available". A mode that keeps its data in mods (a race reading start
and finish from a park mod) could only read it in the players' games.

The server now answers from every mod folder in its Mods, by name, as it
finds its maps there; it has no load order or mods.json. A hidden folder
(.reskate_plugin_data) and names a plugin could not ask for are left out,
and a mod's title is its manifest.json's "name".

The listing and reading moved from plugin_game_runtime.cpp into
plugin_content.cpp, which the game and the server share, so both keep
the same limits: the folders the manifest's "content" names, 1000 files,
four folders deep, 1 MB a file, nothing outside the mod's folder. The
game's side is unchanged apart from calling it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SYabE7FCPgj3SaWeF92EML
2026-10-23 15:50:55 +02:00

41 lines
1.6 KiB
C++

#pragma once
#include <cstdint>
#include <filesystem>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
// Plugins' server copies on a dedicated server (Extension/Plugins): the session's authority, where
// a game mode's rules run. The operator installs them in Plugins beside the server, a folder a
// plugin (with its reskate-plugin.json, "side" "server" or "both"); they load, reload and unload as
// the folder changes, checked every 2 s. The server has no game: what a plugin may do here is the
// session's messages, its players, the server API (kick, say, tell, move), its storage and reading
// the content folders of the mods in Mods (mods.content).
// Everything here runs on the server's tick thread.
namespace dingosdk::server {
class Host;
class ServerPlugins {
public:
using Log = std::function<void(const std::string &)>;
ServerPlugins(Host &host, std::filesystem::path folder, std::filesystem::path storage, Log log);
~ServerPlugins();
ServerPlugins(const ServerPlugins &) = delete;
ServerPlugins &operator=(const ServerPlugins &) = delete;
void tick(std::uint64_t now_us);
// A player's plugin message (plugin_wire.h): for the authority, or for everyone.
void receive(std::uint64_t from, const std::vector<std::uint8_t> &bytes);
// A console line for the plugins: "plugin list|reload|off|on" or a plugin's own command.
// Empty when it is neither.
std::optional<std::string> command(std::string_view line);
private:
struct State;
std::unique_ptr<State> state_;
};
} // namespace dingosdk::server