void SaveInput(SWBytes data, int start, int end) { SWConsole.Info($"SaveItems start={start}, end={end}"); if (end > _lastEndIndex) { _lastEndIndex = end; } return; string partialName = _game.replayFileName + start.ToString("D6") + end.ToString("D6"); SaveReplayoperation operation = new SaveReplayoperation(data.Data(), partialName); operationQueue.AddOperation(operation); }
void DoTick() { _frameNumber++; _sealedFrameNumber = _frameNumber - 10; if (_sealedFrameNumber < 1) { _sealedFrameNumber = 1; } if (_receivedInputFrameDeltas.Count > 0) { SWConsole.Crit($"MockIO: DoTick playerFrameCount={_receivedInputFrameDeltas.Count}"); InputFrameDelta delta = _receivedInputFrameDeltas.Peek(); if (true) { delta = _receivedInputFrameDeltas.Dequeue(); //SWConsole.Crit($"MockIO: DoTick playerFrameCount 1 ={_receivedInputFrameDeltas.Count}"); _inputFrameDeltas[_frameNumber] = delta; _data.Reset(); byte length = (byte)delta.bytes.DataLength; _data.Push(length); _data.PushAll(delta.bytes); SWConsole.Crit($"MockIO: DoTick send PLAYER={delta.frameNumber} roomStep={_frameNumber}"); MockHandleInputFrameOperaion operation = new MockHandleInputFrameOperaion(_handler, _pingMilliseconds); operation.inputFrameData = SWBytes.Clone(_data); operation.playerLastInputFrameOnServer = _receivedInputFrameDeltas.Count; operation.predictionFrameNumber = _predictedFrameNumber; operation.correctFrameNumber = _correctFrameNumber; operation.roomStep = _frameNumber; operation.sealedFrameNumber = _sealedFrameNumber; _operationQueue.AddOperation(operation); return; } //else if(delta.predictedServerFrameNumber < _frameNumber) //{ // delta = _receivedInputFrameDeltas.Dequeue(); // delta.version = 1; // _inputFrameDeltas[delta.predictedServerFrameNumber] = delta; // _data.Reset(); // byte length = (byte)delta.bytes.DataLength; // _data.Push(length); // _data.Push(delta.bytes, 0); // SWConsole.Crit($"MockIO: DoTick send PLAYER={delta.frameNumber} roomStep={_frameNumber} prediction={delta.predictedServerFrameNumber}"); // _frameNumber--; // _sealedFrameNumber = _frameNumber - 10; // if (_sealedFrameNumber < 1) // { // _sealedFrameNumber = 1; // } // MockHandleInputFrameOperaion operation = new MockHandleInputFrameOperaion(_handler, _pingMilliseconds); // operation.inputFrameData = SWBytes.Clone(_data); // operation.playerLastInputFrameOnServer = _receivedInputFrameDeltas.Count; // operation.predictionError = _predictionError; // operation.roomStep = delta.predictedServerFrameNumber; // operation.version = delta.version; // operation.sealedFrameNumber = _sealedFrameNumber; // _operationQueue.AddOperation(operation); // return; //} } { _lastPredictedFrameNumber = _frameNumber; InputFrameDelta delta = new InputFrameDelta(); delta.frameNumber = 0; //playerFrameNumber _inputFrameDeltas[_frameNumber] = delta; _data.Reset(); _data.Push((byte)0); //length SWConsole.Crit($"MockIO: DoTick send EMPTY={delta.frameNumber} roomStep={_frameNumber}"); MockHandleInputFrameOperaion operation = new MockHandleInputFrameOperaion(_handler, _pingMilliseconds); operation.inputFrameData = SWBytes.Clone(_data); operation.playerLastInputFrameOnServer = _receivedInputFrameDeltas.Count; operation.predictionFrameNumber = _predictedFrameNumber; operation.correctFrameNumber = _correctFrameNumber; operation.roomStep = _frameNumber; operation.sealedFrameNumber = _sealedFrameNumber; _operationQueue.AddOperation(operation); } }