• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

[Solved] Does this leak? (Convert player to player group)

Status
Not open for further replies.
Level 9
Joined
Mar 17, 2016
Messages
144
Hi, I just want to make sure this doesn't leak a player group. If it leaks how would I clear it?
Not sure if it's a big deal anyways but I'm sure it's better to make sure it's clean.

And to be clear, I am clearing the point. It's the player group I'm concerned with as it says "Convert player to playergroup".

  • Cinematic - Ping minimap for (Player group((Owner of (Triggering unit)))) at (Center of (Playable map area)) for 1.00 seconds
 
Level 19
Joined
Jan 1, 2018
Messages
728
It leaks, since you're using this function:
JASS:
function GetForceOfPlayer takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceAddPlayer(f, whichPlayer)
    return f
endfunction

What wouldn't leak is using the bj_FORCE_PLAYER array (this is used when you select an option from the 'Preset' dropdown in the playergroup window).
However since you need to select the player based on unit ownership, you cannot use this dropdown. Instead, you can assign a value in this array to a global variable using custom script:

  • Actions
    • Custom script: set udg_playergroup = bj_FORCE_PLAYER[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))]
    • Cinematic - Ping minimap for playergroup at (Center of (Playable map area)) for 1.00 seconds
In the custom script, replace 'playergroup' with the name of your global variable (make sure to keep the 'udg_' prefix).
Since you're not creating a new playergroup, you also don't have to call DestroyForce.
 
If you are in Lua mode you could overwrite the function GetForceOfPlayer to read the playergroup array instead of recreating a new force. Then you don't have to alter your GUI Trigger.
Lua:
function GetForceOfPlayer(player)
    return bj_FORCE_PLAYER[GetPlayerId(player)]
end
That code you would add somewhere into your map, if you wana do that.

I think that Dsg's gc (lab section) handles player groups (force).
 
Status
Not open for further replies.
Top