• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

[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