diff options
Diffstat (limited to 'src/server.h')
-rw-r--r-- | src/server.h | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/src/server.h b/src/server.h index 2741b3157..cb7d77067 100644 --- a/src/server.h +++ b/src/server.h @@ -69,9 +69,11 @@ struct SkyboxParams; struct SunParams; struct MoonParams; struct StarParams; +struct Lighting; class ServerThread; class ServerModManager; class ServerInventoryManager; +struct PackedValue; enum ClientDeletionReason { CDR_LEAVE, @@ -94,30 +96,22 @@ struct MediaInfo } }; -struct ServerSoundParams +// Combines the pure sound (SimpleSoundSpec) with positional information +struct ServerPlayingSound { - enum Type { - SSP_LOCAL, - SSP_POSITIONAL, - SSP_OBJECT - } type = SSP_LOCAL; - float gain = 1.0f; - float fade = 0.0f; - float pitch = 1.0f; - bool loop = false; + SoundLocation type = SoundLocation::Local; + + float gain = 1.0f; // for amplification of the base sound float max_hear_distance = 32 * BS; v3f pos; u16 object = 0; - std::string to_player = ""; - std::string exclude_player = ""; + std::string to_player; + std::string exclude_player; v3f getPos(ServerEnvironment *env, bool *pos_exists) const; -}; -struct ServerPlayingSound -{ - ServerSoundParams params; SimpleSoundSpec spec; + std::unordered_set<session_t> clients; // peer ids }; @@ -234,8 +228,7 @@ public: // Returns -1 if failed, sound handle on success // Envlock - s32 playSound(const SimpleSoundSpec &spec, const ServerSoundParams ¶ms, - bool ephemeral=false); + s32 playSound(ServerPlayingSound ¶ms, bool ephemeral=false); void stopSound(s32 handle); void fadeSound(s32 handle, float step, float gain); @@ -291,11 +284,10 @@ public: virtual const std::vector<ModSpec> &getMods() const; virtual const ModSpec* getModSpec(const std::string &modname) const; - void getModNames(std::vector<std::string> &modlist); - std::string getBuiltinLuaPath(); + static std::string getBuiltinLuaPath(); virtual std::string getWorldPath() const { return m_path_world; } - inline bool isSingleplayer() + inline bool isSingleplayer() const { return m_simple_singleplayer_mode; } inline void setAsyncFatalError(const std::string &error) @@ -333,17 +325,18 @@ public: void overrideDayNightRatio(RemotePlayer *player, bool do_override, float brightness); + void setLighting(RemotePlayer *player, const Lighting &lighting); + + void RespawnPlayer(session_t peer_id); + /* con::PeerHandler implementation. */ void peerAdded(con::Peer *peer); void deletingPeer(con::Peer *peer, bool timeout); void DenySudoAccess(session_t peer_id); - void DenyAccessVerCompliant(session_t peer_id, u16 proto_ver, AccessDeniedCode reason, - const std::string &str_reason = "", bool reconnect = false); void DenyAccess(session_t peer_id, AccessDeniedCode reason, - const std::string &custom_reason = ""); + const std::string &custom_reason = "", bool reconnect = false); void acceptAuth(session_t peer_id, bool forSudoMode); - void DenyAccess_Legacy(session_t peer_id, const std::wstring &reason); void DisconnectPeer(session_t peer_id); bool getClientConInfo(session_t peer_id, con::rtt_stat_type type, float *retval); bool getClientInfo(session_t peer_id, ClientInfo &ret); @@ -351,7 +344,7 @@ public: void printToConsoleOnly(const std::string &text); void HandlePlayerHPChange(PlayerSAO *sao, const PlayerHPChangeReason &reason); - void SendPlayerHP(PlayerSAO *sao); + void SendPlayerHP(PlayerSAO *sao, bool effect); void SendPlayerBreath(PlayerSAO *sao); void SendInventory(PlayerSAO *playerSAO, bool incremental); void SendMovePlayer(session_t peer_id); @@ -386,6 +379,12 @@ public: static bool migrateModStorageDatabase(const GameParams &game_params, const Settings &cmd_args); + // Lua files registered for init of async env, pair of modname + path + std::vector<std::pair<std::string, std::string>> m_async_init_files; + + // Data transferred into async envs at init time + std::unique_ptr<PackedValue> m_async_globals_data; + // Bind address Address m_bind_addr; @@ -419,10 +418,19 @@ private: std::unordered_set<session_t> waiting_players; }; + // The standard library does not implement std::hash for pairs so we have this: + struct SBCHash { + size_t operator() (const std::pair<v3s16, u16> &p) const { + return std::hash<v3s16>()(p.first) ^ p.second; + } + }; + + typedef std::unordered_map<std::pair<v3s16, u16>, std::string, SBCHash> SerializedBlockCache; + void init(); void SendMovement(session_t peer_id); - void SendHP(session_t peer_id, u16 hp); + void SendHP(session_t peer_id, u16 hp, bool effect); void SendBreath(session_t peer_id, u16 breath); void SendAccessDenied(session_t peer_id, AccessDeniedCode reason, const std::string &custom_reason, bool reconnect = false); @@ -459,6 +467,7 @@ private: void SendSetStars(session_t peer_id, const StarParams ¶ms); void SendCloudParams(session_t peer_id, const CloudParams ¶ms); void SendOverrideDayNightRatio(session_t peer_id, bool do_override, float ratio); + void SendSetLighting(session_t peer_id, const Lighting &lighting); void broadcastModChannelMessage(const std::string &channel, const std::string &message, session_t from_peer); @@ -474,11 +483,13 @@ private: std::unordered_set<u16> *far_players = nullptr, float far_d_nodes = 100, bool remove_metadata = true); - void sendMetadataChanged(const std::list<v3s16> &meta_updates, + void sendMetadataChanged(const std::unordered_set<v3s16> &positions, float far_d_nodes = 100); // Environment and Connection must be locked when called - void SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver, u16 net_proto_version); + // `cache` may only be very short lived! (invalidation not handeled) + void SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver, + u16 net_proto_version, SerializedBlockCache *cache = nullptr); // Sends blocks to clients (locks env and con on its own) void SendBlocks(float dtime); @@ -511,7 +522,6 @@ private: */ 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); bool checkInteractDistance(RemotePlayer *player, const f32 d, const std::string &what); @@ -706,11 +716,11 @@ private: MetricCounterPtr m_uptime_counter; MetricGaugePtr m_player_gauge; MetricGaugePtr m_timeofday_gauge; - // current server step lag MetricGaugePtr m_lag_gauge; - MetricCounterPtr m_aom_buffer_counter; + MetricCounterPtr m_aom_buffer_counter[2]; // [0] = rel, [1] = unrel MetricCounterPtr m_packet_recv_counter; MetricCounterPtr m_packet_recv_processed_counter; + MetricCounterPtr m_map_edit_event_counter; }; /* |