From 574596b4e0aefd8ca4b4f8ae22b273c47ac8ddae Mon Sep 17 00:00:00 2001
From: Li
Date: Sun, 20 Nov 2022 15:03:15 +1300
Subject: [PATCH] Cleanup substrings, fix more of em
---
.../HISPd/Properties/AssemblyInfo.cs | 4 +-
.../HISPd/Resources/DEBIAN/control | 2 +-
.../LibHISP/Properties/AssemblyInfo.cs | 4 +-
HorseIsleServer/LibHISP/Server/GameClient.cs | 11 +-
HorseIsleServer/LibHISP/Server/GameServer.cs | 152 +++++++++---------
.../MPN00BS/Properties/AssemblyInfo.cs | 4 +-
6 files changed, 89 insertions(+), 88 deletions(-)
diff --git a/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs b/HorseIsleServer/HISPd/Properties/AssemblyInfo.cs
index e880002..cc94648 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.51.0")]
-[assembly: AssemblyFileVersion("1.8.51.0")]
+[assembly: AssemblyVersion("1.8.54.0")]
+[assembly: AssemblyFileVersion("1.8.54.0")]
diff --git a/HorseIsleServer/HISPd/Resources/DEBIAN/control b/HorseIsleServer/HISPd/Resources/DEBIAN/control
index 8b6b9d4..891a25d 100755
--- a/HorseIsleServer/HISPd/Resources/DEBIAN/control
+++ b/HorseIsleServer/HISPd/Resources/DEBIAN/control
@@ -1,5 +1,5 @@
Package: hisp
-Version: 1.8.51
+Version: 1.8.54
Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev
Maintainer: Li
Homepage: https://islehorse.com
diff --git a/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs b/HorseIsleServer/LibHISP/Properties/AssemblyInfo.cs
index b0e3397..10ac06b 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.51.0")]
-[assembly: AssemblyFileVersion("1.8.51.0")]
+[assembly: AssemblyVersion("1.8.54.0")]
+[assembly: AssemblyFileVersion("1.8.54.0")]
diff --git a/HorseIsleServer/LibHISP/Server/GameClient.cs b/HorseIsleServer/LibHISP/Server/GameClient.cs
index d5ac067..65b62ac 100755
--- a/HorseIsleServer/LibHISP/Server/GameClient.cs
+++ b/HorseIsleServer/LibHISP/Server/GameClient.cs
@@ -438,10 +438,8 @@ namespace HISP.Server
* this prevents the entire server from crashing
* if theres an error in handling a particular packet.
*/
-#if (!DEBUG)
try
{
-#endif
if (!LoggedIn) // Must be either login or policy-file-request
{
switch (identifier)
@@ -529,14 +527,15 @@ namespace HISP.Server
break;
}
}
-#if (!DEBUG)
}
catch(Exception e)
{
- Logger.ErrorPrint("Unhandled Exception: " + e.ToString() + "\n" + e.Message + "\n" + e.StackTrace);
- Kick("Unhandled Exception: " + e.ToString());
- }
+#if OS_DEBUG
+ throw e;
#endif
+ Logger.ErrorPrint("Unhandled Exception: " + e.Message + "\n" + e.StackTrace);
+ Kick("Unhandled Exception: " + e.Message + "\n" + e.StackTrace);
+ }
}
public void Kick(string Reason)
diff --git a/HorseIsleServer/LibHISP/Server/GameServer.cs b/HorseIsleServer/LibHISP/Server/GameServer.cs
index ee047f3..4d2329a 100755
--- a/HorseIsleServer/LibHISP/Server/GameServer.cs
+++ b/HorseIsleServer/LibHISP/Server/GameServer.cs
@@ -24,9 +24,11 @@ namespace HISP.Server
{
public class GameServer
{
+ private const int PACKET_FOOTER_LENGTH;
public static Socket ServerSocket;
+
public static int IdleTimeout;
public static int IdleWarning;
@@ -279,7 +281,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_PROFILE:
string packetStr = Encoding.UTF8.GetString(packet);
- string playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int playerId = -1;
try
{
@@ -302,7 +304,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_MUTE:
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -330,7 +332,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_UNMUTE:
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -358,7 +360,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_REMOVE_BUDDY:
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -386,7 +388,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_TAG:
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -425,7 +427,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_ADD_BUDDY:
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -449,7 +451,7 @@ namespace HISP.Server
break;
packetStr = Encoding.UTF8.GetString(packet);
- string idStr = packetStr.Substring(2, packetStr.Length - 3);
+ string idStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
char firstChar = idStr[0];
switch (firstChar)
{
@@ -520,7 +522,7 @@ namespace HISP.Server
break;
case PacketBuilder.PLAYER_INTERACTION_TRADE:
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -576,7 +578,7 @@ namespace HISP.Server
{
case PacketBuilder.SOCIALS_MENU:
string packetStr = Encoding.UTF8.GetString(packet);
- string playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int playerId = -1;
try
{
@@ -765,7 +767,7 @@ namespace HISP.Server
Auction auctionRoom = Auction.GetAuctionRoomById(int.Parse(tile.Code.Split('-')[1]));
int auctionEntryId = -1;
string packetStr = Encoding.UTF8.GetString(packet);
- string auctionEntryStr = packetStr.Substring(2, packetStr.Length - 3);
+ string auctionEntryStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
auctionEntryId = int.Parse(auctionEntryStr);
@@ -838,7 +840,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_FEED:
int randomId = 0;
string packetStr = Encoding.UTF8.GetString(packet);
- string randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -867,7 +869,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_PET:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -957,7 +959,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_VET_SERVICE:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (randomIdStr == "NaN")
break;
@@ -1018,7 +1020,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_SHOE_IRON:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (randomIdStr == "NaN")
break;
@@ -1142,7 +1144,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_GROOM_SERVICE:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (randomIdStr == "NaN")
break;
@@ -1256,7 +1258,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_BARN_SERVICE:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (randomIdStr == "NaN")
break;
@@ -1372,7 +1374,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_TRAIN:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (randomIdStr == "NaN")
break;
@@ -1477,7 +1479,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_GIVE_FEED:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -1617,7 +1619,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_ENTER_ARENA:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -1707,7 +1709,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_RELEASE:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -1761,7 +1763,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_TACK:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -1800,7 +1802,7 @@ namespace HISP.Server
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -1854,7 +1856,7 @@ namespace HISP.Server
int itemId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- string itemIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string itemIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
itemId = int.Parse(itemIdStr);
@@ -2023,7 +2025,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_DISMOUNT:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if(randomIdStr == "") // F7 Shortcut
{
@@ -2070,7 +2072,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_MOUNT:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -2094,7 +2096,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_LOOK:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
HorseInstance horseInst;
try
{
@@ -2186,7 +2188,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_TRY_CAPTURE:
randomId = 0;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try
{
randomId = int.Parse(randomIdStr);
@@ -2231,7 +2233,7 @@ namespace HISP.Server
return;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string dynamicInputStr = packetStr.Substring(1, packetStr.Length - 2);
+ string dynamicInputStr = packetStr.Substring(1, (packetStr.Length - 1) - PACKET_FOOTER_LENGTH);
if(dynamicInputStr.Contains("|"))
{
string[] dynamicInput = dynamicInputStr.Split('|');
@@ -2830,11 +2832,11 @@ namespace HISP.Server
{
if (!sender.LoggedIn)
{
- Logger.ErrorPrint(sender.RemoteIp + " Clicked dyamic button when not logged in.");
+ Logger.ErrorPrint(sender.RemoteIp + " Clicked dynamic button when not logged in.");
return;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string buttonIdStr = packetStr.Substring(1, packetStr.Length - 2);
+ string buttonIdStr = packetStr.Substring(1, (packetStr.Length - 1) - PACKET_FOOTER_LENGTH);
switch(buttonIdStr)
{
@@ -3636,7 +3638,7 @@ namespace HISP.Server
return;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string scoreStr = packetStr.Substring(1, packet.Length - 2);
+ string scoreStr = packetStr.Substring(1, (packet.Length - 1) - PACKET_FOOTER_LENGTH);
int score = -1;
try
{
@@ -3840,7 +3842,7 @@ namespace HISP.Server
break;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int playerId = -1;
try
{
@@ -3861,7 +3863,7 @@ namespace HISP.Server
break;
}
packetStr = Encoding.UTF8.GetString(packet);
- playerIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1;
try
{
@@ -4057,7 +4059,7 @@ namespace HISP.Server
packetStr = Encoding.UTF8.GetString(packet);
- string drawing = packetStr.Substring(3, packetStr.Length - 4);
+ string drawing = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
if (drawing.Contains("X!")) // Clear byte
{
room.Drawing = "";
@@ -4216,7 +4218,7 @@ namespace HISP.Server
Dressup.DressupRoom room = Dressup.GetDressupRoom(roomId);
packetStr = Encoding.UTF8.GetString(packet);
- string moveStr = packetStr.Substring(3, packetStr.Length - 4);
+ string moveStr = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
string[] moves = moveStr.Split('|');
@@ -4473,7 +4475,7 @@ namespace HISP.Server
{
string packetStr = Encoding.UTF8.GetString(packet);
- if (packet.Length <= 4 || !packetStr.Contains('|'))
+ if (packet.Length <= 3 || !packetStr.Contains('|'))
{
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid Profile SAVE Packet");
return;
@@ -4482,7 +4484,7 @@ namespace HISP.Server
int characterId = (packet[2] - 20) * 64 + (packet[3] - 20);
string profilePage = packetStr.Split('|')[1];
- profilePage = profilePage.Substring(0, profilePage.Length - 1);
+ profilePage = profilePage.Substring(0, profilePage.Length - PACKET_FOOTER_LENGTH);
sender.LoggedinUser.CharacterId = characterId;
if (profilePage.Length > 4000)
@@ -4526,7 +4528,7 @@ namespace HISP.Server
}
string packetStr = Encoding.UTF8.GetString(packet);
- string awardIdStr = packetStr.Substring(6, packetStr.Length - 6 - 1);
+ string awardIdStr = packetStr.Substring(6, (packetStr.Length - 6) - PACKET_FOOTER_LENGTH);
int value = -1;
try
@@ -4569,7 +4571,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet);
- string gameInfoStr = packetStr.Substring(6, packetStr.Length - 6 - 1);
+ string gameInfoStr = packetStr.Substring(6, (packetStr.Length - 6) - PACKET_FOOTER_LENGTH);
if (winloose)
{
string gameTitle = gameInfoStr.Substring(1);
@@ -4693,7 +4695,7 @@ namespace HISP.Server
}
string packetStr = Encoding.UTF8.GetString(packet);
- string gameInfoStr = packetStr.Substring(6, packetStr.Length - 6 - 1);
+ string gameInfoStr = packetStr.Substring(6, (packetStr.Length - 6) - PACKET_FOOTER_LENGTH);
if (gameInfoStr.Contains("|"))
{
string[] moneyInfo = gameInfoStr.Split('|');
@@ -4747,7 +4749,7 @@ namespace HISP.Server
return;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string intStr = packetStr.Substring(6, packetStr.Length - 6 - 1);
+ string intStr = packetStr.Substring(6, (packetStr.Length - 6) - PACKET_FOOTER_LENGTH);
int value = -1;
try
{
@@ -4807,7 +4809,7 @@ namespace HISP.Server
return;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string intStr = packetStr.Substring(6, packetStr.Length - 6 - 1);
+ string intStr = packetStr.Substring(6, (packetStr.Length - 6) - PACKET_FOOTER_LENGTH);
int value = -1;
try
{
@@ -4860,7 +4862,7 @@ namespace HISP.Server
return;
}
string packetStr = Encoding.UTF8.GetString(packet);
- string intStr = packetStr.Substring(6, packetStr.Length - 6 - 1);
+ string intStr = packetStr.Substring(6, (packetStr.Length - 6) - PACKET_FOOTER_LENGTH);
int value = -1;
try
{
@@ -4898,7 +4900,7 @@ namespace HISP.Server
{
sender.LoggedinUser.MajorPriority = true;
string packetStr = Encoding.UTF8.GetString(packet);
- string gameName = packetStr.Substring(2, packetStr.Length - 3);
+ string gameName = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
byte[] metaTag = PacketBuilder.CreateMeta(Meta.BuildTopHighscores(gameName));
sender.SendPacket(metaTag);
}
@@ -4906,7 +4908,7 @@ namespace HISP.Server
{
sender.LoggedinUser.MajorPriority = true;
string packetStr = Encoding.UTF8.GetString(packet);
- string gameName = packetStr.Substring(2, packetStr.Length - 3);
+ string gameName = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
byte[] metaTag = PacketBuilder.CreateMeta(Meta.BuildTopTimes(gameName));
sender.SendPacket(metaTag);
}
@@ -4914,7 +4916,7 @@ namespace HISP.Server
{
sender.LoggedinUser.MajorPriority = true;
string packetStr = Encoding.UTF8.GetString(packet);
- string gameName = packetStr.Substring(2, packetStr.Length - 3);
+ string gameName = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
byte[] metaTag = PacketBuilder.CreateMeta(Meta.BuildTopWinners(gameName));
sender.SendPacket(metaTag);
}
@@ -5242,7 +5244,7 @@ namespace HISP.Server
{
string packetStr = Encoding.UTF8.GetString(packet);
- string number = packetStr.Substring(2, packetStr.Length - 3);
+ string number = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int chatId = 0;
try
@@ -5280,7 +5282,7 @@ namespace HISP.Server
else if (action == PacketBuilder.NPC_CONTINUE_CHAT)
{
string packetStr = Encoding.UTF8.GetString(packet);
- string number = packetStr.Substring(2, packetStr.Length - 3);
+ string number = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int replyId = 0;
try
{
@@ -5331,7 +5333,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet);
- string number = packetStr.Substring(1, packetStr.Length - 2);
+ string number = packetStr.Substring(1, (packetStr.Length - 1) - PACKET_FOOTER_LENGTH);
int transportid;
try
@@ -5431,7 +5433,7 @@ namespace HISP.Server
if (method == PacketBuilder.RANCH_INFO)
{
- string buildingIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string buildingIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int buildingId = 0;
try
{
@@ -5459,7 +5461,7 @@ namespace HISP.Server
}
else if (method == PacketBuilder.RANCH_SELL)
{
- string NanSTR = packetStr.Substring(2, packetStr.Length - 3);
+ string NanSTR = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (NanSTR == "NaN")
{
if (sender.LoggedinUser.OwnedRanch == null)
@@ -5490,7 +5492,7 @@ namespace HISP.Server
}
else if (method == PacketBuilder.RANCH_UPGRADE)
{
- string NanSTR = packetStr.Substring(2, packetStr.Length - 3);
+ string NanSTR = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (NanSTR == "NaN")
{
if (sender.LoggedinUser.OwnedRanch != null)
@@ -5541,7 +5543,7 @@ namespace HISP.Server
}
else if (method == PacketBuilder.RANCH_REMOVE)
{
- string buildingIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string buildingIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int buildingId = 0;
try
{
@@ -5599,7 +5601,7 @@ namespace HISP.Server
}
else if (method == PacketBuilder.RANCH_BUILD)
{
- string buildingIdStr = packetStr.Substring(2, packetStr.Length - 3);
+ string buildingIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int buildingId = 0;
try
{
@@ -5653,7 +5655,7 @@ namespace HISP.Server
}
else if (method == PacketBuilder.RANCH_BUY)
{
- string nan = packetStr.Substring(2, packetStr.Length - 3);
+ string nan = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if (nan == "NaN")
{
if (Ranch.IsRanchHere(sender.LoggedinUser.X, sender.LoggedinUser.Y))
@@ -5778,7 +5780,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet);
Chat.ChatChannel channel = (Chat.ChatChannel)packet[1];
- string message = packetStr.Substring(2, packetStr.Length - 3);
+ string message = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
Logger.DebugPrint(sender.LoggedinUser.Username + " Attempting to say '" + message + "' in channel: " + channel.ToString());
@@ -6053,7 +6055,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet);
if(packetStr.Contains("|"))
{
- string packetContents = packetStr.Substring(1, packetStr.Length - 2);
+ string packetContents = packetStr.Substring(1, (packetStr.Length - 1) - PACKET_FOOTER_LENGTH);
string[] xy = packetContents.Split('|');
int x = 0;
int y = 0;
@@ -6156,7 +6158,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_PICKUP:
string packetStr = Encoding.UTF8.GetString(packet);
- string randomIdStr = packetStr.Substring(2, packet.Length - 3);
+ string randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int randomId = 0;
try
@@ -6321,7 +6323,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_THROW:
packetStr = Encoding.UTF8.GetString(packet);
- string itemidStr = packetStr.Substring(2, packet.Length - 1);
+ string itemidStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int itemId = 0;
try
@@ -6387,7 +6389,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_WRAP:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 1);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
@@ -6423,7 +6425,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_OPEN:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 1);
+ randomIdStr = packetStr.Substring(2, (packet.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
@@ -6469,7 +6471,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_USE:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 3);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if(randomIdStr == "") // f12 ranch shortcut
{
@@ -6506,7 +6508,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_WEAR:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 1);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
@@ -6622,7 +6624,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_DRINK:
packetStr = Encoding.UTF8.GetString(packet);
- string idStr = packetStr.Substring(2, packet.Length - 3);
+ string idStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
if(idStr == "NaN") // Fountain
{
string msg = Messages.FountainDrankYourFull;
@@ -6647,7 +6649,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_CONSUME:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 2);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
@@ -6685,7 +6687,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_DROP:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 1);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
@@ -6759,7 +6761,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_CRAFT:
packetStr = Encoding.UTF8.GetString(packet);
- string craftIdStr = packetStr.Substring(2, packet.Length - 1);
+ string craftIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
int craftId = 0;
// Prevent crashing on non-int string.
try
@@ -6838,7 +6840,7 @@ namespace HISP.Server
int message = 1;
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 1);
+ randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
// Prevent crashing on non-int string.
try
@@ -6862,7 +6864,7 @@ namespace HISP.Server
goto doSell;
case PacketBuilder.ITEM_SELL_ALL:
packetStr = Encoding.UTF8.GetString(packet);
- string itemIdStr = packetStr.Substring(2, packet.Length - 1);
+ string itemIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
itemId = 0;
// Prevent crashing on non-int string.
try
@@ -6940,7 +6942,7 @@ namespace HISP.Server
case PacketBuilder.ITEM_BUY_AND_CONSUME:
packetStr = Encoding.UTF8.GetString(packet);
- itemIdStr = packetStr.Substring(2, packet.Length - 2);
+ itemIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
itemId = 0;
// Prevent crashing on non-int string.
try
@@ -7019,7 +7021,7 @@ namespace HISP.Server
count = 25;
doPurchase:;
packetStr = Encoding.UTF8.GetString(packet);
- itemIdStr = packetStr.Substring(2, packet.Length - 2);
+ itemIdStr = packetStr.Substring(2, (packet.Length - 2) - PACKET_FOOTER_LENGTH);
itemId = 0;
// Prevent crashing on non-int string.
try
@@ -7151,7 +7153,7 @@ namespace HISP.Server
break;
case PacketBuilder.ITEM_RIP:
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(2, packet.Length - 1);
+ randomIdStr = packetStr.Substring(2, (packet.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
{
@@ -7186,7 +7188,7 @@ namespace HISP.Server
if (method == PacketBuilder.ITEM_LOOK)
{
packetStr = Encoding.UTF8.GetString(packet);
- itemIdStr = packetStr.Substring(3, packet.Length - 2);
+ itemIdStr = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
itemId = 0;
try
{
@@ -7215,7 +7217,7 @@ namespace HISP.Server
else if(method == PacketBuilder.ITEM_READ)
{
packetStr = Encoding.UTF8.GetString(packet);
- randomIdStr = packetStr.Substring(3, packet.Length - 2);
+ randomIdStr = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
randomId = 0;
try
{
@@ -7256,7 +7258,7 @@ namespace HISP.Server
break;
case PacketBuilder.PACKET_INFORMATION:
packetStr = Encoding.UTF8.GetString(packet);
- string valueStr = packetStr.Substring(3, packet.Length - 2);
+ string valueStr = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
int value = 0;
try
{
diff --git a/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs b/HorseIsleServer/MPN00BS/Properties/AssemblyInfo.cs
index 4590298..912c3ca 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.51.0")]
-[assembly: AssemblyFileVersion("1.8.51.0")]
+[assembly: AssemblyVersion("1.8.54.0")]
+[assembly: AssemblyFileVersion("1.8.54.0")]