mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 21:55:42 +12:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
fb3ae2a2d5
10 changed files with 70 additions and 48 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 1f9bc06a178dc61964b989a44231c263cdd4edbb
|
Subproject commit 0f9268907fb3cd9d0da9c8ab1cba8308de0e5656
|
|
@ -16,7 +16,7 @@ namespace HISP.Game
|
||||||
private static List<Arena> arenas = new List<Arena>();
|
private static List<Arena> arenas = new List<Arena>();
|
||||||
private List<ArenaEntry> entries;
|
private List<ArenaEntry> entries;
|
||||||
private Timer arenaTimeout;
|
private Timer arenaTimeout;
|
||||||
|
public static int[] ExpRewards;
|
||||||
public int Id;
|
public int Id;
|
||||||
public string Type;
|
public string Type;
|
||||||
public int EntryCost;
|
public int EntryCost;
|
||||||
|
@ -247,23 +247,9 @@ namespace HISP.Game
|
||||||
if(Mode == "COMPETING")
|
if(Mode == "COMPETING")
|
||||||
{
|
{
|
||||||
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[] expRewards = new int[Entries.Length];
|
|
||||||
expRewards[0] = 1;
|
|
||||||
int expAwardMul = 1;
|
|
||||||
for(int i = 1; i < Entries.Length; i++)
|
|
||||||
{
|
|
||||||
expRewards[i] = 2 * expAwardMul;
|
|
||||||
|
|
||||||
if (expAwardMul == 1)
|
|
||||||
expAwardMul = 2;
|
|
||||||
else
|
|
||||||
expAwardMul += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
|
@ -439,15 +439,23 @@ namespace HISP.Game.Chat
|
||||||
|
|
||||||
if(channel == ChatChannel.Dm)
|
if(channel == ChatChannel.Dm)
|
||||||
{
|
{
|
||||||
if (to != null)
|
if (to != null && to != "")
|
||||||
{
|
{
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameClient.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
|
{
|
||||||
if (!client.LoggedinUser.MutePrivateMessage && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MutePrivateMessage && !client.LoggedinUser.MuteAll)
|
||||||
|
{
|
||||||
if (client.LoggedinUser.Username.ToLower().StartsWith(to.ToLower()))
|
if (client.LoggedinUser.Username.ToLower().StartsWith(to.ToLower()))
|
||||||
|
{
|
||||||
recipiants.Add(client);
|
recipiants.Add(client);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return recipiants.ToArray();
|
return recipiants.ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace HISP.Game.Inventory
|
||||||
|
|
||||||
public InventoryItem[] GetItemList()
|
public InventoryItem[] GetItemList()
|
||||||
{
|
{
|
||||||
return inventoryItems.OrderBy(o => o.ItemInstances[0].GetItemInfo().SortBy).ToArray();
|
return inventoryItems.OrderBy(o => Item.GetItemById(o.ItemId).SortBy).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@ namespace HISP.Game.Items
|
||||||
|
|
||||||
public int GetMiscFlag(int no)
|
public int GetMiscFlag(int no)
|
||||||
{
|
{
|
||||||
if (MiscFlags.Length <= no)
|
if (no < 0)
|
||||||
|
return 0;
|
||||||
|
if (no >= MiscFlags.Length)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return MiscFlags[no];
|
return MiscFlags[no];
|
||||||
|
|
|
@ -864,7 +864,7 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20);
|
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20);
|
||||||
if (scores.Length <= 0)
|
if (scores.Length <= 0)
|
||||||
return "ERROR: No scores recorded.";
|
return "ERROR: No scores recorded." + Messages.BackToMap + Messages.MetaTerminator;
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
||||||
message += Messages.FormatHighscoreHeader(gameName);
|
message += Messages.FormatHighscoreHeader(gameName);
|
||||||
|
@ -881,7 +881,7 @@ namespace HISP.Game
|
||||||
{
|
{
|
||||||
Highscore.HighscoreTableEntry[] scores = Database.GetTopWinners(gameName, 20);
|
Highscore.HighscoreTableEntry[] scores = Database.GetTopWinners(gameName, 20);
|
||||||
if (scores.Length <= 0)
|
if (scores.Length <= 0)
|
||||||
return "No wins recorded.";
|
return "ERROR: No wins recorded." + Messages.BackToMap + Messages.MetaTerminator;
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
||||||
message += Messages.FormatWinlooseHeader(gameName);
|
message += Messages.FormatWinlooseHeader(gameName);
|
||||||
|
@ -896,9 +896,9 @@ namespace HISP.Game
|
||||||
}
|
}
|
||||||
public static string BuildTopTimes(string gameName)
|
public static string BuildTopTimes(string gameName)
|
||||||
{
|
{
|
||||||
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20);
|
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20, false);
|
||||||
if (scores.Length <= 0)
|
if (scores.Length <= 0)
|
||||||
return "No times recorded.";
|
return "ERROR: No times recorded. "+Messages.BackToMap+Messages.MetaTerminator;
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
||||||
message += Messages.FormatBestTimeHeader(gameName);
|
message += Messages.FormatBestTimeHeader(gameName);
|
||||||
|
@ -2512,14 +2512,14 @@ namespace HISP.Game
|
||||||
|
|
||||||
foreach(InventoryItem item in user.Inventory.GetItemList())
|
foreach(InventoryItem item in user.Inventory.GetItemList())
|
||||||
{
|
{
|
||||||
Item.ItemInformation itemInfo = item.ItemInstances[0].GetItemInfo();
|
Item.ItemInformation itemInfo = Item.GetItemById(item.ItemId);
|
||||||
if (itemInfo.Type == "TACK")
|
if (itemInfo.Type == "TACK")
|
||||||
{
|
{
|
||||||
if (horse.Breed.Type == "camel" && itemInfo.GetMiscFlag(2) != 1)
|
if (horse.Breed.Type == "camel" && itemInfo.GetMiscFlag(1) != 1)
|
||||||
continue;
|
continue;
|
||||||
else if (horse.Breed.Type == "llama" && itemInfo.GetMiscFlag(2) != 2)
|
else if (horse.Breed.Type == "llama" && itemInfo.GetMiscFlag(1) != 2)
|
||||||
continue;
|
continue;
|
||||||
else if (itemInfo.GetMiscFlag(2) != 0)
|
else if (itemInfo.GetMiscFlag(1) != 0)
|
||||||
continue;
|
continue;
|
||||||
message += Messages.FormatHorseEquip(itemInfo.IconId, item.ItemInstances.Length, itemInfo.Name, itemInfo.Id);
|
message += Messages.FormatHorseEquip(itemInfo.IconId, item.ItemInstances.Length, itemInfo.Name, itemInfo.Id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3597,13 +3597,16 @@ namespace HISP.Server
|
||||||
return entires.ToArray();
|
return entires.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Highscore.HighscoreTableEntry[] GetTopScores(string gameTitle, int limit)
|
public static Highscore.HighscoreTableEntry[] GetTopScores(string gameTitle, int limit, bool scores=true)
|
||||||
{
|
{
|
||||||
List<Highscore.HighscoreTableEntry> entires = new();
|
List<Highscore.HighscoreTableEntry> entires = new();
|
||||||
|
|
||||||
using MySqlConnection db = Connect();
|
using MySqlConnection db = Connect();
|
||||||
MySqlCommand sqlCommand = db.CreateCommand();
|
MySqlCommand sqlCommand = db.CreateCommand();
|
||||||
sqlCommand.CommandText = "SELECT * FROM Leaderboards WHERE minigame=@gameTitle ORDER BY score DESC LIMIT @limit";
|
if(scores)
|
||||||
|
sqlCommand.CommandText = "SELECT * FROM Leaderboards WHERE minigame=@gameTitle ORDER BY score DESC LIMIT @limit";
|
||||||
|
else
|
||||||
|
sqlCommand.CommandText = "SELECT * FROM Leaderboards WHERE minigame=@gameTitle ORDER BY score ASC LIMIT @limit";
|
||||||
sqlCommand.Parameters.AddWithValue("@gameTitle", gameTitle);
|
sqlCommand.Parameters.AddWithValue("@gameTitle", gameTitle);
|
||||||
sqlCommand.Parameters.AddWithValue("@limit", limit);
|
sqlCommand.Parameters.AddWithValue("@limit", limit);
|
||||||
sqlCommand.Prepare();
|
sqlCommand.Prepare();
|
||||||
|
|
|
@ -114,6 +114,8 @@ namespace HISP.Server
|
||||||
// Stop Timers
|
// Stop Timers
|
||||||
if (timeoutTimer != null)
|
if (timeoutTimer != null)
|
||||||
timeoutTimer.Dispose();
|
timeoutTimer.Dispose();
|
||||||
|
if (keepAliveTimer != null)
|
||||||
|
keepAliveTimer.Dispose();
|
||||||
if (warnTimer != null)
|
if (warnTimer != null)
|
||||||
warnTimer.Dispose();
|
warnTimer.Dispose();
|
||||||
if (kickTimer != null)
|
if (kickTimer != null)
|
||||||
|
@ -126,8 +128,11 @@ namespace HISP.Server
|
||||||
LoggedIn = false;
|
LoggedIn = false;
|
||||||
|
|
||||||
// Close Socket
|
// Close Socket
|
||||||
ClientSocket.Close();
|
if(ClientSocket != null)
|
||||||
ClientSocket.Dispose();
|
{
|
||||||
|
ClientSocket.Close();
|
||||||
|
ClientSocket.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,10 +517,8 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
ClientSocket.Send(PacketData);
|
ClientSocket.Send(PacketData);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
if(!(e is SocketException))
|
|
||||||
Logger.ErrorPrint("Exception occured: " + e.Message);
|
|
||||||
Disconnect();
|
Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,19 +731,21 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Arenas
|
// Register Arenas
|
||||||
int totalArenas = gameData.arena.Count;
|
int totalArenas = gameData.arena.arena_list.Count;
|
||||||
for (int i = 0; i < totalArenas; i++)
|
for (int i = 0; i < totalArenas; i++)
|
||||||
{
|
{
|
||||||
int arenaId = gameData.arena[i].arena_id;
|
int arenaId = gameData.arena.arena_list[i].arena_id;
|
||||||
string arenaType = gameData.arena[i].arena_type;
|
string arenaType = gameData.arena.arena_list[i].arena_type;
|
||||||
int arenaEntryCost = gameData.arena[i].entry_cost;
|
int arenaEntryCost = gameData.arena.arena_list[i].entry_cost;
|
||||||
int raceEvery = gameData.arena[i].race_every;
|
int raceEvery = gameData.arena.arena_list[i].race_every;
|
||||||
int slots = gameData.arena[i].slots;
|
int slots = gameData.arena.arena_list[i].slots;
|
||||||
int timeout = gameData.arena[i].timeout;
|
int timeout = gameData.arena.arena_list[i].timeout;
|
||||||
|
|
||||||
Arena arena = new Arena(arenaId, arenaType, arenaEntryCost, raceEvery, slots, timeout);
|
Arena arena = new Arena(arenaId, arenaType, arenaEntryCost, raceEvery, slots, timeout);
|
||||||
Logger.DebugPrint("Registered Arena: " + arena.Id.ToString() + " as " + arena.Type);
|
Logger.DebugPrint("Registered Arena: " + arena.Id.ToString() + " as " + arena.Type);
|
||||||
}
|
}
|
||||||
|
Arena.ExpRewards = gameData.arena.arena_exp.ToObject<int[]>();
|
||||||
|
|
||||||
// Register Leaser
|
// Register Leaser
|
||||||
int totalLeasers = gameData.leaser.Count;
|
int totalLeasers = gameData.leaser.Count;
|
||||||
for (int i = 0; i < totalLeasers; i++)
|
for (int i = 0; i < totalLeasers; i++)
|
||||||
|
|
|
@ -1642,31 +1642,31 @@ namespace HISP.Server
|
||||||
Arena arena = Arena.GetAreaById(arenaId);
|
Arena arena = Arena.GetAreaById(arenaId);
|
||||||
if (!Arena.UserHasEnteredHorseInAnyArena(sender.LoggedinUser))
|
if (!Arena.UserHasEnteredHorseInAnyArena(sender.LoggedinUser))
|
||||||
{
|
{
|
||||||
if (horseInstance.BasicStats.Thirst <= 300)
|
if (horseInstance.BasicStats.Thirst <= 200)
|
||||||
{
|
{
|
||||||
byte[] tooThirsty = PacketBuilder.CreateChat(Messages.ArenaTooThirsty, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] tooThirsty = PacketBuilder.CreateChat(Messages.ArenaTooThirsty, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(tooThirsty);
|
sender.SendPacket(tooThirsty);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (horseInstance.BasicStats.Hunger <= 300)
|
else if (horseInstance.BasicStats.Hunger <= 200)
|
||||||
{
|
{
|
||||||
byte[] tooHungry = PacketBuilder.CreateChat(Messages.ArenaTooHungry, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] tooHungry = PacketBuilder.CreateChat(Messages.ArenaTooHungry, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(tooHungry);
|
sender.SendPacket(tooHungry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (horseInstance.BasicStats.Shoes <= 300)
|
else if (horseInstance.BasicStats.Shoes <= 200)
|
||||||
{
|
{
|
||||||
byte[] needsFarrier = PacketBuilder.CreateChat(Messages.ArenaNeedsFarrier, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] needsFarrier = PacketBuilder.CreateChat(Messages.ArenaNeedsFarrier, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(needsFarrier);
|
sender.SendPacket(needsFarrier);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (horseInstance.BasicStats.Tiredness <= 300)
|
else if (horseInstance.BasicStats.Tiredness <= 200)
|
||||||
{
|
{
|
||||||
byte[] tooTired = PacketBuilder.CreateChat(Messages.ArenaTooTired, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] tooTired = PacketBuilder.CreateChat(Messages.ArenaTooTired, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(tooTired);
|
sender.SendPacket(tooTired);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (horseInstance.BasicStats.Health <= 300)
|
else if (horseInstance.BasicStats.Health <= 200)
|
||||||
{
|
{
|
||||||
byte[] needsVet = PacketBuilder.CreateChat(Messages.ArenaNeedsVet, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] needsVet = PacketBuilder.CreateChat(Messages.ArenaNeedsVet, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(needsVet);
|
sender.SendPacket(needsVet);
|
||||||
|
@ -7553,11 +7553,13 @@ namespace HISP.Server
|
||||||
List<User> usersNearby = new List<User>();
|
List<User> usersNearby = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in GameClient.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (startX <= client.LoggedinUser.X && endX >= client.LoggedinUser.X && startY <= client.LoggedinUser.Y && endY >= client.LoggedinUser.Y)
|
if (startX <= client.LoggedinUser.X && endX >= client.LoggedinUser.X && startY <= client.LoggedinUser.Y && endY >= client.LoggedinUser.Y)
|
||||||
usersNearby.Add(client.LoggedinUser);
|
usersNearby.Add(client.LoggedinUser);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return usersNearby.ToArray();
|
return usersNearby.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -7602,6 +7604,7 @@ namespace HISP.Server
|
||||||
List<User> usersNearby = new List<User>();
|
List<User> usersNearby = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in GameClient.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (!includeStealth && client.LoggedinUser.Stealth)
|
if (!includeStealth && client.LoggedinUser.Stealth)
|
||||||
|
@ -7611,6 +7614,7 @@ namespace HISP.Server
|
||||||
if (startX <= client.LoggedinUser.X && endX >= client.LoggedinUser.X && startY <= client.LoggedinUser.Y && endY >= client.LoggedinUser.Y)
|
if (startX <= client.LoggedinUser.X && endX >= client.LoggedinUser.X && startY <= client.LoggedinUser.Y && endY >= client.LoggedinUser.Y)
|
||||||
usersNearby.Add(client.LoggedinUser);
|
usersNearby.Add(client.LoggedinUser);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return usersNearby.ToArray();
|
return usersNearby.ToArray();
|
||||||
}
|
}
|
||||||
|
@ -7950,12 +7954,26 @@ namespace HISP.Server
|
||||||
foreach (GameClient connectedClient in GameClient.ConnectedClients)
|
foreach (GameClient connectedClient in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (connectedClient.LoggedIn)
|
if (connectedClient.LoggedIn)
|
||||||
|
{
|
||||||
if (connectedClient.LoggedinUser.Inventory.HasItemId(id))
|
if (connectedClient.LoggedinUser.Inventory.HasItemId(id))
|
||||||
{
|
{
|
||||||
InventoryItem invItm = connectedClient.LoggedinUser.Inventory.GetItemByItemId(id);
|
InventoryItem invItm = connectedClient.LoggedinUser.Inventory.GetItemByItemId(id);
|
||||||
foreach (ItemInstance itm in invItm.ItemInstances.ToArray())
|
foreach (ItemInstance itm in invItm.ItemInstances.ToArray())
|
||||||
connectedClient.LoggedinUser.Inventory.Remove(itm);
|
connectedClient.LoggedinUser.Inventory.Remove(itm);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove from shops
|
||||||
|
foreach(Shop shop in Shop.ShopList)
|
||||||
|
{
|
||||||
|
if (shop.Inventory.HasItemId(id))
|
||||||
|
{
|
||||||
|
InventoryItem invItm = shop.Inventory.GetItemByItemId(id);
|
||||||
|
foreach (ItemInstance itm in invItm.ItemInstances.ToArray())
|
||||||
|
shop.Inventory.Remove(itm);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
DroppedItems.DeleteAllItemsWithId(id); // Delete all dropped items
|
DroppedItems.DeleteAllItemsWithId(id); // Delete all dropped items
|
||||||
Database.DeleteAllItemsFromUsers(id); // Delete from offline players
|
Database.DeleteAllItemsFromUsers(id); // Delete from offline players
|
||||||
|
|
Loading…
Add table
Reference in a new issue