mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-19 19:29:15 +12:00
Add report function and player list
This commit is contained in:
parent
29f5ad0ec2
commit
50db63729d
11 changed files with 402 additions and 62 deletions
47
Horse Isle Server/Horse Isle Server/Game/AbuseReport.cs
Normal file
47
Horse Isle Server/Horse Isle Server/Game/AbuseReport.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System.Collections.Generic;
|
||||
namespace HISP.Game
|
||||
{
|
||||
class AbuseReport
|
||||
{
|
||||
public struct ReportReason
|
||||
{
|
||||
public string Id;
|
||||
public string Name;
|
||||
public string Meta;
|
||||
}
|
||||
private static List<ReportReason> reportReasons = new List<ReportReason>();
|
||||
|
||||
public static ReportReason[] ReportReasons
|
||||
{
|
||||
get
|
||||
{
|
||||
return reportReasons.ToArray();
|
||||
}
|
||||
}
|
||||
public static bool DoesReasonExist(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetReasonById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static ReportReason GetReasonById(string id)
|
||||
{
|
||||
foreach(ReportReason reason in ReportReasons)
|
||||
{
|
||||
if (reason.Id == id)
|
||||
return reason;
|
||||
}
|
||||
throw new KeyNotFoundException("No reason of: " + id + " Found.");
|
||||
}
|
||||
public static void AddReason(ReportReason reason)
|
||||
{
|
||||
reportReasons.Add(reason);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -221,7 +221,15 @@ namespace HISP.Game
|
|||
public static string BeatHighscoreFormat;
|
||||
public static string BeatBestTimeFormat;
|
||||
|
||||
// Abuse Report
|
||||
public static string AbuseReportMetaFormat;
|
||||
public static string AbuseReportReasonFormat;
|
||||
public static string AbuseReportPlayerNotFoundFormat;
|
||||
public static string AbuseReportFiled;
|
||||
public static string AbuseReportProvideValidReason;
|
||||
|
||||
// Player List
|
||||
public static string PlayerListAbuseReport;
|
||||
public static string PlayerListHeader;
|
||||
public static string PlayerListSelectFromFollowing;
|
||||
public static string PlayerListOfBuddiesFormat;
|
||||
|
@ -230,7 +238,6 @@ namespace HISP.Game
|
|||
public static string PlayerListOfPlayersAlphabetically;
|
||||
public static string PlayerListMapAllBuddiesForamt;
|
||||
public static string PlayerListMapAllPlayersFormat;
|
||||
public static string PlayerListAbuseReport;
|
||||
|
||||
public static int ThreeMonthSubscripitionIcon;
|
||||
public static int YearSubscriptionIcon;
|
||||
|
@ -244,6 +251,13 @@ namespace HISP.Game
|
|||
public static string BuddyListOfflineBuddys;
|
||||
public static string BuddyListOfflineBuddyEntryFormat;
|
||||
|
||||
public static string NearbyPlayersListHeader;
|
||||
public static string PlayerListEntryFormat;
|
||||
|
||||
public static string PlayerListAllHeader;
|
||||
public static string PlayerListAllAlphabeticalHeader;
|
||||
|
||||
public static string PlayerListIdle;
|
||||
public static string PlayerListIconFormat;
|
||||
public static string PlayerListIconInformation;
|
||||
|
||||
|
@ -281,10 +295,30 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
|
||||
public static string FormatAbuseReportPlayerNotFound(string username)
|
||||
{
|
||||
return AbuseReportPlayerNotFoundFormat.Replace("%USERNAME%", username);
|
||||
}
|
||||
public static string FormatAbuseReportMetaPage(string reasonsMeta)
|
||||
{
|
||||
return AbuseReportMetaFormat.Replace("%REASONS%", reasonsMeta);
|
||||
}
|
||||
|
||||
public static string FormatAbuseReportReason(string id, string name)
|
||||
{
|
||||
return AbuseReportReasonFormat.Replace("%ID%", id).Replace("%NAME%", name);
|
||||
}
|
||||
public static string FormatIconFormat(int iconId)
|
||||
{
|
||||
return PlayerListIconFormat.Replace("%ICON%", iconId.ToString());
|
||||
}
|
||||
|
||||
public static string FormatPlayerEntry(string iconFormat, string username, int userId, int time, int x, int y, bool idle)
|
||||
{
|
||||
string xy = FormatMapLocation(x, y);
|
||||
return PlayerListEntryFormat.Replace("%ICONFORMAT%", iconFormat).Replace("%USERNAME%", username).Replace("%PLAYERID%", userId.ToString()).Replace("%TIME%", time.ToString("N0")).Replace("%MAPXY%", xy).Replace("%IDLE%", idle ? PlayerListIdle : "");
|
||||
}
|
||||
public static string FormatOnlineBuddyEntry(string iconFormat, string username, int userId, int time, int x, int y)
|
||||
{
|
||||
string xy = FormatMapLocation(x, y);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
@ -409,6 +410,98 @@ namespace HISP.Game
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static string BuildNearbyList(User user)
|
||||
{
|
||||
string message = Messages.NearbyPlayersListHeader;
|
||||
User[] nearbyUsers = GameServer.GetNearbyUsers(user.X, user.Y, false, true);
|
||||
foreach (User nearbyUser in nearbyUsers)
|
||||
{
|
||||
if (nearbyUser.Stealth)
|
||||
continue;
|
||||
|
||||
if (nearbyUser.Id == user.Id)
|
||||
continue;
|
||||
|
||||
|
||||
int icon = nearbyUser.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatPlayerEntry(iconFormat, nearbyUser.Username, nearbyUser.Id, (DateTime.UtcNow - nearbyUser.LoginTime).Minutes, nearbyUser.X, nearbyUser.Y, nearbyUser.Idle);
|
||||
}
|
||||
|
||||
message += Messages.PlayerListIconInformation;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildPlayerListAlphabetical()
|
||||
{
|
||||
string message = Messages.PlayerListAllAlphabeticalHeader;
|
||||
GameClient[] clients = GameServer.ConnectedClients;
|
||||
List<User> onlineUsers = new List<User>();
|
||||
|
||||
foreach (GameClient client in clients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Stealth)
|
||||
continue;
|
||||
onlineUsers.Add(client.LoggedinUser);
|
||||
}
|
||||
}
|
||||
|
||||
onlineUsers = onlineUsers.OrderBy(o => o.Username).ToList();
|
||||
|
||||
foreach (User onlineUser in onlineUsers)
|
||||
{
|
||||
|
||||
int icon = onlineUser.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatPlayerEntry(iconFormat, onlineUser.Username, onlineUser.Id, (DateTime.UtcNow - onlineUser.LoginTime).Minutes, onlineUser.X, onlineUser.Y, onlineUser.Idle);
|
||||
}
|
||||
|
||||
message += Messages.PlayerListIconInformation;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildPlayerList()
|
||||
{
|
||||
string message = Messages.PlayerListAllHeader;
|
||||
GameClient[] clients = GameServer.ConnectedClients;
|
||||
foreach(GameClient client in clients)
|
||||
{
|
||||
if(client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Stealth)
|
||||
continue;
|
||||
|
||||
int icon = client.LoggedinUser.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatPlayerEntry(iconFormat, client.LoggedinUser.Username, client.LoggedinUser.Id, (DateTime.UtcNow - client.LoggedinUser.LoginTime).Minutes, client.LoggedinUser.X, client.LoggedinUser.Y, client.LoggedinUser.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
message += Messages.PlayerListIconInformation;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildBuddyList(User user)
|
||||
{
|
||||
string message = Messages.BuddyListHeader;
|
||||
|
@ -417,27 +510,14 @@ namespace HISP.Game
|
|||
try
|
||||
{
|
||||
User friend = GameServer.GetUserById(id);
|
||||
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;
|
||||
if (friend.Stealth)
|
||||
continue;
|
||||
|
||||
int icon = friend.GetPlayerListIcon();
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -529,6 +609,15 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
public static string BuildAbuseReportPage()
|
||||
{
|
||||
string reportReasons = "";
|
||||
foreach(AbuseReport.ReportReason reason in AbuseReport.ReportReasons)
|
||||
{
|
||||
reportReasons += Messages.FormatAbuseReportReason(reason.Id, reason.Name);
|
||||
}
|
||||
return Messages.FormatAbuseReportMetaPage(reportReasons);
|
||||
}
|
||||
public static string BuildPlayerList(User user)
|
||||
{
|
||||
string message = "";
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Game\AbuseReport.cs" />
|
||||
<Compile Include="Game\Chat\Command.cs" />
|
||||
<Compile Include="Game\GameExceptions.cs" />
|
||||
<Compile Include="Game\Inventory\InventoryItem.cs" />
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace HISP.Player
|
|||
public string Gender;
|
||||
public bool MetaPriority = false;
|
||||
|
||||
public bool Idle;
|
||||
public int Facing;
|
||||
public Mailbox MailBox;
|
||||
public Friends Friends;
|
||||
|
@ -153,6 +154,7 @@ namespace HISP.Player
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public int Experience
|
||||
{
|
||||
get
|
||||
|
@ -305,6 +307,29 @@ namespace HISP.Player
|
|||
public int SecCodeInc = 0;
|
||||
public int SecCodeCount = 0;
|
||||
|
||||
|
||||
public int GetPlayerListIcon()
|
||||
{
|
||||
int icon = -1;
|
||||
if (NewPlayer)
|
||||
icon = Messages.NewUserIcon;
|
||||
if (Subscribed)
|
||||
{
|
||||
int months = (DateTime.UtcNow.Month - SubscribedUntil.Month) + 12 * (DateTime.UtcNow.Year - SubscribedUntil.Year);
|
||||
if (months <= 1)
|
||||
icon = Messages.MonthSubscriptionIcon;
|
||||
else if (months <= 3)
|
||||
icon = Messages.ThreeMonthSubscripitionIcon;
|
||||
else
|
||||
icon = Messages.YearSubscriptionIcon;
|
||||
}
|
||||
if (Moderator)
|
||||
icon = Messages.ModeratorIcon;
|
||||
if (Administrator)
|
||||
icon = Messages.AdminIcon;
|
||||
|
||||
return icon;
|
||||
}
|
||||
public void Teleport(int newX, int newY)
|
||||
{
|
||||
Logger.DebugPrint("Teleporting: " + Username + " to: " + newX.ToString() + "," + newY.ToString());
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace HISP.Server
|
|||
string CompetitionGear = "CREATE TABLE CompetitionGear(playerId INT, headItem INT, bodyItem INT, legItem INT, feetItem INT)";
|
||||
string Awards = "CREATE TABLE Awards(playerId INT, awardId INT)";
|
||||
string Jewelry = "CREATE TABLE Jewelry(playerId INT, slot1 INT, slot2 INT, slot3 INT, slot4 INT)";
|
||||
string AbuseReorts = "CREATE TABLE AbuseReports(ReportCreator TEXT(1028), Reporting TEXT(1028), ReportReason TEXT(1028))";
|
||||
string Leaderboards = "CREATE TABLE Leaderboards(playerId INT, minigame TEXT(128), wins INT, looses INT, timesplayed INT, score INT, type TEXT(128))";
|
||||
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
||||
|
||||
|
@ -46,6 +47,19 @@ namespace HISP.Server
|
|||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = AbuseReorts;
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WarnPrint(e.Message);
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
|
@ -1176,6 +1190,25 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static void AddReport(string reportCreator, string reporting, string reportReason)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
int epoch = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
|
||||
sqlCommand.CommandText = "INSERT INTO AbuseReports VALUES(@reportCreator,@reporting,@reportReason)";
|
||||
sqlCommand.Parameters.AddWithValue("@reportCreator", reportCreator);
|
||||
sqlCommand.Parameters.AddWithValue("@reporting", reporting);
|
||||
sqlCommand.Parameters.AddWithValue("@reportReason", reportReason);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
public static void AddMail(int toId, string fromName, string subject, string message)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
|
|
@ -82,7 +82,8 @@ namespace HISP.Server
|
|||
Logger.DebugPrint("Sending inactivity warning to: " + RemoteIp);
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatIdleWarningMessage(), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
SendPacket(chatPacket);
|
||||
|
||||
if (LoggedIn)
|
||||
LoggedinUser.Idle = true;
|
||||
warnTimer.Dispose();
|
||||
warnTimer = null;
|
||||
|
||||
|
@ -167,9 +168,14 @@ namespace HISP.Server
|
|||
byte identifier = Packet[0];
|
||||
|
||||
// Reset timers
|
||||
if (inactivityTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
|
||||
inactivityTimer.Change(keepAliveInterval, keepAliveInterval);
|
||||
|
||||
|
||||
if (inactivityTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
|
||||
{
|
||||
if (LoggedIn)
|
||||
LoggedinUser.Idle = false;
|
||||
inactivityTimer.Change(keepAliveInterval, keepAliveInterval);
|
||||
}
|
||||
|
||||
if (kickTimer != null && identifier != PacketBuilder.PACKET_KEEP_ALIVE)
|
||||
kickTimer = new Timer(new TimerCallback(kickTimerTick), null, kickInterval, kickInterval);
|
||||
|
|
|
@ -394,6 +394,19 @@ namespace HISP.Server
|
|||
Logger.DebugPrint("Registered Award ID: " + award.Id + " - " + award.Title);
|
||||
}
|
||||
|
||||
// Register Abuse Report Reasons
|
||||
|
||||
int totalAbuseReportReasons = gameData.messages.meta.abuse_report.reasons.Count;
|
||||
for(int i = 0; i < totalAbuseReportReasons; i++)
|
||||
{
|
||||
AbuseReport.ReportReason reason = new AbuseReport.ReportReason();
|
||||
reason.Id = gameData.messages.meta.abuse_report.reasons[i].id;
|
||||
reason.Name = gameData.messages.meta.abuse_report.reasons[i].name;
|
||||
reason.Meta = gameData.messages.meta.abuse_report.reasons[i].meta;
|
||||
AbuseReport.AddReason(reason);
|
||||
Logger.DebugPrint("Reigstered Abuse Report Reason: " + reason.Name);
|
||||
}
|
||||
|
||||
Item.Present = gameData.item.special.present;
|
||||
Item.MailMessage = gameData.item.special.mail_message;
|
||||
Item.DorothyShoes = gameData.item.special.dorothy_shoes;
|
||||
|
@ -475,6 +488,13 @@ namespace HISP.Server
|
|||
Messages.CantAffordTransport = gameData.messages.transport.not_enough_money;
|
||||
Messages.WelcomeToAreaFormat = gameData.messages.transport.welcome_to_format;
|
||||
|
||||
// Abuse Reports
|
||||
Messages.AbuseReportMetaFormat = gameData.messages.meta.abuse_report.options_format;
|
||||
Messages.AbuseReportReasonFormat = gameData.messages.meta.abuse_report.report_reason_format;
|
||||
|
||||
Messages.AbuseReportPlayerNotFoundFormat = gameData.messages.abuse_report.player_not_found_format;
|
||||
Messages.AbuseReportFiled = gameData.messages.abuse_report.report_filed;
|
||||
Messages.AbuseReportProvideValidReason = gameData.messages.abuse_report.valid_reason;
|
||||
// Chat
|
||||
|
||||
Messages.ChatViolationMessageFormat = gameData.messages.chat.violation_format;
|
||||
|
@ -574,6 +594,13 @@ namespace HISP.Server
|
|||
Messages.BuddyListOfflineBuddys = gameData.messages.meta.player_list.offline_buddys;
|
||||
Messages.BuddyListOfflineBuddyEntryFormat = gameData.messages.meta.player_list.offline_buddy_format;
|
||||
|
||||
Messages.NearbyPlayersListHeader = gameData.messages.meta.player_list.nearby_player_header;
|
||||
Messages.PlayerListAllAlphabeticalHeader = gameData.messages.meta.player_list.all_players_alphabetical_header;
|
||||
|
||||
Messages.PlayerListEntryFormat = gameData.messages.meta.player_list.player_format;
|
||||
|
||||
Messages.PlayerListIdle = gameData.messages.meta.player_list.idle_text;
|
||||
Messages.PlayerListAllHeader = gameData.messages.meta.player_list.all_players_header;
|
||||
Messages.PlayerListIconFormat = gameData.messages.meta.player_list.icon_format;
|
||||
Messages.PlayerListIconInformation = gameData.messages.meta.player_list.icon_info;
|
||||
// Consume
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace HISP.Server
|
|||
return;
|
||||
}
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string dynamicInputStr = packetStr.Substring(1, packetStr.Length - 2);
|
||||
string dynamicInputStr = packetStr.Substring(1, packetStr.Length - 3);
|
||||
if(dynamicInputStr.Contains("|"))
|
||||
{
|
||||
string[] dynamicInput = dynamicInputStr.Split('|');
|
||||
|
@ -97,22 +97,57 @@ namespace HISP.Server
|
|||
return;
|
||||
}
|
||||
|
||||
if(inputId == 7) // Private Notes
|
||||
switch(inputId) // Private Notes
|
||||
{
|
||||
if(dynamicInput.Length >= 2)
|
||||
{
|
||||
sender.LoggedinUser.PrivateNotes = dynamicInput[1];
|
||||
UpdateStats(sender);
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.PrivateNotesSavedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatPacket);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
||||
return;
|
||||
}
|
||||
case 7:
|
||||
if(dynamicInput.Length >= 2)
|
||||
{
|
||||
sender.LoggedinUser.PrivateNotes = dynamicInput[1];
|
||||
UpdateStats(sender);
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.PrivateNotesSavedMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatPacket);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
if (dynamicInput.Length >= 2)
|
||||
{
|
||||
string userName = dynamicInput[1];
|
||||
string reason = dynamicInput[2];
|
||||
if(Database.CheckUserExist(userName))
|
||||
{
|
||||
if(reason == "")
|
||||
{
|
||||
byte[] validReasonPlz = PacketBuilder.CreateChat(Messages.AbuseReportProvideValidReason, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(validReasonPlz);
|
||||
break;
|
||||
}
|
||||
|
||||
Database.AddReport(sender.LoggedinUser.Username, userName, reason);
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.AbuseReportFiled, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatPacket);
|
||||
Update(sender);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAbuseReportPlayerNotFound(userName), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatPacket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Logger.ErrorPrint("Unknown dynamic input: " + inputId.ToString() + " packet dump: " + BitConverter.ToString(packet).Replace("-", " "));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,49 +193,65 @@ namespace HISP.Server
|
|||
return;
|
||||
}
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string buttonIdStr = packetStr.Substring(1, packetStr.Length - 3);
|
||||
|
||||
// Determine which button it is
|
||||
int buttonId = 0;
|
||||
string buttonIdStr = packetStr.Substring(1, packetStr.Length - 2);
|
||||
try
|
||||
switch(buttonIdStr)
|
||||
{
|
||||
buttonId = int.Parse(buttonIdStr);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to click a invalid dynamic button");
|
||||
return;
|
||||
}
|
||||
|
||||
switch(buttonId)
|
||||
{
|
||||
case 3:
|
||||
case "3": // Quest Log
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildQuestLog(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 21:
|
||||
case "21": // Private Notes
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPrivateNotes(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 20:
|
||||
case "20": // Minigame Rankings
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigameRankingsForUser(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 24:
|
||||
case "24": // Award List
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAwardList(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 35:
|
||||
case "35": // Buddy List
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildBuddyList(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "36":
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildNearbyList(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "37": // All Players List
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPlayerList());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "40": // All Players Alphabetical
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPlayerListAlphabetical());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "28c1":
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAbuseReportPage());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Dynamic button #" + buttonId + " unknown...");
|
||||
if(AbuseReport.DoesReasonExist(buttonIdStr))
|
||||
{
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(AbuseReport.GetReasonById(buttonIdStr).Meta);
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
Logger.ErrorPrint("Dynamic button #" + buttonIdStr + " unknown...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -640,7 +691,7 @@ namespace HISP.Server
|
|||
User loggedInUser = sender.LoggedinUser;
|
||||
byte movementDirection = packet[1];
|
||||
|
||||
if (loggedInUser.Thirst <= 25 || loggedInUser.Hunger <= 25 || loggedInUser.Tiredness <= 25)
|
||||
if (loggedInUser.Thirst <= 0 || loggedInUser.Hunger <= 0 || loggedInUser.Tiredness <= 0)
|
||||
{
|
||||
if (RandomNumberGenerator.Next(0, 10) == 7)
|
||||
{
|
||||
|
@ -652,17 +703,17 @@ namespace HISP.Server
|
|||
if (newDirection != movementDirection)
|
||||
{
|
||||
movementDirection = newDirection;
|
||||
if (loggedInUser.Thirst <= 25)
|
||||
if (loggedInUser.Thirst <= 0)
|
||||
{
|
||||
byte[] chatMessage = PacketBuilder.CreateChat(Messages.FormatRandomMovementMessage(Messages.StatThirst.ToUpper()), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatMessage);
|
||||
}
|
||||
else if (loggedInUser.Hunger <= 25)
|
||||
else if (loggedInUser.Hunger <= 0)
|
||||
{
|
||||
byte[] chatMessage = PacketBuilder.CreateChat(Messages.FormatRandomMovementMessage(Messages.StatHunger.ToUpper()), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatMessage);
|
||||
}
|
||||
else if (loggedInUser.Tiredness <= 25)
|
||||
else if (loggedInUser.Tiredness <= 0)
|
||||
{
|
||||
byte[] chatMessage = PacketBuilder.CreateChat(Messages.FormatRandomMovementMessage(Messages.StatTired.ToUpper()), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(chatMessage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue