Cleanup substrings, fix more of em

This commit is contained in:
Li 2022-11-20 15:03:15 +13:00
parent a9a5ef65b0
commit 574596b4e0
6 changed files with 89 additions and 88 deletions

View file

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.51.0")] [assembly: AssemblyVersion("1.8.54.0")]
[assembly: AssemblyFileVersion("1.8.51.0")] [assembly: AssemblyFileVersion("1.8.54.0")]

View file

@ -1,5 +1,5 @@
Package: hisp Package: hisp
Version: 1.8.51 Version: 1.8.54
Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev Depends: coreutils,systemd,mariadb-server,libsqlite3-dev,zlib1g-dev,libicu-dev,libkrb5-dev
Maintainer: Li Maintainer: Li
Homepage: https://islehorse.com Homepage: https://islehorse.com

View file

@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.8.51.0")] [assembly: AssemblyVersion("1.8.54.0")]
[assembly: AssemblyFileVersion("1.8.51.0")] [assembly: AssemblyFileVersion("1.8.54.0")]

View file

@ -438,10 +438,8 @@ namespace HISP.Server
* this prevents the entire server from crashing * this prevents the entire server from crashing
* if theres an error in handling a particular packet. * if theres an error in handling a particular packet.
*/ */
#if (!DEBUG)
try try
{ {
#endif
if (!LoggedIn) // Must be either login or policy-file-request if (!LoggedIn) // Must be either login or policy-file-request
{ {
switch (identifier) switch (identifier)
@ -529,14 +527,15 @@ namespace HISP.Server
break; break;
} }
} }
#if (!DEBUG)
} }
catch(Exception e) catch(Exception e)
{ {
Logger.ErrorPrint("Unhandled Exception: " + e.ToString() + "\n" + e.Message + "\n" + e.StackTrace); #if OS_DEBUG
Kick("Unhandled Exception: " + e.ToString()); throw e;
}
#endif #endif
Logger.ErrorPrint("Unhandled Exception: " + e.Message + "\n" + e.StackTrace);
Kick("Unhandled Exception: " + e.Message + "\n" + e.StackTrace);
}
} }
public void Kick(string Reason) public void Kick(string Reason)

View file

