• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] leak check

Status
Not open for further replies.
Level 3
Joined
Dec 20, 2007
Messages
44
JASS:
function boss1 takes nothing y returns itempool
    local itempool i = CreateItemPool()
    ItemPoolAddItemType(i, 'I002',2)
    ItemPoolAddItemType(i, 'I003',3)
    return i
endfunction

Will this leak? if so is there any way to fix it?
 
Level 11
Joined
Aug 25, 2006
Messages
971
Yes. It leaks two things. The itempool (Because you return it, you must destroy it sometime in the future) And you don't null the itempool, which can't be fixed because you need to return it.
 
Level 3
Joined
Dec 20, 2007
Messages
44
I was afraid of that. Is there a way to do something similar using globals/constants (which I believe have to be done through VJass, but I'm not familiar with using either)?
 
Level 3
Joined
Dec 20, 2007
Messages
44
boss1 will not pass syntax, as it takes "nothing y" which is invalid as there is no type of passable variable called "nothing".

you mean
JASS:
function boss1 takes nothing returns itempool

yeah... forgot to remove the y when I changed the argument to nothing
 
Level 3
Joined
Dec 20, 2007
Messages
44
I would tell you to use a global variable, but I don't know if you can create an itempool global variable...

You can use an item-type array instead of an itempool if the items will always be the same. Also, you won't need to create an itempool every time you want to get an item from the pool.

I heard a rumor somewhere that VJass allows you to create itempools as global variables, and I don't want to use item-type arrays because I want the drop chances of the items to be easy to modify and there will probably be 50+ unique itempools/arrays.
 
Status
Not open for further replies.
Top