• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Region leaks?

Status
Not open for further replies.
Level 3
Joined
Feb 7, 2011
Messages
29
Question about leaks.

hello,

I have been searching everywhere for a command to remove regions [not pre-placed ones] . i set a variable with region type, and used it in my trigger, now i don't know if that will leak or not. If so, what is the command to remove/destroy, is it same as points [RemoveLocation] ?

Regards.
- zheavy -

Edit: Changed title not to make another thread about leaks.
 
Last edited:
Level 3
Joined
Feb 7, 2011
Messages
29
For Region Leaks: Custom Script: call RemoveRect(udg_Temp_Region)
+Rep me if i helped you. :D

Hello,

I had to try it 3 to 5 times for it work, have no clue why and i already tried it earlier today but wasn't sure, anyway thank you for the reassurance Marc Mamales. It's working now :) +rep

Regards.
- zheavy -
 
Level 3
Joined
Feb 7, 2011
Messages
29
Question about leaks.

Hello,

I have another question since in the link u gave me there is nothing mentioned about sound leaks, i have read some tutorials but it doesn't explained my following problem. I'm trying to make a sound play after construction of a certain building, i tried in the object editor with "Sound-Construction" option, but that doesn't seem to alter anything, i am guessing that's for unit training.
So i went with adding the sound in the a trigger related to the constructed building and here it is.
  • Lumber Mill Build 1 loop
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Lumber Mill
    • Actions
      • Unit - Create 1 Circle of Power for Player 1 (Red) at LMAP facing LMP
      • Sound - Play HumanLumberMillWhat1 <gen> at 100.00% volume, attached to LMB
      • Wait 2.00 game-time seconds
      • Sound - Destroy HumanLumberMillWhat1 <gen>
      • Custom script: call DestroyGroup (udg_LMUG)
      • Custom script: call RemoveLocation (udg_LMAP)
      • Custom script: call RemoveLocation (udg_LMP)
      • Trigger - Turn off (This trigger)
The problem with the 3 lines related to the sound tags, the rest of the trigger is of no importance here, my question is, should i destroy the sound after it's played or not? [meaning is that a leak if i don't destroy it] cause while i am trying this, it will only work the first time i build this building and no sound will be done afterwords if i rebuild it again.

Edit: thank you for the replies above.
Edit2:
Want to add another question, using for example in a trigger:
Unit group - pick every unit in (Units in(playable map area)) and do [action here]
Is there a leak with this action?

Regards.
- zheavy -
 
Last edited:
Level 9
Joined
Dec 26, 2010
Messages
475
Hello,

I have another question since in the link u gave me there is nothing mentioned about sound leaks, i have read some tutorials but it doesn't explained my following problem. I'm trying to make a sound play after construction of a certain building, i tried in the object editor with "Sound-Construction" option, but that doesn't seem to alter anything, i am guessing that's for unit training.
So i went with adding the sound in the a trigger related to the constructed building and here it is.
  • Lumber Mill Build 1 loop
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Lumber Mill
    • Actions
      • Unit - Create 1 Circle of Power for Player 1 (Red) at LMAP facing LMP
      • Sound - Play HumanLumberMillWhat1 <gen> at 100.00% volume, attached to LMB
      • Wait 2.00 game-time seconds
      • Sound - Destroy HumanLumberMillWhat1 <gen>
      • Custom script: call DestroyGroup (udg_LMUG)
      • Custom script: call RemoveLocation (udg_LMAP)
      • Custom script: call RemoveLocation (udg_LMP)
      • Trigger - Turn off (This trigger)
The problem with the 3 lines related to the sound tags, the rest of the trigger is of no importance here, my question is, should i destroy the sound after it's played or not? [meaning is that a leak if i don't destroy it] cause while i am trying this, it will only work the first time i build this building and no sound will be done afterwords if i rebuild it again.

Edit: thank you for the replies above.

Regards.
- zheavy -

to destroy the sound :D
  • Sound - Destroy (Last played sound)
 
Level 26
Joined
Aug 18, 2009
Messages
4,099
Just think logically about this problem.

When you have

  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
there, you have provided a function "Units In Group" to the "Pick Every Units In And Do Actions"-action. This function is a parameter to the outer action but you do not pass the function as itself, you rather use the returned value of this function. This means that the inner function is executed first and the outer action cannot influence it, it only sees the result. To pass it to the outer action, the result must therefore be saved meanwhile. Even if you do not store it in an own variable, it has to be done internally. Now, primitive types like integers have a fixed size and contain their data in themselves. Objects like groups are data structures that can consist of many different things and even be dynamically expandable. You would not copy them completly, instead just have a pointer addressing the cluster. But this also means that the object might be shared among different pointers, so when one pointer alone expires, it should not destroy the object that others still might want to use. There are even interactive objects like units that not only you refer to by code. If we exclude interactive objects, a garbage collector could do the job and monitor all objects that are not longer pointed to, to delete them. Unfortunately, Wc3 does not have one and even misses to remove local pointers (local variables).

You could have also provided the group in another way like

  • Set <groupVar> = (Units in (Playable map area))
  • Unit Group - Pick every unit in <groupVar> and do (Actions)
It lies near that you can reuse the picked group then. So ofc, something was created and should be destroyed.

Neither would you expect a second "(Units in (Playable map area))"-line to return the first object, so a new one really gets instantiated.

And no, you do not need to destroy the sound, as you do not create one each time there.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Regions get removed with the...
native RemoveRegion takes region whichRegion returns nothing
Rects get removed with the...
native RemoveRect takes rect whichRect returns nothing

GUI "Regions" are actualy rects so you need to use the rect remover on them.
Real regions are a container for multiple rects and terrain "cells".
 
Status
Not open for further replies.
Top