MeleeCheckForCrippledPlayers
- comment
- bug
Leaks handle
crippledPlayers: In Jass you must set local variables that hold agents (or any child type) tonullat the end of functions to avoid reference counter leaks.The function was refactored, it no longer uses locals
indexRaceandcrippledPlayers.- patch
1.07
- Source
- Blizzard.j (suggest an edit or discuss on Github)
- return type
nothing- Source code
function MeleeCheckForCrippledPlayers takes nothing returns nothing local integer playerIndex local player indexPlayer local force crippledPlayers = CreateForce() local boolean isNowCrippled local race indexRace // The "finish soon" exposure of all players overrides any "crippled" exposure if bj_finishSoonAllExposed then return endif // Check each player to see if he or she has been crippled or uncrippled. set playerIndex = 0 loop set indexPlayer = Player(playerIndex) set isNowCrippled = MeleePlayerIsCrippled(indexPlayer) if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then // Player became crippled; start their cripple timer. set bj_playerIsCrippled[playerIndex] = true call TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, function MeleeCrippledPlayerTimeout) if (GetLocalPlayer() == indexPlayer) then // Use only local code (no net traffic) within this block to avoid desyncs. // Show the timer window. call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true) // Display a warning message. call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, MeleeGetCrippledWarningMessage(indexPlayer)) endif elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then // Player became uncrippled; stop their cripple timer. set bj_playerIsCrippled[playerIndex] = false call PauseTimer(bj_crippledTimer[playerIndex]) if (GetLocalPlayer() == indexPlayer) then // Use only local code (no net traffic) within this block to avoid desyncs. // Hide the timer window for this player. call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false) // Display a confirmation message if the player's team is still alive. if (MeleeGetAllyStructureCount(indexPlayer) > 0) then if (bj_playerIsExposed[playerIndex]) then call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNREVEALED")) else call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNCRIPPLED")) endif endif endif // If the player granted shared vision, deny that vision now. call MeleeExposePlayer(indexPlayer, false) endif set playerIndex = playerIndex + 1 exitwhen playerIndex == bj_MAX_PLAYERS endloop endfunction