fix: Update LabelTo, SendMessage, etc to Interpolated Strings (#1283)

This commit is contained in:
Fabrizio 2022-11-29 04:58:12 +01:00 • committed by GitHub
parent 0facd73842
commit 537526a328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
94 changed files with 514 additions and 769 deletions

View file

@ -145,7 +145,7 @@ namespace Server.Misc
if (shouldKick)
{
state.Mobile.SendMessage(0x22, "You will be disconnected in {0} seconds.", KickDelay.TotalSeconds);
state.Mobile.SendMessage(0x22, $"You will be disconnected in {KickDelay.TotalSeconds} seconds.");
Timer.StartTimer(KickDelay, () => OnKick(state));
return;
}
@ -189,9 +189,7 @@ namespace Server.Misc
if (_invalidClientResponse == InvalidClientResponse.LenientKick)
{
from.SendMessage(
"Invalid clients will be kicked after {0} days of character age and {1} hours of play time",
_ageLeniency,
_gameTimeLeniency
$"Invalid clients will be kicked after {_ageLeniency} days of character age and {_gameTimeLeniency} hours of play time"
);
}

View file

@ -392,11 +392,7 @@ namespace Server
World.Broadcast(
0x35,
true,
"Door generation complete. Trammel: {0}; Felucca: {1}; Ilshenar: {2}; Malas: {3};",
trammelCount,
feluccaCount,
ilshenarCount,
malasCount
$"Door generation complete. Trammel: {trammelCount}; Felucca: {feluccaCount}; Ilshenar: {ilshenarCount}; Malas: {malasCount};"
);
}

View file

@ -274,11 +274,6 @@ namespace Server.Guilds
}
}
public void AllianceMessage(int num, bool append, string format, params object[] args)
{
AllianceMessage(num, append, string.Format(format, args));
}
public void AllianceMessage(int number)
{
for (var i = 0; i < m_Members.Count; ++i)
@ -303,15 +298,7 @@ namespace Server.Guilds
}
}
public void AllianceTextMessage(string text)
{
AllianceTextMessage(0x3B2, text);
}
public void AllianceTextMessage(string format, params object[] args)
{
AllianceTextMessage(0x3B2, string.Format(format, args));
}
public void AllianceTextMessage(string text) => AllianceTextMessage(0x3B2, text);
public void AllianceTextMessage(int hue, string text)
{
@ -321,11 +308,6 @@ namespace Server.Guilds
}
}
public void AllianceTextMessage(int hue, string format, params object[] args)
{
AllianceTextMessage(hue, string.Format(format, args));
}
public void AllianceChat(Mobile from, int hue, string text)
{
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
@ -1462,11 +1444,6 @@ namespace Server.Guilds
}
}
public void GuildMessage(int num, bool append, string format, params object[] args)
{
GuildMessage(num, append, string.Format(format, args));
}
public void GuildMessage(int number)
{
for (var i = 0; i < Members.Count; ++i)
@ -1491,15 +1468,7 @@ namespace Server.Guilds
}
}
public void GuildTextMessage(string text)
{
GuildTextMessage(0x3B2, text);
}
public void GuildTextMessage(string format, params object[] args)
{
GuildTextMessage(0x3B2, string.Format(format, args));
}
public void GuildTextMessage(string text) => GuildTextMessage(0x3B2, text);
public void GuildTextMessage(int hue, string text)
{
@ -1509,11 +1478,6 @@ namespace Server.Guilds
}
}
public void GuildTextMessage(int hue, string format, params object[] args)
{
GuildTextMessage(hue, string.Format(format, args));
}
public void GuildChat(Mobile from, int hue, string text)
{
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();

View file

@ -113,10 +113,7 @@ namespace Server
{
CommandLogging.WriteLine(
from,
"{0} {1} viewing hardware info of {2}",
from.AccessLevel,
CommandLogging.Format(from),
CommandLogging.Format(m)
$"{from.AccessLevel} {CommandLogging.Format(from)} viewing hardware info of {CommandLogging.Format(m)}"
);
}

View file

@ -31,16 +31,14 @@ namespace Server.Misc
{
if (!Core.SE)
{
from.SendMessage("Short Term Murders : {0}", from.ShortTermMurders);
from.SendMessage("Long Term Murders : {0}", from.Kills);
from.SendMessage($"Short Term Murders : {from.ShortTermMurders}");
from.SendMessage($"Long Term Murders : {from.Kills}");
}
else
{
from.SendMessage(
0x3B2,
"Short Term Murders: {0} Long Term Murders: {1}",
from.ShortTermMurders,
from.Kills
$"Short Term Murders: {from.ShortTermMurders} Long Term Murders: {from.Kills}"
);
}

View file

@ -44,7 +44,7 @@ namespace Server
if (e.Length >= 1)
{
LevelOverride = e.GetInt32(0);
e.Mobile.SendMessage("Global light level override has been changed to {0}.", m_LevelOverride);
e.Mobile.SendMessage($"Global light level override has been changed to {m_LevelOverride}.");
}
else
{

View file

@ -17,15 +17,8 @@ namespace Server.Misc
var mobileCount = World.Mobiles.Count;
m.SendMessage(
"Welcome, {0}! There {1} currently {2} user{3} online, with {4} item{5} and {6} mobile{7} in the world.",
m.Name,
userCount == 1 ? "is" : "are",
userCount,
userCount == 1 ? "" : "s",
itemCount,
itemCount == 1 ? "" : "s",
mobileCount,
mobileCount == 1 ? "" : "s"
$"Welcome, {m.Name}! There {(userCount == 1 ? "is" : "are")} currently {userCount} user{(userCount == 1 ? "" : "s")} " +
$"online, with {itemCount} item{(itemCount == 1 ? "" : "s")} and {mobileCount} mobile{(mobileCount == 1 ? "" : "s")} in the world."
);
}
}

View file

@ -72,7 +72,7 @@ namespace Server.Network
return;
}
e.Mobile.SendMessage("Packet 0x{0:X} throttle is currently {1}ms.", packetID, Delays[packetID]);
e.Mobile.SendMessage($"Packet 0x{packetID:X} throttle is currently {Delays[packetID]}ms.");
}
[Usage("SetThrottle <packetID> <timeInMilliseconds>")]

View file

@ -555,10 +555,15 @@ namespace Server.Misc
{
if (!m_Poller.Active)
{
m_From.SendMessage(
"Enter a title for the option. Escape to cancel.{0}",
opt == null ? "" : " Use \"DEL\" to delete."
);
if (opt == null)
{
m_From.SendMessage($"Enter a title for the option. Escape to cancel.");
}
else
{
m_From.SendMessage($"Enter a title for the option. Escape to cancel. Use \"DEL\" to delete.");
}
m_From.Prompt = new ShardPollPrompt(m_Poller, opt);
}
else