• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Trigger Question

Status
Not open for further replies.
Level 4
Joined
Feb 9, 2010
Messages
48
I have a question towards people that have a lot of knowledge in WC3 triggers:

If I'm creating an action with:

- Spawn unit at Center of the Region (That is in the game, created by me) ...

Will it cause leaks? Do I have to go with the Set Variable = center of the region.. etc.

Or is it fine? Thanks for help.

(Sorry for creating a thread for it, but I couldn't find anywhere info that specifies clearly that center of the regions counts as leaks or not)
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
Yeah you need to store the center of region x into a variable and remove it.

The game is creating a new location pointing to the center of that rect each time. So if you do not save it to a variable so you can remove it, it will remain in the memory because you have no way to reference and remove it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,204
Unless you move or resize the rect (GUI region) then the centre will always represent the same location on the map. As such you could set a variable to it at map initialization and re-use the same location object to spawn as many units as required without leaking any locations. It even is a performance improvement and faster than JASS X/Y based spawning.
 
Unless you move or resize the rect (GUI region) then the centre will always represent the same location on the map. As such you could set a variable to it at map initialization and re-use the same location object to spawn as many units as required without leaking any locations. It even is a performance improvement and faster than JASS X/Y based spawning.

Why not just use one point/location and just move it? Wouldn't it be faster then moving a rect?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,204
Why not just use one point/location and just move it? Wouldn't it be faster then moving a rect?
The rects are often used to represent locations because WC3 lacks a nice UI for pre-placing locations on the map (something SC2 has). In this context they never moved and so the centre point is always in the same place. As such one can assign a variable to the centre at map initialization and re-use it as much as required. Since the same location is being re-used as opposed to new ones being created there are no location leaks.

However if one moves the rect around, possibly for other purposes such as enumeration of nearby objects, then constant variables will not work as the centre is not constant. One could cache the centre at the same time the rect is moved, however one could also just look it up again when required and apply appropriate clean-up to prevent leaks.
 
Status
Not open for further replies.
Top