From cc117f24af36b195d3f542ac2026f17cd0c66f3a Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Fri, 1 Jul 2022 02:37:24 +0700 Subject: [PATCH] Change which players `othersConsole` addresses Before this patch `othersConsole` didn't address any targeted players, now it addresses all players expect command's instigator and a player for who `ExecutedFor()` is currently being called. --- sources/Commands/Command.uc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/sources/Commands/Command.uc b/sources/Commands/Command.uc index 7d43aa7..9a52729 100644 --- a/sources/Commands/Command.uc +++ b/sources/Commands/Command.uc @@ -378,7 +378,8 @@ public final function bool Execute(CallData callData, EPlayer callerPlayer) return false; } targetPlayers = callData.targetPlayers; - MakeConsoles(targetPlayers, callerPlayer); + publicConsole = _.console.ForAll(); + callerConsole = _.console.For(callerPlayer); callerConsole.Write(P("Executing command `")) .Write(commandData.name) .Say(P("`")); @@ -388,28 +389,21 @@ public final function bool Execute(CallData callData, EPlayer callerPlayer) for (i = 0; i < targetPlayers.length; i += 1) { targetConsole = _.console.For(targetPlayers[i]); + othersConsole = _.console + .ForAll() + .ButPlayer(callerPlayer) + .ButPlayer(targetPlayers[i]); ExecutedFor(targetPlayers[i], callData, callerPlayer); + _.memory.Free(othersConsole); _.memory.Free(targetConsole); - targetConsole = none; } } + othersConsole = none; + targetConsole = none; DeallocateConsoles(); return true; } -private final function MakeConsoles( - array targetPlayers, - EPlayer callerPlayer) -{ - local int i; - publicConsole = _.console.ForAll(); - callerConsole = _.console.For(callerPlayer); - othersConsole = _.console.ForAll().ButPlayer(callerPlayer); - for (i = 0; i < targetPlayers.length; i += 1) { - othersConsole.ButPlayer(targetPlayers[i]); - } -} - private final function DeallocateConsoles() { if (publicConsole != none && publicConsole.IsAllocated()) {