• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[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?
 
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.
 
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)?
 
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
 
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.
Back
Top