From 393dc147da9615397f875b1e899724fc634ed650 Mon Sep 17 00:00:00 2001
From: Li
Date: Tue, 15 Nov 2022 04:07:40 +1300
Subject: [PATCH] Add silly tile debug feature
---
.../HISPd/Properties/AssemblyInfo.cs | 4 +-
.../HISPd/Resources/DEBIAN/control | 2 +-
.../HISPtests/UnitTests/UserTest.cs | 79 +++++++++++++++++++
HorseIsleServer/LibHISP/Game/Ranch.cs | 19 ++++-
HorseIsleServer/LibHISP/Player/User.cs | 6 +-
.../LibHISP/Properties/AssemblyInfo.cs | 4 +-
HorseIsleServer/LibHISP/Server/GameServer.cs | 9 +--
.../MPN00BS/Properties/AssemblyInfo.cs | 4 +-
8 files changed, 108 insertions(+), 19 deletions(-)
diff --git a/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs b/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
index aa433bd..70e4b4e 100755
--- a/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
+++ b/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.8.30.0")]
-[assembly: AssemblyFileVersion("1.8.30.0")]
+[assembly: AssemblyVersion("1.8.32.0")]
+[assembly: AssemblyFileVersion("1.8.32.0")]
diff --git a/HorseIsleServer/HISPd/Resources/DEBIAN/control b/HorseIsleServer/HISPd/Resources/DEBIAN/control
index 388bc17..b4498a9 100755
--- a/HorseIsleServer/HISPd/Resources/DEBIAN/control
+++ b/HorseIsleServer/HISPd/Resources/DEBIAN/control
@@ -1,5 +1,5 @@
Package: hisp
-Version: 1.8.30
+Version: 1.8.32
Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev
Maintainer: Li
Homepage: https://islehorse.com
diff --git a/HorseIsleServer/HISPtests/UnitTests/UserTest.cs b/HorseIsleServer/HISPtests/UnitTests/UserTest.cs
index dc10e53..55242bc 100644
--- a/HorseIsleServer/HISPtests/UnitTests/UserTest.cs
+++ b/HorseIsleServer/HISPtests/UnitTests/UserTest.cs
@@ -1,4 +1,6 @@
using HISP.Game;
+using HISP.Game.Horse;
+using HISP.Game.Items;
using HISP.Player;
using HISP.Security;
using HISP.Server;
@@ -104,6 +106,17 @@ namespace HISP.Tests.UnitTests
user.Hunger = -8000;
results.Add(Test("HungerMinimumEnforcement", user.Hunger, 0));
+ user.Thirst = 8000;
+ results.Add(Test("ThirstMaximumEnforcement", user.Thirst, 1000));
+ user.Thirst = -8000;
+ results.Add(Test("ThirstMinimumEnforcement", user.Thirst, 0));
+
+ user.Tiredness = 8000;
+ results.Add(Test("TirednessMaximumEnforcement", user.Tiredness, 1000));
+ user.Tiredness = -8000;
+ results.Add(Test("TirednessMinimumEnforcement", user.Tiredness, 0));
+
+
user.BankMoney = 9999999999.9999;
user.BankMoney += 1000.0;
results.Add(Test("BankMoneyMaximumEnforcement", user.BankMoney, 9999999999.9999));
@@ -154,6 +167,72 @@ namespace HISP.Tests.UnitTests
results.Add(Test("GenerateSecCode", gotSecCode.SequenceEqual(expectedSecCodeResult), true));
+ // Check max horses count
+ user.Subscribed = false;
+ results.Add(Test("UnsubbedMaxHorses", user.MaxHorses, 7));
+
+ user.Subscribed = true;
+ results.Add(Test("SubbedMaxHorses", user.MaxHorses, 11));
+
+
+ HorseInstance horse = new HorseInstance(HorseInfo.GetBreedById(170));
+ horse.BasicStats.Thirst = 0;
+ horse.BasicStats.Hunger = 0;
+ int horseId = horse.RandomId;
+
+ user.HorseInventory.AddHorse(horse);
+
+ /*
+ * Test Ranches
+ */
+
+ // Give player ranch id 10
+ Ranch.GetRanchById(37).OwnerId = user.Id;
+
+ // Check ranch is now owned by that player, and propagates to user object.
+ results.Add(Test("GiveRanchTest", user.OwnedRanch.Id, 37));
+ results.Add(Test("HaveDorothyShoes", user.Inventory.HasItemId(Item.DorothyShoes), true));
+
+ // Ranch upgrade test
+ foreach(Ranch.RanchUpgrade upgrade in Ranch.RanchUpgrade.RanchUpgrades)
+ {
+ int id = upgrade.Id;
+
+ results.Add(Test("RanchUpgradeLevel" + id, user.OwnedRanch.UpgradedLevel, id));
+ user.OwnedRanch.UpgradedLevel = id;
+ }
+
+ // Test swf
+ results.Add(Test("RanchSwfMine", user.OwnedRanch.GetSwf(true), "ranchviewer.swf?H=10&B1=11&B2=&B3=&B4=&B5=&B6=&B7=&B8=&B9=&B10=&B11=&B12=&B13=&B14=&B15=&B16=&MINE=1"));
+ results.Add(Test("RanchSwf", user.OwnedRanch.GetSwf(false), "ranchviewer.swf?H=10&B1=11&B2=&B3=&B4=&B5=&B6=&B7=&B8=&B9=&B10=&B11=&B12=&B13=&B14=&B15=&B16="));
+
+ // Test Ranch Building Functionality
+
+ // Test Barn
+ user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(1)); // Barn
+ results.Add(Test("RanchBarnMaxHorses", user.MaxHorses, 11 + 4));
+
+ // Test Water Well
+ user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(2)); // Water Well
+ user.Teleport(user.OwnedRanch.X, user.OwnedRanch.Y);
+ results.Add(Test("RanchWaterWellWatering", user.HorseInventory.GetHorseById(horseId).BasicStats.Thirst, 1000));
+
+ // Test Grain Silo
+ user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(3)); // Grain Silo
+ user.Teleport(user.OwnedRanch.X, user.OwnedRanch.Y);
+ results.Add(Test("RanchGrainSiloFeeding", user.HorseInventory.GetHorseById(horseId).BasicStats.Hunger, 1000));
+
+
+ // Set building id 0 to a big barn
+ user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(10)); // Big Barn
+ results.Add(Test("RanchBigBarnMaxHorses", user.MaxHorses, 11 + 8));
+
+ // Set building id 0 to a gold barn
+ user.OwnedRanch.SetBuilding(0, Ranch.RanchBuilding.GetRanchBuildingById(11)); // Gold Barn
+ results.Add(Test("RanchGoldBarnMaxHorses", user.MaxHorses, 11 + 12));
+
+
+
foreach (bool result in results)
if (!result)
diff --git a/HorseIsleServer/LibHISP/Game/Ranch.cs b/HorseIsleServer/LibHISP/Game/Ranch.cs
index 5a768a9..f0f7a24 100755
--- a/HorseIsleServer/LibHISP/Game/Ranch.cs
+++ b/HorseIsleServer/LibHISP/Game/Ranch.cs
@@ -30,10 +30,10 @@ namespace HISP.Game
}
public static RanchUpgrade GetRanchUpgradeById(int id)
{
- foreach (RanchUpgrade rachUpgrade in RanchUpgrades)
+ foreach (RanchUpgrade ranchUpgrade in RanchUpgrades)
{
- if (rachUpgrade.Id == id)
- return rachUpgrade;
+ if (ranchUpgrade.Id == id)
+ return ranchUpgrade;
}
throw new KeyNotFoundException("No ranch found.");
}
@@ -168,7 +168,7 @@ namespace HISP.Game
}
else
{
- if(Database.IsRanchOwned(this.Id))
+ if (Database.IsRanchOwned(this.Id))
{
Database.SetRanchOwner(this.Id, ownerId);
removeDorothyShoes(ownerId);
@@ -180,6 +180,17 @@ namespace HISP.Game
}
}
+ if (GameServer.IsUserOnline(value))
+ {
+ User user = GameServer.GetUserById(value);
+ user.OwnedRanch = this;
+ user.Inventory.AddIgnoringFull(new ItemInstance(Item.DorothyShoes));
+ }
+ else
+ {
+ Database.AddItemToInventory(value, new ItemInstance(Item.DorothyShoes));
+ }
+
ownerId = value;
}
}
diff --git a/HorseIsleServer/LibHISP/Player/User.cs b/HorseIsleServer/LibHISP/Player/User.cs
index 9dfc07a..11f5eb1 100755
--- a/HorseIsleServer/LibHISP/Player/User.cs
+++ b/HorseIsleServer/LibHISP/Player/User.cs
@@ -284,10 +284,10 @@ namespace HISP.Player
if (Administrator)
return true;
- int Timestamp = Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());
- if(Timestamp > subscribedUntil && subscribed) // sub expired.
+ int timestamp = Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());
+ if(timestamp > subscribedUntil && subscribed) // sub expired.
{
- Logger.InfoPrint(Username + "'s Subscription expired. (timestamp now: " + Timestamp + " exp date: " + subscribedUntil+" )");
+ Logger.InfoPrint(Username + "'s Subscription expired. (timestamp now: " + timestamp + " exp date: " + subscribedUntil+" )");
Database.SetUserSubscriptionStatus(this.Id, false);
subscribed = false;
}
diff --git a/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs b/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
index d813a22..0075f9c 100755
--- a/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
+++ b/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
@@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.8.30.0")]
-[assembly: AssemblyFileVersion("1.8.30.0")]
+[assembly: AssemblyVersion("1.8.32.0")]
+[assembly: AssemblyFileVersion("1.8.32.0")]
diff --git a/HorseIsleServer/LibHISP/Server/GameServer.cs b/HorseIsleServer/LibHISP/Server/GameServer.cs
index 65f4022..fa72cb2 100755
--- a/HorseIsleServer/LibHISP/Server/GameServer.cs
+++ b/HorseIsleServer/LibHISP/Server/GameServer.cs
@@ -5680,8 +5680,6 @@ namespace HISP.Server
sender.LoggedinUser.TakeMoney(ranch.Value);
ranch.OwnerId = sender.LoggedinUser.Id;
ranch.InvestedMoney += ranch.Value;
- sender.LoggedinUser.OwnedRanch = ranch;
- sender.LoggedinUser.Inventory.AddIgnoringFull(new ItemInstance(Item.DorothyShoes));
UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, true);
}
@@ -6124,9 +6122,10 @@ namespace HISP.Server
}
returnedMsg = Messages.FormatPlayerHereMessage(usernameStr);
- }
-
- byte[] tileInfoPacket = PacketBuilder.CreateTileClickInfo(returnedMsg);
+ }
+ // TODO: REMEMBER TO CHANGE THIS BACK
+ //byte[] tileInfoPacket = PacketBuilder.CreateTileClickInfo(returnedMsg);
+ byte[] tileInfoPacket = PacketBuilder.CreateTileClickInfo("ground: "+Map.GetTileId(x, y, false)+ ", overlay: "+ Map.GetTileId(x, y, true))
sender.SendPacket(tileInfoPacket);
}
}
diff --git a/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs b/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
index d749588..f5a7378 100755
--- a/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
+++ b/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
@@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.8.30.0")]
-[assembly: AssemblyFileVersion("1.8.30.0")]
+[assembly: AssemblyVersion("1.8.32.0")]
+[assembly: AssemblyFileVersion("1.8.32.0")]