• 🏆 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!

How necessary is "null" the variables?

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
Oh thank you, and one more question: I heard I have to avoid the "Do nothing" function, but I have to use it if I use the "If/Then/Else"(One action) function, Is it necessary?
You can use:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Then - Actions
    • Else - Actions
And no, it does nothing. I think it was needed a while back in the early days of wc3.

I really can't confirm or deny whether it's actually a bad thing.
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
You can use:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Then - Actions
    • Else - Actions
And no, it does nothing. I think it was needed a while back in the early days of wc3.

I really can't confirm or deny whether it's actually a bad thing.
I know I can do that, but that will make my trigger look less elegant, when I ask Is it necessary? I mean Is it necessary avoid that function?
 
Level 20
Joined
Apr 12, 2018
Messages
494
Do Nothing was necessary to complete an If-Then-Else function which you could only do one Action or Condition on them back during RoC (every section had to be filled with something, hence where Do Nothing comes in). TFT introduced the Multi version so it's no longer necessary.

And really it doesn't do anything, it doesn't matter if its there or not unless you're really that particular about not 'wasting' a process.
 
Level 1
Joined
Apr 8, 2020
Messages
110
They could have filled the else part with comments, so Do Nothing wasn't necessary back then. It is just that they did not realize this hehe.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,455
You only null local variables. So yes, you're doing it correctly there.

"local unit u" would exist forever in the game's memory if it wasn't nulled.

udg_Temp_Unit, a global variable, is intended to exist forever, so it doesn't need the same treatment.
  • Example
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Custom script: local unit u
      • Custom script: set u = GetTriggerUnit()
      • Custom script: set udg_Unit = u
      • Custom script: set u = null
      • Game - Display to (All players) for 30.00 seconds the text: (Name of Unit)
Using this trigger as an example:
I set u = the entering unit and I set udg_Unit = the entering unit.
I then null u and display the name of udg_Unit.
udg_Unit is pointing to the entering unit, not u, and will display the unit's name properly.
u has been successfully cleaned up and will return null.
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
Memory Leaks Again, this tutorial explains it all.
But yes, only agents need to be nulled (local variables only), you don't null strings, they will always leak, but once. Meaning that once a character is in the string table it won't leak anymore.
Oh I miss the word "agent", thank you.
If someone wanna know these aren't agents:
vJASS:
igamestate
image
itempool
itemtype
lightning
limitop
mapcontrol
mapdensity
mapflag
mapsetting
mapvisibility
pathingtype
placement
playercolor
playerevent
playergameresult
playerscore
playerslotstate
playerstate
playerunitevent
race
racepreference
raritycontrol
soundtype
startlocprio
terraindeformation
texmapflags
texttag
triggeraction
triggercondition
ubersplat
unitevent
unitpool
unitstate
unittype
version
volumegroup
weapontype
weathereffect
widgetevent
 
There are more missing. All primitives, enums and handles that are not listed unter 'agent' are not agents JASS Manual: API Browser - Type handle.

1620557095340.png


It's easier to say what IS an agent, looking at JASS Manual: API Browser - Type agent.
 
Status
Not open for further replies.
Top