mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-18 03:39:04 -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);
|
||||
if (who == null) return;
|
||||
|
||||
if (p != who && !CheckExtraPerm(p, data, 1)) return;
|
||||
|
||||
PingList ping = who.Session.Ping;
|
||||
|
||||
if (!who.Supports(CpeExt.TwoWayPing)) {
|
||||
p.Message("{0} client does not support measuring ping",
|
||||
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.");
|
||||
} else {
|
||||
p.Message(p.FormatNick(who) + " &S- " + who.Ping.Format());
|
||||
p.Message(p.FormatNick(who) + " &S- " + ping.Format());
|
||||
}
|
||||
} else {
|
||||
if (!CheckExtraPerm(p, data, 1)) return;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
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 (target.Ping.Measures() == 0) continue;
|
||||
p.Message(target.Ping.FormatAll() + " &S- " + p.FormatNick(target));
|
||||
PingList ping = target.Session.Ping;
|
||||
|
||||
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));
|
||||
} else {
|
||||
// Server -> client ping, set time received for reply.
|
||||
player.Ping.Update(data);
|
||||
Ping.Update(data);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@ -494,7 +494,7 @@ namespace MCGalaxy.Network
|
||||
|
||||
public override void SendPing() {
|
||||
if (hasTwoWayPing) {
|
||||
Send(Packet.TwoWayPing(true, player.Ping.NextTwoWayPingData()));
|
||||
Send(Packet.TwoWayPing(true, Ping.NextTwoWayPingData()));
|
||||
} else {
|
||||
Send(Packet.Ping());
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ namespace MCGalaxy.Network
|
||||
/// <summary> Temporary unique ID for this network session </summary>
|
||||
public int ID;
|
||||
|
||||
public PingList Ping = new PingList();
|
||||
|
||||
public int ProcessReceived(byte[] buffer, int bufferLen) {
|
||||
int read = 0;
|
||||
try {
|
||||
|
@ -44,7 +44,6 @@ namespace MCGalaxy {
|
||||
/// <summary> The underlying socket for sending/receiving raw data </summary>
|
||||
public INetSocket Socket;
|
||||
public IGameSession Session;
|
||||
public PingList Ping = new PingList();
|
||||
|
||||
public DateTime LastAction, AFKCooldown;
|
||||
public bool IsAfk, AutoAfk;
|
||||
|
@ -130,7 +130,7 @@ namespace MCGalaxy
|
||||
}
|
||||
|
||||
/// <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) {
|
||||
List<Player> list = new List<Player>();
|
||||
foreach (Player pl in players) {
|
||||
|
@ -210,6 +210,7 @@ namespace MCGalaxy {
|
||||
OnConfigUpdatedEvent.Call();
|
||||
}
|
||||
|
||||
|
||||
static readonly object stopLock = new object();
|
||||
static volatile Thread stopThread;
|
||||
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
|
||||
// - see detailed comment in HACK_Execvp for why this is required
|
||||
if (HACK_TryExecvp()) HACK_Execvp();
|
||||
Process.Start(RestartPath);
|
||||
Process.Start(GetRestartPath());
|
||||
}
|
||||
Environment.Exit(0);
|
||||
}
|
||||
@ -312,7 +313,23 @@ namespace MCGalaxy {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
public static bool RunningOnMono() {
|
||||
if (!checkedOnMono) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user