1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Enable dynamic_add_media to take the file data instead of a path

This commit is contained in:
sfan5 2024-01-23 21:15:09 +01:00
parent c90ebad46b
commit d4b107e2e8
8 changed files with 167 additions and 67 deletions

View file

@ -44,6 +44,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <map>
#include <vector>
#include <unordered_set>
#include <optional>
#include <string_view>
class ChatEvent;
struct ChatEventChat;
@ -87,13 +89,17 @@ struct MediaInfo
{
std::string path;
std::string sha1_digest; // base64-encoded
bool no_announce; // true: not announced in TOCLIENT_ANNOUNCE_MEDIA (at player join)
// true = not announced in TOCLIENT_ANNOUNCE_MEDIA (at player join)
bool no_announce;
// does what it says. used by some cases of dynamic media.
bool delete_at_shutdown;
MediaInfo(const std::string &path_="",
const std::string &sha1_digest_=""):
path(path_),
sha1_digest(sha1_digest_),
no_announce(false)
no_announce(false),
delete_at_shutdown(false)
{
}
};
@ -258,8 +264,15 @@ public:
void deleteParticleSpawner(const std::string &playername, u32 id);
bool dynamicAddMedia(std::string filename, std::string filepath, u32 token,
const std::string &to_player, bool ephemeral);
struct DynamicMediaArgs {
std::string filename;
std::optional<std::string> filepath;
std::optional<std::string_view> data;
u32 token;
std::string to_player;
bool ephemeral = false;
};
bool dynamicAddMedia(const DynamicMediaArgs &args);
ServerInventoryManager *getInventoryMgr() const { return m_inventory_mgr.get(); }
void sendDetachedInventory(Inventory *inventory, const std::string &name, session_t peer_id);