| 06-25-2011, 10:21 PM | #1 | ||
First off: destroying triggers
Question 2: ihateyou, JASS:TriggerRegisterUnitInRange
Question 2b is there a difference between a trigger you make in the trigger editor and a trigger you declare as a global? Last question Why can't you register functions that have arguments to triggers simply Like instead of doing TriggerAddAction(t, function f(<arguments>)) you have to through a dummy function (which takes nothing) in there which calls f<arguments> and nothing else so those are my questions sorry for throwing so much out at once also I'm going camping so I might not get a chance to respond for ~a week, but still in advanced - many many thank you's |
| 06-26-2011, 01:05 AM | #2 | |
Question 1: Never. The only justification for needing to is damage detection. Question 2: Quote:
False. You forgot "call" before the line. Also false because it does not pass a pointer to the native. It passes the current value of the variable. (Qualification: It does pass a pointer, but that's the handle. Different thing.) Question 2b: This question makes no sense. You cannot declare a trigger. You declare a global variable, when can then have the value of a trigger (well, of the handle). If you understood the difference between an object and a variable you wouldn't have asked the question, go read up on that. Last question: Arguments might be dynamic. Conceptually it makes no sense within the framework of Jass. Say the arguments were local variables. Those locals would be local to a function which is not being run when the event triggers the action. Hence wtf would it be doing? Non-dynamic arguments would fail for a lot of arguments which were function calls, as the behaviour would be wrong. |
| 06-26-2011, 11:28 AM | #3 | ||||
Quote:
JASS:function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing 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 By deleting the highlighted text, you have already prevented the trigger from being created in the first place, so there is nothing there to destroy. Quote:
Quote:
Likewise, having a trigger variable does not mean you also have a trigger. Like any other handle object, a trigger must be created by calling the appropriate function, the variable is just a way to reference the trigger once it's created. You can have multiple variables referencing the same trigger (or unit, or group, or special effect, or any other handle), you can have variables that don't reference anything (variables which haven't been initialized or whose value has been set to null) and you can end up having handles that aren't referenced by any variables, in which case you may have what we call a memory leak since there's no way to destroy handles which you can't reference (the exception here are non-hero units which will remove themselves automatically once they have decayed). Quote:
On the other hand, if you don't want dynamic arguments like that, but just want to attach constant data to a trigger, there are other ways of doing it. Of course, the only reason to do such data attachment is if you're using dynamic triggers which there's really no reason to do (besides damage detection). For example, your maze collision could be done by periodically enumerating units in range of your unit instead of using a unit-in-range trigger. The former approach has been shown to be no less efficient than the latter. |
| 06-30-2011, 12:18 AM | #4 | |||||
Quote:
does it have glitches, negative effects, etc? is it just considered bad practice to need to use trigger destruction (similar to the views on the break keyword)? i assume by damage detection you mean like if i were to create a local trigger that kept track of the moment a specific unit died, then after the event/action; i should destroy it Quote:
i think i made that mistake another time i was stumped i always forget 1 languages quirks after just having programmed in another Quote:
one or both of us is/has misunderstood what the other meant what i was saying is the function is being passed the vars exactly what the function is being passed (for my purpose) would be completely static after compile time. perhaps what the pointers are pointing to might change, but it'd always use the same pointers its not by any means necessary but it'd save time and make sense Quote:
if i wanted to get rid of the trigger handle floating around, would i have to use a vjass library/scope/module? Quote:
i had hoped that unit-in-range was one of those magic functions that languages are made having in mind (and thus ran really efficiently) any idea how often the periodic can run before its on the same level efficiency wise? and how do you compare efficiency of jass functions in wc? like what do you use to benchmark? if i were to do this i'd have an option to add a filterfunc to check which units in range of the mazer should be considered are filterfuncs more efficient than an equivalent outermost if statement in the group function? and real quick basically, anything that isnt an atom is a handle? |
| 06-30-2011, 01:34 AM | #5 | ||||||
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
All handles are stored in the handle stack where each newly created handle gets a unique address, either by increasing the last new address given by 1 or by reusing the address of a handle that was previously destroyed. We used to use the return bug to get the address of a handle, which was useful for all sorts of things like testing for memory leaks and attaching data to handles. When Blizzard fixed the return bug because of the exploits that it made possible with the code type as mentioned above, they gave us the GetHandleId( h ) native so we could continue to use the handle addresses like before. Pseudo-handles like lightnings and texttags have a similar address allocation to handles, except that they don't share the same address space, but have their own stack. You can see all the types at the start of the common.j file, the latest version of which you can extract from the war3patch.mpq. Note the agent subtype which is a reference counted handle, which means that it keeps track of how many variables are pointing to its handle address and the address will only get recycled for a new handle once the old one is destroyed and no more variables point tot address (this is why we set local handle variables to null to avoid leaks - due to a WC3 bug, the reference counter isn't properly decreased for local variables when a function ends). |
| 06-30-2011, 11:23 PM | #6 | ||||||
Quote:
oh ok that sounds pretty awful and from the few things i read on it, is pretty awful Quote:
wow <3s for the tip about map optimizer thats gonna save me so much time Quote:
k ill check it out this weekend and maybe post the results back here if anyone is interested Quote:
are filter functions more efficient than an equivalent if then? or are they just a way to easily pass a condition to an enumeration? Quote:
especially to integers it'd be so cool to be able to modify/access triggers like that Quote:
wow that is a lot of types i thought there were a bunch but wow also the needing to null locals makes a lot more sense now ty |
| 07-01-2011, 12:04 AM | #7 | |
Quote:
http://www.wc3c.net/showthread.php?t=105677 |
| 07-01-2011, 12:06 PM | #8 | ||
Quote:
Quote:
|
