Add buddy list ..

This commit is contained in:
SilicaAndPina 2020-12-29 23:01:10 +13:00
parent f84db853fe
commit df44358ad7
9 changed files with 279 additions and 18 deletions

View file

@ -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,

View file

@ -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)
{

View file

@ -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)

View file

@ -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

View file

@ -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;
}
}
}

View file

@ -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))

View file

@ -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;

View file

@ -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<User> usersInIsle = new List<User>();

View file

@ -0,0 +1,133 @@
<HEAD>
<TITLE>HORSE ISLE - Online Multiplayer Horse Game</TITLE>
<META NAME="keywords" CONTENT="Horse Game Online MMORPG Multiplayer Horses RPG Girls Girly Isle World Island Virtual Horseisle Sim Virtual">
<META NAME="description" CONTENT="A multiplayer online horse world where players can capture, train, care for and compete their horses against other players. A very unique virtual sim horse game.">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="meta" href="http://horseisle.com/labels.rdf" type="application/rdf+xml" title="ICRA labels" />
<meta http-equiv="pics-Label" content='(pics-1.1 "http://www.icra.org/pics/vocabularyv03/" l gen true for "http://horseisle.com" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 1) gen true for "http://hi1.horseisle.com" r (n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 1))' />
<style type="text/css">
hr {
height: 1;
color: #000000;
background-color: #000000;
border: 0;
}
a {
font: bold 14px arial;
color: #6E3278;
}
TH {
background-color: #EDE5B4;
padding: 1px 6px;
border: 2px dotted #6E3278;
font: small-caps 900 14px arial;
color: #000000;
}
TR.a0 {
background-color: #EDE5B4;
}
TR.a1 {
background-color: #D4CCA1;
}
TD {
font: 14px arial;
color: #000000;
}
TD.forum {
font: 12px arial;
color: #000000;
}
TD.forumlist {
padding: 1px 6px;
border: 2px dotted #6E3278;
background-color: #EDE5B4;
text-align: center;
font: bold 14px arial;
color: #000000;
}
TD.forumpost {
padding: 5px 10px;
border: 2px dotted #6E3278;
background-color: #EDE5B4;
text-align: left;
}
TD.adminforumpost {
padding: 5px 20px;
border: 2px dotted #6E3278;
background-color: #BFE9C9;
text-align: left;
}
TD.newslist {
padding: 4px 4px;
border: 2px dotted #6E3278;
background-color: #FFDDEE;
text-align: left;
font: 14px arial;
color: #000000;
}
FORUMSUBJECT {
font: bold 14px arial;
color: #004400;
}
FORUMUSER {
font: 12px arial;
color: #000044;
}
FORUMDATE {
font: 12px arial;
color: #444444;
}
FORUMTEXT {
font: 14px arial;
color: #440000;
}
</style>
</HEAD>
<BODY BGCOLOR=E0D8AA>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR WIDTH=100%>
<TD WIDTH=512 ROWSPAN=3><A HREF=/><IMG SRC=/web/hoilgui1.gif ALT="Welcome to Horse Isle" BORDER=0></A></TD>
<TD WIDTH=100% BACKGROUND=/web/hoilgui2.gif>&nbsp;</TD>
<TD WIDTH=29><IMG SRC=/web/hoilgui3.gif></TD>
</TR>
<TR>
<TD WIDTH=100% BACKGROUND=/web/hoilgui4.gif align=right>
<B>
<TABLE CELLPADDING=0 CELLSPACING=2 BORDER=0><FORM METHOD=POST ACTION=/account.php>
<TR><TD><B>USER:</B></TD><TD><INPUT TYPE=TEXT SIZE=14 NAME=USER></TD></TR>
<TR><TD><B>PASS:</B></TD><TD><INPUT TYPE=PASSWORD SIZE=14 NAME=PASS></TD></TR>
<TR><TD></TD><TD><INPUT TYPE=SUBMIT VALUE=LOGIN> (<A HREF=/web/forgotpass.php>Forgot?</A>)</TD></TR></FORM></TABLE>
</TD>
<TD WIDTH=29><IMG SRC=/web/hoilgui5.gif></TD></TR>
<TR>
<TD WIDTH=100% BACKGROUND=/web/hoilgui6.gif>&nbsp;</TD>
<TD WIDTH=29><IMG SRC=/web/hoilgui7.gif></TD></TR>
</TABLE>
<CENTER>
<HR><B>Your IP Address (<?php $_SERVER['REMOTE_ADDR']; ?>) 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.<BR>Please realize this game is for ALL AGES, and so we struggle to keep it a clean, safe, friendly place.<BR>Thanks.</B><BR><HR><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR>
<TD><IMG SRC=/web/hoilgui10.gif></TD>
<TD WIDTH=100% BACKGROUND=/web/hoilgui11.gif></TD>
<TD><IMG SRC=/web/hoilgui12.gif></TD>
</TR></TABLE>
<CENTER><B>
[ <A HREF=//master.horseisle.com/beginnerguide/>New Player Guide</A> ]<BR>
[ <A HREF=/web/rules.php>Rules</A> ]
[ <A HREF=/web/termsandconditions.php>Terms and Conditions</A> ]
[ <A HREF=/web/privacypolicy.php>Privacy Policy</A> ]</B><BR>
[ <A HREF=/web/expectedbehavior.php>Expected Behavior</A> ]
[ <A HREF=/web/contactus.php>Contact Us</A> ]
[ <A HREF=/web/credits.php>Credits</A> ]<BR>
<FONT FACE=Verdana,Arial SIZE=-2>Copyright &copy; 2020 Horse Isle</FONT>
<!-- Google Analytics -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1805076-1";
urchinTracker();
</script>