MeleeCheckForVictors
- comment
- bug
Leaks handle
opponentlessPlayers: In Jass you must set local variables that hold agents (or any child type) tonullat the end of functions to avoid reference counter leaks.- patch
1.00
- Source
- Blizzard.j (raise an issue to discuss on Github or submit a PR)
- return type
force- Source code
function MeleeCheckForVictors takes nothing returns force local integer playerIndex local integer opponentIndex local force opponentlessPlayers = CreateForce() local boolean gameOver = false // Check to see if any players have opponents remaining. set playerIndex = 0 loop if (not bj_meleeDefeated[playerIndex]) then // Determine whether or not this player has any remaining opponents. set opponentIndex = 0 loop // If anyone has an opponent, noone can be victorious yet. if MeleePlayerIsOpponent(playerIndex, opponentIndex) then return CreateForce() endif set opponentIndex = opponentIndex + 1 exitwhen opponentIndex == bj_MAX_PLAYERS endloop // Keep track of each opponentless player so that we can give // them a victory later. call ForceAddPlayer(opponentlessPlayers, Player(playerIndex)) set gameOver = true endif set playerIndex = playerIndex + 1 exitwhen playerIndex == bj_MAX_PLAYERS endloop // Set the game over global flag set bj_meleeGameOver = gameOver return opponentlessPlayers endfunction