mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-19 12:18:03 -04:00
Move Ping field to IGameSession
This commit is contained in:
parent
ad68660649
commit
4ea13c2146
@ -31,25 +31,30 @@ namespace MCGalaxy.Commands.Chatting {
|
|||||||
|
|
||||||
Player who = PlayerInfo.FindMatches(p, message);
|
Player who = PlayerInfo.FindMatches(p, message);
|
||||||
if (who == null) return;
|
if (who == null) return;
|
||||||
|
|
||||||
if (p != who && !CheckExtraPerm(p, data, 1)) return;
|
if (p != who && !CheckExtraPerm(p, data, 1)) return;
|
||||||
|
PingList ping = who.Session.Ping;
|
||||||
|
|
||||||
if (!who.Supports(CpeExt.TwoWayPing)) {
|
if (!who.Supports(CpeExt.TwoWayPing)) {
|
||||||
p.Message("{0} client does not support measuring ping",
|
p.Message("{0} client does not support measuring ping",
|
||||||
p == who ? "Your" : p.FormatNick(who) + "&S's");
|
p == who ? "Your" : p.FormatNick(who) + "&S's");
|
||||||
} else if (who.Ping.Measures() == 0) {
|
} else if (ping.Measures() == 0) {
|
||||||
p.Message("No ping measurements yet. Try again in a bit.");
|
p.Message("No ping measurements yet. Try again in a bit.");
|
||||||
} else {
|
} else {
|
||||||
p.Message(p.FormatNick(who) + " &S- " + who.Ping.Format());
|
p.Message(p.FormatNick(who) + " &S- " + ping.Format());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!CheckExtraPerm(p, data, 1)) return;
|
if (!CheckExtraPerm(p, data, 1)) return;
|
||||||
Player[] players = PlayerInfo.Online.Items;
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
p.Message("Ping/latency list of online players: (&aLo&S:&7Avg&S:&cHi&S)ms");
|
p.Message("Ping/latency list of online players: (&aLo&S:&7Avg&S:&cHi&S)ms");
|
||||||
|
|
||||||
foreach (Player target in players) {
|
foreach (Player target in players)
|
||||||
|
{
|
||||||
if (!p.CanSee(target, data.Rank)) continue;
|
if (!p.CanSee(target, data.Rank)) continue;
|
||||||
if (target.Ping.Measures() == 0) continue;
|
PingList ping = target.Session.Ping;
|
||||||
p.Message(target.Ping.FormatAll() + " &S- " + p.FormatNick(target));
|
|
||||||
|
if (ping.Measures() == 0) continue;
|
||||||
|
p.Message(ping.FormatAll() + " &S- " + p.FormatNick(target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ namespace MCGalaxy.Network
|
|||||||
Send(Packet.TwoWayPing(false, data));
|
Send(Packet.TwoWayPing(false, data));
|
||||||
} else {
|
} else {
|
||||||
// Server -> client ping, set time received for reply.
|
// Server -> client ping, set time received for reply.
|
||||||
player.Ping.Update(data);
|
Ping.Update(data);
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@ namespace MCGalaxy.Network
|
|||||||
|
|
||||||
public override void SendPing() {
|
public override void SendPing() {
|
||||||
if (hasTwoWayPing) {
|
if (hasTwoWayPing) {
|
||||||
Send(Packet.TwoWayPing(true, player.Ping.NextTwoWayPingData()));
|
Send(Packet.TwoWayPing(true, Ping.NextTwoWayPingData()));
|
||||||
} else {
|
} else {
|
||||||
Send(Packet.Ping());
|
Send(Packet.Ping());
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ namespace MCGalaxy.Network
|
|||||||
/// <summary> Temporary unique ID for this network session </summary>
|
/// <summary> Temporary unique ID for this network session </summary>
|
||||||
public int ID;
|
public int ID;
|
||||||
|
|
||||||
|
public PingList Ping = new PingList();
|
||||||
|
|
||||||
public int ProcessReceived(byte[] buffer, int bufferLen) {
|
public int ProcessReceived(byte[] buffer, int bufferLen) {
|
||||||
int read = 0;
|
int read = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -44,7 +44,6 @@ namespace MCGalaxy {
|
|||||||
/// <summary> The underlying socket for sending/receiving raw data </summary>
|
/// <summary> The underlying socket for sending/receiving raw data </summary>
|
||||||
public INetSocket Socket;
|
public INetSocket Socket;
|
||||||
public IGameSession Session;
|
public IGameSession Session;
|
||||||
public PingList Ping = new PingList();
|
|
||||||
|
|
||||||
public DateTime LastAction, AFKCooldown;
|
public DateTime LastAction, AFKCooldown;
|
||||||
public bool IsAfk, AutoAfk;
|
public bool IsAfk, AutoAfk;
|
||||||
|
@ -130,7 +130,7 @@ namespace MCGalaxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Filters input list to only players that the source player can see. </summary>
|
/// <summary> Filters input list to only players that the source player can see. </summary>
|
||||||
internal static List<Player> OnlyCanSee(Player p, LevelPermission plRank,
|
public static List<Player> OnlyCanSee(Player p, LevelPermission plRank,
|
||||||
IEnumerable<Player> players) {
|
IEnumerable<Player> players) {
|
||||||
List<Player> list = new List<Player>();
|
List<Player> list = new List<Player>();
|
||||||
foreach (Player pl in players) {
|
foreach (Player pl in players) {
|
||||||
|
@ -210,6 +210,7 @@ namespace MCGalaxy {
|
|||||||
OnConfigUpdatedEvent.Call();
|
OnConfigUpdatedEvent.Call();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static readonly object stopLock = new object();
|
static readonly object stopLock = new object();
|
||||||
static volatile Thread stopThread;
|
static volatile Thread stopThread;
|
||||||
public static Thread Stop(bool restart, string msg) {
|
public static Thread Stop(bool restart, string msg) {
|
||||||
@ -272,7 +273,7 @@ namespace MCGalaxy {
|
|||||||
// first try to use excevp to restart in CLI mode under mono
|
// first try to use excevp to restart in CLI mode under mono
|
||||||
// - see detailed comment in HACK_Execvp for why this is required
|
// - see detailed comment in HACK_Execvp for why this is required
|
||||||
if (HACK_TryExecvp()) HACK_Execvp();
|
if (HACK_TryExecvp()) HACK_Execvp();
|
||||||
Process.Start(RestartPath);
|
Process.Start(GetRestartPath());
|
||||||
}
|
}
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
@ -313,6 +314,22 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string GetRestartPath() {
|
||||||
|
#if !NETSTANDARD
|
||||||
|
return RestartPath;
|
||||||
|
#else
|
||||||
|
// NET core/5/6 executables tend to use the following structure:
|
||||||
|
// MCGalaxyCLI_core --> MCGalaxyCLI_core.dll
|
||||||
|
// in this case, 'RestartPath' will include '.dll' since this file
|
||||||
|
// is actually the managed assembly, but we need to remove '.dll'
|
||||||
|
// as the actual executable which must be started is the non .dll file
|
||||||
|
string path = RestartPath;
|
||||||
|
if (path.CaselessEnds(".dll")) path = path.Substring(0, path.Length - 4);
|
||||||
|
return path;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool checkedOnMono, runningOnMono;
|
static bool checkedOnMono, runningOnMono;
|
||||||
public static bool RunningOnMono() {
|
public static bool RunningOnMono() {
|
||||||
if (!checkedOnMono) {
|
if (!checkedOnMono) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user