@ -24,9 +24,11 @@ namespace HISP.Server
{ {
public class GameServer public class GameServer
{ {
private const int PACKET_FOOTER_LENGTH;
public static Socket ServerSocket; public static Socket ServerSocket;
public static int IdleTimeout; public static int IdleTimeout;
public static int IdleWarning; public static int IdleWarning;
@ -279,7 +281,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_PROFILE: case PacketBuilder.PLAYER_INTERACTION_PROFILE:
string packetStr = Encoding.UTF8.GetString(packet); 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; int playerId = -1;
try try
{ {
@ -302,7 +304,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_MUTE: case PacketBuilder.PLAYER_INTERACTION_MUTE:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -330,7 +332,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_UNMUTE: case PacketBuilder.PLAYER_INTERACTION_UNMUTE:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -358,7 +360,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_REMOVE_BUDDY: case PacketBuilder.PLAYER_INTERACTION_REMOVE_BUDDY:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -386,7 +388,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_TAG: case PacketBuilder.PLAYER_INTERACTION_TAG:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -425,7 +427,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_ADD_BUDDY: case PacketBuilder.PLAYER_INTERACTION_ADD_BUDDY:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -449,7 +451,7 @@ namespace HISP.Server
break; break;
packetStr = Encoding.UTF8.GetString(packet); 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]; char firstChar = idStr[0];
switch (firstChar) switch (firstChar)
{ {
@ -520,7 +522,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PLAYER_INTERACTION_TRADE: case PacketBuilder.PLAYER_INTERACTION_TRADE:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -576,7 +578,7 @@ namespace HISP.Server
{ {
case PacketBuilder.SOCIALS_MENU: case PacketBuilder.SOCIALS_MENU:
string packetStr = Encoding.UTF8.GetString(packet); 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; int playerId = -1;
try try
{ {
@ -765,7 +767,7 @@ namespace HISP.Server
Auction auctionRoom = Auction.GetAuctionRoomById(int.Parse(tile.Code.Split('-')[1])); Auction auctionRoom = Auction.GetAuctionRoomById(int.Parse(tile.Code.Split('-')[1]));
int auctionEntryId = -1; int auctionEntryId = -1;
string packetStr = Encoding.UTF8.GetString(packet); 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 try
{ {
auctionEntryId = int.Parse(auctionEntryStr); auctionEntryId = int.Parse(auctionEntryStr);
@ -838,7 +840,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_FEED: case PacketBuilder.HORSE_FEED:
int randomId = 0; int randomId = 0;
string packetStr = Encoding.UTF8.GetString(packet); 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 try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -867,7 +869,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_PET: case PacketBuilder.HORSE_PET:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -957,7 +959,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_VET_SERVICE: case PacketBuilder.HORSE_VET_SERVICE:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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") if (randomIdStr == "NaN")
break; break;
@ -1018,7 +1020,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_SHOE_IRON: case PacketBuilder.HORSE_SHOE_IRON:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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") if (randomIdStr == "NaN")
break; break;
@ -1142,7 +1144,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_GROOM_SERVICE: case PacketBuilder.HORSE_GROOM_SERVICE:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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") if (randomIdStr == "NaN")
break; break;
@ -1256,7 +1258,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_BARN_SERVICE: case PacketBuilder.HORSE_BARN_SERVICE:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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") if (randomIdStr == "NaN")
break; break;
@ -1372,7 +1374,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_TRAIN: case PacketBuilder.HORSE_TRAIN:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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") if (randomIdStr == "NaN")
break; break;
@ -1477,7 +1479,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_GIVE_FEED: case PacketBuilder.HORSE_GIVE_FEED:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -1617,7 +1619,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_ENTER_ARENA: case PacketBuilder.HORSE_ENTER_ARENA:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -1707,7 +1709,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_RELEASE: case PacketBuilder.HORSE_RELEASE:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -1761,7 +1763,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_TACK: case PacketBuilder.HORSE_TACK:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -1800,7 +1802,7 @@ namespace HISP.Server
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -1854,7 +1856,7 @@ namespace HISP.Server
int itemId = 0; int itemId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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 try
{ {
itemId = int.Parse(itemIdStr); itemId = int.Parse(itemIdStr);
@ -2023,7 +2025,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_DISMOUNT: case PacketBuilder.HORSE_DISMOUNT:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); 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 if(randomIdStr == "") // F7 Shortcut
{ {
@ -2070,7 +2072,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_MOUNT: case PacketBuilder.HORSE_MOUNT:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -2094,7 +2096,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_LOOK: case PacketBuilder.HORSE_LOOK:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
HorseInstance horseInst; HorseInstance horseInst;
try try
{ {
@ -2186,7 +2188,7 @@ namespace HISP.Server
case PacketBuilder.HORSE_TRY_CAPTURE: case PacketBuilder.HORSE_TRY_CAPTURE:
randomId = 0; randomId = 0;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packetStr.Length - 3); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
try try
{ {
randomId = int.Parse(randomIdStr); randomId = int.Parse(randomIdStr);
@ -2231,7 +2233,7 @@ namespace HISP.Server
return; return;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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("|")) if(dynamicInputStr.Contains("|"))
{ {
string[] dynamicInput = dynamicInputStr.Split('|'); string[] dynamicInput = dynamicInputStr.Split('|');
@ -2830,11 +2832,11 @@ namespace HISP.Server
{ {
if (!sender.LoggedIn) 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; return;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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) switch(buttonIdStr)
{ {
@ -3636,7 +3638,7 @@ namespace HISP.Server
return; return;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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; int score = -1;
try try
{ {
@ -3840,7 +3842,7 @@ namespace HISP.Server
break; break;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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; int playerId = -1;
try try
{ {
@ -3861,7 +3863,7 @@ namespace HISP.Server
break; break;
} }
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
playerIdStr = packetStr.Substring(2, packetStr.Length - 3); playerIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
playerId = -1; playerId = -1;
try try
{ {
@ -4057,7 +4059,7 @@ namespace HISP.Server
packetStr = Encoding.UTF8.GetString(packet); 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 if (drawing.Contains("X!")) // Clear byte
{ {
room.Drawing = ""; room.Drawing = "";
@ -4216,7 +4218,7 @@ namespace HISP.Server
Dressup.DressupRoom room = Dressup.GetDressupRoom(roomId); Dressup.DressupRoom room = Dressup.GetDressupRoom(roomId);
packetStr = Encoding.UTF8.GetString(packet); 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('|'); string[] moves = moveStr.Split('|');
@ -4473,7 +4475,7 @@ namespace HISP.Server
{ {
string packetStr = Encoding.UTF8.GetString(packet); 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"); Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid Profile SAVE Packet");
return; return;
@ -4482,7 +4484,7 @@ namespace HISP.Server
int characterId = (packet[2] - 20) * 64 + (packet[3] - 20); int characterId = (packet[2] - 20) * 64 + (packet[3] - 20);
string profilePage = packetStr.Split('|')[1]; 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; sender.LoggedinUser.CharacterId = characterId;
if (profilePage.Length > 4000) if (profilePage.Length > 4000)
@ -4526,7 +4528,7 @@ namespace HISP.Server
} }
string packetStr = Encoding.UTF8.GetString(packet); 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; int value = -1;
try try
@ -4569,7 +4571,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet); 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) if (winloose)
{ {
string gameTitle = gameInfoStr.Substring(1); string gameTitle = gameInfoStr.Substring(1);
@ -4693,7 +4695,7 @@ namespace HISP.Server
} }
string packetStr = Encoding.UTF8.GetString(packet); 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("|")) if (gameInfoStr.Contains("|"))
{ {
string[] moneyInfo = gameInfoStr.Split('|'); string[] moneyInfo = gameInfoStr.Split('|');
@ -4747,7 +4749,7 @@ namespace HISP.Server
return; return;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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; int value = -1;
try try
{ {
@ -4807,7 +4809,7 @@ namespace HISP.Server
return; return;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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; int value = -1;
try try
{ {
@ -4860,7 +4862,7 @@ namespace HISP.Server
return; return;
} }
string packetStr = Encoding.UTF8.GetString(packet); 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; int value = -1;
try try
{ {
@ -4898,7 +4900,7 @@ namespace HISP.Server
{ {
sender.LoggedinUser.MajorPriority = true; sender.LoggedinUser.MajorPriority = true;
string packetStr = Encoding.UTF8.GetString(packet); 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)); byte[] metaTag = PacketBuilder.CreateMeta(Meta.BuildTopHighscores(gameName));
sender.SendPacket(metaTag); sender.SendPacket(metaTag);
} }
@ -4906,7 +4908,7 @@ namespace HISP.Server
{ {
sender.LoggedinUser.MajorPriority = true; sender.LoggedinUser.MajorPriority = true;
string packetStr = Encoding.UTF8.GetString(packet); 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)); byte[] metaTag = PacketBuilder.CreateMeta(Meta.BuildTopTimes(gameName));
sender.SendPacket(metaTag); sender.SendPacket(metaTag);
} }
@ -4914,7 +4916,7 @@ namespace HISP.Server
{ {
sender.LoggedinUser.MajorPriority = true; sender.LoggedinUser.MajorPriority = true;
string packetStr = Encoding.UTF8.GetString(packet); 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)); byte[] metaTag = PacketBuilder.CreateMeta(Meta.BuildTopWinners(gameName));
sender.SendPacket(metaTag); sender.SendPacket(metaTag);
} }
@ -5242,7 +5244,7 @@ namespace HISP.Server
{ {
string packetStr = Encoding.UTF8.GetString(packet); 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; int chatId = 0;
try try
@ -5280,7 +5282,7 @@ namespace HISP.Server
else if (action == PacketBuilder.NPC_CONTINUE_CHAT) else if (action == PacketBuilder.NPC_CONTINUE_CHAT)
{ {
string packetStr = Encoding.UTF8.GetString(packet); 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; int replyId = 0;
try try
{ {
@ -5331,7 +5333,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet); 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; int transportid;
try try
@ -5431,7 +5433,7 @@ namespace HISP.Server
if (method == PacketBuilder.RANCH_INFO) 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; int buildingId = 0;
try try
{ {
@ -5459,7 +5461,7 @@ namespace HISP.Server
} }
else if (method == PacketBuilder.RANCH_SELL) 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 (NanSTR == "NaN")
{ {
if (sender.LoggedinUser.OwnedRanch == null) if (sender.LoggedinUser.OwnedRanch == null)
@ -5490,7 +5492,7 @@ namespace HISP.Server
} }
else if (method == PacketBuilder.RANCH_UPGRADE) 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 (NanSTR == "NaN")
{ {
if (sender.LoggedinUser.OwnedRanch != null) if (sender.LoggedinUser.OwnedRanch != null)
@ -5541,7 +5543,7 @@ namespace HISP.Server
} }
else if (method == PacketBuilder.RANCH_REMOVE) 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; int buildingId = 0;
try try
{ {
@ -5599,7 +5601,7 @@ namespace HISP.Server
} }
else if (method == PacketBuilder.RANCH_BUILD) 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; int buildingId = 0;
try try
{ {
@ -5653,7 +5655,7 @@ namespace HISP.Server
} }
else if (method == PacketBuilder.RANCH_BUY) 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 (nan == "NaN")
{ {
if (Ranch.IsRanchHere(sender.LoggedinUser.X, sender.LoggedinUser.Y)) if (Ranch.IsRanchHere(sender.LoggedinUser.X, sender.LoggedinUser.Y))
@ -5778,7 +5780,7 @@ namespace HISP.Server
string packetStr = Encoding.UTF8.GetString(packet); string packetStr = Encoding.UTF8.GetString(packet);
Chat.ChatChannel channel = (Chat.ChatChannel)packet[1]; 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()); 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); string packetStr = Encoding.UTF8.GetString(packet);
if(packetStr.Contains("|")) 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('|'); string[] xy = packetContents.Split('|');
int x = 0; int x = 0;
int y = 0; int y = 0;
@ -6156,7 +6158,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_PICKUP: case PacketBuilder.ITEM_PICKUP:
string packetStr = Encoding.UTF8.GetString(packet); 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; int randomId = 0;
try try
@ -6321,7 +6323,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_THROW: case PacketBuilder.ITEM_THROW:
packetStr = Encoding.UTF8.GetString(packet); 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; int itemId = 0;
try try
@ -6387,7 +6389,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_WRAP: case PacketBuilder.ITEM_WRAP:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 1); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
@ -6423,7 +6425,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_OPEN: case PacketBuilder.ITEM_OPEN:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 1); randomIdStr = packetStr.Substring(2, (packet.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
@ -6469,7 +6471,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_USE: case PacketBuilder.ITEM_USE:
packetStr = Encoding.UTF8.GetString(packet); 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 if(randomIdStr == "") // f12 ranch shortcut
{ {
@ -6506,7 +6508,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_WEAR: case PacketBuilder.ITEM_WEAR:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 1); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
@ -6622,7 +6624,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_DRINK: case PacketBuilder.ITEM_DRINK:
packetStr = Encoding.UTF8.GetString(packet); 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 if(idStr == "NaN") // Fountain
{ {
string msg = Messages.FountainDrankYourFull; string msg = Messages.FountainDrankYourFull;
@ -6647,7 +6649,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_CONSUME: case PacketBuilder.ITEM_CONSUME:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 2); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
@ -6685,7 +6687,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_DROP: case PacketBuilder.ITEM_DROP:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 1); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
@ -6759,7 +6761,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_CRAFT: case PacketBuilder.ITEM_CRAFT:
packetStr = Encoding.UTF8.GetString(packet); 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; int craftId = 0;
// Prevent crashing on non-int string. // Prevent crashing on non-int string.
try try
@ -6838,7 +6840,7 @@ namespace HISP.Server
int message = 1; int message = 1;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 1); randomIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
// Prevent crashing on non-int string. // Prevent crashing on non-int string.
try try
@ -6862,7 +6864,7 @@ namespace HISP.Server
goto doSell; goto doSell;
case PacketBuilder.ITEM_SELL_ALL: case PacketBuilder.ITEM_SELL_ALL:
packetStr = Encoding.UTF8.GetString(packet); 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; itemId = 0;
// Prevent crashing on non-int string. // Prevent crashing on non-int string.
try try
@ -6940,7 +6942,7 @@ namespace HISP.Server
case PacketBuilder.ITEM_BUY_AND_CONSUME: case PacketBuilder.ITEM_BUY_AND_CONSUME:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
itemIdStr = packetStr.Substring(2, packet.Length - 2); itemIdStr = packetStr.Substring(2, (packetStr.Length - 2) - PACKET_FOOTER_LENGTH);
itemId = 0; itemId = 0;
// Prevent crashing on non-int string. // Prevent crashing on non-int string.
try try
@ -7019,7 +7021,7 @@ namespace HISP.Server
count = 25; count = 25;
doPurchase:; doPurchase:;
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
itemIdStr = packetStr.Substring(2, packet.Length - 2); itemIdStr = packetStr.Substring(2, (packet.Length - 2) - PACKET_FOOTER_LENGTH);
itemId = 0; itemId = 0;
// Prevent crashing on non-int string. // Prevent crashing on non-int string.
try try
@ -7151,7 +7153,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.ITEM_RIP: case PacketBuilder.ITEM_RIP:
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(2, packet.Length - 1); randomIdStr = packetStr.Substring(2, (packet.Length - 2) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
{ {
@ -7186,7 +7188,7 @@ namespace HISP.Server
if (method == PacketBuilder.ITEM_LOOK) if (method == PacketBuilder.ITEM_LOOK)
{ {
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
itemIdStr = packetStr.Substring(3, packet.Length - 2); itemIdStr = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
itemId = 0; itemId = 0;
try try
{ {
@ -7215,7 +7217,7 @@ namespace HISP.Server
else if(method == PacketBuilder.ITEM_READ) else if(method == PacketBuilder.ITEM_READ)
{ {
packetStr = Encoding.UTF8.GetString(packet); packetStr = Encoding.UTF8.GetString(packet);
randomIdStr = packetStr.Substring(3, packet.Length - 2); randomIdStr = packetStr.Substring(3, (packetStr.Length - 3) - PACKET_FOOTER_LENGTH);
randomId = 0; randomId = 0;
try try
{ {
@ -7256,7 +7258,7 @@ namespace HISP.Server
break; break;
case PacketBuilder.PACKET_INFORMATION: case PacketBuilder.PACKET_INFORMATION:
packetStr = Encoding.UTF8.GetString(packet); 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; int value = 0;
try try
{ {

View file

@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.8.51.0")] [assembly: AssemblyVersion("1.8.54.0")]
[assembly: AssemblyFileVersion("1.8.51.0")] [assembly: AssemblyFileVersion("1.8.54.0")]