somewhat better jitter handling

This commit is contained in:
RandomityGuy 2024-04-10 12:20:31 +05:30
parent afc80769c5
commit 568d6c0fac
2 changed files with 24 additions and 3 deletions

View file

@ -1811,14 +1811,18 @@ class Marble extends GameObject {
var nextMove = this.connection.getNextMove();
// trace('Moves left: ${@:privateAccess this.connection.moveManager.queuedMoves.length}');
if (nextMove == null) {
var axis = getMarbleAxis()[1];
var innerMove = new Move();
innerMove.d = new Vector(0, 0);
var axis = moveMotionDir != null ? moveMotionDir : getMarbleAxis()[1];
var innerMove = lastMove;
if (innerMove == null) {
innerMove = new Move();
innerMove.d = new Vector(0, 0);
}
move = new NetMove(innerMove, axis, timeState, recvServerTick, 65535);
} else {
move = nextMove;
moveMotionDir = nextMove.motionDir;
moveId = nextMove.id;
lastMove = move.move;
}
}
if (move == null && !this.controllable) {

View file

@ -51,6 +51,8 @@ class MoveManager {
var serverAvgMoveListSize = 3.0;
var serverSmoothMoveAvg = 0.15;
var serverMoveListSizeSlack = 1.0;
var serverDefaultMinTargetMoveListSize = 3;
var serverAbnormalMoveCount = 0;
public var stall = false;
@ -168,6 +170,13 @@ class MoveManager {
if (serverAvgMoveListSize < serverTargetMoveListSize - serverMoveListSizeSlack
&& queuedMoves.length < serverTargetMoveListSize
&& queuedMoves.length != 0) {
serverAvgMoveListSize = Math.max(Std.int(serverAvgMoveListSize + serverMoveListSizeSlack + 0.5), queuedMoves.length);
serverAbnormalMoveCount++;
if (serverAbnormalMoveCount > 3) {
serverTargetMoveListSize += 1;
if (serverTargetMoveListSize > serverMaxMoveListSize)
serverTargetMoveListSize = serverMaxMoveListSize;
}
// Send null move
return null;
}
@ -179,6 +188,14 @@ class MoveManager {
queuedMoves.pop();
}
serverAvgMoveListSize = serverTargetMoveListSize;
serverAbnormalMoveCount++;
if (serverAbnormalMoveCount > 3) {
serverTargetMoveListSize -= 1;
if (serverTargetMoveListSize < serverDefaultMinTargetMoveListSize)
serverTargetMoveListSize = serverDefaultMinTargetMoveListSize;
} else {
serverAbnormalMoveCount = 0;
}
}
}
if (queuedMoves.length == 0) {