mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
ping icons
This commit is contained in:
parent
98de4cff1c
commit
d893ca30e6
4 changed files with 18 additions and 7 deletions
|
|
@ -1938,6 +1938,7 @@ class Marble extends GameObject {
|
|||
marbleUpdate.netFlags = this.netFlags;
|
||||
marbleUpdate.gravityDirection = this.currentUp;
|
||||
marbleUpdate.trapdoorUpdates = this.trapdoorContacts;
|
||||
marbleUpdate.pingTicks = connection != null ? connection.pingTicks : 0;
|
||||
marbleUpdate.serialize(b);
|
||||
|
||||
this.trapdoorContacts = [];
|
||||
|
|
|
|||
|
|
@ -118,13 +118,14 @@ class ProfilerUI {
|
|||
+ 'Server Move Queue Size: ${Net.isClient ? @:privateAccess MarbleGame.instance.world.lastMoves.myMarbleUpdate.moveQueueSize : 0}\n'
|
||||
+ 'Last Sent Move: ${Net.isClient ? lastSentMove : 0}\n'
|
||||
+ 'Last Ack Move: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.lastAckMoveId : 0}\n'
|
||||
+ 'Move Ack RTT: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.ackRTT : 0}';
|
||||
+ 'Move Ack RTT: ${Net.isClient ? @:privateAccess Net.clientConnection.moveManager.ackRTT : 0}'
|
||||
+ 'Ping: ${Net.clientConnection.pingTicks}';
|
||||
}
|
||||
if (Net.isHost) {
|
||||
var strs = [];
|
||||
strs.push('World Ticks: ${MarbleGame.instance.world.timeState.ticks}');
|
||||
for (dc => cc in Net.clients) {
|
||||
strs.push('${cc.id} move: sz ${@:privateAccess cc.moveManager.getQueueSize()} avg ${@:privateAccess cc.moveManager.serverAvgMoveListSize}');
|
||||
strs.push('${cc.id} move: sz ${@:privateAccess cc.moveManager.getQueueSize()} avg ${@:privateAccess cc.moveManager.serverAvgMoveListSize}, ping: ${cc.pingTicks}');
|
||||
}
|
||||
|
||||
instance.networkStats.text = strs.join('\n');
|
||||
|
|
|
|||
|
|
@ -716,6 +716,8 @@ class Net {
|
|||
var marbleUpdatePacket = new MarbleUpdatePacket();
|
||||
marbleUpdatePacket.deserialize(input);
|
||||
var cc = marbleUpdatePacket.clientId;
|
||||
var client = cc != Net.clientId ? clientIdMap[cc] : Net.clientConnection;
|
||||
client.pingTicks = marbleUpdatePacket.pingTicks;
|
||||
if (MarbleGame.instance.world != null && !MarbleGame.instance.world._disposed) {
|
||||
var m = MarbleGame.instance.world.lastMoves;
|
||||
m.enqueue(marbleUpdatePacket);
|
||||
|
|
@ -726,9 +728,13 @@ class Net {
|
|||
var movePacket = new MarbleMovePacket();
|
||||
movePacket.deserialize(input);
|
||||
var cc = clientIdMap[movePacket.clientId];
|
||||
if (cc.state == GAME)
|
||||
if (cc.state == GAME) {
|
||||
var startRecvId = cc.moveManager.getQueueSize();
|
||||
for (move in movePacket.moves)
|
||||
cc.queueMove(move);
|
||||
var endRecvId = cc.moveManager.getQueueSize();
|
||||
cc.pingTicks = movePacket.moves.length - (endRecvId - startRecvId);
|
||||
}
|
||||
}
|
||||
|
||||
case PowerupPickup:
|
||||
|
|
|
|||
|
|
@ -71,16 +71,18 @@ class MarbleUpdatePacket implements NetPacket {
|
|||
var oob:Bool;
|
||||
var powerUpId:Int;
|
||||
var moveQueueSize:Int;
|
||||
var pingTicks:Int;
|
||||
var netFlags:Int;
|
||||
var trapdoorUpdates:Map<Int, Int> = [];
|
||||
|
||||
public function new() {}
|
||||
|
||||
public inline function serialize(b:OutputBitStream) {
|
||||
b.writeByte(clientId);
|
||||
b.writeInt(clientId, 6);
|
||||
MoveManager.packMove(move, b);
|
||||
b.writeUInt16(serverTicks);
|
||||
b.writeByte(moveQueueSize);
|
||||
b.writeInt(moveQueueSize, 6);
|
||||
b.writeInt(pingTicks, 6);
|
||||
b.writeFloat(position.x);
|
||||
b.writeFloat(position.y);
|
||||
b.writeFloat(position.z);
|
||||
|
|
@ -160,10 +162,11 @@ class MarbleUpdatePacket implements NetPacket {
|
|||
}
|
||||
|
||||
public inline function deserialize(b:InputBitStream) {
|
||||
clientId = b.readByte();
|
||||
clientId = b.readInt(6);
|
||||
move = MoveManager.unpackMove(b);
|
||||
serverTicks = b.readUInt16();
|
||||
moveQueueSize = b.readByte();
|
||||
moveQueueSize = b.readInt(6);
|
||||
pingTicks = b.readInt(6);
|
||||
position = new Vector(b.readFloat(), b.readFloat(), b.readFloat());
|
||||
velocity = new Vector(b.readFloat(), b.readFloat(), b.readFloat());
|
||||
omega = new Vector(b.readFloat(), b.readFloat(), b.readFloat());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue