Browse Source

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.
pull/8/head
Anton Tarasenko 2 years ago
parent
commit
cc117f24af
  1. 24
      sources/Commands/Command.uc

24
sources/Commands/Command.uc

@ -378,7 +378,8 @@ public final function bool Execute(CallData callData, EPlayer callerPlayer)
return false; return false;
} }
targetPlayers = callData.targetPlayers; targetPlayers = callData.targetPlayers;
MakeConsoles(targetPlayers, callerPlayer); publicConsole = _.console.ForAll();
callerConsole = _.console.For(callerPlayer);
callerConsole.Write(P("Executing command `")) callerConsole.Write(P("Executing command `"))
.Write(commandData.name) .Write(commandData.name)
.Say(P("`")); .Say(P("`"));
@ -388,28 +389,21 @@ public final function bool Execute(CallData callData, EPlayer callerPlayer)
for (i = 0; i < targetPlayers.length; i += 1) for (i = 0; i < targetPlayers.length; i += 1)
{ {
targetConsole = _.console.For(targetPlayers[i]); targetConsole = _.console.For(targetPlayers[i]);
othersConsole = _.console
.ForAll()
.ButPlayer(callerPlayer)
.ButPlayer(targetPlayers[i]);
ExecutedFor(targetPlayers[i], callData, callerPlayer); ExecutedFor(targetPlayers[i], callData, callerPlayer);
_.memory.Free(othersConsole);
_.memory.Free(targetConsole); _.memory.Free(targetConsole);
targetConsole = none;
} }
} }
othersConsole = none;
targetConsole = none;
DeallocateConsoles(); DeallocateConsoles();
return true; return true;
} }
private final function MakeConsoles(
array<EPlayer> 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() private final function DeallocateConsoles()
{ {
if (publicConsole != none && publicConsole.IsAllocated()) { if (publicConsole != none && publicConsole.IsAllocated()) {

Loading…
Cancel
Save