From 2097da26da0ea0daab0b5c70c096e4487d5f5d2b Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 5 Aug 2017 13:00:15 +1000 Subject: [PATCH] Fix /afk list --- MCGalaxy/Commands/Chat/CmdAfk.cs | 2 +- MCGalaxy/Database/BlockDB/BlockDBFile.V1.cs | 6 +++++- MCGalaxy/Database/BlockDB/BlockDBFile.cs | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/MCGalaxy/Commands/Chat/CmdAfk.cs b/MCGalaxy/Commands/Chat/CmdAfk.cs index a450d4c36..5fb43e694 100644 --- a/MCGalaxy/Commands/Chat/CmdAfk.cs +++ b/MCGalaxy/Commands/Chat/CmdAfk.cs @@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Chatting { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!Entities.CanSee(p, pl) || !pl.IsAfk) continue; - Player.Message(p, p.name); + Player.Message(p, pl.ColoredName); } return; } diff --git a/MCGalaxy/Database/BlockDB/BlockDBFile.V1.cs b/MCGalaxy/Database/BlockDB/BlockDBFile.V1.cs index 875b5188e..9e4fb266d 100644 --- a/MCGalaxy/Database/BlockDB/BlockDBFile.V1.cs +++ b/MCGalaxy/Database/BlockDB/BlockDBFile.V1.cs @@ -22,7 +22,7 @@ using MCGalaxy.Maths; namespace MCGalaxy.DB { - public unsafe sealed class BlockDBFile_V1 : BlockDBFile { + public unsafe sealed class BlockDBFile_V1 : BlockDBFile { public override void WriteEntries(Stream s, FastList entries) { byte[] bulk = new byte[BulkEntries * EntrySize]; @@ -39,6 +39,10 @@ namespace MCGalaxy.DB { node = node.Next; } } + + public override long CountEntries(Stream s) { + return (s.Length / BlockDBFile.EntrySize) - BlockDBFile.HeaderEntries; + } static void WriteEntries(Stream s, byte[] bulk, BlockDBEntry[] entries, int count) { for (int i = 0; i < count; i += BulkEntries) { diff --git a/MCGalaxy/Database/BlockDB/BlockDBFile.cs b/MCGalaxy/Database/BlockDB/BlockDBFile.cs index fcdfec414..135ab066d 100644 --- a/MCGalaxy/Database/BlockDB/BlockDBFile.cs +++ b/MCGalaxy/Database/BlockDB/BlockDBFile.cs @@ -74,6 +74,8 @@ namespace MCGalaxy.DB { /// whether an entry before start time was reached. public abstract bool FindChangesBy(Stream s, int[] ids, int start, int end, Action output); + /// Returns number of entries in the backing file. + public abstract long CountEntries(Stream s); /// Deletes the backing file on disc if it exists. public static void DeleteBackingFile(string map) { @@ -95,8 +97,9 @@ namespace MCGalaxy.DB { string path = FilePath(map); if (!File.Exists(path)) return 0; - using (Stream src = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)) - return (src.Length / 16) - 1; + using (Stream src = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)) { + return V1.CountEntries(src); + } }