Various fixes

This commit is contained in:
Bluzume 2021-11-07 22:41:36 -05:00
parent 763b3ec9e3
commit 0df62c80c6
11 changed files with 181 additions and 113 deletions

@ -1 +1 @@
Subproject commit a044032daca22e2d76d54d1e5e073e6527eb43de
Subproject commit d44f6107e607e3e23c137f4678235c12965af533

View file

@ -101,7 +101,7 @@ namespace HISP.Game.Chat
if (message.ToUpper().StartsWith("%RULES"))
return Command.Rules(message, args, user);
if (message.ToUpper().StartsWith("%PRISON"))
return Command.Prision(message, args, user);
return Command.Prison(message, args, user);
if (message.ToUpper().StartsWith("%NOCLIP"))
return Command.NoClip(message, args, user);
if (message.ToUpper().StartsWith("%STEALTH"))
@ -114,6 +114,8 @@ namespace HISP.Game.Chat
return Command.Escape(message, args, user);
if (message.ToUpper().StartsWith("%MODHORSE"))
return Command.ModHorse(message, args, user);
if (message.ToUpper().StartsWith("%DELITEM"))
return Command.DelItem(message, args, user);
if (message.ToUpper().StartsWith("%CALL HORSE"))
return Command.CallHorse(message, args, user);
return false;

View file

