From f14355bae81437c8ca2e87a37658b67e320300d3 Mon Sep 17 00:00:00 2001
From: Li
Date: Sun, 8 May 2022 16:25:53 +1200
Subject: [PATCH] Add %% command."
---
HorseIsleServer/HISPd/Resources/DEBIAN/prerm | 1 +
HorseIsleServer/LibHISP/Game/Chat/Command.cs | 34 +++++++++++++------
HorseIsleServer/LibHISP/Game/Messages.cs | 10 +++++-
.../LibHISP/Server/GameDataJson.cs | 2 ++
.../LibHISP/Server/ServerVersion.cs | 2 +-
5 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/HorseIsleServer/HISPd/Resources/DEBIAN/prerm b/HorseIsleServer/HISPd/Resources/DEBIAN/prerm
index 3133209..f425856 100644
--- a/HorseIsleServer/HISPd/Resources/DEBIAN/prerm
+++ b/HorseIsleServer/HISPd/Resources/DEBIAN/prerm
@@ -1,3 +1,4 @@
#!/bin/sh
systemctl stop HISP
systemctl disable HISP
+userdel horseisle
diff --git a/HorseIsleServer/LibHISP/Game/Chat/Command.cs b/HorseIsleServer/LibHISP/Game/Chat/Command.cs
index 5c6fde2..0073770 100644
--- a/HorseIsleServer/LibHISP/Game/Chat/Command.cs
+++ b/HorseIsleServer/LibHISP/Game/Chat/Command.cs
@@ -42,8 +42,9 @@ namespace HISP.Game.Chat
new CommandRegister('%', "MODHORSE", Command.ModHorse);
new CommandRegister('%', "DELITEM", Command.DelItem);
new CommandRegister('%', "SHUTDOWN", Command.Shutdown);
- new CommandRegister('%', "RELOAD", Command.Reload);
new CommandRegister('%', "CALL", Command.CallHorse);
+ new CommandRegister('%', "MESSAGE", Command.Message);
+ new CommandRegister('%', "%", Command.Message);
// Moderator commands
new CommandRegister('%', "RULES", Command.Rules);
@@ -64,14 +65,25 @@ namespace HISP.Game.Chat
new CommandRegister('!', "VERSION", Command.Version);
}
- public static bool Reload(string message, string[] args, User user)
+ public static bool Message(string message, string[] args, User user)
{
if (!user.Administrator)
return false;
+ string serverAnnoucement = String.Join(" ", args);
- byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message), PacketBuilder.CHAT_BOTTOM_LEFT);
- user.LoggedinClient.SendPacket(chatPacket);
+ byte[] chatLeftPacket = PacketBuilder.CreateChat(Messages.FormatServerAnnoucement(serverAnnoucement), PacketBuilder.CHAT_BOTTOM_LEFT);
+ byte[] chatRightPacket = PacketBuilder.CreateChat(Messages.FormatServerAnnoucement(serverAnnoucement), PacketBuilder.CHAT_BOTTOM_LEFT);
+
+ foreach (GameClient client in GameClient.ConnectedClients)
+ {
+ if (client.LoggedIn)
+ {
+ client.SendPacket(chatLeftPacket);
+ client.SendPacket(chatRightPacket);
+ }
+ }
+
return true;
}
public static bool Shutdown(string message, string[] args, User user)
@@ -303,12 +315,12 @@ namespace HISP.Game.Chat
public static bool Version(string message, string[] args, User user)
{
// Get current version and send to client
- byte[] versionPacket = PacketBuilder.CreateChat(ServerVersion.GetBuildString(), PacketBuilder.CHAT_BOTTOM_RIGHT);
- user.LoggedinClient.SendPacket(versionPacket);
-
- // Send Command complete message to client.
- byte[] versionCommandCompletePacket = PacketBuilder.CreateChat(Messages.FormatPlayerCommandCompleteMessage(message), PacketBuilder.CHAT_BOTTOM_LEFT);
- user.LoggedinClient.SendPacket(versionCommandCompletePacket);
+ byte[] versionPacket = PacketBuilder.CreateChat(ServerVersion.GetBuildString(), PacketBuilder.CHAT_BOTTOM_LEFT);
+ user.LoggedinClient.SendPacket(versionPacket);
+
+
+ byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatPlayerCommandCompleteMessage(message), PacketBuilder.CHAT_BOTTOM_LEFT);
+ user.LoggedinClient.SendPacket(chatPacket);
return true;
}
public static bool Ban(string message, string[] args, User user)
@@ -774,7 +786,7 @@ namespace HISP.Game.Chat
return false;
if (args.Length >= 1)
- if (args[1].ToUpper() != "HORSE")
+ if (args[0].ToUpper() != "HORSE")
return false;
string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message);
diff --git a/HorseIsleServer/LibHISP/Game/Messages.cs b/HorseIsleServer/LibHISP/Game/Messages.cs
index 02e7d53..b9bb53f 100644
--- a/HorseIsleServer/LibHISP/Game/Messages.cs
+++ b/HorseIsleServer/LibHISP/Game/Messages.cs
@@ -656,6 +656,8 @@ namespace HISP.Game
public static string AdminChatFormatForSender;
public static string ModChatFormatForSender;
+ public static string ServerAnnoucementFormat;
+
public static string DmModBadge;
public static string DmAutoResponse;
@@ -2946,7 +2948,7 @@ namespace HISP.Game
{
return ModChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message);
}
-
+ // NOTE: i dont have the correct format for this, im just guessing
public static string FormatAdminChatMessage(string username, string message)
{
return AdminChatFormat.Replace("%USERNAME%", username).Replace("%MESSAGE%", message);
@@ -3013,6 +3015,12 @@ namespace HISP.Game
return WelcomeFormat.Replace("%USERNAME%", username);
}
+ // NOTE: i dont have the correct format for this, im just guessing
+ public static string FormatServerAnnoucement(string message)
+ {
+ return ServerAnnoucementFormat.Replace("%MESSAGE%", message);
+ }
+
// Transport
public static string FormatWelcomeToAreaMessage(string placeName)
{
diff --git a/HorseIsleServer/LibHISP/Server/GameDataJson.cs b/HorseIsleServer/LibHISP/Server/GameDataJson.cs
index 71c810f..cc41141 100644
--- a/HorseIsleServer/LibHISP/Server/GameDataJson.cs
+++ b/HorseIsleServer/LibHISP/Server/GameDataJson.cs
@@ -1887,6 +1887,8 @@ namespace HISP.Server
Messages.AdsChatFormatForSender = gameData.messages.chat.for_sender.ads_format;
Messages.AdminChatFormatForSender = gameData.messages.chat.for_sender.admin_format;
+ Messages.ServerAnnoucementFormat = gameData.messages.chat.server_annoucement;
+
Messages.DmModBadge = gameData.messages.chat.dm_moderator;
Messages.DmAutoResponse = gameData.messages.chat.dm_autoreply;
diff --git a/HorseIsleServer/LibHISP/Server/ServerVersion.cs b/HorseIsleServer/LibHISP/Server/ServerVersion.cs
index 26f66cb..774f37f 100644
--- a/HorseIsleServer/LibHISP/Server/ServerVersion.cs
+++ b/HorseIsleServer/LibHISP/Server/ServerVersion.cs
@@ -72,7 +72,7 @@ namespace HISP.Server
}
public static string GetBuildString()
{
- return PRODUCT + " " + GetVersionString() + " " + GetBranch() + "@" + GetCommitHash(4) + " (" + GetArchitecture() + "; " + GetPlatform() + "); Built @ " + GetBuildDate() + " " + GetBuildTime();
+ return PRODUCT + " " + GetVersionString() + " " + GetBranch() + "@" + GetCommitHash(6) + " (" + GetArchitecture() + "; " + GetPlatform() + "); Built @ " + GetBuildDate() + " " + GetBuildTime();
}
}
}