perf(messages): mechanical interpolation cleanups (#2436)
## Summary Phase 3.1 of the message-interpolation optimization series. Fixes 9 of the 28 sites flagged in the Phase 2 audit (PR #2435): | File | Fix | |---|---| | `Commands/StaffAccess.cs:88,99` | Drop redundant `.ToString()` on enum holes | | `Commands/Handlers.cs:102` | `builder.ToString()` -> `builder.AsSpan()` | | `World Saves/SaveCommands.cs:71-75` | Merge 3 concatenated `$"..."` into one literal | | `Server/Items/Item.cs:4213` | Hoist nested ternary `$"..."` to if/else | | `Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs:140-150` | Convert switch expression to switch statement | | `Mobiles/Monsters/LBR/Jukas/JukaLord.cs:85` | Restructure `string.Format(toSay.RandomElement(), ...)` into switch | | `Misc/AttackMessage.cs:30-41` | Inline `AggressorFormat`/`AggressedFormat` constants | No functional changes. Each site emits identical text; the only difference is that the message string is now built into a pooled char buffer instead of being allocated as a `string` first.
This commit is contained in:
parent
679e66b99d
commit
b2ccc7e4f3
6 changed files with 53 additions and 21 deletions
|
|
@ -137,17 +137,39 @@ namespace Server.Factions
|
|||
{
|
||||
Direction = GetDirectionTo(m);
|
||||
|
||||
var warning = Utility.Random(6) switch
|
||||
switch (Utility.Random(6))
|
||||
{
|
||||
0 => $"I warn you, {m.Name}, you would do well to leave this area before someone shows you the world of gray.",
|
||||
1 => $"It would be wise to leave this area, {m.Name}, lest your head become my commanders' trophy.",
|
||||
2 => $"You are bold, {m.Name}, for one of the meager {Faction.Find(m)?.Definition.FriendlyName ?? "civilians"}. Leave now, lest you be taught the taste of dirt.",
|
||||
3 => $"Your presence here is an insult, {m.Name}. Be gone now, knave.",
|
||||
4 => $"Dost thou wish to be hung by your toes, {m.Name}? Nay? Then come no closer.",
|
||||
_ => $"Hey, {m.Name}. Yeah, you. Get out of here before I beat you with a stick." // 5
|
||||
};
|
||||
|
||||
Say(warning);
|
||||
case 0:
|
||||
{
|
||||
Say($"I warn you, {m.Name}, you would do well to leave this area before someone shows you the world of gray.");
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
Say($"It would be wise to leave this area, {m.Name}, lest your head become my commanders' trophy.");
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
Say($"You are bold, {m.Name}, for one of the meager {Faction.Find(m)?.Definition.FriendlyName ?? "civilians"}. Leave now, lest you be taught the taste of dirt.");
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
Say($"Your presence here is an insult, {m.Name}. Be gone now, knave.");
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
Say($"Dost thou wish to be hung by your toes, {m.Name}? Nay? Then come no closer.");
|
||||
break;
|
||||
}
|
||||
default: // 5
|
||||
{
|
||||
Say($"Hey, {m.Name}. Yeah, you. Get out of here before I beat you with a stick.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue