mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 21:55:42 +12:00
Use Async Io instead of threads
This commit is contained in:
parent
392a3dfcaa
commit
edb27809bd
17 changed files with 128 additions and 104 deletions
|
@ -304,7 +304,7 @@ namespace HISP.Game.Chat
|
||||||
if (channel == ChatChannel.All)
|
if (channel == ChatChannel.All)
|
||||||
{
|
{
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MuteGlobal && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MuteGlobal && !client.LoggedinUser.MuteAll)
|
||||||
|
@ -318,7 +318,7 @@ namespace HISP.Game.Chat
|
||||||
if(channel == ChatChannel.Ads)
|
if(channel == ChatChannel.Ads)
|
||||||
{
|
{
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MuteAds && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MuteAds && !client.LoggedinUser.MuteAll)
|
||||||
|
@ -332,7 +332,7 @@ namespace HISP.Game.Chat
|
||||||
if(channel == ChatChannel.Buddies)
|
if(channel == ChatChannel.Buddies)
|
||||||
{
|
{
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MuteBuddy && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MuteBuddy && !client.LoggedinUser.MuteAll)
|
||||||
|
@ -403,7 +403,7 @@ namespace HISP.Game.Chat
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.Moderator)
|
if (client.LoggedinUser.Moderator)
|
||||||
|
@ -423,7 +423,7 @@ namespace HISP.Game.Chat
|
||||||
|
|
||||||
|
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.Administrator)
|
if (client.LoggedinUser.Administrator)
|
||||||
|
@ -438,7 +438,7 @@ namespace HISP.Game.Chat
|
||||||
if (to != null)
|
if (to != null)
|
||||||
{
|
{
|
||||||
List<GameClient> recipiants = new List<GameClient>();
|
List<GameClient> recipiants = new List<GameClient>();
|
||||||
foreach (GameClient client in GameServer.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)
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace HISP.Game.Chat
|
||||||
|
|
||||||
private static User findNamePartial(string name)
|
private static User findNamePartial(string name)
|
||||||
{
|
{
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client == null)
|
if (client == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace HISP.Game.Events
|
||||||
tradingTimeout = new Timer(new TimerCallback(tradeTimedOut), null, TRADING_TIMEOUT * 60 * 1000, TRADING_TIMEOUT * 60 * 1000);
|
tradingTimeout = new Timer(new TimerCallback(tradeTimedOut), null, TRADING_TIMEOUT * 60 * 1000, TRADING_TIMEOUT * 60 * 1000);
|
||||||
byte[] msg = PacketBuilder.CreateChat(Messages.EventStartIsleTradingGame, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] msg = PacketBuilder.CreateChat(Messages.EventStartIsleTradingGame, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(msg);
|
client.SendPacket(msg);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace HISP.Game.Events
|
||||||
{
|
{
|
||||||
Active = false;
|
Active = false;
|
||||||
|
|
||||||
foreach(GameClient client in GameServer.ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if(client.LoggedIn)
|
if(client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace HISP.Game.Events
|
||||||
|
|
||||||
byte[] annoucePacket = PacketBuilder.CreateChat(Messages.EventStartModsRevenge, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] annoucePacket = PacketBuilder.CreateChat(Messages.EventStartModsRevenge, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(annoucePacket);
|
client.SendPacket(annoucePacket);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace HISP.Game.Events
|
||||||
|
|
||||||
byte[] annoucePacket = PacketBuilder.CreateChat(Messages.EventEndModsRevenge, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] annoucePacket = PacketBuilder.CreateChat(Messages.EventEndModsRevenge, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
|
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(annoucePacket);
|
client.SendPacket(annoucePacket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace HISP.Game.Events
|
||||||
quizTimer = new Timer(new TimerCallback(quizTimesUp), null, QUIZ_TIMEOUT * 60 * 1000, QUIZ_TIMEOUT * 60 * 1000);
|
quizTimer = new Timer(new TimerCallback(quizTimesUp), null, QUIZ_TIMEOUT * 60 * 1000, QUIZ_TIMEOUT * 60 * 1000);
|
||||||
|
|
||||||
byte[] quizStartMessage = PacketBuilder.CreateChat(Messages.EventStartRealTimeQuiz, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] quizStartMessage = PacketBuilder.CreateChat(Messages.EventStartRealTimeQuiz, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(quizStartMessage);
|
client.SendPacket(quizStartMessage);
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ namespace HISP.Game.Events
|
||||||
public void WinEvent(User winner)
|
public void WinEvent(User winner)
|
||||||
{
|
{
|
||||||
byte[] eventWinMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeQuizWin(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] eventWinMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeQuizWin(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(eventWinMessage);
|
client.SendPacket(eventWinMessage);
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ namespace HISP.Game.Events
|
||||||
public void EndEvent()
|
public void EndEvent()
|
||||||
{
|
{
|
||||||
byte[] eventEndMessage = PacketBuilder.CreateChat(Messages.EventEndRealTimeQuiz, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] eventEndMessage = PacketBuilder.CreateChat(Messages.EventEndRealTimeQuiz, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if(client.LoggedIn)
|
if(client.LoggedIn)
|
||||||
client.SendPacket(eventEndMessage);
|
client.SendPacket(eventEndMessage);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace HISP.Game.Events
|
||||||
riddleTimeout = new Timer(new TimerCallback(riddleTimedOut), null, RIDDLE_TIMEOUT * 60 * 1000, RIDDLE_TIMEOUT * 60 * 1000);
|
riddleTimeout = new Timer(new TimerCallback(riddleTimedOut), null, RIDDLE_TIMEOUT * 60 * 1000, RIDDLE_TIMEOUT * 60 * 1000);
|
||||||
|
|
||||||
// Send riddle message to all players
|
// Send riddle message to all players
|
||||||
foreach(GameClient client in GameServer.ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
ShowStartMessage(client);
|
ShowStartMessage(client);
|
||||||
|
@ -74,7 +74,7 @@ namespace HISP.Game.Events
|
||||||
winner.AddMoney(Reward);
|
winner.AddMoney(Reward);
|
||||||
byte[] riddleWonMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeRiddleWonForOthers(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] riddleWonMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeRiddleWonForOthers(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
byte[] riddleYouWonMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeRiddleWonForYou(Reward), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] riddleYouWonMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeRiddleWonForYou(Reward), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.Id != winner.Id)
|
if (client.LoggedinUser.Id != winner.Id)
|
||||||
|
@ -95,7 +95,7 @@ namespace HISP.Game.Events
|
||||||
private void riddleTimedOut(object state)
|
private void riddleTimedOut(object state)
|
||||||
{
|
{
|
||||||
byte[] riddleTimedOutMessage = PacketBuilder.CreateChat(Messages.EventEndRealTimeRiddle, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] riddleTimedOutMessage = PacketBuilder.CreateChat(Messages.EventEndRealTimeRiddle, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(riddleTimedOutMessage);
|
client.SendPacket(riddleTimedOutMessage);
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace HISP.Game.Events
|
||||||
if (timesTicked >= 1)
|
if (timesTicked >= 1)
|
||||||
{
|
{
|
||||||
byte[] giveAwayMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveaway1Min(HorseGiveaway.Color, HorseGiveaway.Breed.Name, HorseGiveaway.Gender, ShopName, Town.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] giveAwayMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveaway1Min(HorseGiveaway.Color, HorseGiveaway.Breed.Name, HorseGiveaway.Gender, ShopName, Town.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(giveAwayMessage);
|
client.SendPacket(giveAwayMessage);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ namespace HISP.Game.Events
|
||||||
giveAwayTimer = new Timer(new TimerCallback(giveawayTick), null, TACKSHOP_TIMEOUT * 60 * 1000, TACKSHOP_TIMEOUT * 60 * 1000);
|
giveAwayTimer = new Timer(new TimerCallback(giveawayTick), null, TACKSHOP_TIMEOUT * 60 * 1000, TACKSHOP_TIMEOUT * 60 * 1000);
|
||||||
|
|
||||||
byte[] giveAwayMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayStart(HorseGiveaway.Color, HorseGiveaway.Breed.Name, HorseGiveaway.Gender, ShopName, Town.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] giveAwayMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayStart(HorseGiveaway.Color, HorseGiveaway.Breed.Name, HorseGiveaway.Gender, ShopName, Town.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(giveAwayMessage);
|
client.SendPacket(giveAwayMessage);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace HISP.Game.Events
|
||||||
winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.TackShopGiveaway).Count++;
|
winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.TackShopGiveaway).Count++;
|
||||||
|
|
||||||
byte[] horseWonMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayWon(winner.Username, HorseGiveaway.Breed.Name, ShopName, Town.Name, usersHere.Length), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] horseWonMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayWon(winner.Username, HorseGiveaway.Breed.Name, ShopName, Town.Name, usersHere.Length), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(horseWonMessage);
|
client.SendPacket(horseWonMessage);
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ namespace HISP.Game.Events
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] eventEndedMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayEnd(ShopName, Town.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] eventEndedMessage = PacketBuilder.CreateChat(Messages.FormatEventTackShopGiveawayEnd(ShopName, Town.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(eventEndedMessage);
|
client.SendPacket(eventEndedMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace HISP.Game.Events
|
||||||
gameTimeout = new Timer(new TimerCallback(gameTimedOut), null, WATER_BALLOON_GAME_TIMEOUT * 60 * 1000, WATER_BALLOON_GAME_TIMEOUT * 60 * 1000);
|
gameTimeout = new Timer(new TimerCallback(gameTimedOut), null, WATER_BALLOON_GAME_TIMEOUT * 60 * 1000, WATER_BALLOON_GAME_TIMEOUT * 60 * 1000);
|
||||||
|
|
||||||
byte[] gameStartMessage = PacketBuilder.CreateChat(Messages.EventStartWaterBallonGame, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] gameStartMessage = PacketBuilder.CreateChat(Messages.EventStartWaterBallonGame, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(gameStartMessage);
|
client.SendPacket(gameStartMessage);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace HISP.Game.Events
|
||||||
|
|
||||||
// Send to all online users
|
// Send to all online users
|
||||||
byte[] gameWinnerAnnoucement = PacketBuilder.CreateChat(winMsg, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] gameWinnerAnnoucement = PacketBuilder.CreateChat(winMsg, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
foreach (GameClient client in GameServer.ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
client.SendPacket(gameWinnerAnnoucement);
|
client.SendPacket(gameWinnerAnnoucement);
|
||||||
|
|
||||||
|
|
|
@ -1165,7 +1165,7 @@ namespace HISP.Game
|
||||||
public static string BuildPlayerListAlphabetical(User currentUser)
|
public static string BuildPlayerListAlphabetical(User currentUser)
|
||||||
{
|
{
|
||||||
string message = Messages.PlayerListAllAlphabeticalHeader;
|
string message = Messages.PlayerListAllAlphabeticalHeader;
|
||||||
GameClient[] clients = GameServer.ConnectedClients;
|
GameClient[] clients = GameClient.ConnectedClients;
|
||||||
List<User> onlineUsers = new List<User>();
|
List<User> onlineUsers = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in clients)
|
foreach (GameClient client in clients)
|
||||||
|
@ -1202,7 +1202,7 @@ namespace HISP.Game
|
||||||
public static string BuildPlayerList(User currentUser)
|
public static string BuildPlayerList(User currentUser)
|
||||||
{
|
{
|
||||||
string message = Messages.PlayerListAllHeader;
|
string message = Messages.PlayerListAllHeader;
|
||||||
GameClient[] clients = GameServer.ConnectedClients;
|
GameClient[] clients = GameClient.ConnectedClients;
|
||||||
foreach (GameClient client in clients)
|
foreach (GameClient client in clients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace HISP
|
||||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Console.Title = "HISP - HorseIsleServer Emulator";
|
Console.Title = ServerVersion.GetVersionString();
|
||||||
ConfigReader.OpenConfig();
|
ConfigReader.OpenConfig();
|
||||||
CrossDomainPolicy.GetPolicy();
|
CrossDomainPolicy.GetPolicy();
|
||||||
Database.OpenDatabase();
|
Database.OpenDatabase();
|
||||||
|
@ -41,6 +41,7 @@ namespace HISP
|
||||||
|
|
||||||
GameServer.StartServer();
|
GameServer.StartServer();
|
||||||
|
|
||||||
|
while (true) { };
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
@ -10,7 +9,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("SilicaAndPina")]
|
[assembly: AssemblyCompany("SilicaAndPina")]
|
||||||
[assembly: AssemblyProduct("HISP")]
|
[assembly: AssemblyProduct("HISP")]
|
||||||
[assembly: AssemblyCopyright("Public Domain © 2021")]
|
[assembly: AssemblyCopyright("Public Domain © 2021")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -32,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.3.0.0")]
|
[assembly: AssemblyVersion("1.2.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.3.0.0")]
|
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
2d7ceb8b12b72d2b16189c41b099488d8ca15f6a
|
392a3dfcaaaca0e4f3aba9b428d07830550dbd78
|
||||||
|
|
|
@ -21,7 +21,17 @@ namespace HISP.Server
|
||||||
ConnectionString = "server=" + ConfigReader.DatabaseIP + ";user=" + ConfigReader.DatabaseUsername + ";password=" + ConfigReader.DatabasePassword + ";database=" + ConfigReader.DatabaseName;
|
ConnectionString = "server=" + ConfigReader.DatabaseIP + ";user=" + ConfigReader.DatabaseUsername + ";password=" + ConfigReader.DatabasePassword + ";database=" + ConfigReader.DatabaseName;
|
||||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
db.Open();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.Open();
|
||||||
|
}
|
||||||
|
catch (MySqlException e)
|
||||||
|
{
|
||||||
|
Logger.ErrorPrint("Failed to connect to Database: "+e.Message);
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
string UserTable = "CREATE TABLE IF NOT EXISTS Users(Id INT, Username TEXT(16), PassHash TEXT(128), Salt TEXT(128), Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))";
|
string UserTable = "CREATE TABLE IF NOT EXISTS Users(Id INT, Username TEXT(16), PassHash TEXT(128), Salt TEXT(128), Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))";
|
||||||
string ExtTable = "CREATE TABLE IF NOT EXISTS UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance DOUBLE, BankInterest DOUBLE, ProfilePage Text(4000),IpAddress TEXT(1028),PrivateNotes Text(65535), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT, TotalLogins INT)";
|
string ExtTable = "CREATE TABLE IF NOT EXISTS UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance DOUBLE, BankInterest DOUBLE, ProfilePage Text(4000),IpAddress TEXT(1028),PrivateNotes Text(65535), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT, TotalLogins INT)";
|
||||||
string MailTable = "CREATE TABLE IF NOT EXISTS Mailbox(RandomId INT, IdTo INT, IdFrom INT, Subject TEXT(100), Message Text(65535), TimeSent INT, BeenRead TEXT(3))";
|
string MailTable = "CREATE TABLE IF NOT EXISTS Mailbox(RandomId INT, IdTo INT, IdFrom INT, Subject TEXT(100), Message Text(65535), TimeSent INT, BeenRead TEXT(3))";
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Collections.Generic;
|
||||||
using HISP.Player;
|
using HISP.Player;
|
||||||
using HISP.Game;
|
using HISP.Game;
|
||||||
using HISP.Game.Horse;
|
using HISP.Game.Horse;
|
||||||
|
@ -12,6 +13,15 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
public class GameClient
|
public class GameClient
|
||||||
{
|
{
|
||||||
|
private static List<GameClient> connectedClients = new List<GameClient>();
|
||||||
|
public static GameClient[] ConnectedClients // Done to prevent Enumerator Changed errors.
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return connectedClients.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Socket ClientSocket;
|
public Socket ClientSocket;
|
||||||
public string RemoteIp;
|
public string RemoteIp;
|
||||||
|
|
||||||
|
@ -33,8 +43,6 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public User LoggedinUser;
|
public User LoggedinUser;
|
||||||
|
|
||||||
private Thread recvPackets;
|
|
||||||
|
|
||||||
private Timer inactivityTimer;
|
private Timer inactivityTimer;
|
||||||
|
|
||||||
|
@ -233,8 +241,11 @@ namespace HISP.Server
|
||||||
SendPacket(chatPacket);
|
SendPacket(chatPacket);
|
||||||
if (LoggedIn)
|
if (LoggedIn)
|
||||||
LoggedinUser.Idle = true;
|
LoggedinUser.Idle = true;
|
||||||
warnTimer.Dispose();
|
if(warnTimer != null)
|
||||||
warnTimer = null;
|
{
|
||||||
|
warnTimer.Dispose();
|
||||||
|
warnTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +257,7 @@ namespace HISP.Server
|
||||||
public void Login(int id)
|
public void Login(int id)
|
||||||
{
|
{
|
||||||
// Check for duplicate
|
// Check for duplicate
|
||||||
foreach(GameClient Client in GameServer.ConnectedClients)
|
foreach(GameClient Client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if(Client.LoggedIn)
|
if(Client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -317,16 +328,17 @@ namespace HISP.Server
|
||||||
warnTimer.Dispose();
|
warnTimer.Dispose();
|
||||||
if(kickTimer != null)
|
if(kickTimer != null)
|
||||||
kickTimer.Dispose();
|
kickTimer.Dispose();
|
||||||
|
|
||||||
// Call OnDisconnect
|
// Call OnDisconnect
|
||||||
|
connectedClients.Remove(this);
|
||||||
GameServer.OnDisconnect(this);
|
GameServer.OnDisconnect(this);
|
||||||
LoggedIn = false;
|
LoggedIn = false;
|
||||||
// LoggedinUser = null;
|
|
||||||
// Close Sockets
|
// Close Socket
|
||||||
ClientSocket.Close();
|
ClientSocket.Close();
|
||||||
ClientSocket.Dispose();
|
ClientSocket.Dispose();
|
||||||
|
|
||||||
return isDisconnecting; // Stop the thread.
|
return isDisconnecting; // Stop the task.
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parsePackets(byte[] Packet)
|
private void parsePackets(byte[] Packet)
|
||||||
|
@ -492,12 +504,25 @@ namespace HISP.Server
|
||||||
warnTimer = new Timer(new TimerCallback(warnTimerTick), null, warnInterval, warnInterval);
|
warnTimer = new Timer(new TimerCallback(warnTimerTick), null, warnInterval, warnInterval);
|
||||||
minuteTimer = new Timer(new TimerCallback(minuteTimerTick), null, oneMinute, oneMinute);
|
minuteTimer = new Timer(new TimerCallback(minuteTimerTick), null, oneMinute, oneMinute);
|
||||||
|
|
||||||
recvPackets = new Thread(() =>
|
connectedClients.Add(this);
|
||||||
{
|
|
||||||
receivePackets();
|
receivePackets();
|
||||||
});
|
|
||||||
recvPackets.Start();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AcceptConnections(SocketAsyncEventArgs e, Socket socket)
|
||||||
|
{
|
||||||
|
e.AcceptSocket = null;
|
||||||
|
socket.AcceptAsync(e);
|
||||||
|
}
|
||||||
|
public static void CreateClient(object sender, SocketAsyncEventArgs e)
|
||||||
|
{
|
||||||
|
Socket eSocket = e.AcceptSocket;
|
||||||
|
AcceptConnections(e, GameServer.ServerSocket);
|
||||||
|
|
||||||
|
GameClient client = new GameClient(eSocket);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
public static Socket ServerSocket;
|
public static Socket ServerSocket;
|
||||||
|
|
||||||
public static GameClient[] ConnectedClients // Done to prevent Enumerator Changed errors.
|
|
||||||
{
|
|
||||||
get {
|
|
||||||
return connectedClients.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int IdleTimeout;
|
public static int IdleTimeout;
|
||||||
public static int IdleWarning;
|
public static int IdleWarning;
|
||||||
|
|
||||||
|
@ -52,7 +45,6 @@ namespace HISP.Server
|
||||||
private static int gameTickSpeed = 480; // Changing this to ANYTHING else will cause desync with the client.
|
private static int gameTickSpeed = 480; // Changing this to ANYTHING else will cause desync with the client.
|
||||||
private static int totalMinutesElapsed = 0;
|
private static int totalMinutesElapsed = 0;
|
||||||
private static int oneMinute = 1000 * 60;
|
private static int oneMinute = 1000 * 60;
|
||||||
private static List<GameClient> connectedClients = new List<GameClient>();
|
|
||||||
private static Timer gameTimer; // Controls in-game time.
|
private static Timer gameTimer; // Controls in-game time.
|
||||||
private static Timer minuteTimer; // ticks every real world minute.
|
private static Timer minuteTimer; // ticks every real world minute.
|
||||||
private static int lastServerTime = 0;
|
private static int lastServerTime = 0;
|
||||||
|
@ -193,7 +185,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client == null)
|
if (client == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -3629,7 +3621,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
UpdateArea(sender);
|
UpdateArea(sender);
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -3690,7 +3682,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
// Send login message
|
// Send login message
|
||||||
byte[] loginMessageBytes = PacketBuilder.CreateChat(Messages.FormatLoginMessage(sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_LEFT);
|
byte[] loginMessageBytes = PacketBuilder.CreateChat(Messages.FormatLoginMessage(sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MuteLogins && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MuteLogins && !client.LoggedinUser.MuteAll)
|
||||||
if (client.LoggedinUser.Id != sender.LoggedinUser.Id)
|
if (client.LoggedinUser.Id != sender.LoggedinUser.Id)
|
||||||
|
@ -3702,7 +3694,7 @@ namespace HISP.Server
|
||||||
byte[] yourPlayerInfo = PacketBuilder.CreatePlayerInfoUpdateOrCreate(sender.LoggedinUser.X, sender.LoggedinUser.Y, sender.LoggedinUser.Facing, sender.LoggedinUser.CharacterId, sender.LoggedinUser.Username);
|
byte[] yourPlayerInfo = PacketBuilder.CreatePlayerInfoUpdateOrCreate(sender.LoggedinUser.X, sender.LoggedinUser.Y, sender.LoggedinUser.Facing, sender.LoggedinUser.CharacterId, sender.LoggedinUser.Username);
|
||||||
byte[] yourPlayerInfoOffscreen = PacketBuilder.CreatePlayerInfoUpdateOrCreate(1000 + 4, 1000 + 1, sender.LoggedinUser.Facing, sender.LoggedinUser.CharacterId, sender.LoggedinUser.Username);
|
byte[] yourPlayerInfoOffscreen = PacketBuilder.CreatePlayerInfoUpdateOrCreate(1000 + 4, 1000 + 1, sender.LoggedinUser.Facing, sender.LoggedinUser.CharacterId, sender.LoggedinUser.Username);
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -5687,7 +5679,6 @@ namespace HISP.Server
|
||||||
Chat.ChatChannel channel = (Chat.ChatChannel)packet[1];
|
Chat.ChatChannel channel = (Chat.ChatChannel)packet[1];
|
||||||
string message = packetStr.Substring(2, packetStr.Length - 4);
|
string message = packetStr.Substring(2, packetStr.Length - 4);
|
||||||
|
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
string nameTo = null;
|
string nameTo = null;
|
||||||
|
@ -5697,14 +5688,11 @@ namespace HISP.Server
|
||||||
message = Chat.GetDmMessage(message);
|
message = Chat.GetDmMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message == "")
|
if (message.StartsWith("/"))
|
||||||
return;
|
|
||||||
|
|
||||||
if(message.StartsWith("/"))
|
|
||||||
{
|
{
|
||||||
string channelString = message.Split(' ')[0].ToLower();
|
string channelString = message.Split(' ')[0].ToLower();
|
||||||
string newMessage = string.Join(' ', message.Split(' ').Skip(1));
|
string newMessage = string.Join(' ', message.Split(' ').Skip(1));
|
||||||
message = newMessage;
|
message = newMessage.Trim();
|
||||||
switch(channelString)
|
switch(channelString)
|
||||||
{
|
{
|
||||||
case "/$":
|
case "/$":
|
||||||
|
@ -5748,11 +5736,20 @@ namespace HISP.Server
|
||||||
nameTo = channelString.Substring(1);
|
nameTo = channelString.Substring(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (message == "") // this is how pinto does it, im serious.
|
||||||
|
{
|
||||||
|
channel = Chat.ChatChannel.Dm;
|
||||||
|
nameTo = channelString.Substring(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message = message.Trim();
|
message = message.Trim();
|
||||||
|
|
||||||
if(channel == Chat.ChatChannel.All && message.Length > 150)
|
if (message == "")
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (channel == Chat.ChatChannel.All && message.Length > 150)
|
||||||
{
|
{
|
||||||
byte[] tooLong = PacketBuilder.CreateChat(Messages.GlobalChatTooLong, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] tooLong = PacketBuilder.CreateChat(Messages.GlobalChatTooLong, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(tooLong);
|
sender.SendPacket(tooLong);
|
||||||
|
@ -6573,7 +6570,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid object interaction packet.");
|
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid object interaction packet. (drop)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6592,6 +6589,8 @@ namespace HISP.Server
|
||||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.DroppedAnItemMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
byte[] chatPacket = PacketBuilder.CreateChat(Messages.DroppedAnItemMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||||
sender.SendPacket(chatPacket);
|
sender.SendPacket(chatPacket);
|
||||||
UpdateInventory(sender);
|
UpdateInventory(sender);
|
||||||
|
|
||||||
|
UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, false, sender.LoggedinUser);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7283,10 +7282,6 @@ namespace HISP.Server
|
||||||
|
|
||||||
public static void OnDisconnect(GameClient sender)
|
public static void OnDisconnect(GameClient sender)
|
||||||
{
|
{
|
||||||
|
|
||||||
connectedClients.Remove(sender);
|
|
||||||
|
|
||||||
|
|
||||||
if (sender.LoggedIn)
|
if (sender.LoggedIn)
|
||||||
{
|
{
|
||||||
Database.SetPlayerLastLogin(Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()), sender.LoggedinUser.Id); // Set last login date
|
Database.SetPlayerLastLogin(Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()), sender.LoggedinUser.Id); // Set last login date
|
||||||
|
@ -7321,7 +7316,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
// Send disconnect message
|
// Send disconnect message
|
||||||
byte[] logoutMessageBytes = PacketBuilder.CreateChat(Messages.FormatLogoutMessage(sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_LEFT);
|
byte[] logoutMessageBytes = PacketBuilder.CreateChat(Messages.FormatLogoutMessage(sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MuteLogins && !client.LoggedinUser.MuteAll)
|
if (!client.LoggedinUser.MuteLogins && !client.LoggedinUser.MuteAll)
|
||||||
if (client.LoggedinUser.Id != sender.LoggedinUser.Id)
|
if (client.LoggedinUser.Id != sender.LoggedinUser.Id)
|
||||||
|
@ -7329,13 +7324,12 @@ namespace HISP.Server
|
||||||
|
|
||||||
// Tell clients of diconnect (remove from chat)
|
// Tell clients of diconnect (remove from chat)
|
||||||
byte[] playerRemovePacket = PacketBuilder.CreatePlayerLeavePacket(sender.LoggedinUser.Username);
|
byte[] playerRemovePacket = PacketBuilder.CreatePlayerLeavePacket(sender.LoggedinUser.Username);
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.Id != sender.LoggedinUser.Id)
|
if (client.LoggedinUser.Id != sender.LoggedinUser.Id)
|
||||||
client.SendPacket(playerRemovePacket);
|
client.SendPacket(playerRemovePacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7359,7 +7353,7 @@ namespace HISP.Server
|
||||||
public static User[] GetUsersInTown(World.Town town, bool includeStealth = false, bool includeMuted = false)
|
public static User[] GetUsersInTown(World.Town town, bool includeStealth = false, bool includeMuted = false)
|
||||||
{
|
{
|
||||||
List<User> usersInTown = new List<User>();
|
List<User> usersInTown = new List<User>();
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (!includeStealth && client.LoggedinUser.Stealth)
|
if (!includeStealth && client.LoggedinUser.Stealth)
|
||||||
|
@ -7376,7 +7370,7 @@ namespace HISP.Server
|
||||||
public static User[] GetUsersInIsle(World.Isle isle, bool includeStealth = false, bool includeMuted = false)
|
public static User[] GetUsersInIsle(World.Isle isle, bool includeStealth = false, bool includeMuted = false)
|
||||||
{
|
{
|
||||||
List<User> usersInIsle = new List<User>();
|
List<User> usersInIsle = new List<User>();
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (!includeStealth && client.LoggedinUser.Stealth)
|
if (!includeStealth && client.LoggedinUser.Stealth)
|
||||||
|
@ -7395,7 +7389,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
List<User> userList = new List<User>();
|
List<User> userList = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in connectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -7416,7 +7410,7 @@ namespace HISP.Server
|
||||||
public static User[] GetUsersAt(int x, int y, bool includeStealth = false, bool includeMuted = false)
|
public static User[] GetUsersAt(int x, int y, bool includeStealth = false, bool includeMuted = false)
|
||||||
{
|
{
|
||||||
List<User> usersHere = new List<User>();
|
List<User> usersHere = new List<User>();
|
||||||
foreach(GameClient client in ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if(client.LoggedIn)
|
if(client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -7432,7 +7426,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
public static User GetUserByName(string username)
|
public static User GetUserByName(string username)
|
||||||
{
|
{
|
||||||
foreach(GameClient client in ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if(client.LoggedIn)
|
if(client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -7445,7 +7439,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
public static User GetUserById(int id)
|
public static User GetUserById(int id)
|
||||||
{
|
{
|
||||||
foreach(GameClient client in ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.Id == id)
|
if (client.LoggedinUser.Id == id)
|
||||||
|
@ -7463,7 +7457,7 @@ namespace HISP.Server
|
||||||
int endY = y + 3;
|
int endY = y + 3;
|
||||||
List<User> usersNearby = new List<User>();
|
List<User> usersNearby = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in 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)
|
||||||
|
@ -7490,7 +7484,7 @@ namespace HISP.Server
|
||||||
|
|
||||||
List<User> usersOnScreen = new List<User>();
|
List<User> usersOnScreen = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (!includeStealth && client.LoggedinUser.Stealth)
|
if (!includeStealth && client.LoggedinUser.Stealth)
|
||||||
|
@ -7512,7 +7506,7 @@ namespace HISP.Server
|
||||||
int endY = y + 19;
|
int endY = y + 19;
|
||||||
List<User> usersNearby = new List<User>();
|
List<User> usersNearby = new List<User>();
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (!includeStealth && client.LoggedinUser.Stealth)
|
if (!includeStealth && client.LoggedinUser.Stealth)
|
||||||
|
@ -7528,7 +7522,7 @@ namespace HISP.Server
|
||||||
public static int GetNumberOfPlayers(bool includeStealth=false)
|
public static int GetNumberOfPlayers(bool includeStealth=false)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach(GameClient client in ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
if (!includeStealth && client.LoggedinUser.Stealth)
|
if (!includeStealth && client.LoggedinUser.Stealth)
|
||||||
|
@ -7544,7 +7538,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
List<Point> allLocations = new List<Point>();
|
List<Point> allLocations = new List<Point>();
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -7566,7 +7560,7 @@ namespace HISP.Server
|
||||||
{
|
{
|
||||||
List<Point> allLocations = new List<Point>();
|
List<Point> allLocations = new List<Point>();
|
||||||
|
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
{
|
{
|
||||||
|
@ -7586,7 +7580,7 @@ namespace HISP.Server
|
||||||
public static int GetNumberOfPlayersListeningToAdsChat()
|
public static int GetNumberOfPlayersListeningToAdsChat()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (!client.LoggedinUser.MuteAds)
|
if (!client.LoggedinUser.MuteAds)
|
||||||
|
@ -7598,7 +7592,7 @@ namespace HISP.Server
|
||||||
public static int GetNumberOfModsOnline()
|
public static int GetNumberOfModsOnline()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if(client.LoggedinUser.Moderator)
|
if(client.LoggedinUser.Moderator)
|
||||||
|
@ -7623,7 +7617,7 @@ namespace HISP.Server
|
||||||
public static int GetNumberOfAdminsOnline()
|
public static int GetNumberOfAdminsOnline()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (GameClient client in ConnectedClients)
|
foreach (GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.Administrator)
|
if (client.LoggedinUser.Administrator)
|
||||||
|
@ -7740,7 +7734,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
public static void UpdateAreaForAll(int x, int y, bool ignoreMetaPrio=false, User exceptMe=null)
|
public static void UpdateAreaForAll(int x, int y, bool ignoreMetaPrio=false, User exceptMe=null)
|
||||||
{
|
{
|
||||||
foreach(GameClient client in ConnectedClients)
|
foreach(GameClient client in GameClient.ConnectedClients)
|
||||||
{
|
{
|
||||||
if (client.LoggedIn)
|
if (client.LoggedIn)
|
||||||
if (client.LoggedinUser.X == x && client.LoggedinUser.Y == y)
|
if (client.LoggedinUser.X == x && client.LoggedinUser.Y == y)
|
||||||
|
@ -7856,7 +7850,7 @@ namespace HISP.Server
|
||||||
public static void RemoveAllItemsOfIdInTheGame(int id)
|
public static void RemoveAllItemsOfIdInTheGame(int id)
|
||||||
{
|
{
|
||||||
// Remove from all online players
|
// Remove from all online players
|
||||||
foreach (GameClient connectedClient in GameServer.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))
|
||||||
|
@ -8042,22 +8036,15 @@ namespace HISP.Server
|
||||||
IPAddress hostIP = IPAddress.Parse(ConfigReader.BindIP);
|
IPAddress hostIP = IPAddress.Parse(ConfigReader.BindIP);
|
||||||
IPEndPoint ep = new IPEndPoint(hostIP, ConfigReader.Port);
|
IPEndPoint ep = new IPEndPoint(hostIP, ConfigReader.Port);
|
||||||
ServerSocket.Bind(ep);
|
ServerSocket.Bind(ep);
|
||||||
Logger.InfoPrint("Binding to ip: " + ConfigReader.BindIP + " On port: " + ConfigReader.Port.ToString());
|
ServerSocket.Listen(0x7fffffff);
|
||||||
ServerSocket.Listen(10000);
|
|
||||||
gameTimer = new Timer(new TimerCallback(onGameTick), null, gameTickSpeed, gameTickSpeed);
|
gameTimer = new Timer(new TimerCallback(onGameTick), null, gameTickSpeed, gameTickSpeed);
|
||||||
minuteTimer = new Timer(new TimerCallback(onMinuteTick), null, oneMinute, oneMinute);
|
minuteTimer = new Timer(new TimerCallback(onMinuteTick), null, oneMinute, oneMinute);
|
||||||
while (true)
|
Logger.InfoPrint("Binding to ip: " + ConfigReader.BindIP + " On port: " + ConfigReader.Port.ToString());
|
||||||
{
|
|
||||||
Logger.InfoPrint("Waiting for new connections...");
|
|
||||||
|
|
||||||
Socket cientSocket = ServerSocket.Accept();
|
SocketAsyncEventArgs e = new SocketAsyncEventArgs();
|
||||||
GameClient client = new GameClient(cientSocket);
|
e.Completed += GameClient.CreateClient;
|
||||||
connectedClients.Add(client);
|
GameClient.AcceptConnections(e, ServerSocket);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,10 +340,12 @@ namespace HISP.Server
|
||||||
public static byte[] CreateDrawingUpdatePacket(string Drawing)
|
public static byte[] CreateDrawingUpdatePacket(string Drawing)
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
|
|
||||||
ms.WriteByte(PACKET_SWFMODULE);
|
ms.WriteByte(PACKET_SWFMODULE);
|
||||||
byte[] drawingBytes = Encoding.UTF8.GetBytes(Drawing);
|
byte[] drawingBytes = Encoding.UTF8.GetBytes(Drawing);
|
||||||
ms.Write(drawingBytes, 0x00, drawingBytes.Length);
|
ms.Write(drawingBytes, 0x00, drawingBytes.Length);
|
||||||
ms.WriteByte(PACKET_TERMINATOR);
|
ms.WriteByte(PACKET_TERMINATOR);
|
||||||
|
|
||||||
ms.Seek(0x00, SeekOrigin.Begin);
|
ms.Seek(0x00, SeekOrigin.Begin);
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace HISP.Server
|
||||||
}
|
}
|
||||||
public static string GetCommitHash(int TotalBytes)
|
public static string GetCommitHash(int TotalBytes)
|
||||||
{
|
{
|
||||||
return Resources.GitCommit.Substring(0, TotalBytes * 2);
|
return Resources.GitCommit.Substring(0, TotalBytes);
|
||||||
}
|
}
|
||||||
public static string GetBuildString()
|
public static string GetBuildString()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue