Skip to content

Commit

Permalink
Always show client name in 'player X connected' message, even for cli…
Browse files Browse the repository at this point in the history
…ents that aren't CPE

e.g. classic mode shows a client name of 'Classic 0.28-0.30'
  • Loading branch information
UnknownShadow200 committed Feb 3, 2023
1 parent 781f463 commit 0e3cc6d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions MCGalaxy/Network/ClassicProtocol.cs
Expand Up @@ -208,7 +208,7 @@ public class ClassicProtocol : IGameSession
const int size = 1 + 64 + 2;
if (left < size) return 0;

player.appName = NetUtils.ReadString(buffer, offset + 1);
appName = NetUtils.ReadString(buffer, offset + 1);
extensionCount = buffer[offset + 66];
CheckReadAllExtensions(); // in case client supports 0 CPE packets
return size;
Expand Down Expand Up @@ -636,7 +636,7 @@ public class ClassicProtocol : IGameSession
}

public override string ClientName() {
if (!string.IsNullOrEmpty(player.appName)) return player.appName;
if (!string.IsNullOrEmpty(appName)) return appName;
byte version = ProtocolVersion;

if (version == Server.VERSION_0016) return "Classic 0.0.16";
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Network/IGameSession.cs
Expand Up @@ -29,6 +29,7 @@ public abstract class IGameSession : INetProtocol
public byte[] fallback = new byte[256]; // fallback for classic+CPE block IDs
public BlockID MaxRawBlock = Block.CLASSIC_MAX_BLOCK;
public bool hasCpe;
public string appName;

// these are checked very frequently, so avoid overhead of .Supports(
public bool hasCustomBlocks, hasExtBlocks, hasBlockDefs, hasBulkBlockUpdate;
Expand Down
1 change: 0 additions & 1 deletion MCGalaxy/Network/Player.Networking.cs
Expand Up @@ -22,7 +22,6 @@ namespace MCGalaxy
{
public partial class Player : IDisposable
{
public string appName;
// these are checked very frequently, so avoid overhead of .Supports(
public bool hasChangeModel, hasExtList, hasCP437;

Expand Down
7 changes: 1 addition & 6 deletions MCGalaxy/Player/Player.Login.cs
Expand Up @@ -138,12 +138,7 @@ public partial class Player : IDisposable
if (Server.Config.PositionUpdateInterval > 1000)
Message("Lowlag mode is currently &aON.");

if (String.IsNullOrEmpty(appName)) {
Logger.Log(LogType.UserActivity, "{0} [{1}] connected.", truename, IP);
} else {
Logger.Log(LogType.UserActivity, "{0} [{1}] connected using {2}.", truename, IP, appName);
}

Logger.Log(LogType.UserActivity, "{0} [{1}] connected using {2}.", truename, IP, Session.ClientName());
PlayerActions.PostSentMap(this, null, level, false);
Loading = false;
}
Expand Down

0 comments on commit 0e3cc6d

Please sign in to comment.