From a116a27f0ad409752ab5db7ecdba3670076ad8ea Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Mon, 8 Mar 2021 14:58:06 +1300 Subject: [PATCH] Add tag and fix socials crashing --- DataCollection/gamedata.json | 20 +++++-- .../HorseIsleServer/Game/Messages.cs | 12 +++++ .../HorseIsleServer/Server/GameDataJson.cs | 4 ++ .../HorseIsleServer/Server/GameServer.cs | 54 +++++++++++++++++-- .../HorseIsleServer/Server/PacketBuilder.cs | 1 + 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index bd97d92..0b5bfb1 100755 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -225,6 +225,10 @@ "buddy_button":"^B1B%PLAYERID%", "tag_button":"^B1X%PLAYERID%", "pm_button":"^B1P%PLAYERNAME%", + "tag":{ + "tag_player":"TAG!! %PLAYERNAME% is now it! (tagged by %USERNAME%)", + "total_buddies":" [%TOTALBUDDIESON% buds]", + }, "add_buddy":{ "add_pending":"Attempting to Add Buddy. The other player must click ADD BUDDY as well. (Many players reserve this for just a couple players so don't feel insulted if they do not).", "other_pending":"%PLAYERNAME% is trying to add you as a buddy, click ADD BUDDY to make them a buddy.", @@ -1102,6 +1106,8 @@ {"word":"stfu","reason_type":"profanity","match_all":false}, {"word":"nigga","reason_type":"profanity","match_all":true}, {"word":"homo","reason_type":"profanity","match_all":false}, + {"word":"hetero","reason_type":"profanity","match_all":false}, + {"word":"heterosexual","reason_type":"profanity","match_all":true}, {"word":"homosexual","reason_type":"profanity","match_all":true}, {"word":"sexual","reason_type":"profanity","match_all":false}, {"word":"penis","reason_type":"profanity","match_all":true}, @@ -1118,12 +1124,14 @@ {"word":"whats your age","reason_type":"personal_info","match_all":true}, {"word":"your phone","reason_type":"personal_info","match_all":true}, {"word":"my phone","reason_type":"personal_info","match_all":true}, + {"word":"your address","reason_type":"personal_info","match_all":true}, + {"word":"my phone","reason_type":"personal_info","match_all":true}, {"word":"phone number","reason_type":"personal_info","match_all":true}, {"word":"home address","reason_type":"personal_info","match_all":true}, - {"word":"https","reason_type":"personal_info","match_all":true}, - {"word":"//","reason_type":"personal_info","match_all":true}, {"word":".com","reason_type":"personal_info","match_all":true}, {"word":".net","reason_type":"personal_info","match_all":true}, + {"word":".org","reason_type":"personal_info","match_all":true}, + {"word":"www.","reason_type":"personal_info","match_all":false}, {"word":"http","reason_type":"personal_info","match_all":true}, {"word":"40lb","reason_type":"personal_info","match_all":true} ], @@ -1134,10 +1142,15 @@ {"word":"rofl","new_word":"*rolling on floor laughing*"}, {"word":"ppp","new_word":"*petting a pretty pony*"}, {"word":"wtf","new_word":"what the horse poo!"}, + {"word":"wtg","new_word":"!!- Way To Go -!!"}, {"word":"ty","new_word":"thank you"}, {"word":"asl","new_word":"how are you"}, {"word":"omg","new_word":"oh my gosh"}, {"word":"god","new_word":"unicorns"}, + {"word":"devil","new_word":"unicorns"}, + {"word":"satan","new_word":"unicorns"}, + {"word":"jesus","new_word":"unicorns"}, + {"word":"allah","new_word":"unicorns"}, {"word":"hell","new_word":"heck"}, {"word":"sex","new_word":"gender"}, {"word":"sexy","new_word":"cute"}, @@ -1145,7 +1158,8 @@ {"word":"gay","new_word":"happy"}, {"word":"boob","new_word":"dork"}, {"word":"damn","new_word":"dang"}, - {"word":"suck","new_word":"ingurgitate"} + {"word":"suck","new_word":"ingurgitate"}, + ], "reason_messages":[ {"name":"profanity","message":"Profanity detected."}, diff --git a/Horse Isle Server/HorseIsleServer/Game/Messages.cs b/Horse Isle Server/HorseIsleServer/Game/Messages.cs index 322304f..2f96cef 100755 --- a/Horse Isle Server/HorseIsleServer/Game/Messages.cs +++ b/Horse Isle Server/HorseIsleServer/Game/Messages.cs @@ -18,6 +18,10 @@ namespace HISP.Game public static string AddBuddyOtherPendingFormat; public static string AddBuddyYourNowBuddiesFormat; + // Tag + public static string TagYourItFormat; + public static string TagOtherBuddiesOnlineFormat; + // Socials public static string SocialButton; public static string SocialMessageFormat; @@ -1025,6 +1029,14 @@ namespace HISP.Game // Click public static string NothingInterestingHere; + public static string FormatTagTotalBuddies(int count) + { + return TagOtherBuddiesOnlineFormat.Replace("%TOTALBUDDIESON%", count.ToString("N0", CultureInfo.InvariantCulture)); + } + public static string FormatTagYourIt(string taggedPlayer, string tagger) + { + return TagYourItFormat.Replace("%PLAYERNAME%", taggedPlayer).Replace("%USERNAME%", tagger); + } public static string FormatAddBuddyConfirmed(string playername) { return AddBuddyYourNowBuddiesFormat.Replace("%PLAYERNAME%", playername); diff --git a/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs b/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs index 075f236..ba50e43 100755 --- a/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs +++ b/Horse Isle Server/HorseIsleServer/Server/GameDataJson.cs @@ -834,6 +834,7 @@ namespace HISP.Server Map.NewUserStartX = gameData.messages.new_user.starting_x; Map.NewUserStartY = gameData.messages.new_user.starting_y; + // Warp Command Messages.SuccessfullyWarpedToPlayer = gameData.messages.commands.warp.player; @@ -847,6 +848,9 @@ namespace HISP.Server Map.ModIsleX = gameData.messages.commands.mod_isle.x; Map.ModIsleY = gameData.messages.commands.mod_isle.y; + // Tag + Messages.TagYourItFormat = gameData.messages.meta.player_interaction.tag.tag_player; + Messages.TagOtherBuddiesOnlineFormat = gameData.messages.meta.player_interaction.tag.total_buddies; // Add Buddy Messages.AddBuddyPending = gameData.messages.meta.player_interaction.add_buddy.add_pending; diff --git a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs index 52ee320..b53bf26 100755 --- a/Horse Isle Server/HorseIsleServer/Server/GameServer.cs +++ b/Horse Isle Server/HorseIsleServer/Server/GameServer.cs @@ -263,6 +263,45 @@ namespace HISP.Server sender.SendPacket(metaTag); } break; + case PacketBuilder.PLAYER_INTERACTION_TAG: + packetStr = Encoding.UTF8.GetString(packet); + playerIdStr = packetStr.Substring(2, packetStr.Length - 4); + playerId = -1; + try + { + playerId = int.Parse(playerIdStr); + } + catch (FormatException) + { + Logger.ErrorPrint(sender.LoggedinUser.Username + " tried to trade with User ID NaN."); + break; + } + + if (IsUserOnline(playerId)) + { + User user = GetUserById(playerId);; + string TAGYourIT = Messages.FormatTagYourIt(user.Username, sender.LoggedinUser.Username); + int totalBuds = 0; + foreach(int friendId in sender.LoggedinUser.Friends.List) + { + if (friendId == sender.LoggedinUser.Id) + continue; + + if(IsUserOnline(friendId)) + { + User buddy = GetUserById(friendId); + byte[] tagYourItPacket = PacketBuilder.CreateChat(TAGYourIT, PacketBuilder.CHAT_BOTTOM_RIGHT); + buddy.LoggedinClient.SendPacket(tagYourItPacket); + totalBuds++; + } + } + string budStr = Messages.FormatTagTotalBuddies(totalBuds); + + byte[] tagYouItPacket = PacketBuilder.CreateChat(TAGYourIT + budStr, PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(tagYouItPacket); + + } + break; case PacketBuilder.PLAYER_INTERACTION_ADD_BUDDY: packetStr = Encoding.UTF8.GetString(packet); playerIdStr = packetStr.Substring(2, packetStr.Length - 4); @@ -454,8 +493,11 @@ namespace HISP.Server if (user.MuteAll || user.MuteSocials) continue; + string socialTarget = ""; + if(sender.LoggedinUser.SocializingWith != null) + socialTarget = sender.LoggedinUser.SocializingWith.Username; - byte[] msgEveryone = PacketBuilder.CreateChat(Messages.FormatSocialMessage(social.ForEveryone, sender.LoggedinUser.SocializingWith.Username, sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); + byte[] msgEveryone = PacketBuilder.CreateChat(Messages.FormatSocialMessage(social.ForEveryone, socialTarget, sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); user.LoggedinClient.SendPacket(msgEveryone); } if(social.ForTarget != null) @@ -474,12 +516,14 @@ namespace HISP.Server } if(social.ForSender != null) { + string socialTarget = ""; if (sender.LoggedinUser.SocializingWith != null) - { - byte[] msgSender = PacketBuilder.CreateChat(Messages.FormatSocialMessage(social.ForSender, sender.LoggedinUser.SocializingWith.Username, sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); - sender.SendPacket(msgSender); + socialTarget = sender.LoggedinUser.SocializingWith.Username; - } + byte[] msgSender = PacketBuilder.CreateChat(Messages.FormatSocialMessage(social.ForSender, socialTarget, sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); + sender.SendPacket(msgSender); + + } foreach(User user in GetUsersAt(sender.LoggedinUser.X, sender.LoggedinUser.Y, true, true)) diff --git a/Horse Isle Server/HorseIsleServer/Server/PacketBuilder.cs b/Horse Isle Server/HorseIsleServer/Server/PacketBuilder.cs index 0fa636a..4deec89 100755 --- a/Horse Isle Server/HorseIsleServer/Server/PacketBuilder.cs +++ b/Horse Isle Server/HorseIsleServer/Server/PacketBuilder.cs @@ -57,6 +57,7 @@ namespace HISP.Server public const byte SOCIALS_USE = 0x15; public const byte PLAYER_INTERACTION_PROFILE = 0x14; + public const byte PLAYER_INTERACTION_TAG = 0x23; public const byte PLAYER_INTERACTION_TRADE = 0x28; public const byte PLAYER_INTERACTION_ADD_ITEM = 0x29; public const byte PLAYER_INTERACTION_ACCEPT = 0x2A;