aboutsummaryrefslogtreecommitdiff
path: root/src/sound.h
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2022-06-20 21:56:12 +0200
committerGitHub <noreply@github.com>2022-06-20 21:56:12 +0200
commita463620edbe57071a7101297d33226507567ca73 (patch)
tree342d433ca55f4e3d1826508c303f2e6229d503f1 /src/sound.h
parent0b41533763bc9f104a2da2e4191f4654b8d8dab4 (diff)
downloadhax-minetest-server-a463620edbe57071a7101297d33226507567ca73.tar.gz
hax-minetest-server-a463620edbe57071a7101297d33226507567ca73.zip
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.
Diffstat (limited to 'src/sound.h')
-rw-r--r--src/sound.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/sound.h b/src/sound.h
index 6f7b0a1af..ddb4e3dc2 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -24,30 +24,28 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/serialize.h"
#include "irrlichttypes_bloated.h"
+// This class describes the basic sound information for playback.
+// Positional handling is done separately.
+
struct SimpleSoundSpec
{
SimpleSoundSpec(const std::string &name = "", float gain = 1.0f,
- float fade = 0.0f, float pitch = 1.0f) :
- name(name),
- gain(gain), fade(fade), pitch(pitch)
+ bool loop = false, float fade = 0.0f, float pitch = 1.0f) :
+ name(name), gain(gain), fade(fade), pitch(pitch), loop(loop)
{
}
bool exists() const { return !name.empty(); }
- // Take cf_version from ContentFeatures::serialize to
- // keep in sync with item definitions
- void serialize(std::ostream &os, u8 cf_version) const
+ void serialize(std::ostream &os, u16 protocol_version) const
{
os << serializeString16(name);
writeF32(os, gain);
writeF32(os, pitch);
writeF32(os, fade);
- // if (cf_version < ?)
- // return;
}
- void deSerialize(std::istream &is, u8 cf_version)
+ void deSerialize(std::istream &is, u16 protocol_version)
{
name = deSerializeString16(is);
gain = readF32(is);
@@ -59,4 +57,5 @@ struct SimpleSoundSpec
float gain = 1.0f;
float fade = 0.0f;
float pitch = 1.0f;
+ bool loop = false;
};