Skip to content

Commit 1208b7b

Browse files
committed
Merge branch 'dev' of https://github.com/ExMod-Team/EXILED into dev
2 parents 934022a + b39f906 commit 1208b7b

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

EXILED/Exiled.API/Features/DamageHandlers/DamageHandlerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public static implicit operator BaseHandler.CassieAnnouncement(CassieAnnouncemen
289289
new()
290290
{
291291
Announcement = cassieAnnouncement.Announcement,
292-
SubtitleParts = cassieAnnouncement.SubtitleParts.ToArray(),
292+
SubtitleParts = cassieAnnouncement.SubtitleParts?.ToArray() ?? Array.Empty<Subtitles.SubtitlePart>(),
293293
};
294294

295295
/// <summary>

EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage
233233
/// </summary>
234234
public PlayerStatsSystem.DamageHandlerBase Base { get; set; }
235235

236+
/// <summary>
237+
/// Gets the <see cref="PlayerStatsSystem.DamageHandlerBase.CassieAnnouncement"/> the base game uses when a player dies.
238+
/// </summary>
239+
public override CassieAnnouncement CassieDeathAnnouncement => customCassieAnnouncement;
240+
236241
/// <summary>
237242
/// Gets or sets the current attacker.
238243
/// </summary>

EXILED/Exiled.Events/Patches/Events/Map/AnnouncingTeamEntrance.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,32 @@ namespace Exiled.Events.Patches.Events.Map
2828
[HarmonyPatch(typeof(WaveAnnouncementBase), nameof(WaveAnnouncementBase.PlayAnnouncement))]
2929
internal static class AnnouncingTeamEntrance
3030
{
31-
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instruction, ILGenerator generator)
31+
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
3232
{
33-
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instruction);
33+
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);
3434

3535
Label returnLabel = generator.DefineLabel();
3636

37-
int index = newInstructions.FindLastIndex(i => i.opcode == OpCodes.Ldsfld);
37+
// the instruction that sends subtitles is called before stringReturn is created (and thus checked) so we need to move it so that empty (or disallowed) message's subtitles are not sent.
38+
// this removes the Ldarg_0 and the CallVirt
39+
int index = newInstructions.FindIndex(instruction => instruction.Calls(Method(typeof(WaveAnnouncementBase), nameof(WaveAnnouncementBase.SendSubtitles))));
40+
CodeInstruction sendSubtitlesInstruction = newInstructions[index];
41+
newInstructions.RemoveRange(index - 1, 2);
3842

39-
newInstructions.InsertRange(index, new CodeInstruction[]
43+
index = newInstructions.FindLastIndex(i => i.opcode == OpCodes.Ldsfld);
44+
45+
newInstructions.InsertRange(index, new[]
4046
{
4147
// if (stringReturn == "")
4248
// return;
4349
new(OpCodes.Ldloc_S, 4),
4450
new(OpCodes.Ldstr, string.Empty),
4551
new(OpCodes.Ceq),
4652
new(OpCodes.Brtrue_S, returnLabel),
53+
54+
// send subtitles before cassie message, but after our check.
55+
new(OpCodes.Ldarg_0),
56+
sendSubtitlesInstruction,
4757
});
4858

4959
newInstructions[newInstructions.Count - 1].labels.Add(returnLabel);

0 commit comments

Comments
 (0)