| 01-23-2006, 10:01 AM | #1 |
What does null means? "Set a = null" vs "RemoveLocation" or "DestroyGroup" Whats the difference? JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing call DoNothing( ) endfunction //=========================================================================== function InitTrig_Untitled_Trigger_001 takes nothing returns nothing set gg_trg_Untitled_Trigger_001 = CreateTrigger( ) call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions ) endfunction Smiley ![]() |
| 01-23-2006, 10:05 AM | #2 |
When you set a variable to null you're telling it to point to nothing. the "//====" does nothing, it's a comment. |
| 01-23-2006, 10:07 AM | #3 | |
Quote:
I mean the jass code below //---- |
| 01-23-2006, 10:08 AM | #4 |
Oh, sorry, that's the function that sets up the trigger with its events, conditions, and actions. |
| 01-23-2006, 10:45 AM | #5 |
While I can't articulate what they do technically, I can elaborate on their application. Everytime you create a location, rectangle, unit, unit group, player group, or other non-integer/real/player objects, they are stored in memory. In most cases, they remain there indefinately and over the long run may result in late game lag and long exit times. The actions you are querying are used to remove these references and stores of memory. Hence, the range of actions such as : call RemoveLocation(udg_LeakyLoc) call DestroyRect(BigBadRect) call DestroyGroup(udg_ResourceHungry) The above actions remove the data, I suppose. Then, the follow up step is to remove the reference to this now empty data. set udg_LeakyLoc = null set BigBadRect = null set udg_ResourceHungry = null The reference removal does not help as much as the data removal step itself, but every bit counts, some would argue. Reference removal is used only if you do not want to use that variable again. This is almost exclusively used for local variables, ie. variables that are created for a temporary purpose. Global variables are continually re-used and hence do not need to be de-referenced. I'm terrible at this. Anitarf or AIAndy can articulate this a lot better. There are many posts on this topic in the forums, and using the search 'memory leak' field will yield a lot of results. ================================== The JASS below the comment line creates the trigger and assigns the events, conditions and actions of the trigger. In the very long run, it will be more efficient to consolidate as much of these Init Functions into a core function for generic initialisation to improve efficiency, once you have a sufficient command of what you are doing. The benefits may not be material, but it looks neat. A map with 150 triggers, for instance, would benefit from consolidation. |
| 01-23-2006, 01:25 PM | #6 | |
each world editor 'trigger' (which are different to JASS' triggers) includes a global variable called gg_trg_trigger_name and a function called InitTrig_trigger_name. When world editor saves the map it makes the main function call all the InitTrig_trigger_name() functions. You can't remove that function and that function is supposed to be used for initializing the trigger, creating it, giving actions/conditions and registering events. But you can do whatever you want with them. Quote:
|
| 01-23-2006, 07:21 PM | #7 |
As far as i know, SmileyJeff, setting a variable to null is only needed when it comes to local handles and at the end of the function (when you arent going to use the variables anymore). So you wouldnt have to set a global to null. (you'll also have to destroy/remove the variable before setting it to null if you arent going to use it anymore) |
