aboutsummaryrefslogtreecommitdiff
path: root/src/server.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.h')
-rw-r--r--src/server.h43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/server.h b/src/server.h
index 9857215d0..2741b3157 100644
--- a/src/server.h
+++ b/src/server.h
@@ -43,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <list>
#include <map>
#include <vector>
+#include <unordered_set>
class ChatEvent;
struct ChatEventChat;
@@ -81,12 +82,14 @@ enum ClientDeletionReason {
struct MediaInfo
{
std::string path;
- std::string sha1_digest;
+ std::string sha1_digest; // base64-encoded
+ bool no_announce; // true: not announced in TOCLIENT_ANNOUNCE_MEDIA (at player join)
MediaInfo(const std::string &path_="",
const std::string &sha1_digest_=""):
path(path_),
- sha1_digest(sha1_digest_)
+ sha1_digest(sha1_digest_),
+ no_announce(false)
{
}
};
@@ -197,6 +200,7 @@ public:
void handleCommand_FirstSrp(NetworkPacket* pkt);
void handleCommand_SrpBytesA(NetworkPacket* pkt);
void handleCommand_SrpBytesM(NetworkPacket* pkt);
+ void handleCommand_HaveMedia(NetworkPacket *pkt);
void ProcessData(NetworkPacket *pkt);
@@ -257,7 +261,8 @@ public:
void deleteParticleSpawner(const std::string &playername, u32 id);
- bool dynamicAddMedia(const std::string &filepath, std::vector<RemotePlayer*> &sent_to);
+ bool dynamicAddMedia(std::string filepath, u32 token,
+ const std::string &to_player, bool ephemeral);
ServerInventoryManager *getInventoryMgr() const { return m_inventory_mgr.get(); }
void sendDetachedInventory(Inventory *inventory, const std::string &name, session_t peer_id);
@@ -278,6 +283,7 @@ public:
virtual u16 allocateUnknownNodeId(const std::string &name);
IRollbackManager *getRollbackManager() { return m_rollback; }
virtual EmergeManager *getEmergeManager() { return m_emerge; }
+ virtual ModMetadataDatabase *getModStorageDatabase() { return m_mod_storage_database; }
IWritableItemDefManager* getWritableItemDefManager();
NodeDefManager* getWritableNodeDefManager();
@@ -288,13 +294,16 @@ public:
void getModNames(std::vector<std::string> &modlist);
std::string getBuiltinLuaPath();
virtual std::string getWorldPath() const { return m_path_world; }
- virtual std::string getModStoragePath() const;
inline bool isSingleplayer()
{ return m_simple_singleplayer_mode; }
inline void setAsyncFatalError(const std::string &error)
{ m_async_fatal_error.set(error); }
+ inline void setAsyncFatalError(const LuaError &e)
+ {
+ setAsyncFatalError(std::string("Lua: ") + e.what());
+ }
bool showFormspec(const char *name, const std::string &formspec, const std::string &formname);
Map & getMap() { return m_env->getMap(); }
@@ -341,7 +350,8 @@ public:
void printToConsoleOnly(const std::string &text);
- void SendPlayerHPOrDie(PlayerSAO *player, const PlayerHPChangeReason &reason);
+ void HandlePlayerHPChange(PlayerSAO *sao, const PlayerHPChangeReason &reason);
+ void SendPlayerHP(PlayerSAO *sao);
void SendPlayerBreath(PlayerSAO *sao);
void SendInventory(PlayerSAO *playerSAO, bool incremental);
void SendMovePlayer(session_t peer_id);
@@ -368,6 +378,14 @@ public:
// Get or load translations for a language
Translations *getTranslationLanguage(const std::string &lang_code);
+ static ModMetadataDatabase *openModStorageDatabase(const std::string &world_path);
+
+ static ModMetadataDatabase *openModStorageDatabase(const std::string &backend,
+ const std::string &world_path, const Settings &world_mt);
+
+ static bool migrateModStorageDatabase(const GameParams &game_params,
+ const Settings &cmd_args);
+
// Bind address
Address m_bind_addr;
@@ -395,6 +413,12 @@ private:
float m_timer = 0.0f;
};
+ struct PendingDynamicMediaCallback {
+ std::string filename; // only set if media entry and file is to be deleted
+ float expiry_timer;
+ std::unordered_set<session_t> waiting_players;
+ };
+
void init();
void SendMovement(session_t peer_id);
@@ -415,7 +439,6 @@ private:
virtual void SendChatMessage(session_t peer_id, const ChatMessage &message);
void SendTimeOfDay(session_t peer_id, u16 time, f32 time_speed);
- void SendPlayerHP(session_t peer_id);
void SendLocalPlayerAnimations(session_t peer_id, v2s32 animation_frames[4],
f32 animation_speed);
@@ -466,6 +489,7 @@ private:
void sendMediaAnnouncement(session_t peer_id, const std::string &lang_code);
void sendRequestedMedia(session_t peer_id,
const std::vector<std::string> &tosend);
+ void stepPendingDynMediaCallbacks(float dtime);
// Adds a ParticleSpawner on peer with peer_id (PEER_ID_INEXISTENT == all)
void SendAddParticleSpawner(session_t peer_id, u16 protocol_version,
@@ -486,7 +510,7 @@ private:
Something random
*/
- void DiePlayer(session_t peer_id, const PlayerHPChangeReason &reason);
+ void HandlePlayerDeath(PlayerSAO* sao, const PlayerHPChangeReason &reason);
void RespawnPlayer(session_t peer_id);
void DeleteClient(session_t peer_id, ClientDeletionReason reason);
void UpdateCrafting(RemotePlayer *player);
@@ -650,6 +674,10 @@ private:
// media files known to server
std::unordered_map<std::string, MediaInfo> m_media;
+ // pending dynamic media callbacks, clients inform the server when they have a file fetched
+ std::unordered_map<u32, PendingDynamicMediaCallback> m_pending_dyn_media;
+ float m_step_pending_dyn_media_timer = 0.0f;
+
/*
Sounds
*/
@@ -658,6 +686,7 @@ private:
s32 nextSoundId();
std::unordered_map<std::string, ModMetadata *> m_mod_storages;
+ ModMetadataDatabase *m_mod_storage_database = nullptr;
float m_mod_storage_save_timer = 10.0f;
// CSM restrictions byteflag