Fix MULTIROOM priority shenanigans

This commit is contained in:
Bluzume 2021-11-26 21:29:45 -05:00
parent 52e5e6a883
commit 4165b01e00
4 changed files with 92 additions and 14 deletions

View file

@ -92,6 +92,8 @@ namespace HISP.Game.Chat
{
if (message.ToUpper().StartsWith("%GIVE"))
return Command.Give(message, args, user);
if (message.ToUpper().StartsWith("%SWF"))
return Command.Swf(message, args, user);
if (message.ToUpper().StartsWith("%GOTO"))
return Command.Goto(message, args, user);
if (message.ToUpper().StartsWith("%JUMP"))
@ -492,7 +494,7 @@ namespace HISP.Game.Chat
}
public static string EscapeMessage(string message)
{
return message.Replace("&", "&amp;").Replace("<", "&lt;");
return message.Replace("<", "&lt;");
}
public static string FormatChatForOthers(User user, ChatChannel channel, string message, bool autoReply=false)

View file

@ -76,20 +76,48 @@ namespace HISP.Game.Chat
int itemId = 0;
try
{
itemId = int.Parse(args[1]);
Item.GetItemById(itemId);
ItemInstance newItemInstance = new ItemInstance(itemId);
if(args.Length >= 3)
if(args[1] != "RANDOM")
{
findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance);
itemId = int.Parse(args[1]);
}
else
{
itemId = Item.GetRandomItem(false).Id;
}
Item.GetItemById(itemId); // Calling this makes sure this item id exists.
ItemInstance newItemInstance = new ItemInstance(itemId);
if (itemId == Item.Present)
newItemInstance.Data = Item.GetRandomItem(false).Id;
if (args.Length >= 3)
{
if(args[2] == "ALL")
{
foreach (GameClient client in GameClient.ConnectedClients)
{
if (client.LoggedIn)
{
ItemInstance itmInstance = new ItemInstance(itemId);
if (itemId == Item.Present)
itmInstance.Data = Item.GetRandomItem(false).Id;
client.LoggedinUser.Inventory.AddIgnoringFull(itmInstance);
}
}
}
else
{
findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance);
}
}
else
{
user.Inventory.AddIgnoringFull(newItemInstance);
}
}
catch(Exception)
{
@ -112,8 +140,6 @@ namespace HISP.Game.Chat
{
user.HorseInventory.AddHorse(horse);
}
}
catch (Exception)
{
@ -155,8 +181,6 @@ namespace HISP.Game.Chat
{
user.AddMoney(money);
}
}
catch (Exception)
{
@ -194,6 +218,44 @@ namespace HISP.Game.Chat
return true;
}
public static bool Swf(string message, string[] args, User user)
{
if (args.Length <= 2)
return false;
if (!(user.Administrator || user.Moderator))
return false;
try
{
string swfName = args[0];
string swfUser = args[1];
byte[] packetBytes = PacketBuilder.CreateSwfModulePacket(swfName, PacketBuilder.PACKET_SWF_MODULE_FORCE);
if (swfUser.ToUpper() == "ALL")
{
foreach (GameClient client in GameClient.ConnectedClients)
{
if (client.LoggedIn)
client.SendPacket(packetBytes);
}
}
else
{
User player = findNamePartial(args[2]);
player.LoggedinClient.SendPacket(packetBytes);
}
}
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 UnBan(string message, string[] args, User user)
{
if(args.Length <= 0)

View file

@ -121,6 +121,20 @@ namespace HISP.Game.Items
public int ItemId;
public int ItemCount;
}
public static ItemInformation GetRandomItem(bool allowQuest)
{
while (true)
{
Item.ItemInformation itm = Items[GameServer.RandomNumberGenerator.Next(0, Items.Length)];
if(!allowQuest)
if (itm.Type == "QUEST")
continue;
return itm;
}
}
public static void UseItem(User user, ItemInstance item)
{
if (user.Inventory.HasItem(item.RandomId))

View file

@ -64,7 +64,6 @@ namespace HISP.Game
}
}
}
public Multiroom(int x, int y)
{
this.x = x;
@ -72,6 +71,7 @@ namespace HISP.Game
multirooms.Add(this);
}
public void Join(User user)
{
if (!JoinedUsers.Contains(user))