Skip to content
Permalink
Browse files

fix PingList not including self

  • Loading branch information...
UnknownShadow200 committed Jun 21, 2017
1 parent 7bcc3bc commit e77633ab46ab56fbb8ad3877ec2f1f726cd59a1b
Showing with 16 additions and 14 deletions.
  1. +1 −1 fCraft/Commands/InfoCommands.cs
  2. +15 −13 fCraft/Network/Player.Networking.cs
@@ -2098,7 +2098,7 @@ static void clpHandler(Player player, CommandReader cmd)
int offset = 0;
if (!int.TryParse(offsetStr, out offset)) offset = 0;

Player[] candidates = Server.Players.CanBeSeen(player)
Player[] candidates = Server.Players.CanBeSeen(player).Union(player)
.Where(p => p.AveragePingMilliseconds() != 0)
.OrderBy(p => p.AveragePingMilliseconds()).Reverse().ToArray();
if (candidates.Length < 1) {
@@ -327,19 +327,21 @@ public sealed partial class Player {
if( PingList[i].TimeSent.Ticks != 0 ) continue;

ushort prev = i > 0 ? PingList[i - 1].Data : (ushort)0;
PingList[i].Data = (ushort)(prev + 1);
PingList[i].TimeSent = DateTime.UtcNow;
return (ushort)(prev + 1);
}

// Remove oldest ping slot
for( int i = 0; i < PingList.Length - 1; i++ ) {
PingList[i] = PingList[i + 1];
}

PingList[PingList.Length - 1].Data++;
PingList[PingList.Length - 1].TimeSent = DateTime.UtcNow;
return PingList[PingList.Length - 1].Data;
return SetTwoWayPing( i, prev );
}

// Remove oldest ping slot
for( int i = 0; i < PingList.Length - 1; i++ ) {
PingList[i] = PingList[i + 1];
}
int j = PingList.Length - 1;
return SetTwoWayPing( j, PingList[j].Data );
}

ushort SetTwoWayPing( int i, ushort prev ) {
PingList[i].Data = (ushort)(prev + 1);
PingList[i].TimeSent = DateTime.UtcNow;
return (ushort)(prev + 1);
}

void ProcessPingPacket() {

0 comments on commit e77633a

Please sign in to comment.
You can’t perform that action at this time.