@ -6,6 +6,7 @@ using System.Collections.Generic;
using HISP.Game.Events;
using HISP.Game.Horse;
using System.Linq;
using HISP.Game.Inventory;
namespace HISP.Game.Chat
{
@ -20,7 +21,7 @@ namespace HISP.Game.Chat
continue;
if (client.LoggedIn)
{
if (client.LoggedinUser.Username.ToLower().Contains(name.ToLower()))
if (client.LoggedinUser.Username.ToLower().StartsWith(name.ToLower()))
{
return client.LoggedinUser;
}
@ -286,7 +287,7 @@ namespace HISP.Game.Chat
return true;
}
public static bool Prision(string message, string[] args, User user)
public static bool Prison(string message, string[] args, User user)
{
if (!(user.Administrator || user.Moderator))
return false;
@ -368,7 +369,41 @@ namespace HISP.Game.Chat
return true;
}
public static bool DelItem(string message, string[] args, User user)
{
if (args.Length <= 0)
return false;
if (!user.Administrator)
return false;
int itemId = 0;
try
{
itemId = int.Parse(args[0]);
User target = user;
if (args.Length > 1)
target = findNamePartial(args[1]);
if (target.Inventory.HasItemId(itemId))
{
InventoryItem itm = target.Inventory.GetItemByItemId(itemId);
foreach (ItemInstance instance in itm.ItemInstances)
{
itm.RemoveItem(instance);
}
}
}
catch (Exception)
{
return false;
}
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Goto(string message, string[] args, User user)
{
if (args.Length <= 0)
@ -464,7 +499,6 @@ namespace HISP.Game.Chat
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
@ -483,7 +517,8 @@ namespace HISP.Game.Chat
try
{
id = int.Parse(args[0]);
amount = int.Parse(args[2]);
if(args[1].ToUpper() == "COLOR")
amount = int.Parse(args[2]);
}
catch (Exception)
{
@ -546,6 +581,7 @@ namespace HISP.Game.Chat
user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Warp(string message, string[] args, User user)
{
@ -577,10 +613,13 @@ namespace HISP.Game.Chat
}
else
{
string areaName = string.Join(" ", args).ToLower();
string areaName = string.Join(" ", args).ToLower();
areaName = areaName.Trim();
if (areaName == "")
areaName = "Horse Isle";
try
{
User tp = findNamePartial(areaName);
User tp = GameServer.GetUserByName(areaName);
user.Teleport(tp.X, tp.Y);
formattedmessage += Messages.SuccessfullyWarpedToPlayer;
@ -591,7 +630,7 @@ namespace HISP.Game.Chat
{
foreach (World.Waypoint waypoint in World.Waypoints)
{
if (waypoint.Name.ToLower().Contains(areaName))
if (waypoint.Name.ToLower().StartsWith(areaName))
{
user.Teleport(waypoint.PosX, waypoint.PosY);
formattedmessage += Messages.SuccessfullyWarpedToLocation;

View file

@ -57,7 +57,11 @@ namespace HISP.Game.Events
return;
if (Database.HasPlayerCompletedRealTimeRiddle(RiddleId, winner.Id))
{
byte[] alreadyWonRiddleMessage = PacketBuilder.CreateChat(Messages.EventAlreadySovledRealTimeRiddle, PacketBuilder.CHAT_BOTTOM_RIGHT);
winner.LoggedinClient.SendPacket(alreadyWonRiddleMessage);
return;
}
LastWon = true;
@ -86,10 +90,13 @@ namespace HISP.Game.Events
}
public void EndEvent()
{
Active = false;
if(Active)
{
Active = false;
riddleTimeout.Dispose();
riddleTimeout = null;
riddleTimeout.Dispose();
riddleTimeout = null;
}
}
private void riddleTimedOut(object state)

View file

@ -119,6 +119,7 @@ namespace HISP.Game
public static string EventEndRealTimeRiddle;
public static string EventWonRealTimeRiddleForOthersFormat;
public static string EventWonRealTimeRiddleForYouFormat;
public static string EventAlreadySovledRealTimeRiddle;
// Events : Tack Shop Giveaway
public static string EventStartTackShopGiveawayFormat;

View file

@ -525,7 +525,7 @@ namespace HISP.Game
message += Messages.FormatTradeOfferHorse(horse.Name, tacked, horse.RandomId);
}
if(trade.Trader.Inventory.Count >= trade.Trader.MaxItems)
if(trade.OtherTrade.Trader.Inventory.Count >= trade.OtherTrade.Trader.MaxItems)
{
message += Messages.TradeOfferItemOtherPlayerInvFull;
}
@ -1762,6 +1762,7 @@ namespace HISP.Game
if (mine) // This is My DS.
{
GameServer.CheckMail(user);
user.DoRanchActions();
string title = ranch.Title;
@ -2799,17 +2800,7 @@ namespace HISP.Game
}
private static string buildTownHall(User user)
{
if(user.MailBox.UnreadMailCount > 0)
{
byte[] RipOffAOLSound = PacketBuilder.CreatePlaysoundPacket(Messages.MailSe);
user.LoggedinClient.SendPacket(RipOffAOLSound);
byte[] mailReceivedText = PacketBuilder.CreateChat(Messages.MailReceivedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(mailReceivedText);
user.MailBox.ReadAllMail();
}
GameServer.CheckMail(user);
string message = Messages.CityHallMenu;
message += Messages.ExitThisPlace;

View file

@ -112,13 +112,13 @@ namespace HISP.Player
Trader.LoggedinClient.SendPacket(tradeYouHaveTooManyHorses);
fail = true;
}
if(OtherTrade.Trader.Money + MoneyOffered > 2100000000)
if(MoneyOffered > 0 && OtherTrade.Trader.Money + MoneyOffered > 2100000000)
{
byte[] tradeOtherHasTooMuchMoney = PacketBuilder.CreateChat(Messages.TradeWillGiveOtherTooMuchMoney, PacketBuilder.CHAT_BOTTOM_RIGHT);
Trader.LoggedinClient.SendPacket(tradeOtherHasTooMuchMoney);
fail = true;
}
if(Trader.Money + OtherTrade.MoneyOffered > 2100000000)
if(OtherTrade.MoneyOffered > 0 && Trader.Money + OtherTrade.MoneyOffered > 2100000000)
{
byte[] tradeYouHasTooMuchMoney = PacketBuilder.CreateChat(Messages.TradeWillGiveYouTooMuchMoney, PacketBuilder.CHAT_BOTTOM_RIGHT);
Trader.LoggedinClient.SendPacket(tradeYouHasTooMuchMoney);
@ -135,7 +135,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 > ConfigReader.MAX_STACK)
{
itemYouFail = true;
}
@ -155,7 +155,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 > ConfigReader.MAX_STACK)
{
itemOtherFail = true;
}

View file

@ -409,96 +409,109 @@ namespace HISP.Server
if (warnTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
warnTimer.Change(warnInterval, warnInterval);
if (!LoggedIn) // Must be either login or policy-file-request
try
{
if (Encoding.UTF8.GetString(Packet).StartsWith("<policy-file-request/>")) // Policy File Request
if (!LoggedIn) // Must be either login or policy-file-request
{
GameServer.OnCrossdomainPolicyRequest(this);
if (Encoding.UTF8.GetString(Packet).StartsWith("<policy-file-request/>")) // Policy File Request
{
GameServer.OnCrossdomainPolicyRequest(this);
}
switch (identifier)
{
case PacketBuilder.PACKET_LOGIN:
GameServer.OnLoginRequest(this, Packet);
break;
}
}
switch (identifier)
else
{
case PacketBuilder.PACKET_LOGIN:
GameServer.OnLoginRequest(this, Packet);
break;
switch (identifier)
{
case PacketBuilder.PACKET_LOGIN:
GameServer.OnUserInfoRequest(this, Packet);
break;
case PacketBuilder.PACKET_MOVE:
GameServer.OnMovementPacket(this, Packet);
break;
case PacketBuilder.PACKET_PLAYERINFO:
GameServer.OnPlayerInfoPacket(this, Packet);
break;
case PacketBuilder.PACKET_PLAYER:
GameServer.OnProfilePacket(this, Packet);
break;
case PacketBuilder.PACKET_CHAT:
GameServer.OnChatPacket(this, Packet);
break;
case PacketBuilder.PACKET_CLICK:
GameServer.OnClickPacket(this, Packet);
break;
case PacketBuilder.PACKET_KEEP_ALIVE:
GameServer.OnKeepAlive(this, Packet);
break;
case PacketBuilder.PACKET_TRANSPORT:
GameServer.OnTransportUsed(this, Packet);
break;
case PacketBuilder.PACKET_INVENTORY:
GameServer.OnInventoryRequested(this, Packet);
break;
case PacketBuilder.PACKET_DYNAMIC_BUTTON:
GameServer.OnDynamicButtonPressed(this, Packet);
break;
case PacketBuilder.PACKET_DYNAMIC_INPUT:
GameServer.OnDynamicInputReceived(this, Packet);
break;
case PacketBuilder.PACKET_ITEM_INTERACTION:
GameServer.OnItemInteraction(this, Packet);
break;
case PacketBuilder.PACKET_ARENA_SCORE:
GameServer.OnArenaScored(this, Packet);
break;
case PacketBuilder.PACKET_QUIT:
GameServer.OnQuitPacket(this, Packet);
break;
case PacketBuilder.PACKET_NPC:
GameServer.OnNpcInteraction(this, Packet);
break;
case PacketBuilder.PACKET_BIRDMAP:
GameServer.OnBirdMapRequested(this, Packet);
break;
case PacketBuilder.PACKET_SWFMODULE:
GameServer.OnSwfModuleCommunication(this, Packet);
break;
case PacketBuilder.PACKET_HORSE:
GameServer.OnHorseInteraction(this, Packet);
break;
case PacketBuilder.PACKET_WISH:
GameServer.OnWish(this, Packet);
break;
case PacketBuilder.PACKET_RANCH:
GameServer.OnRanchPacket(this, Packet);
break;
case PacketBuilder.PACKET_AUCTION:
GameServer.OnAuctionPacket(this, Packet);
break;
case PacketBuilder.PACKET_PLAYER_INTERACTION:
GameServer.OnPlayerInteration(this, Packet);
break;
case PacketBuilder.PACKET_SOCIALS:
GameServer.OnSocialPacket(this, Packet);
break;
default:
Logger.ErrorPrint("Unimplemented Packet: " + BitConverter.ToString(Packet).Replace('-', ' '));
break;
}
}
}
else
catch(Exception e)
{
switch (identifier)
{
case PacketBuilder.PACKET_LOGIN:
GameServer.OnUserInfoRequest(this, Packet);
break;
case PacketBuilder.PACKET_MOVE:
GameServer.OnMovementPacket(this, Packet);
break;
case PacketBuilder.PACKET_PLAYERINFO:
GameServer.OnPlayerInfoPacket(this, Packet);
break;
case PacketBuilder.PACKET_PLAYER:
GameServer.OnProfilePacket(this, Packet);
break;
case PacketBuilder.PACKET_CHAT:
GameServer.OnChatPacket(this, Packet);
break;
case PacketBuilder.PACKET_CLICK:
GameServer.OnClickPacket(this, Packet);
break;
case PacketBuilder.PACKET_KEEP_ALIVE:
GameServer.OnKeepAlive(this, Packet);
break;
case PacketBuilder.PACKET_TRANSPORT:
GameServer.OnTransportUsed(this, Packet);
break;
case PacketBuilder.PACKET_INVENTORY:
GameServer.OnInventoryRequested(this, Packet);
break;
case PacketBuilder.PACKET_DYNAMIC_BUTTON:
GameServer.OnDynamicButtonPressed(this, Packet);
break;
case PacketBuilder.PACKET_DYNAMIC_INPUT:
GameServer.OnDynamicInputReceived(this, Packet);
break;
case PacketBuilder.PACKET_ITEM_INTERACTION:
GameServer.OnItemInteraction(this,Packet);
break;
case PacketBuilder.PACKET_ARENA_SCORE:
GameServer.OnArenaScored(this, Packet);
break;
case PacketBuilder.PACKET_QUIT:
GameServer.OnQuitPacket(this, Packet);
break;
case PacketBuilder.PACKET_NPC:
GameServer.OnNpcInteraction(this, Packet);
break;
case PacketBuilder.PACKET_BIRDMAP:
GameServer.OnBirdMapRequested(this, Packet);
break;
case PacketBuilder.PACKET_SWFMODULE:
GameServer.OnSwfModuleCommunication(this, Packet);
break;
case PacketBuilder.PACKET_HORSE:
GameServer.OnHorseInteraction(this, Packet);
break;
case PacketBuilder.PACKET_WISH:
GameServer.OnWish(this, Packet);
break;
case PacketBuilder.PACKET_RANCH:
GameServer.OnRanchPacket(this, Packet);
break;
case PacketBuilder.PACKET_AUCTION:
GameServer.OnAuctionPacket(this, Packet);
break;
case PacketBuilder.PACKET_PLAYER_INTERACTION:
GameServer.OnPlayerInteration(this, Packet);
break;
case PacketBuilder.PACKET_SOCIALS:
GameServer.OnSocialPacket(this, Packet);
break;
default:
Logger.ErrorPrint("Unimplemented Packet: " + BitConverter.ToString(Packet).Replace('-', ' '));
break;
}
Logger.ErrorPrint("Unhandled Exception: " + e.ToString());
Logger.ErrorPrint(e.Message);
Logger.ErrorPrint("");
Logger.ErrorPrint(e.StackTrace);
Kick("Unhandled Exception: " + e.ToString());
}
}

View file

@ -1048,6 +1048,7 @@ namespace HISP.Server
Messages.EventEndRealTimeRiddle = gameData.messages.events.real_time_riddle.event_end;
Messages.EventWonRealTimeRiddleForOthersFormat = gameData.messages.events.real_time_riddle.event_won_others;
Messages.EventWonRealTimeRiddleForYouFormat = gameData.messages.events.real_time_riddle.event_won_you;
Messages.EventAlreadySovledRealTimeRiddle = gameData.messages.events.real_time_riddle.event_solved_already;
// Events : Tack Shop Giveaway
@ -2042,7 +2043,7 @@ namespace HISP.Server
// Awards
Messages.AwardHeader = gameData.messages.meta.awards_page.awards_header;
Messages.AwardOthersFormat = gameData.messages.meta.awards_page.awards_head;
Messages.AwardOthersFormat = gameData.messages.meta.awards_page.awards_others_header;
Messages.NoAwards = gameData.messages.meta.awards_page.no_awards;
Messages.AwardFormat = gameData.messages.meta.awards_page.award_format;

View file

@ -7688,6 +7688,20 @@ namespace HISP.Server
return count;
}
public static void CheckMail(User user)
{
if (user.MailBox.UnreadMailCount > 0)
{
byte[] RipOffAOLSound = PacketBuilder.CreatePlaysoundPacket(Messages.MailSe);
user.LoggedinClient.SendPacket(RipOffAOLSound);
byte[] mailReceivedText = PacketBuilder.CreateChat(Messages.MailReceivedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(mailReceivedText);
user.MailBox.ReadAllMail();
}
}
public static int GetNumberOfModsOnline()
{
int count = 0;

@ -1 +1 @@
Subproject commit 007bccccbc19fe4469ad7ac4aba63effeb520128
Subproject commit 66bbfd79136875e04822171c5b755f0129b23061