HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Fixing Player Group Leaks?

03-20-2009, 07:40 PM#1
sPyRaLz
To whom it may concern,

Im building a map and i used a leak checker to see if ive made any leaks.

The leak checker is telling me there are leaks in this program, a player group leak.
But i cant think of any way to solve it.

Trigger:
Die Good
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Good <gen> contains (Triggering unit)) Equal to True
Collapse Actions
Set TempPoint = (Position of (Dying unit))
Set TempUnitGroup = (Units within 85.00 of TempPoint)
Collapse Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Collapse Loop - Actions
Set TempPlayerGroup = (Player group((Owner of (Picked unit))))
Set TempInt = ((Player number of (Owner of (Picked unit))) - 1)
Game - Display to TempPlayerGroup the text: Good
Set ComboCount[TempInt] = (ComboCount[TempInt] + 1)
Set ComboGood[TempInt] = (ComboGood[TempInt] + 1)
Custom script: call RemoveLocation (udg_TempPoint)
Custom script: call DestroyGroup (udg_TempUnitGroup)
Custom script: call DestroyForce (udg_TempPlayerGroup)

The leak checker detects a Leak on this line:
Set TempPlayerGroup = (Player group((Owner of (Picked unit))))

Summary of Trigger function:
This is a code which detects whenever a unit dies.
The code then selects all units within 85 range of the dying unit.
Then awards the kill to the owner of the selected units.

PS: I would prefer a solution in the GUI. I know it sucks, but im not familiar with JASS and the last time i looked at it i got really demoralized. and thanks for anyone who manages to help in advance.
03-21-2009, 12:15 AM#2
Anitarf
Move the DestroyForce call into your loop, where you have the force creation call.
03-21-2009, 02:16 AM#3
Blacktastic
Erhm..

Leakchecker?


Is this GUI only?
03-21-2009, 02:31 AM#4
PurplePoot
Yes, and it doesn't do a stellar job of even that.
03-21-2009, 04:03 PM#5
busterkomo
Quote:
Originally Posted by sPyRaLz
To whom it may concern,

Im building a map and i used a leak checker to see if ive made any leaks.

The leak checker is telling me there are leaks in this program, a player group leak.
But i cant think of any way to solve it.

Trigger:
Die Good
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Good <gen> contains (Triggering unit)) Equal to True
Collapse Actions
Set TempPoint = (Position of (Dying unit))
Set TempUnitGroup = (Units within 85.00 of TempPoint)
Collapse Unit Group - Pick every unit in TempUnitGroup and do (Actions)
Collapse Loop - Actions
Set TempPlayerGroup = (Player group((Owner of (Picked unit))))
Set TempInt = ((Player number of (Owner of (Picked unit))) - 1)
Game - Display to TempPlayerGroup the text: Good
Set ComboCount[TempInt] = (ComboCount[TempInt] + 1)
Set ComboGood[TempInt] = (ComboGood[TempInt] + 1)
Custom script: call RemoveLocation (udg_TempPoint)
Custom script: call DestroyGroup (udg_TempUnitGroup)
Custom script: call DestroyForce (udg_TempPlayerGroup)

The leak checker detects a Leak on this line:
Set TempPlayerGroup = (Player group((Owner of (Picked unit))))

Summary of Trigger function:
This is a code which detects whenever a unit dies.
The code then selects all units within 85 range of the dying unit.
Then awards the kill to the owner of the selected units.

PS: I would prefer a solution in the GUI. I know it sucks, but im not familiar with JASS and the last time i looked at it i got really demoralized. and thanks for anyone who manages to help in advance.
You have to think of it as a force is being created individually for each unit. As your code is now, you'll only remove the last created force. I guess you could also have a double free if the enumerated group was empty. As anitarf said, move the destroy force to your group loop. You could avoid the creation of groups entirely if you wanted to use:
Trigger:
Custom script: call DisplayTextToPlayer(GetOwningPlayer(GetEnumUnit()), 0, 0, "good")
03-23-2009, 11:14 AM#6
sPyRaLz
Alright,

Thanks for the Tips everyone . Sorry about the late reply, haven't had a chance to log on over the weekend.

I actually managed to find a workaround by manually adding TempPlayer to TempPlayerGroup, Showing the message, then removing TempPlayer from the group thereafter. But i do not think it is a very good solution.

After taking a look for the third time.. JASS is finally starting to make a bit of sense. The annoying part is knowing which native functions to call.

Once i complete the entire map.. ill probably try recode everything in JASS to clean things up. Will probably come back here again when i need help =)