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

The question about arrays

Status
Not open for further replies.
Level 10
Joined
May 24, 2016
Messages
339
I just noticed I declared global region array with [8]
JASS:
globals 
region array LivingRegionGlobal[8]
endglobals

I used 8, even though I found that Ive been actually using 12 globals regions

f.e this one
JASS:
function InitTrig_LivingGroupLeaves_region takes nothing returns nothing
    set gg_trg_LivingGroupLeaves_region = CreateTrigger(  )
    
set LivingRegionGlobal[1] =  CreateRegion()
set LivingRegionGlobal[2] =  CreateRegion()
set LivingRegionGlobal[3] =  CreateRegion()
set LivingRegionGlobal[4] =  CreateRegion()
set LivingRegionGlobal[5] =  CreateRegion()
set LivingRegionGlobal[6] =  CreateRegion()
set LivingRegionGlobal[7] =  CreateRegion()
set LivingRegionGlobal[8] =  CreateRegion()
set LivingRegionGlobal[9] =  CreateRegion()
set LivingRegionGlobal[10] =  CreateRegion()
set LivingRegionGlobal[11] =  CreateRegion()
set LivingRegionGlobal[12] =  CreateRegion()

call RegionAddRect(LivingRegionGlobal[1],gg_rct_LivingRegion1)
call RegionAddRect(LivingRegionGlobal[2],gg_rct_LivingRegion2)
call RegionAddRect(LivingRegionGlobal[3],gg_rct_LivingRegion3)
call RegionAddRect(LivingRegionGlobal[4],gg_rct_LivingRegion4)
call RegionAddRect(LivingRegionGlobal[5],gg_rct_LivingRegion5)
call RegionAddRect(LivingRegionGlobal[6],gg_rct_LivingRegion6)
call RegionAddRect(LivingRegionGlobal[7],gg_rct_LivingRegion7)
call RegionAddRect(LivingRegionGlobal[8],gg_rct_LivingRegion8)
call RegionAddRect(LivingRegionGlobal[9],gg_rct_LivingRegion9)

call RegionAddRect(LivingRegionGlobal[10],gg_rct_LivingRegion10)

call RegionAddRect(LivingRegionGlobal[11],gg_rct_LivingRegion11)
call RegionAddRect(LivingRegionGlobal[12],gg_rct_LivingRegion12)
....
endfunction


There were many little functions in the map that were using LivingRegionGlobal[] to check for needed rect,

JASS:
set i2 = 1 
set barrfound = false
loop
exitwhen i2 > 12 or barrfound == true
if IsUnitInRegion(LivingRegionGlobal[i2],F) and not IsUnitDead(Barrack[i2]) and ISRECTALIVE[i2] == true and CaptainIsOnCd[i2] != true then
set barrfound = true
set whatBarrack = i2
endif
i2++
endloop
Since I declared LivingRegionGlobal only as [8], does it mean there were not working at all: LivingRegionGlobal[9], LivingRegionGlobal[10], LivingRegionGlobal[11], LivingRegionGlobal[12] at all?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Nothing you put there will change anything. All 16384 indices are available to you no matter what size you attempt to declare the array to be. Numbers in brackets after array names are only used to define multi-dimensional arrays with JASSHelper:
JASS:
globals
  Square array ChessBoardSquares[8][8]
  unit array TripleUnitsWahoo[100][3][2]
endglobals
Even with that, though, you can manually refer to ChessBoardSquare[64] or TripleUnitsWahoo[8191] even though they're outside the 'defined' array bounds.
 
Level 10
Joined
May 24, 2016
Messages
339
Nothing you put there will change anything. All 16384 indices are available to you no matter what size you attempt to declare the array to be. Numbers in brackets after array names are only used to define multi-dimensional arrays with JASSHelper:
JASS:
globals
  Square array ChessBoardSquares[8][8]
  unit array TripleUnitsWahoo[100][3][2]
endglobals
Even with that, though, you can manually refer to ChessBoardSquare[64] or TripleUnitsWahoo[8191] even though they're outside the 'defined' array bounds.
Thx you, you have clarifies this to me. Solved. About PathLib. Are not you bothered to answer the thing about loops I mentioned in the topic?
 
Status
Not open for further replies.
Top