• 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.

Removing Point (Array)

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
I made a Variable Called "CenterOfRegion" for all those "CenterOfRegion" points, but as an Array (Since there's a lot of different "Center Of Region" in use)

I use "call DestroyGroup(udg_CenterOfRegion)" for all of them, or "call DestroyGroup(udg_CenterOfRegion[index number])" ?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I addded Variables this way:

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Set CenterOfRegion[1] = (Center of Hero chooser appear <gen>)
      • Set CenterOfRegion[2] = (Center of AoW appear DOCKS <gen>)
  • etc...
If i add "call RemoveLocation(udg_CenterOfRegion) the game doesn't even start. Crashes. But placing "call RemoveLocation(udg_CenterOfRegion[1]) doesn't =), i guess it's because it works.

btw, i didn't understand what you sayd. [udg_YourPoint[bj_forLoopAindex] ?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
You need to learn basic JASS.

For an array you reference a single value via...
arrayname[integer]

arrayname is the name of the variable.
integer is any integer value (can be constant, returned, calculated, referenced etc).

Arrays are not collections (to put it in a JAVA way). As such you can not do controled opperations on the entire contense directly.

You can turn JASS arrays into collections if you also provide an integer variable to accompany it which stores how many indicies are used. You can then make an itterator using the loop structure and a local to itterate through all index values which will logically let you manipulate every value in the collection.
 
btw, i didn't understand what you sayd. [udg_YourPoint[bj_forLoopAindex] ?

Basically: if you are in need of removing non array location variable:
  • Custom script: call RemoveLocation(udg_variableName)
The 'udg_' prefix is here because you are using global declared in variable editor.

If you are using array variables (and I see you do) the script is a bit longer:
  • Custom script: call RemoveLocation(udg_variableName[index])
If 'index' isn't variable, you just enter the number itself. If 'index' is another integer variable, you're forced to represent it like a global:
  • Custom script: call RemoveLocation(udg_variableName[udg_integerVar])
What is: bj_forLoopAindex? It's jass default bj that refers to (Integer A).
Converting Integer A into custom text shows you: GetForLoopIndexA(), and the function truly looks like:
JASS:
function GetForLoopIndexA takes nothing returns integer
    return bj_forLoopAIndex
endfunction
So, it's more effective if we use immidiately the 'bj_forLoopAIndex' instead of calling function.

Considering that you are using array location parameters with indexes represented with single numbers, for proper leak removal you should enter:
  • Custom script: call RemoveLocation(udg_CenterOfRegion[1])
  • Custom script: call RemoveLocation(udg_CenterOfRegion[2])
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm new in variables and leak fixing xD
I did it as an Array because it's the same "Center of Region" but different regions. As you said
If you are using array variables (and I see you do) the script is a bit longer:
  • Custom script: call RemoveLocation(udg_variableName[index])

I'm using script: call RemoveLocation(udg_CenterOfRegion[3]) to remove that specific region.

What you say:
If you are using array variables (and I see you do) the script is a bit longer:
  • Custom script: call RemoveLocation(udg_CenterOfRegion[1])
  • Custom script: call RemoveLocation(udg_CenterOfRegion[2])
... means than whenever I want to remove a Index point withing a variable, i have to remove the other indexes inside the variable?...

This is the way i'm using it:
A unit is sold
  • Unit - Move (Sold unit) instantly to CenterOfRegion[3]
...and other stuff.
 
What you say:
If you are using array variables (and I see you do) the script is a bit longer:
  • Custom script: call RemoveLocation(udg_CenterOfRegion[1])
  • Custom script: call RemoveLocation(udg_CenterOfRegion[2])
... means than whenever I want to remove a Index point withing a variable, i have to remove the other indexes inside the variable?...

Why you combine two pieces of my message even that both of them were about two differend things? Be kind, and next time don't do that.

And no, you have to remove only the index that is useless for you. I've shown RemoveLocation() for both only because you have used such in your trigger above.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Sorry, I miss explained myself, also missunderstood what you said. That's why I combined stuff. I never meant to be rude. Excuse me for that. (Language barriers?)

Thanks for answering. As I'm concerned, this issue is solved. I already removed locations the way you said/I found, and leak is fixed. I'll may post the map soon for beta testers and some experts (like some of you, if want) to check the triggers for improvement.

EDIT: Lol, i was reading everything again and found that my inital explanation was really really wrong. I made the variables that way (to set and store them), but i'm not using the RemoveLocation in that trigger, but in others. =P
 
Last edited:
Status
Not open for further replies.
Top