diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index 0c97a76..4c48386 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -32,9 +32,13 @@ "chat":{ "for_others":{ "global_format":"%USERNAME%: %MESSAGE%", - "mod_format":"%USERNAME%: %MESSAGE%", - "global_format_moderator":"%USERNAME%: %MESSAGE%", - "ads_format":"%USERNAME%: %MESSAGE%" + "global_format_moderator":"%USERNAME%: %MESSAGE%", + "mod_format":"%USERNAME%: %MESSAGE%", + "admin_format":"%USERNAME%: %MESSAGE%", + "ads_format":"%USERNAME%: %MESSAGE%", + "friend_format":"%USERNAME%: %MESSAGE%", + "dm_format":"%USERNAME%: %MESSAGE%", + "dm_format)moderator":"%USERNAME%[mod: %MESSAGE%" }, "for_sender":{ @@ -42,7 +46,7 @@ "isle_format":"%USERNAME%: %MESSAGE% [%AMOUNT% on isle]", "near_format":"%USERNAME%: %MESSAGE% [%AMOUNT% near]", "mod_format":"%USERNAME%: %MESSAGE% [%AMOUNT% mods]", - "admin_format":"%USERNAME%: %MESSAGE% [%AMOUNT% mods]", + "admin_format":"%USERNAME%: %MESSAGE% [%AMOUNT% admins]", "friend_format":"%USERNAME%: %MESSAGE% [%AMOUNT% buds]", "dm_format":"%FROMUSER%>%TOUSER%: %MESSAGE%" }, diff --git a/Horse Isle Server/Horse Isle Server/Chat.cs b/Horse Isle Server/Horse Isle Server/Chat.cs index 96d639b..5fe6f6d 100644 --- a/Horse Isle Server/Horse Isle Server/Chat.cs +++ b/Horse Isle Server/Horse Isle Server/Chat.cs @@ -32,8 +32,9 @@ namespace Horse_Isle_Server Near = 0x15, Buddies = 0x17, Isle = 0x24, - Mod, - Admin + Dm = 0x16, + Mod = 0x1c, + Admin = 0x1b } public static List FilteredWords = new List(); @@ -71,13 +72,13 @@ namespace Horse_Isle_Server { foreach (string word in wordsSaid) { - if (word == filter.FilteredWord) + if (word.ToLower() == filter.FilteredWord.ToLower()) return filter.Reason; } } else { - if (message.Contains(filter.FilteredWord)) + if (message.ToLower().Contains(filter.FilteredWord.ToLower())) return filter.Reason; } } @@ -93,10 +94,12 @@ namespace Horse_Isle_Server case ChatChannel.Ads: case ChatChannel.Isle: return PacketBuilder.CHAT_BOTTOM_LEFT; + case ChatChannel.Buddies: case ChatChannel.Admin: case ChatChannel.Mod: - case ChatChannel.Buddies: return PacketBuilder.CHAT_BOTTOM_RIGHT; + case ChatChannel.Dm: + return PacketBuilder.CHAT_BTMR_W_DM_SFX; default: Logger.ErrorPrint("unknown channel: " + (byte)channel); return PacketBuilder.CHAT_BOTTOM_LEFT; @@ -105,19 +108,162 @@ namespace Horse_Isle_Server } public static Client[] GetRecipiants(User user, ChatChannel channel) { - if(channel == ChatChannel.All) + if (channel == ChatChannel.All) { List recipiants = new List(); foreach (Client client in Server.ConnectedClients) + { if (client.LoggedIn) if (!client.LoggedinUser.MuteGlobal) - recipiants.Add(client); + if (client.LoggedinUser.Id != user.Id) + recipiants.Add(client); + } + return recipiants.ToArray(); + } + + if(channel == ChatChannel.Ads) + { + List recipiants = new List(); + foreach (Client client in Server.ConnectedClients) + { + if (client.LoggedIn) + if (!client.LoggedinUser.MuteAds) + if (client.LoggedinUser.Id != user.Id) + recipiants.Add(client); + } return recipiants.ToArray(); } + if(channel == ChatChannel.Buddies) + { + List recipiants = new List(); + foreach (Client client in Server.ConnectedClients) + { + if (client.LoggedIn) + if (!client.LoggedinUser.MuteBuddy) + if (client.LoggedinUser.Id != user.Id) + if (client.LoggedinUser.Friends.List.Contains(user.Id)) + recipiants.Add(client); + } + return recipiants.ToArray(); + } + + if (channel == ChatChannel.Mod) + { + if (!user.Moderator || !user.Administrator) // No mod chat for non-mods! + { + Logger.WarnPrint(user.Username + " attempted to send in MOD chat, without being a MOD."); + return new Client[0]; + } + + List recipiants = new List(); + foreach (Client client in Server.ConnectedClients) + { + if (client.LoggedIn) + if (client.LoggedinUser.Moderator) + if (client.LoggedinUser.Id != user.Id) + recipiants.Add(client); + } + return recipiants.ToArray(); + } + + if(channel == ChatChannel.Admin) + { + if (!user.Administrator) // No admin chat for non-admins! + { + Logger.WarnPrint(user.Username + " attempted to send in ADMIN chat, without being an ADMIN."); + return new Client[0]; + } + + + List recipiants = new List(); + foreach (Client client in Server.ConnectedClients) + { + if (client.LoggedIn) + if (client.LoggedinUser.Administrator) + if (client.LoggedinUser.Id != user.Id) + recipiants.Add(client); + } + return recipiants.ToArray(); + } + + Logger.ErrorPrint(user.Username + " Sent message in unknown channel: " + (byte)channel); return new Client[0]; // No recipiants } + + public static string DoCorrections(string message) + { + if (!ConfigReader.DoCorrections) + return message; + + foreach(Correction correct in CorrectedWords) + message = message.Replace(correct.FilteredWord, correct.ReplacedWord); + + return message; + } + public static string EscapeMessage(string message) + { + return message.Replace("<", "<"); + } + + public static string FormatChatForOthers(User user, ChatChannel channel, string message) + { + + switch (channel) + { + case ChatChannel.All: + if (user.Moderator || user.Administrator) + return Messages.FormatGlobalChatMessageForMod(user.Username, message); + else + return Messages.FormatGlobalChatMessage(user.Username, message); + case ChatChannel.Ads: + return Messages.FormatAdsChatMessage(user.Username, message); + case ChatChannel.Buddies: + return Messages.FormatBuddyChatMessage(user.Username, message); + case ChatChannel.Dm: + if (user.Moderator || user.Administrator) + return Messages.FormatDirectMessageForMod(user.Username, message); + else + return Messages.FormatDirectMessage(user.Username, message); + case ChatChannel.Mod: + if (user.Moderator || user.Administrator) + return Messages.FormatModChatMessage(user.Username, message); + else + return "Hacker!"; + case ChatChannel.Admin: + if (user.Administrator) + return Messages.FormatAdminChatMessage(user.Username, message); + else + return "Hacker!"; + default: + Logger.ErrorPrint(user.Username + " is trying to end a message in unknown channel " + channel.ToString("X")); + return "not implemented yet :("; + } + } + + public static string FormatChatForSender(User user, ChatChannel channel, string message) + { + switch (channel) + { + case ChatChannel.All: + if (user.Moderator || user.Administrator) + return Messages.FormatGlobalChatMessageForMod(user.Username, message); + else + return Messages.FormatGlobalChatMessage(user.Username, message); + case ChatChannel.Ads: + return Messages.FormatAdsChatMessage(user.Username, message); + case ChatChannel.Buddies: + return Messages.FormatBuddyChatMessageForSender(user.Friends.Count, user.Username, message); + case ChatChannel.Mod: + return Messages.FormatModChatForSender(Server.GetNumberOfModsOnline(), user.Username, message); + case ChatChannel.Admin: + return Messages.FormatAdminChatForSender(Server.GetNumberOfAdminsOnline(),user.Username, message); + default: + Logger.ErrorPrint(user.Username + " is trying to end a message in unknown channel " + channel.ToString("X")); + return "not implemented yet :("; + } + } public static Reason GetReason(string name) { foreach (Reason reason in Reasons) diff --git a/Horse Isle Server/Horse Isle Server/ConfigReader.cs b/Horse Isle Server/Horse Isle Server/ConfigReader.cs index 17ca0e0..3197888 100644 --- a/Horse Isle Server/Horse Isle Server/ConfigReader.cs +++ b/Horse Isle Server/Horse Isle Server/ConfigReader.cs @@ -23,7 +23,7 @@ namespace Horse_Isle_Server public static bool Debug; public static bool BadWords; - public static bool ExpandSlang; + public static bool DoCorrections; private static string ConfigurationFileName = "server.properties"; public static void OpenConfig() @@ -94,7 +94,7 @@ namespace Horse_Isle_Server BadWords = data == "true"; break; case "enable_word_filter": - ExpandSlang = data == "true"; + DoCorrections = data == "true"; break; case "debug": Debug = data == "true"; diff --git a/Horse Isle Server/Horse Isle Server/Database.cs b/Horse Isle Server/Horse Isle Server/Database.cs index 3edd2b0..cbe9db1 100644 --- a/Horse Isle Server/Horse Isle Server/Database.cs +++ b/Horse Isle Server/Horse Isle Server/Database.cs @@ -16,6 +16,7 @@ namespace Horse_Isle_Server string UserTable = "CREATE TABLE Users(Id INT, Username TEXT(16),Email TEXT(128),Country TEXT(128),SecurityQuestion Text(128),SecurityAnswerHash TEXT(128),Age INT,PassHash TEXT(128), Salt TEXT(128),Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))"; string ExtTable = "CREATE TABLE UserExt(Id INT, X INT, Y INT, Money INT, BankBalance BIGINT,ProfilePage Text(1028), CharId INT, ChatViolations INT)"; string MailTable = "CREATE TABLE Mailbox(IdTo INT, PlayerFrom TEXT(16),Subject TEXT(128), Message Text(1028), TimeSent INT)"; + string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending BOOL)"; string WorldTable = "CREATE TABLE World(TimeStarted INT, Weather TEXT(64))"; string DroppedTable = "CREATE TABLE DroppedItems(X INT, Y INT, ItemID INT)"; @@ -53,6 +54,18 @@ namespace Horse_Isle_Server Logger.WarnPrint(e.Message); }; + try + { + + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = BuddyTable; + sqlCommand.ExecuteNonQuery(); + } + catch (Exception e) + { + Logger.WarnPrint(e.Message); + }; + try { @@ -227,6 +240,82 @@ namespace Horse_Isle_Server } } + public static int GetBuddyCount(int id) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "SELECT COUNT(1) FROM BuddyList WHERE Id=@id OR IdFriend=@id AND Pending=false"; + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Prepare(); + + Int32 count = Convert.ToInt32(sqlCommand.ExecuteScalar()); + return count; + } + + public static int[] GetBuddyList(int id) + { + if (GetBuddyCount(id) <= 0) + return new int[0]; // user is forever alone. + + List buddyList = new List(); + + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "SELECT Id,IdFriend FROM BuddyList WHERE Id=@id OR IdFriend=@id AND Pending=false"; + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Prepare(); + MySqlDataReader dataReader = sqlCommand.ExecuteReader(); + + while(dataReader.Read()) + { + int adder = dataReader.GetInt32(0); + int friend = dataReader.GetInt32(1); + if (adder != id) + buddyList.Add(adder); + else if (friend != id) + buddyList.Add(adder); + } + + return buddyList.ToArray(); + } + + public static bool IsPendingBuddyRequestExist(int id, int friendId) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "SELECT COUNT(1) FROM BuddyList WHERE (Id=@id AND IdFriend=@friendId) OR (Id=@friendid AND IdFriend=@Id) AND Pending=true"; + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Parameters.AddWithValue("@friendId", friendId); + sqlCommand.Prepare(); + + Int32 count = Convert.ToInt32(sqlCommand.ExecuteScalar()); + return count >= 1; + } + + public static void RemoveBuddy(int id, int friendId) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "DELETE FROM BuddyList WHERE (Id=@id AND IdFriend=@friendId) OR (Id=@friendid AND IdFriend=@Id)"; + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Parameters.AddWithValue("@friendId", friendId); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + } + public static void AcceptBuddyRequest(int id, int friendId) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "UPDATE BuddyList SET Pending=false WHERE (Id=@id AND IdFriend=@friendId) OR (Id=@friendid AND IdFriend=@Id)"; + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Parameters.AddWithValue("@friendId", friendId); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + } + public static void AddPendingBuddyRequest(int id, int friendId) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "INSERT INTO BuddyList VALUES(@id,@friendId,true)"; + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Parameters.AddWithValue("@friendId", friendId); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + } public static void CreateUserExt(int id) { if (CheckUserExtExists(id)) // user allready exists! diff --git a/Horse Isle Server/Horse Isle Server/Friends.cs b/Horse Isle Server/Horse Isle Server/Friends.cs new file mode 100644 index 0000000..fe39f09 --- /dev/null +++ b/Horse Isle Server/Horse Isle Server/Friends.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Horse_Isle_Server +{ + class Friends + { + private User baseUser; + public List List; + + public int Count + { + get + { + return List.Count; + } + } + + public Friends(User user) + { + baseUser = user; + List = new List(); + + int[] friends = Database.GetBuddyList(user.Id); + foreach(int friendId in friends) + { + List.Add(friendId); + } + + } + public void AddFriend(User userToFriend) + { + bool pendingRequest = Database.IsPendingBuddyRequestExist(baseUser.Id, userToFriend.Id); + if (pendingRequest) + { + Database.AcceptBuddyRequest(baseUser.Id, userToFriend.Id); + List.Add(userToFriend.Id); + } + else + { + Database.AddPendingBuddyRequest(baseUser.Id, userToFriend.Id); + } + } + + } +} diff --git a/Horse Isle Server/Horse Isle Server/Gamedata.cs b/Horse Isle Server/Horse Isle Server/Gamedata.cs index 87434bf..32cd91f 100644 --- a/Horse Isle Server/Horse Isle Server/Gamedata.cs +++ b/Horse Isle Server/Horse Isle Server/Gamedata.cs @@ -126,15 +126,23 @@ namespace Horse_Isle_Server Messages.ChatViolationMessageFormat = gameData.messages.chat.violation_format; Messages.RequiredChatViolations = gameData.messages.chat.violation_points_required; - Messages.GlobalChatFormat = gameData.messages.chat.for_others.global_format; Messages.GlobalChatFormatForModerators = gameData.messages.chat.for_others.global_format_moderator; + Messages.DirectChatFormatForModerators = gameData.messages.chat.for_others.dm_format_moderator; + + Messages.GlobalChatFormat = gameData.messages.chat.for_others.global_format; Messages.AdsChatFormat = gameData.messages.chat.for_others.ads_format; + Messages.DirectChatFormat = gameData.messages.chat.for_others.dm_format; + Messages.BuddyChatFormat = gameData.messages.chat.for_others.friend_format; + Messages.ModChatFormat = gameData.messages.chat.for_others.mod_format; + Messages.AdminChatFormat = gameData.messages.chat.for_others.admin_format; Messages.HereChatFormatForSender = gameData.messages.chat.for_sender.here_format; Messages.IsleChatFormatForSender = gameData.messages.chat.for_sender.isle_format; Messages.NearChatFormatForSender = gameData.messages.chat.for_sender.near_format; Messages.BuddyChatFormatForSender = gameData.messages.chat.for_sender.friend_format; Messages.DirectChatFormatForSender = gameData.messages.chat.for_sender.dm_format; + Messages.ModChatFormatForSender = gameData.messages.chat.for_sender.mod_format; + Messages.AdminChatFormatForSender = gameData.messages.chat.for_sender.admin_format; // Meta Format diff --git a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj index 2ec82ea..429e5b1 100644 --- a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj +++ b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj @@ -75,6 +75,7 @@ + diff --git a/Horse Isle Server/Horse Isle Server/Messages.cs b/Horse Isle Server/Horse Isle Server/Messages.cs index 89174a3..b1e49ad 100644 --- a/Horse Isle Server/Horse Isle Server/Messages.cs +++ b/Horse Isle Server/Horse Isle Server/Messages.cs @@ -20,14 +20,21 @@ namespace Horse_Isle_Server // Chat public static string GlobalChatFormat; public static string AdsChatFormat; + public static string BuddyChatFormat; + public static string DirectChatFormat; + public static string ModChatFormat; + public static string AdminChatFormat; public static string GlobalChatFormatForModerators; + public static string DirectChatFormatForModerators; public static string HereChatFormatForSender; public static string IsleChatFormatForSender; public static string NearChatFormatForSender; public static string BuddyChatFormatForSender; public static string DirectChatFormatForSender; + public static string AdminChatFormatForSender; + public static string ModChatFormatForSender; public static string ChatViolationMessageFormat; public static int RequiredChatViolations; @@ -46,14 +53,75 @@ namespace Horse_Isle_Server { return ChatViolationMessageFormat.Replace("%AMOUNT%", RequiredChatViolations.ToString()).Replace("%REASON%", violationReason.Message); } - public static string FormatGlobalChatMessage(User sender, string message) - { - if (sender.Moderator) - return GlobalChatFormatForModerators.Replace("%USERNAME%", sender.Username).Replace("%MESSAGE%", message); - else - return GlobalChatFormat.Replace("%USERNAME%", sender.Username).Replace("%MESSAGE%", message); + // For all + public static string FormatGlobalChatMessage(string username, string message) + { + return GlobalChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); } + + public static string FormatBuddyChatMessage(string username, string message) + { + return BuddyChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + + public static string FormatDirectMessage(string username, string message) + { + return DirectChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + public static string FormatDirectMessageForMod(string username, string message) + { + return DirectChatFormatForModerators.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + + public static string FormatGlobalChatMessageForMod(string username, string message) + { + return GlobalChatFormatForModerators.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + + public static string FormatAdsChatMessage(string username, string message) + { + return AdsChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + + public static string FormatModChatMessage(string username, string message) + { + return ModChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + + public static string FormatAdminChatMessage(string username, string message) + { + return AdminChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message); + } + + + // For Sender + public static string FormatBuddyChatMessageForSender(int numbBuddies, string username, string message) + { + return BuddyChatFormatForSender.Replace("%USERNAME%", username).Replace("%MESSAGE%", message).Replace("%AMOUNT%", numbBuddies.ToString()); + } + + public static string FormatAdminChatForSender(int numbAdmins, string username, string message) + { + return AdminChatFormatForSender.Replace("%USERNAME%", username).Replace("%MESSAGE%", message).Replace("%AMOUNT%", numbAdmins.ToString()); + } + + public static string FormatModChatForSender(int numbMods, string username, string message) + { + return ModChatFormatForSender.Replace("%USERNAME%", username).Replace("%MESSAGE%", message).Replace("%AMOUNT%", numbMods.ToString()); + } + public static string FormatDirectChatMessageForSender(string username,string toUsername, string message) + { + return DirectChatFormatForSender.Replace("%FROMUSER%", username).Replace("%TOUSER%", toUsername).Replace(" %MESSAGE%", message); + } + + + + + + + + public static string FormatMOTD() { return MotdFormat.Replace("%MOTD%", ConfigReader.Motd); diff --git a/Horse Isle Server/Horse Isle Server/PacketBuilder.cs b/Horse Isle Server/Horse Isle Server/PacketBuilder.cs index 0bae708..41d2fb8 100644 --- a/Horse Isle Server/Horse Isle Server/PacketBuilder.cs +++ b/Horse Isle Server/Horse Isle Server/PacketBuilder.cs @@ -40,7 +40,7 @@ namespace Horse_Isle_Server public const byte CHAT_BOTTOM_LEFT = 0x14; public const byte CHAT_BOTTOM_RIGHT = 0x15; - + public const byte CHAT_BTMR_W_DM_SFX = 0x16; public const byte LOGIN_INVALID_USER_PASS = 0x15; public const byte LOGIN_SUCCESS = 0x14; diff --git a/Horse Isle Server/Horse Isle Server/Server.cs b/Horse Isle Server/Horse Isle Server/Server.cs index 34bc117..b0ae606 100644 --- a/Horse Isle Server/Horse Isle Server/Server.cs +++ b/Horse Isle Server/Horse Isle Server/Server.cs @@ -49,8 +49,7 @@ namespace Horse_Isle_Server sender.SendPacket(WorldData); byte[] SecCodePacket = PacketBuilder.CreateSecCode(user.SecCodeSeeds, user.SecCodeInc, user.Administrator, user.Moderator); - Logger.DebugPrint("SecCode: [5] == "+SecCodePacket[5]+" dump: " + BitConverter.ToString(SecCodePacket).Replace('-', ' ')); - sender.SendPacket(new byte[] { 0x81, 0x7C, 0x70, 0x73, 0x26, 0x41, 0x00 }); + sender.SendPacket(SecCodePacket); byte[] BaseStatsPacketData = PacketBuilder.CreateBaseStats(user.Money, Server.GetNumberOfPlayers(), user.MailBox.MailCount); sender.SendPacket(BaseStatsPacketData); @@ -244,15 +243,20 @@ namespace Horse_Isle_Server Client[] recipiants = Chat.GetRecipiants(sender.LoggedinUser, channel); byte chatSide = Chat.GetSide(channel); - - string formattedMessage = Messages.FormatGlobalChatMessage(sender.LoggedinUser, message); - byte[] chatPacket = PacketBuilder.CreateChat(formattedMessage, chatSide); - + message = Chat.DoCorrections(message); + message = Chat.EscapeMessage(message); + string formattedMessage = Chat.FormatChatForOthers(sender.LoggedinUser,channel,message); + string formattedMessageSender = Chat.FormatChatForSender(sender.LoggedinUser, channel, message); + byte[] chatPacketOthers = PacketBuilder.CreateChat(formattedMessage, chatSide); + byte[] chatPacketSender = PacketBuilder.CreateChat(formattedMessageSender, chatSide); // Send to clients ... foreach (Client recipiant in recipiants) { - recipiant.SendPacket(chatPacket); + recipiant.SendPacket(chatPacketOthers); } + + // Send to sender + sender.SendPacket(chatPacketSender); } public static void OnLoginRequest(Client sender, byte[] packet) { @@ -320,6 +324,31 @@ namespace Horse_Isle_Server } return count; } + + public static int GetNumberOfModsOnline() + { + int count = 0; + foreach (Client client in ConnectedClients) + { + if (client.LoggedIn) + if(client.LoggedinUser.Moderator) + count++; + } + return count; + } + + public static int GetNumberOfAdminsOnline() + { + int count = 0; + foreach (Client client in ConnectedClients) + { + if (client.LoggedIn) + if (client.LoggedinUser.Administrator) + count++; + } + return count; + } + public static void StartServer() { ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); diff --git a/Horse Isle Server/Horse Isle Server/User.cs b/Horse Isle Server/Horse Isle Server/User.cs index 39720eb..05ba372 100644 --- a/Horse Isle Server/Horse Isle Server/User.cs +++ b/Horse Isle Server/Horse Isle Server/User.cs @@ -17,13 +17,13 @@ namespace Horse_Isle_Server public bool MuteNear = false; public bool MuteHere = false; public bool MuteBuddy = false; - public bool MutePM = false; - public bool MuteBR = false; + public bool MutePrivateMessage = false; + public bool MuteBuddyRequests = false; public bool MuteSocials = false; public bool MuteLogins = false; public Mailbox MailBox; - + public Friends Friends; public int ChatViolations { get @@ -181,6 +181,9 @@ namespace Horse_Isle_Server SecCodeSeeds[2] = (byte)rng.Next(40, 140); SecCodeInc = (byte)rng.Next(0, 99); + // Make some friends! (Get a life!) + + Friends = new Friends(this); } } }