1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. Hey guys, we've posted the Results for the 30th Modeling Contest. Check them out!
    Dismiss Notice
  3. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  4. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  5. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Does this leak? Setting a point to be equal to itself offset by a distance

Discussion in 'World Editor Help Zone' started by Uncle, May 18, 2019.

Tags:
  1. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    236
    Resources:
    0
    Resources:
    0
    Quick question. In this trigger does tempPoint[0] leak? I'm curious about this line "Set tempPoint[0] = (tempPoint[0] offset by (_0, _n3))", setting it to itself plus an offset, does this cause a leak in regards to it's previous position?

    • Untitled Trigger 001
      • Events
      • Conditions
      • Actions
        • Set tempPoint[0] = (RoomTL[RoomCount] offset by (_n6, _p6))
        • Set tempPoint[0] = (tempPoint[0] offset by (_0, _n3))
        • Custom script: call RemoveLocation( udg_tempPoint[0] )
     
    Last edited: May 18, 2019
  2. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,110
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Correct, it does indeed leak. Once you overwrite the variable value with a new value (a new point-object actually), the old one can't be removed anymore. That is a normal leak.
     
  3. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    236
    Resources:
    0
    Resources:
    0
    Thanks, I thought as much
     
  4. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    236
    Resources:
    0
    Resources:
    0
    While I have your attention, would you happen to know if cleaning up a Point that doesn't currently exist could cause a problem? In other words, what happens if I try to "call RemoveLocation( udg_tempPoint[0] )" when it doesn't exist yet?
     
  5. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,110
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    It's pretty easy to try it out. Or what do you mean exactly?
     
  6. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    236
    Resources:
    0
    Resources:
    0
    • Untitled Trigger 001
      • Events
      • Conditions
      • Actions
        • For each (Integer A) from 1 to 10, do (Actions)
          • Loop - Actions
            • Custom script: call RemoveLocation( udg_tempPoint[0] )
            • Set tempPoint[0] = (Center of (Playable map area))


    There's a reason why I have to have it setup this way before you ask :p Anyway, the trigger works as intended, but I was just wondering if it was bad practice to remove a location that hasn't been created yet. The first time this loop runs it tries to remove tempPoint[0] which hasn't been created yet. I guess that's fine?
     
    Last edited: May 18, 2019
  7. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,110
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    I'm not sure it works as intended with using index 0 always. Also, have you tried printing a message after it? When trying to use an unitialisized variable it will crash the thread, meaning no further action will continue in the trigger.

    So basically trying to destroy ...
    1. ... something that was not initiailized, yet, aka holds no value yet, will crash the thread. Leading to stop further trigger exectuion.
    2. ... something initialisized but already destroyed, should just do nothing.
     
  8. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    236
    Resources:
    0
    Resources:
    0
    What's the issue with using a Point Array? Also, that trigger is just an example, I removed all of the other actions to make it look clean. The real trigger seems to run fine, everything works beyond that line. Just to be safe though, I put the RemoveLocation inside an If/Else Statement so it doesn't fire the first time.
     
  9. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,110
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    In regards of what I meant might be not working is using always the same arrays index in the loop "0" instead of IntegerA.
     
  10. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    236
    Resources:
    0
    Resources:
    0
    Ah, I see, I simply wanted to show an example of removing a point that didn't exist, the loop was just leftover from the original trigger I pulled from my map. No worries, everything seems to work fine.
     
  11. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,370
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Yes it is bad practice to remove null or double remove an already removed location. I would hope Blizzard added safety checks to the RemoveLocation native to prevent this being a problem so in worst case it should just result in functionally wasted cycles.