Fix bugs (bzzt)

This commit is contained in:
Bluzume 2021-11-08 22:00:20 -05:00
parent 7da883115b
commit 07952c6c02
10 changed files with 75 additions and 72 deletions

@ -1 +1 @@
Subproject commit 98f385f4adaad7e58d265001f4f109869ca9c88d Subproject commit 257f8910d6f8bf2024b9785d64871c1ebe35cce7

View file

@ -249,15 +249,21 @@ namespace HISP.Game
string chatMessage = Messages.ArenaResultsMessage; string chatMessage = Messages.ArenaResultsMessage;
string[] avaliblePlacings = new string[6] { Messages.ArenaFirstPlace, Messages.ArenaSecondPlace, Messages.ArenaThirdPlace, Messages.ArenaFourthPlace, Messages.ArenaFifthPlace, Messages.ArenaSixthPlace }; string[] avaliblePlacings = new string[6] { Messages.ArenaFirstPlace, Messages.ArenaSecondPlace, Messages.ArenaThirdPlace, Messages.ArenaFourthPlace, Messages.ArenaFifthPlace, Messages.ArenaSixthPlace };
int[] expRewards = ExpRewards.ToArray().Reverse().ToArray();
int place = 0; int place = 0;
ArenaEntry[] winners = Entries.OrderByDescending(o => o.SubmitScore).ToArray(); ArenaEntry[] winners = Entries.OrderByDescending(o => o.SubmitScore).ToArray();
int[] expRewards = new int[winners.Length];
Array.Copy(ExpRewards, expRewards, winners.Length);
expRewards = expRewards.Reverse().ToArray();
foreach (ArenaEntry entry in winners) foreach (ArenaEntry entry in winners)
{ {
string placing = avaliblePlacings[place % avaliblePlacings.Length]; string placing = avaliblePlacings[place % avaliblePlacings.Length];
chatMessage += Messages.FormatArenaPlacing(placing, entry.EnteredUser.Username, entry.SubmitScore); chatMessage += Messages.FormatArenaPlacing(placing, entry.EnteredUser.Username, entry.SubmitScore);
place++; place++;
} }
place = 0; place = 0;

View file

@ -215,8 +215,13 @@ namespace HISP.Game.Chat
else if (message.ToUpper().StartsWith("!QUIZ")) else if (message.ToUpper().StartsWith("!QUIZ"))
return Command.Quiz(message, args, user); return Command.Quiz(message, args, user);
else if (message.ToUpper().StartsWith("!WARP")) else if (message.ToUpper().StartsWith("!WARP")) // some stupid handling on this one.
return Command.Warp(message, args, user); {
string placeName = message.Substring("!WARP".Length);
placeName = placeName.Trim();
return Command.Warp(message, placeName.Split(' '), user);
}
else if (message.ToUpper().StartsWith("!DANCE")) else if (message.ToUpper().StartsWith("!DANCE"))
return Command.Dance(message, args, user); return Command.Dance(message, args, user);

View file

@ -642,41 +642,33 @@ namespace HISP.Game.Chat
doCommand:; doCommand:;
if (args.Length <= 0) string areaName = string.Join(" ", args).ToLower();
areaName = areaName.Trim();
if (areaName == "")
areaName = "Horse Isle";
try
{ {
goto cantUnderstandCommand; User tp = GameServer.GetUserByName(areaName);
user.Teleport(tp.X, tp.Y);
formattedmessage += Messages.SuccessfullyWarpedToPlayer;
goto playSwf;
} }
else catch (KeyNotFoundException)
{ {
string areaName = string.Join(" ", args).ToLower(); foreach (World.Waypoint waypoint in World.Waypoints)
areaName = areaName.Trim();
if (areaName == "")
areaName = "Horse Isle";
try
{ {
User tp = GameServer.GetUserByName(areaName); if (waypoint.Name.ToLower().StartsWith(areaName))
user.Teleport(tp.X, tp.Y);
formattedmessage += Messages.SuccessfullyWarpedToPlayer;
goto playSwf;
}
catch (KeyNotFoundException)
{
foreach (World.Waypoint waypoint in World.Waypoints)
{ {
if (waypoint.Name.ToLower().StartsWith(areaName)) user.Teleport(waypoint.PosX, waypoint.PosY);
{ formattedmessage += Messages.SuccessfullyWarpedToLocation;
user.Teleport(waypoint.PosX, waypoint.PosY); goto playSwf;
formattedmessage += Messages.SuccessfullyWarpedToLocation;
goto playSwf;
}
} }
goto cantUnderstandCommand;
} }
} goto cantUnderstandCommand;
}
playSwf:; playSwf:;
byte[] swfPacket = PacketBuilder.CreateSwfModulePacket("warpcutscene", PacketBuilder.PACKET_SWF_CUTSCENE); byte[] swfPacket = PacketBuilder.CreateSwfModulePacket("warpcutscene", PacketBuilder.PACKET_SWF_CUTSCENE);

