diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index 5cb9026..c50cb12 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -129,11 +129,12 @@ "map_all_players_format":"^T4Show all players online on map:^B1M%ALLXYLIST%^R1", "abuse_report":"^R1^T4If you witness a rule violation:^D28c1|ABUSE REPORT^R1", + "icon_format":"^I%ICON%", "online_buddy_header":"^ATYour Buddies Currently Online^H", - "online_buddy_format":"^I%ICON%^T3%USERNAME% (on %TIME% min)^B1L%PLAYERID%^B1R%PLAYERID%^B1M%MAPXY%^B1P%USERNAME%^R1", - "offline_buddys":"H^LBuddies Currently Offline:^R1", + "online_buddy_format":"%ICONFORMAT%^T3%USERNAME% (on %TIME% min)^B1L%PLAYERID%^B1R%PLAYERID%^B1M%MAPXY%^B1P%USERNAME%^R1", + "offline_buddys":"^LBuddies Currently Offline:^R1", "offline_buddy_format":"^T3%USERNAME% (off %TIME% min)^B1R%PLAYERID%^R1", - "online_format":"^I%ICON%^T3%USERNAME% (on %TIME% min)^B1L%PLAYERID%B1M%MAPXY%^B1I%PLAYERID%^B1P%USERNAME%^R1", + "online_format":"%ICONFORMAT%^T3%USERNAME% (on %TIME% min)^B1L%PLAYERID%B1M%MAPXY%^B1I%PLAYERID%^B1P%USERNAME%^R1", "icon_info":"^L [Star = Subscriber] [A = Admin] [M = Moderator]^R1", "icon_subbed_3month":415, "icon_subbed_year":416, diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs index 3217301..5fc12f3 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs @@ -244,6 +244,7 @@ namespace HISP.Game public static string BuddyListOfflineBuddys; public static string BuddyListOfflineBuddyEntryFormat; + public static string PlayerListIconFormat; public static string PlayerListIconInformation; // Meta @@ -280,10 +281,14 @@ namespace HISP.Game // Click public static string NothingInterestingHere; - public static string FormatOnlineBuddyEntry(int iconId, string username, int userId, int time, int x, int y) + public static string FormatIconFormat(int iconId) + { + return PlayerListIconFormat.Replace("%ICON%", iconId.ToString()); + } + public static string FormatOnlineBuddyEntry(string iconFormat, string username, int userId, int time, int x, int y) { string xy = FormatMapLocation(x, y); - return BuddyListOnlineBuddyEntryFormat.Replace("%ICON%", iconId.ToString()).Replace("%USERNAME%", username).Replace("%TIME%", time.ToString("N0")).Replace("%PLAYERID%", userId.ToString()).Replace("%MAPXY%", xy); + return BuddyListOnlineBuddyEntryFormat.Replace("%ICONFORMAT%", iconFormat).Replace("%USERNAME%", username).Replace("%TIME%", time.ToString("N0")).Replace("%PLAYERID%", userId.ToString()).Replace("%MAPXY%", xy); } public static string FormatOfflineBuddyEntry(string username, int userId, int time) { diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs index 363d3e4..bb49665 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs @@ -417,10 +417,52 @@ namespace HISP.Game try { User friend = GameServer.GetUserById(id); - message += Messages.FormatOnlineBuddyEntry() + int icon = -1; + if (friend.NewPlayer) + icon = Messages.NewUserIcon; + if (friend.Subscribed) + { + int months = (DateTime.UtcNow.Month - friend.SubscribedUntil.Month) + 12 * (DateTime.UtcNow.Year - friend.SubscribedUntil.Year); + if (months <= 1) + icon = Messages.MonthSubscriptionIcon; + else if (months <= 3) + icon = Messages.ThreeMonthSubscripitionIcon; + else + icon = Messages.YearSubscriptionIcon; + } + if (friend.Moderator) + icon = Messages.ModeratorIcon; + if (friend.Administrator) + icon = Messages.AdminIcon; + + string iconFormat = ""; + if (icon != -1) + iconFormat = Messages.FormatIconFormat(icon); + message += Messages.FormatOnlineBuddyEntry(iconFormat, friend.Username, friend.Id, (DateTime.UtcNow - friend.LoginTime).Minutes, friend.X, friend.Y); + } - catch (KeyNotFoundException) { }; + catch (KeyNotFoundException) { } + } + message += Messages.BuddyListOfflineBuddys; + + foreach(int id in user.Friends.List.ToArray()) + { + if (GameServer.IsUserOnline(id)) + continue; + + message += Messages.BuddyListOfflineBuddys; + string username = Database.GetUsername(id); + int minutes = (DateTime.UtcNow - Converters.UnixTimeStampToDateTime(Database.GetPlayerLastLogin(id))).Minutes; + + message += Messages.FormatOfflineBuddyEntry(username, id, minutes); + } + + message += Messages.PlayerListIconInformation; + message += Messages.BackToMap; + message += Messages.MetaTerminator; + + return message; } public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile) diff --git a/Horse Isle Server/Horse Isle Server/Player/User.cs b/Horse Isle Server/Horse Isle Server/Player/User.cs index fe2c888..fc63fcc 100644 --- a/Horse Isle Server/Horse Isle Server/Player/User.cs +++ b/Horse Isle Server/Horse Isle Server/Player/User.cs @@ -42,16 +42,19 @@ namespace HISP.Player public Highscore Highscores; public Award Awards; public DateTime LoginTime; + + public DateTime SubscribedUntil + { + get + { + return Converters.UnixTimeStampToDateTime(subscribedUntil); + } + } public int FreeMinutes { get { int freeTime = Database.GetFreeTime(Id); - if(freeTime > 360) - { - Database.SetFreeTime(Id, 360); - return 360; - } return freeTime; } set diff --git a/Horse Isle Server/Horse Isle Server/Server/Converters.cs b/Horse Isle Server/Horse Isle Server/Server/Converters.cs index 976b5c7..2cff15c 100644 --- a/Horse Isle Server/Horse Isle Server/Server/Converters.cs +++ b/Horse Isle Server/Horse Isle Server/Server/Converters.cs @@ -34,6 +34,14 @@ namespace HISP.Server return arr; } + public static DateTime UnixTimeStampToDateTime(double unixTimeStamp) + { + // Unix timestamp is seconds past epoch + System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); + dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime(); + return dtDateTime; + } + } } diff --git a/Horse Isle Server/Horse Isle Server/Server/Database.cs b/Horse Isle Server/Horse Isle Server/Server/Database.cs index 0477ed9..b3f8adc 100644 --- a/Horse Isle Server/Horse Isle Server/Server/Database.cs +++ b/Horse Isle Server/Horse Isle Server/Server/Database.cs @@ -17,7 +17,7 @@ namespace HISP.Server { db.Open(); string UserTable = "CREATE TABLE Users(Id INT, Username TEXT(16),Email TEXT(128),Country TEXT(128),SecurityQuestion Text(128),SecurityAnswerHash TEXT(128),Age INT,PassHash TEXT(128), Salt TEXT(128),Gender TEXT(16), Admin TEXT(3), Moderator TEXT(3))"; - string ExtTable = "CREATE TABLE UserExt(Id INT, X INT, Y INT, Money INT, QuestPoints INT, BankBalance BIGINT,ProfilePage Text(1028),PrivateNotes Text(1028), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT)"; + string ExtTable = "CREATE TABLE UserExt(Id INT, X INT, Y INT, LastLogin INT, Money INT, QuestPoints INT, BankBalance BIGINT, ProfilePage Text(1028),PrivateNotes Text(1028), CharId INT, ChatViolations INT,Subscriber TEXT(3), SubscribedUntil INT, Experience INT, Tiredness INT, Hunger INT, Thirst INT, FreeMinutes INT)"; string MailTable = "CREATE TABLE Mailbox(IdTo INT, PlayerFrom TEXT(16),Subject TEXT(128), Message Text(1028), TimeSent INT)"; string BuddyTable = "CREATE TABLE BuddyList(Id INT, IdFriend INT, Pending BOOL)"; string WorldTable = "CREATE TABLE World(Time INT,Day INT, Year INT, Weather TEXT(64))"; @@ -33,7 +33,6 @@ namespace HISP.Server string DeleteOnlineUsers = "DELETE FROM OnlineUsers"; - try { @@ -1412,8 +1411,9 @@ namespace HISP.Server throw new Exception("Userid " + id + " Allready in userext."); MySqlCommand sqlCommand = db.CreateCommand(); - sqlCommand.CommandText = "INSERT INTO UserExt VALUES(@id,@x,@y,0,0,0,'','',0,0,'NO',0,0,1000,1000,1000, 360)"; + sqlCommand.CommandText = "INSERT INTO UserExt VALUES(@id,@x,@y,@timestamp,0,0,0,'','',0,0,'NO',0,0,1000,1000,1000, 360)"; sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Parameters.AddWithValue("@timestamp", Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds())); sqlCommand.Parameters.AddWithValue("@x", Map.NewUserStartX); sqlCommand.Parameters.AddWithValue("@y", Map.NewUserStartY); sqlCommand.Prepare(); @@ -1722,6 +1722,7 @@ namespace HISP.Server } } + public static void SetPlayerMoney(int money, int id) { using (MySqlConnection db = new MySqlConnection(ConnectionString)) @@ -2026,6 +2027,52 @@ namespace HISP.Server } } + public static int GetPlayerLastLogin(int userId) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + if (CheckUserExtExists(userId)) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "SELECT LastLogin FROM UserExt WHERE Id=@id"; + sqlCommand.Parameters.AddWithValue("@id", userId); + sqlCommand.Prepare(); + int lastLogin = Convert.ToInt32(sqlCommand.ExecuteScalar()); + + sqlCommand.Dispose(); + return lastLogin; + } + else + { + throw new KeyNotFoundException("Id " + userId + " not found in database."); + } + } + } + + public static void SetPlayerLastLogin(int lastlogin, int id) + { + using (MySqlConnection db = new MySqlConnection(ConnectionString)) + { + db.Open(); + if (CheckUserExist(id)) + { + MySqlCommand sqlCommand = db.CreateCommand(); + sqlCommand.CommandText = "UPDATE UserExt SET LastLogin=@lastlogin WHERE Id=@id"; + sqlCommand.Parameters.AddWithValue("@lastlogin", lastlogin); + sqlCommand.Parameters.AddWithValue("@id", id); + sqlCommand.Prepare(); + sqlCommand.ExecuteNonQuery(); + + sqlCommand.Dispose(); + } + else + { + throw new KeyNotFoundException("Id " + id + " not found in database."); + } + } + } + public static int GetPlayerMoney(int userId) { using (MySqlConnection db = new MySqlConnection(ConnectionString)) diff --git a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs index 5d98d1f..7ab9b94 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs @@ -571,10 +571,11 @@ namespace HISP.Server Messages.BuddyListHeader = gameData.messages.meta.player_list.online_buddy_header; Messages.BuddyListOnlineBuddyEntryFormat = gameData.messages.meta.player_list.online_buddy_format; - Messages.BuddyListOfflineBuddys = gameData.messages.meta.offline_buddys; - Messages.BuddyListOfflineBuddyEntryFormat = gameData.messages.player_list.offline_buddy_format; + Messages.BuddyListOfflineBuddys = gameData.messages.meta.player_list.offline_buddys; + Messages.BuddyListOfflineBuddyEntryFormat = gameData.messages.meta.player_list.offline_buddy_format; - Messages.PlayerListIconInformation = gameData.messages.player_list.icon_info; + Messages.PlayerListIconFormat = gameData.messages.meta.player_list.icon_format; + Messages.PlayerListIconInformation = gameData.messages.meta.player_list.icon_info; // Consume Messages.ConsumeItemFormat = gameData.messages.consume.consumed_item_format; diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs index 07016d3..991bc99 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs @@ -194,6 +194,11 @@ namespace HISP.Server metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAwardList(sender.LoggedinUser)); sender.SendPacket(metaPacket); break; + case 35: + sender.LoggedinUser.MetaPriority = true; + metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildBuddyList(sender.LoggedinUser)); + sender.SendPacket(metaPacket); + break; default: Logger.ErrorPrint("Dynamic button #" + buttonId + " unknown..."); break; @@ -1899,11 +1904,14 @@ namespace HISP.Server } } + public static void OnDisconnect(GameClient sender) { connectedClients.Remove(sender); if (sender.LoggedIn) { + Database.SetPlayerLastLogin(Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds()), sender.LoggedinUser.Id); // Set last login date + Database.RemoveOnlineUser(sender.LoggedinUser.Id); // Send disconnect message byte[] logoutMessageBytes = PacketBuilder.CreateChat(Messages.FormatLogoutMessage(sender.LoggedinUser.Username), PacketBuilder.CHAT_BOTTOM_LEFT); @@ -1926,6 +1934,19 @@ namespace HISP.Server * Get(Some Information) */ + + public static bool IsUserOnline(int id) + { + try + { + GetUserById(id); + return true; + } + catch (KeyNotFoundException) + { + return false; + } + } public static User[] GetUsersUsersInIsle(World.Isle isle, bool includeStealth = false, bool includeMuted = false) { List usersInIsle = new List(); diff --git a/WebInterface/master-site/ipbanned.php b/WebInterface/master-site/ipbanned.php new file mode 100644 index 0000000..bfe5a61 --- /dev/null +++ b/WebInterface/master-site/ipbanned.php @@ -0,0 +1,133 @@ + +HORSE ISLE - Online Multiplayer Horse Game + + + + + + + + + + + + + + + + + + + + + +
Welcome to Horse Isle 
+ + + + + +
USER:
PASS:
(Forgot?)
+ +
 
+
+
Your IP Address () Has been banned due to An Account on the same Computer/Internet source having Seriously Violated our Terms of Service / Rules. We do not Ban unless we have good reason. Email: support@horseisle.com if you wish to discuss this matter.
Please realize this game is for ALL AGES, and so we struggle to keep it a clean, safe, friendly place.
Thanks.


+ + + + +
+
+[ New Player Guide ]
+[ Rules ] +[ Terms and Conditions ] +[ Privacy Policy ]

+[ Expected Behavior ] +[ Contact Us ] +[ Credits ]
+Copyright © 2020 Horse Isle + + + +