mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-31 19:19:03 +01:00
multiplayer: replicate the machinery you hear, not only the machinery you set
A bystander heard nothing of somebody else's converter, compressors, brake air or relays. Two different reasons for that, and they need two different answers. The devices whose sound runs for as long as they do - the converter, the main compressor, the pantograph compressor, the releaser - are outputs of a physics that a peer only half runs for a vehicle it does not own. Their running flags travel now, alongside the permits that were already going. The clicks and hisses are a harder case: MoverParameters::SoundFlag is raised and wiped inside a single frame, so sampling it when an update happens to be put together would catch almost none of them. They are collected as the vehicle finishes with them, just before it clears the field, and the accumulation rides along with the next update. On arrival they are added to whatever the receiving peer's own physics produced, and its sound handling plays them once and wipes the lot, exactly as it does for its own.
This commit is contained in:
@@ -18,7 +18,7 @@ namespace network
|
||||
{
|
||||
|
||||
// layout of the snapshot container. a reader refuses a blob it does not understand
|
||||
constexpr uint32_t SNAPSHOT_VERSION = 3;
|
||||
constexpr uint32_t SNAPSHOT_VERSION = 4;
|
||||
|
||||
// the sections a snapshot is built from. a reader skips over any id it does not know,
|
||||
// which is what makes the format extensible: a peer built before a section existed can
|
||||
@@ -72,4 +72,9 @@ snapshot_result apply_snapshot(std::string const &Blob, snapshot_mode Mode, Peer
|
||||
// forgets what was last sent, so that the next delta comes out complete
|
||||
void reset_snapshot_history();
|
||||
|
||||
// remembers the one-shot sound events a vehicle produced. they are set and cleared inside
|
||||
// a single frame, so by the time an update is put together they would be long gone; this
|
||||
// is called from the vehicle's own sound handling, just before it wipes them
|
||||
void note_sound_events(std::string const &Vehicle, int Events);
|
||||
|
||||
} // namespace network
|
||||
|
||||
Reference in New Issue
Block a user