PerformStockUpdates
- comment
- bug
Leaks handle
pickedItemType: 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.07
- Source
- Blizzard.j (raise an issue to discuss on Github or submit a PR)
- return type
nothing- Source code
function PerformStockUpdates takes nothing returns nothing local integer pickedItemId local itemtype pickedItemType local integer pickedItemLevel = 0 local integer allowedCombinations = 0 local integer iLevel // Give each type/level combination a chance of being picked. set iLevel = 1 loop if (bj_stockAllowedPermanent[iLevel]) then set allowedCombinations = allowedCombinations + 1 if (GetRandomInt(1, allowedCombinations) == 1) then set pickedItemType = ITEM_TYPE_PERMANENT set pickedItemLevel = iLevel endif endif if (bj_stockAllowedCharged[iLevel]) then set allowedCombinations = allowedCombinations + 1 if (GetRandomInt(1, allowedCombinations) == 1) then set pickedItemType = ITEM_TYPE_CHARGED set pickedItemLevel = iLevel endif endif if (bj_stockAllowedArtifact[iLevel]) then set allowedCombinations = allowedCombinations + 1 if (GetRandomInt(1, allowedCombinations) == 1) then set pickedItemType = ITEM_TYPE_ARTIFACT set pickedItemLevel = iLevel endif endif set iLevel = iLevel + 1 exitwhen iLevel > bj_MAX_ITEM_LEVEL endloop // Make sure we found a valid item type to add. if (allowedCombinations == 0) then return endif call UpdateEachStockBuilding(pickedItemType, pickedItemLevel) endfunction