From 9eefcc6b6d3cbbda6695552dfc88f68106fb9087 Mon Sep 17 00:00:00 2001 From: Bluzume <39113159+KuromeSan@users.noreply.github.com> Date: Sat, 27 Nov 2021 15:44:28 -0500 Subject: [PATCH] Fix Pinto Bugs? --- .../Game/Inventory/PlayerInventory.cs | 2 +- .../HorseIsleServer/Game/Items/Item.cs | 3 + HorseIsleServer/HorseIsleServer/Game/Meta.cs | 16 ++++- .../HorseIsleServer/Player/Trade.cs | 4 +- .../Resources/server.properties | 59 +++++++++++++------ .../HorseIsleServer/Server/ConfigReader.cs | 37 ++++++------ .../HorseIsleServer/Server/GameClient.cs | 13 ++++ .../HorseIsleServer/Server/GameServer.cs | 21 ++++--- 8 files changed, 105 insertions(+), 50 deletions(-) diff --git a/HorseIsleServer/HorseIsleServer/Game/Inventory/PlayerInventory.cs b/HorseIsleServer/HorseIsleServer/Game/Inventory/PlayerInventory.cs index d333517..2bde518 100644 --- a/HorseIsleServer/HorseIsleServer/Game/Inventory/PlayerInventory.cs +++ b/HorseIsleServer/HorseIsleServer/Game/Inventory/PlayerInventory.cs @@ -162,7 +162,7 @@ namespace HISP.Game.Inventory if(HasItemId(item.ItemId)) { InventoryItem items = GetItemByItemId(item.ItemId); - if (items.ItemInstances.Length >= ConfigReader.MAX_STACK) + if (items.ItemInstances.Length >= Item.MAX_STACK) { throw new InventoryMaxStackException(); } diff --git a/HorseIsleServer/HorseIsleServer/Game/Items/Item.cs b/HorseIsleServer/HorseIsleServer/Game/Items/Item.cs index b59a333..771c2e6 100644 --- a/HorseIsleServer/HorseIsleServer/Game/Items/Item.cs +++ b/HorseIsleServer/HorseIsleServer/Game/Items/Item.cs @@ -8,6 +8,9 @@ namespace HISP.Game.Items { public class Item { + + public const int MAX_STACK = 50; + public struct Effects { public string EffectsWhat; diff --git a/HorseIsleServer/HorseIsleServer/Game/Meta.cs b/HorseIsleServer/HorseIsleServer/Game/Meta.cs index e1b0d47..bfb7524 100644 --- a/HorseIsleServer/HorseIsleServer/Game/Meta.cs +++ b/HorseIsleServer/HorseIsleServer/Game/Meta.cs @@ -2701,8 +2701,20 @@ namespace HISP.Game statCalculator = speedStat; break; } - - if(statCalculator.BreedValue < statCalculator.MaxValue) + + bool allowed = false; + + /* + * Pinto bug: If you try to train a horse, but doing so would go over the maximum amount + * Then it just says its maxed trained, and u have to use a ranch. + */ + + if (ConfigReader.FixOfficalBugs) + allowed = (statCalculator.BreedValue < statCalculator.MaxValue); + else + allowed = (statCalculator.BreedValue + statCalculator.BreedOffset < statCalculator.MaxValue); + + if(allowed) message += Messages.FormatTrainerTrainInEntry(horse.Name, statCalculator.BreedValue, statCalculator.MaxValue, horse.RandomId); else message += Messages.FormatTrainerFullyTrained(horse.Name, statCalculator.BreedValue); diff --git a/HorseIsleServer/HorseIsleServer/Player/Trade.cs b/HorseIsleServer/HorseIsleServer/Player/Trade.cs index e1dbad4..ec6790e 100644 --- a/HorseIsleServer/HorseIsleServer/Player/Trade.cs +++ b/HorseIsleServer/HorseIsleServer/Player/Trade.cs @@ -168,7 +168,7 @@ namespace HISP.Player if (Trader.Inventory.HasItemId(inst[0].ItemId)) { InventoryItem items = Trader.Inventory.GetItemByItemId(inst[0].ItemId); - if (items.ItemInstances.Length + inst.Length > ConfigReader.MAX_STACK) + if (items.ItemInstances.Length + inst.Length > Item.MAX_STACK) { byte[] tradeTooManyItems = PacketBuilder.CreateChat(Messages.TradeYouCantCarryMoreItems, PacketBuilder.CHAT_BOTTOM_RIGHT); Trader.LoggedinClient.SendPacket(tradeTooManyItems); @@ -186,7 +186,7 @@ namespace HISP.Player if (OtherTrade.Trader.Inventory.HasItemId(inst[0].ItemId)) { InventoryItem items = OtherTrade.Trader.Inventory.GetItemByItemId(inst[0].ItemId); - if (items.ItemInstances.Length + inst.Length > ConfigReader.MAX_STACK) + if (items.ItemInstances.Length + inst.Length > Item.MAX_STACK) { byte[] tradeTooManyItems = PacketBuilder.CreateChat(Messages.TradeOtherCantCarryMoreItems, PacketBuilder.CHAT_BOTTOM_RIGHT); Trader.LoggedinClient.SendPacket(tradeTooManyItems); diff --git a/HorseIsleServer/HorseIsleServer/Resources/server.properties b/HorseIsleServer/HorseIsleServer/Resources/server.properties index 9e8b286..74dbb70 100644 --- a/HorseIsleServer/HorseIsleServer/Resources/server.properties +++ b/HorseIsleServer/HorseIsleServer/Resources/server.properties @@ -1,30 +1,43 @@ -# HISP Default Configuration File +# ======================= +# Server Configuration +# ======================= # Ip address the server will bind to (default: 0.0.0.0 ALL INTERFACES) ip=0.0.0.0 -# Port the server will bind to (default: 12321) + +# Port the server will bind to defaults: (on beta.horseisle.com: 12321, on pinto.horseisle.com: 443) +# Though, 443 is likely to interfere with TLS, if you happen to have a web server or something +# running on the same port, so i prefer 12321. port=12321 -# MariaDB Database +# MariaDB Database Information +# For best performance, the database should be hosted on the SAME MACHINE as the HISP server. +# Or atleast, on a local network. db_ip=127.0.0.1 -db_name=beta +db_name=game1 db_username=root db_password=test123 db_port=3306 -# Map Data +# File that contains the map tile data +# the default was downloaded from the original server map=HI1.MAP -# JSON Format Data +# This file contains all definitions in the game +# such as items, horses. and quest data. gamedata=gamedata.json -# Cross-Domain Policy File +# ======================= +# Security +# ======================= + +# Adobe Flash; Cross-Domain Policy File. (see: https://help.adobe.com/en_US/air/html/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7c60.html) +# The default file, just allows all domains access to all ports. crossdomain=CrossDomainPolicy.xml -# Red Text Stating "Todays Note:" -motd=April 11, 2020. New breed, Camarillo White Horse. Two new quests. - -# Chat Filter Settings +# ======================= +# Chat Filter Settings +# ======================= # Wether to block 'bad' words # ex 'Fuck You!' gets blocked @@ -40,24 +53,32 @@ enable_corrections=true # and FULL CAPS messages. non_violation=true -# Should the server consider all users "Subscribers" -# (warning might make ranches be in use forever.) -all_users_subscribed=false - # Limits ad and global chat # to just a few messages every minute # by each user enable_spam_filter=true +# ======================= +# Misc Settings. +# ======================= + +# Should the server consider all users "Subscribers" +# (warning: makes ranches be in use forever.) +all_users_subscribed=false + +# Red Text Stating "Todays Note:" +# Default is "April 11, 2020. New breed, Camarillo White Horse. Two new quests." +motd=April 11, 2020. New breed, Camarillo White Horse. Two new quests. + # Equation is: BANK_BALANCE * (1/INTREST_RATE); # on All servers except Black its 3333, on black its 1000. # but of course you can make it whatever you want intrest_rate=3333 -# Allows all users to use BBCODE in chat -# BBCode is the [b] [blue] etc colors -# If false, this only works for admins and moderators. -allow_bbcode_in_chat=false +# Should i fix bugs all the bugs +# That were in the original Horse Isle Game?? +# (eg training, special treat, ranch descriptions, etc) +fix_offical_bugs=false # Should print extra debug logs # 0 - no logs diff --git a/HorseIsleServer/HorseIsleServer/Server/ConfigReader.cs b/HorseIsleServer/HorseIsleServer/Server/ConfigReader.cs index 0eeb4c6..61f34c6 100644 --- a/HorseIsleServer/HorseIsleServer/Server/ConfigReader.cs +++ b/HorseIsleServer/HorseIsleServer/Server/ConfigReader.cs @@ -6,38 +6,37 @@ namespace HISP.Server public class ConfigReader { - public static int Port; + public static int Port = 12321; public static string BindIP = "0.0.0.0"; - public static string DatabaseIP; - public static string DatabaseUsername; - public static string DatabaseName; - public static string DatabasePassword; - public static int DatabasePort; - public static int IntrestRate; - public static string Motd; - public static string MapFile; - public static string GameDataFile; - public static string CrossDomainPolicyFile; + public static string DatabaseIP = "127.0.0.1"; + public static string DatabaseName = "game1"; + public static string DatabaseUsername = "root"; + public static string DatabasePassword = "test123"; - public static int LogLevel = 0; + public static int DatabasePort = 3306; + public static int IntrestRate = 3333; + public static string Motd = "April 11, 2020. New breed, Camarillo White Horse. Two new quests."; + public static string MapFile = "HI1.MAP"; + public static string GameDataFile = "gamedata.json"; + public static string CrossDomainPolicyFile = "CrossDomainPolicy.xml"; + + public static int LogLevel = 4; public static bool EnableSpamFilter = true; public static bool AllUsersSubbed = false; - public static bool AllowBbcode = false; + public static bool FixOfficalBugs = false; public static bool BadWords = true; public static bool DoCorrections = true; public static bool DoNonViolations = true; - public const int MAX_STACK = 50; - private static string ConfigurationFileName = "server.properties"; public static void OpenConfig() { if (!File.Exists(ConfigurationFileName)) { Logger.WarnPrint(ConfigurationFileName+" not found! writing default."); - File.WriteAllText(ConfigurationFileName,Resources.DefaultServerProperties); - Logger.InfoPrint("! Its very likely database connection will fail..."); + File.WriteAllText(ConfigurationFileName, Resources.DefaultServerProperties); + Logger.WarnPrint("! Its very likely database connection will fail..."); } string[] configFile = File.ReadAllLines(ConfigurationFileName); @@ -108,8 +107,8 @@ namespace HISP.Server case "enable_spam_filter": EnableSpamFilter = data == "true"; break; - case "allow_bbcode_in_chat": - AllowBbcode = data == "true"; + case "fix_offical_bugs": + FixOfficalBugs = data == "true"; break; case "enable_word_filter": BadWords = data == "true"; diff --git a/HorseIsleServer/HorseIsleServer/Server/GameClient.cs b/HorseIsleServer/HorseIsleServer/Server/GameClient.cs index 46f262e..f06249e 100644 --- a/HorseIsleServer/HorseIsleServer/Server/GameClient.cs +++ b/HorseIsleServer/HorseIsleServer/Server/GameClient.cs @@ -387,6 +387,19 @@ namespace HISP.Server public void Login(int id) { + /* + * Check for duplicate user + * and disconnect them. + */ + foreach (GameClient Client in GameClient.ConnectedClients) + { + if (Client.LoggedIn) + { + if (Client.LoggedinUser.Id == id) + Client.Kick(Messages.KickReasonDuplicateLogin); + } + } + LoggedinUser = new User(this, id); LoggedIn = true; diff --git a/HorseIsleServer/HorseIsleServer/Server/GameServer.cs b/HorseIsleServer/HorseIsleServer/Server/GameServer.cs index 2c0431a..a3ec993 100644 --- a/HorseIsleServer/HorseIsleServer/Server/GameServer.cs +++ b/HorseIsleServer/HorseIsleServer/Server/GameServer.cs @@ -2659,8 +2659,16 @@ namespace HISP.Server } byte[] descriptionEditedMessage = PacketBuilder.CreateChat(Messages.RanchSavedRanchDescripton, PacketBuilder.CHAT_BOTTOM_RIGHT); sender.SendPacket(descriptionEditedMessage); - // Completely forgot! public server opens your stats menu when you save your ranch info like DUH!! - UpdateStats(sender); + + /* + * Pinto bug: Saving ranch description will take you to the STATS menu + * instead of just back to your ranch. + */ + + if (ConfigReader.FixOfficalBugs) + UpdateArea(sender); + else + UpdateStats(sender); } else { @@ -5921,10 +5929,6 @@ namespace HISP.Server message = Chat.DoCorrections(message); message = Chat.EscapeMessage(message); - // Encode bbcode message. - if(ConfigReader.AllowBbcode || (sender.LoggedinUser.Moderator || sender.LoggedinUser.Administrator)) - message = BBCode.EncodeBBCodeToMeta(message); - string failedReason = Chat.NonViolationChecks(sender.LoggedinUser, message); if (failedReason != null) { @@ -6464,6 +6468,7 @@ namespace HISP.Server break; } + try { sender.LoggedinUser.Inventory.Add(new ItemInstance(newItem)); @@ -7080,7 +7085,7 @@ namespace HISP.Server if (sender.LoggedinUser.Inventory.HasItemId(itemId)) { InventoryItem items = sender.LoggedinUser.Inventory.GetItemByItemId(itemId); - if (items.ItemInstances.Length + count > ConfigReader.MAX_STACK) + if (items.ItemInstances.Length + count > Item.MAX_STACK) { goto showError; } @@ -7398,6 +7403,8 @@ namespace HISP.Server } + + sender.Login(userId); sender.LoggedinUser.Password = password;