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

[Trigger] Trigger Crash

Status
Not open for further replies.
Level 5
Joined
Nov 21, 2014
Messages
151
Okay in the attachments you can see a trigger made by me, which functions normally until a unit attacks the tree and then you try to "burn tree" it. I did this once on accident and it crashed my game. (with the usual crash message). This shouldn't happen normally but if you misspress the keybind it can happen that your units attack it, and if you then use the ability boom, game closes... Can anyone maybe point out the problem or show an alternative that doesn't crash the game? Awesome, thanks in advance! :goblin_yeah:
 

Attachments

  • trigger.PNG
    trigger.PNG
    13.4 KB · Views: 79
Level 13
Joined
Jan 2, 2016
Messages
973
Well, I see no reason for crash, but I see leaks...
1) Set a (point) variable to the position of the destructable, and destroy (remove) it in the end.
2) Stop destroying the tree 2-ce. The custom script you are using does the same thing as the GUI Remove Destructable.
3) Destroy the effect (tho you'd need to store it into a local variable, and destoy it after a wait :p)
 
Level 5
Joined
Nov 21, 2014
Messages
151
Well, I see no reason for crash, but I see leaks...
1) Set a (point) variable to the position of the destructable, and destroy (remove) it in the end.
2) Stop destroying the tree 2-ce. The custom script you are using does the same thing as the GUI Remove Destructable.
3) Destroy the effect (tho you'd need to store it into a local variable, and destoy it after a wait :p)

It's based off sentinel, can that be a problem?

(see attachment) fixed it... I don't know why it crashed but you kind of helped me achieve it... Thanks!

Also, does it still leak now? ( I never work with special effects)
 

Attachments

  • trigger.PNG
    trigger.PNG
    13.3 KB · Views: 53
Last edited by a moderator:
Level 13
Joined
Jan 2, 2016
Messages
973
Yeah, you still leak the special effect.. you need to do:
Actions:
Custom script: local effect e
--- set point ---
--- kill destructable ---
--- create special effect ---
Custom script: set e = bj_lastCreatedEffect
--- add lumber ---
--- remove location ---
Wait 3.00 seconds
Custom script: call DestroyEffect(e)
 
Level 5
Joined
Nov 21, 2014
Messages
151
Yeah, you still leak the special effect.. you need to do:
Actions:
Custom script: local effect e
--- set point ---
--- kill destructable ---
--- create special effect ---
Custom script: set e = bj_lastCreatedEffect
--- add lumber ---
--- remove location ---
Wait 3.00 seconds
Custom script: call DestroyEffect(e)

If units cast the ability like almost at the same time ,doesn't the wait time screw this over?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
It seems the problem was solved, but I just wanted to point out that it crashed because you were trying to remove a destructable that doesn't exist. Targettree was removed by the GUI function, so when it was turn for the JASS native, targettree was a null value.

Nope, the effect is stored into a local variable, thus it doesn't get screwed.
Effects are agents, so remember to null them.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Some people managed to confuse me..
I've seen posts, claiming that you don't need to null a variable after destroying it.
So in the end - do I need to null them or not??

It's not that big of an issue if it is a global variable. However, you should always null a local agent. Letting them fall out of scope will create a reference leak. There was a mini discussion about it somewhere in IcemanBo's tutorial.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
You have to null them, else you will have a reference leak. You just don't have to null reals and integers (because they don't have a null, they have 0 which is a value itself).

@KILLCIDE: Strings are natives but they can cause a reference leak.

@DatScriptWithWait: Try your own script and adding a "Destroy (last created special effect)" after "Create a special effect blablabla". If it didn't work and you didn't see the effect, try WereElf's script and consider adding a "Custom Script: set e = null" in the end.
 
You just don't have to null reals and integers (because they don't have a null, they have 0 which is a value itself).
Almost, but not exactly.
Also next the mentioned reals, integers, also boolean, strings, and code are primitive types in JASS.
But only handles that extend the "agent" type potentially need to be nulled.

Strings are natives but they can cause a reference leak.
If a certain string is used for the first time it gets stored into the string table: http://www.hiveworkshop.com/forums/lab-715/documentation-string-type-240473/
When the same string is used again, the same entry will be referenced again.
If a new, unique string gets used, there will be a new entry in the string table, also.
You don't really leak the entries, because they can be re-used but you also don't have the possibility to remove entries of the string table.
 
Level 5
Joined
Nov 21, 2014
Messages
151
It seems the problem was solved, but I just wanted to point out that it crashed because you were trying to remove a destructable that doesn't exist. Targettree was removed by the GUI function, so when it was turn for the JASS native, targettree was a null value.


Effects are agents, so remember to null them.

Sadly that's was not the case, it worked properly, it didn't crash normally except if the tree was attacked in the process..
 
Status
Not open for further replies.
Top