mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 12:09:19 +02:00
multiplayer: hold the authority's readings between updates, and hear the brakes
Two complaints, one cause underneath them. The brake and squeal sounds came out in shreds as a train got going. Both are shaped from UnitBrakeForce and Vel, and both of those are results of a physics step. An update arrives ten times a second; in the twenty-odd frames between them the local physics carries on computing its own speed and its own brake force for a train it has no business simulating, they fall away, and the next update snaps them back. rsBrake pitches on Vel and rsPisk gains on the brake force ratio, so what the ear got was that sawtooth. So the physics outputs of somebody else's train are now put back after every local step, not only on the frame an update lands: speed, brake force, wheel and engine revolutions, engine power, wheelslip, sand, and the running flags of the converter and the compressors, which the local physics kept switching off because the conditions it evaluates are not the ones the owner is evaluating. The relays are the same problem wearing a different hat. MainCtrlActualPos - the notch the resistors are actually on, as opposed to the one the handle is at - was being stepped by the local automatic notching, off its own guesses, so the clicks either fired at the wrong moment or never fired at all. It travels now, together with ScndCtrlActualPos and StLinFlag, which stops the local notching inventing anything, and every relay heard here is one that operated over there. The brake unit keeps a sound bitfield of its own, and that is where the accelerator and the cylinder venting live. Reading it clears it, so watching it had to be done without consuming it: TBrake grows PeekSoundFlag(), and only the flags that have just come up count as an event - the vehicle only clears them when it has an accelerator sound to play, so a bit that stays lit is one event, not one per frame. RaiseSoundFlag() hands them to the far end. Snapshot version 5.
This commit is contained in:
@@ -30,6 +30,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "rendering/renderer.h"
|
||||
#include "utilities/Logs.h"
|
||||
#include "network/entities.h"
|
||||
#include "network/snapshot.h"
|
||||
/*
|
||||
namespace input {
|
||||
|
||||
@@ -449,6 +450,11 @@ bool driver_mode::update()
|
||||
|
||||
Timer::subsystem.sim_total.stop();
|
||||
|
||||
// what the other peers' trains are doing is theirs to decide, and the local physics
|
||||
// has spent this frame disagreeing about it. put their readings back before anything
|
||||
// is heard or drawn from them
|
||||
network::hold_remote_state();
|
||||
|
||||
simulation::Region->update_sounds();
|
||||
audio::renderer.update(Global.iPause ? 0.0 : deltarealtime);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user