View file

@ -52,11 +52,23 @@ namespace HISP.Game.Inventory
horsesList.Add(horse); horsesList.Add(horse);
} }
public void DeleteHorseId(int id, bool removeFromDb = true)
{
foreach(HorseInstance horse in HorseList)
{
if(horse.RandomId == id)
{
if (removeFromDb)
Database.RemoveHorse(horse.RandomId);
horsesList.Remove(horse);
}
}
}
public void DeleteHorse(HorseInstance horse, bool removeFromDb=true) public void DeleteHorse(HorseInstance horse, bool removeFromDb=true)
{ {
if(removeFromDb) DeleteHorseId(horse.RandomId, removeFromDb);
Database.RemoveHorse(horse.RandomId);
horsesList.Remove(horse);
} }
public bool HorseIdExist(int randomId) public bool HorseIdExist(int randomId)

View file

@ -236,7 +236,7 @@ namespace HISP.Game
public static string PlayerHereAddBuddyButton; public static string PlayerHereAddBuddyButton;
public static string PlayerHereTagButton; public static string PlayerHereTagButton;
public static string PlayerHerePmButton; public static string PmButton;
// Auction House // Auction House
public static string AuctionsRunning; public static string AuctionsRunning;
@ -1085,7 +1085,6 @@ namespace HISP.Game
public static string MuteButton; public static string MuteButton;
public static string HearButton; public static string HearButton;
public static string PmButton;
public static int ThreeMonthSubscripitionIcon; public static int ThreeMonthSubscripitionIcon;
public static int YearSubscriptionIcon; public static int YearSubscriptionIcon;
@ -1529,9 +1528,9 @@ namespace HISP.Game
} }
// Player Interactions // Player Interactions
public static string FormatPlayerHerePMButton(string playerName) public static string FormatPmButton(string playerName)
{ {
return PlayerHerePmButton.Replace("%PLAYERNAME%", playerName); return PmButton.Replace("%PLAYERNAME%", playerName);
} }
public static string FormatPlayerHereTagButton(int playerId) public static string FormatPlayerHereTagButton(int playerId)
{ {
@ -2249,9 +2248,9 @@ namespace HISP.Game
{ {
return HorseNameYoursFormat.Replace("%NAME%", name); return HorseNameYoursFormat.Replace("%NAME%", name);
} }
public static string FormatHorseNameOthers(string name) public static string FormatHorseNameOthers(string name, string username)
{ {
return HorseNameOthersFormat.Replace("%NAME%", name); return HorseNameOthersFormat.Replace("%NAME%", name).Replace("%USERNAME%", username);
} }
public static string FormatHorseDescription(string Description) public static string FormatHorseDescription(string Description)
{ {
@ -2487,10 +2486,6 @@ namespace HISP.Game
{ {
return HearButton.Replace("%PLAYERID%", playerId.ToString()); return HearButton.Replace("%PLAYERID%", playerId.ToString());
} }
public static string FormatPmButton(string playerName)
{
return PmButton.Replace("%USERNAME%", playerName);
}
public static string FormatPlayerEntry(string iconFormat, string username, int userId, int time, int x, int y, bool idle, bool muteOrHear, bool isYou) public static string FormatPlayerEntry(string iconFormat, string username, int userId, int time, int x, int y, bool idle, bool muteOrHear, bool isYou)
{ {
string xy = FormatMapLocation(x, y); string xy = FormatMapLocation(x, y);
@ -2501,7 +2496,7 @@ namespace HISP.Game
if (isYou) if (isYou)
msg = msg.Replace("%MUTEORHEAR%", "").Replace("%PMBUTTON%", ""); msg = msg.Replace("%MUTEORHEAR%", "").Replace("%PMBUTTON%", "");
else else
msg = msg.Replace("%MUTEORHEAR%", muteOrHear ? hearButton : muteButton).Replace("%PMBUTTON", pmButton); msg = msg.Replace("%MUTEORHEAR%", muteOrHear ? hearButton : muteButton).Replace("%PMBUTTON%", pmButton);
return msg; return msg;
} }
public static string FormatOnlineBuddyEntry(string iconFormat, string username, int userId, int time, int x, int y) public static string FormatOnlineBuddyEntry(string iconFormat, string username, int userId, int time, int x, int y)

View file

@ -60,7 +60,7 @@ namespace HISP.Game
buttons += Messages.FormatPlayerHereTagButton(playerAt.Id); buttons += Messages.FormatPlayerHereTagButton(playerAt.Id);
else else
buttons += Messages.FormatPlayerHereBuddyButton(playerAt.Id); buttons += Messages.FormatPlayerHereBuddyButton(playerAt.Id);
buttons += Messages.FormatPlayerHerePMButton(playerAt.Username); buttons += Messages.FormatPmButton(playerAt.Username);
playersHere += Messages.FormatPlayerHereMenu(playerAt.GetPlayerListIcon(), playerAt.Username,buttons); playersHere += Messages.FormatPlayerHereMenu(playerAt.GetPlayerListIcon(), playerAt.Username,buttons);
count++; count++;
@ -1670,15 +1670,13 @@ namespace HISP.Game
HorseInstance[] horses = Database.GetCheapestHorseAutoSell(); HorseInstance[] horses = Database.GetCheapestHorseAutoSell();
foreach(HorseInstance horse in horses) foreach(HorseInstance horse in horses)
{ {
if(horse.AutoSell > 0) message += Messages.FormatCityHallCheapAutoSellEntry(horse.AutoSell, Database.GetUsername(horse.Owner), horse.Name, horse.Color, horse.Breed.Name, horse.BasicStats.Experience);
message += Messages.FormatCityHallCheapAutoSellEntry(horse.AutoSell, Database.GetUsername(horse.Owner), horse.Name, horse.Color, horse.Breed.Name, horse.BasicStats.Experience);
} }
message += Messages.CityHallMostExpAutoSells; message += Messages.CityHallMostExpAutoSells;
horses = Database.GetBiggestExpAutoSell(); HorseInstance[] horsesExp = Database.GetBiggestExpAutoSell();
foreach (HorseInstance horse in horses) foreach (HorseInstance horse in horsesExp)
{ {
if(horse.AutoSell > 0) message += Messages.FormatCityHallBestExpAutoSellEntry(horse.BasicStats.Experience, Database.GetUsername(horse.Owner), horse.Name, horse.AutoSell, horse.Color, horse.Breed.Name);
message += Messages.FormatCityHallBestExpAutoSellEntry(horse.BasicStats.Experience, Database.GetUsername(horse.Owner), horse.Name, horse.AutoSell, horse.Color, horse.Breed.Name);
} }
message += Messages.BackToMap; message += Messages.BackToMap;
message += Messages.MetaTerminator; message += Messages.MetaTerminator;
@ -2306,7 +2304,7 @@ namespace HISP.Game
if (isMyHorse) if (isMyHorse)
message += Messages.FormatHorseNameYours(horse.Name); message += Messages.FormatHorseNameYours(horse.Name);
else else
message += Messages.FormatHorseNameOthers(horse.Name); message += Messages.FormatHorseNameOthers(horse.Name, Database.GetUsername(horse.Owner));
message += Messages.FormatHorseDescription(horse.Description); message += Messages.FormatHorseDescription(horse.Description);
message += Messages.FormatHorseHandsHigh(horse.Color, horse.Breed.Name, horse.Gender, HorseInfo.CalculateHands(horse.AdvancedStats.Height, false)); message += Messages.FormatHorseHandsHigh(horse.Color, horse.Breed.Name, horse.Gender, HorseInfo.CalculateHands(horse.AdvancedStats.Height, false));

View file

@ -5297,7 +5297,7 @@ namespace HISP.Server
db.Open(); db.Open();
MySqlCommand sqlCommand = db.CreateCommand(); MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT * FROM Horses ORDER BY experience DESC LIMIT 50"; sqlCommand.CommandText = "SELECT * FROM Horses WHERE autoSell > 0 ORDER BY experience DESC LIMIT 50";
sqlCommand.Prepare(); sqlCommand.Prepare();
MySqlDataReader reader = sqlCommand.ExecuteReader(); MySqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read()) while (reader.Read())
@ -5316,7 +5316,7 @@ namespace HISP.Server
db.Open(); db.Open();
MySqlCommand sqlCommand = db.CreateCommand(); MySqlCommand sqlCommand = db.CreateCommand();
sqlCommand.CommandText = "SELECT * FROM Horses ORDER BY autoSell LIMIT 100"; sqlCommand.CommandText = "SELECT * FROM Horses WHERE autoSell > 0 ORDER BY autoSell LIMIT 100";
sqlCommand.Prepare(); sqlCommand.Prepare();
MySqlDataReader reader = sqlCommand.ExecuteReader(); MySqlDataReader reader = sqlCommand.ExecuteReader();
while(reader.Read()) while(reader.Read())

View file

@ -1169,7 +1169,7 @@ namespace HISP.Server
Messages.PlayerHereTradeButton = gameData.messages.meta.player_interaction.trade_button; Messages.PlayerHereTradeButton = gameData.messages.meta.player_interaction.trade_button;
Messages.PlayerHereAddBuddyButton = gameData.messages.meta.player_interaction.buddy_button; Messages.PlayerHereAddBuddyButton = gameData.messages.meta.player_interaction.buddy_button;
Messages.PlayerHereTagButton = gameData.messages.meta.player_interaction.tag_button; Messages.PlayerHereTagButton = gameData.messages.meta.player_interaction.tag_button;
Messages.PlayerHerePmButton = gameData.messages.meta.player_interaction.pm_button; Messages.PmButton = gameData.messages.meta.player_interaction.pm_button;
// Auction // Auction
@ -1950,7 +1950,6 @@ namespace HISP.Server
Messages.MuteButton = gameData.messages.meta.player_list.mute_button; Messages.MuteButton = gameData.messages.meta.player_list.mute_button;
Messages.HearButton = gameData.messages.meta.player_list.hear_button; Messages.HearButton = gameData.messages.meta.player_list.hear_button;
Messages.PmButton = gameData.messages.meta.player_list.pm_button;
Messages.ThreeMonthSubscripitionIcon = gameData.messages.meta.player_list.icon_subbed_3month; Messages.ThreeMonthSubscripitionIcon = gameData.messages.meta.player_list.icon_subbed_3month;
Messages.YearSubscriptionIcon = gameData.messages.meta.player_list.icon_subbed_year; Messages.YearSubscriptionIcon = gameData.messages.meta.player_list.icon_subbed_year;

View file

@ -3042,7 +3042,6 @@ namespace HISP.Server
{ {
User seller = GetUserById(horseToSell.Owner); User seller = GetUserById(horseToSell.Owner);
seller.HorseInventory.DeleteHorse(horseToSell, false); seller.HorseInventory.DeleteHorse(horseToSell, false);
seller.AddMoney(horseToSell.AutoSell); seller.AddMoney(horseToSell.AutoSell);
byte[] horseBrought = PacketBuilder.CreateChat(Messages.FormatAutoSellSold(horseToSell.Name, horseToSell.AutoSell, sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] horseBrought = PacketBuilder.CreateChat(Messages.FormatAutoSellSold(horseToSell.Name, horseToSell.AutoSell, sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
@ -5807,11 +5806,7 @@ namespace HISP.Server
break; break;
default: default:
channel = Chat.ChatChannel.Dm; channel = Chat.ChatChannel.Dm;
nameTo = channelString.Substring(1); nameTo = channelString.Substring(1).Trim();
if (nameTo == "")
break;
break; break;
} }
@ -5890,23 +5885,24 @@ namespace HISP.Server
GameClient[] recipiants = Chat.GetRecipiants(sender.LoggedinUser, channel, nameTo); GameClient[] recipiants = Chat.GetRecipiants(sender.LoggedinUser, channel, nameTo);
// Spam Protection
if(channel == Chat.ChatChannel.Dm) if(channel == Chat.ChatChannel.Dm)
{ {
try if(recipiants.Length <= 0)
{
nameTo = GetUserByNameStartswith(nameTo).Username;
}
catch(KeyNotFoundException)
{ {
byte[] cantFindPlayer = PacketBuilder.CreateChat(Messages.CantFindPlayerToPrivateMessage, PacketBuilder.CHAT_BOTTOM_RIGHT); byte[] cantFindPlayer = PacketBuilder.CreateChat(Messages.CantFindPlayerToPrivateMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cantFindPlayer); sender.SendPacket(cantFindPlayer);
return; return;
} }
else
{
nameTo = recipiants[0].LoggedinUser.Username;
}
} }
else if(channel == Chat.ChatChannel.Ads)
// Spam filter
if(channel == Chat.ChatChannel.Ads)
{ {
if(!sender.LoggedinUser.CanUseAdsChat && !sender.LoggedinUser.Administrator) if(!sender.LoggedinUser.CanUseAdsChat && !sender.LoggedinUser.Administrator)
{ {