- Joined
- Nov 24, 2007
- Messages
- 55
I can't seem to get the array of my custom "locStack" to work properly...at all. I am quite confused. I *can* theoretically do this without the Array (since there are only 4 stacks...but having them in array makes a lot of my code a bunch prettier and simpler.
Here is my code in my header (I am using JassNewGenPack if that helps).
I added the pingStack for testing purposes. Here is where the stack array is initialized...
I commented out those last ones for testing and changed the loc of 2. Also i wasn't reusing a single 'loc' because i thought that maybe that was what was causing the bug. And here is the "testing" function that runs when i type in -stack in game.
What this ends up doing is actually putting all four pings on the center of that gg_rct_Lvlr3...even though theGYs[2] and theGYs[3] theoretically haven't had any data put in them...
I will assume this has somethign with the way that JassNewGen or w/e converts my struct?
Any help (or a simple, "No, you will just have to make 4 seperate locStacks and have ugly code") would be greatly appreciated.
Thanks
Here is my code in my header (I am using JassNewGenPack if that helps).
JASS:
struct locStack
location array a[100]
// the Top Of Stack represents our empty position
integer tos = 0
endstruct
function pushStack takes locStack s, location loc returns nothing
if( s.tos <= 99 ) then
set s.a[s.tos] = loc
set s.tos = s.tos + 1
else
endif
endfunction
function popStack takes locStack s returns location
if( s.tos >= 1 ) then
set s.tos = s.tos - 1
return s.a[s.tos]
else
return null
endif
endfunction
function peekStack takes locStack s returns location
return s.a[s.tos-1]
endfunction
globals
locStack array theGYs[4]
endglobals
function pingStack takes locStack s returns nothing
call PingMinimapLocForPlayer( Player(0), s.a[s.tos-1], 2 )
endfunction
I added the pingStack for testing purposes. Here is where the stack array is initialized...
JASS:
set loc1 = GetRectCenter(gg_rct_Lvlr1)
call pushStack(theGYs[0], loc1)
set loc2 = GetRectCenter(gg_rct_Lvlr3)
call pushStack(theGYs[1], loc2)
//set loc3 = GetRectCenter(gg_rct_Lvlr3)
//call pushStack(theGYs[2], loc3)
//set loc4 = GetRectCenter(gg_rct_Lvlr4)
//call pushStack(theGYs[3], loc4)
I commented out those last ones for testing and changed the loc of 2. Also i wasn't reusing a single 'loc' because i thought that maybe that was what was causing the bug. And here is the "testing" function that runs when i type in -stack in game.
JASS:
function Trig_stack_messing_Actions takes nothing returns nothing
call pingStack( theGYs[0] )
call BJDebugMsg("ping coming")
call PolledWait( 3.0 )
call pingStack( theGYs[1] )
call BJDebugMsg("2nd Ping")
call PolledWait( 3.0 )
call pingStack( theGYs[2] )
call BJDebugMsg("3rd ping")
call PolledWait( 3.0 )
call pingStack( theGYs[3] )
call BJDebugMsg("4th ping")
endfunction
What this ends up doing is actually putting all four pings on the center of that gg_rct_Lvlr3...even though theGYs[2] and theGYs[3] theoretically haven't had any data put in them...
I will assume this has somethign with the way that JassNewGen or w/e converts my struct?
Any help (or a simple, "No, you will just have to make 4 seperate locStacks and have ugly code") would be greatly appreciated.
Thanks