From a463620edbe57071a7101297d33226507567ca73 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 20 Jun 2022 21:56:12 +0200 Subject: Re-order sound-related code (#12382) Dropped ServerSoundParams -> moved to ServerPlayingSound. This gets rid of the duplicated 'fade' and 'pitch' values on server-side where only one was used anyway. SimpleSoundSpec is the basic sound without positional information, hence 'loop' is included. Recursively added PROTOCOL_VERSION to most functions to reduce the versioning mess in the future. Per-type version numbers are kept for now as a safety rope in a special case. --- src/server.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/server.h') diff --git a/src/server.h b/src/server.h index 79db913aa..00b6f897d 100644 --- a/src/server.h +++ b/src/server.h @@ -96,30 +96,26 @@ 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; + + 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 clients; // peer ids }; @@ -236,8 +232,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); -- cgit v1.2.3