forked from Mirrorlandia_minetest/minetest
Fix no sound bug (#5968)
This commit is contained in:
parent
ddcd026344
commit
bbe3dd9a7a
@ -124,8 +124,8 @@ void ItemDefinition::reset()
|
|||||||
|
|
||||||
void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
|
void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
|
||||||
{
|
{
|
||||||
|
u8 version = (protocol_version >= 34) ? 4 : 3;
|
||||||
writeU8(os, 3); // version (proto > 20)
|
writeU8(os, version);
|
||||||
writeU8(os, type);
|
writeU8(os, type);
|
||||||
os << serializeString(name);
|
os << serializeString(name);
|
||||||
os << serializeString(description);
|
os << serializeString(description);
|
||||||
@ -156,8 +156,11 @@ void ItemDefinition::serialize(std::ostream &os, u16 protocol_version) const
|
|||||||
writeF1000(os, sound_place_failed.gain);
|
writeF1000(os, sound_place_failed.gain);
|
||||||
os << serializeString(palette_image);
|
os << serializeString(palette_image);
|
||||||
writeU32(os, color.color);
|
writeU32(os, color.color);
|
||||||
|
|
||||||
|
if (version >= 4) {
|
||||||
writeF1000(os, sound_place.pitch);
|
writeF1000(os, sound_place.pitch);
|
||||||
writeF1000(os, sound_place_failed.pitch);
|
writeF1000(os, sound_place_failed.pitch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemDefinition::deSerialize(std::istream &is)
|
void ItemDefinition::deSerialize(std::istream &is)
|
||||||
@ -167,7 +170,7 @@ void ItemDefinition::deSerialize(std::istream &is)
|
|||||||
|
|
||||||
// Deserialize
|
// Deserialize
|
||||||
int version = readU8(is);
|
int version = readU8(is);
|
||||||
if(version < 1 || version > 3)
|
if (version < 1 || version > 4)
|
||||||
throw SerializationError("unsupported ItemDefinition version");
|
throw SerializationError("unsupported ItemDefinition version");
|
||||||
type = (enum ItemType)readU8(is);
|
type = (enum ItemType)readU8(is);
|
||||||
name = deSerializeString(is);
|
name = deSerializeString(is);
|
||||||
@ -216,8 +219,11 @@ void ItemDefinition::deSerialize(std::istream &is)
|
|||||||
sound_place_failed.gain = readF1000(is);
|
sound_place_failed.gain = readF1000(is);
|
||||||
palette_image = deSerializeString(is);
|
palette_image = deSerializeString(is);
|
||||||
color.set(readU32(is));
|
color.set(readU32(is));
|
||||||
|
|
||||||
|
if (version >= 4) {
|
||||||
sound_place.pitch = readF1000(is);
|
sound_place.pitch = readF1000(is);
|
||||||
sound_place_failed.pitch = readF1000(is);
|
sound_place_failed.pitch = readF1000(is);
|
||||||
|
}
|
||||||
} catch(SerializationError &e) {};
|
} catch(SerializationError &e) {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ public:
|
|||||||
}
|
}
|
||||||
int handle = -1;
|
int handle = -1;
|
||||||
if (fade > 0) {
|
if (fade > 0) {
|
||||||
handle = playSoundRaw(buf, loop, 0.0f, 0.0f);
|
handle = playSoundRaw(buf, loop, 0.0f, pitch);
|
||||||
fadeSound(handle, fade, volume);
|
fadeSound(handle, fade, volume);
|
||||||
} else {
|
} else {
|
||||||
handle = playSoundRaw(buf, loop, volume, pitch);
|
handle = playSoundRaw(buf, loop, volume, pitch);
|
||||||
|
Loading…
Reference in New Issue
Block a user