HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Loop not covering playablemap area?

01-27-2007, 03:18 AM#1
Mythic Fr0st
The loop does not cover the playable map area


Map area = | |
Coverage = |........ |

code

Collapse JASS:
function Trig_Remove_All_Pathing_Actions takes nothing returns nothing
local real x_start
local real y_start
local real x
local real y
local real x_end
local real y_end
local rect aodt = GetPlayableMapRect()
    set y_end = GetRectMaxY(aodt)
    set x_end = GetRectMaxX(aodt)
    set y_start = GetRectMinY(aodt)
    set x_start = GetRectMinX(aodt)
    set x = x_start
    set y = y_start
    loop
        exitwhen x > x_end
        call SetTerrainPathableBJ(Location(x, y), PATHING_TYPE_AMPHIBIOUSPATHING, false )
        set y = y + 32
        if y > y_end then
            set x = x + 32
            set y = y_start
        endif
    endloop
endfunction

//===========================================================================
function InitTrig_Remove_All_Pathing takes nothing returns nothing
    set gg_trg_Remove_All_Pathing = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Remove_All_Pathing, function Trig_Remove_All_Pathing_Actions )
endfunction
01-27-2007, 03:48 AM#2
Ammorth
Change the BJ with the native, that way you will cut your function calls in half, thus increasing the amount of loops the function will hit before it reaches the thread limit, and crashes.

You are also leaking a point (I think) with the Cords to Point. I think the native will take cords instead of a point, but if not, don't forget to set it to a variable, and then destroy it after.
01-27-2007, 04:02 AM#3
Mythic Fr0st
Whats the native for it?

Quote:
You are also leaking a point (I think) with the Cords to Point. I think the native will take cords instead of a point, but if not, don't forget to set it to a variable, and then destroy it after.

I dont think I am leaking a point, im using real coordinates as an option not an actual location...

In GUI this is

Convert Coordinates To Point

I thought coords didnt leak?

>> im looking at this part
Collapse JASS:
call SetTerrainPathableBJ(Location(x, y)
01-27-2007, 04:14 AM#4
The_AwaKening
Ya, using that BJ is pretty pointless. Here's what it converts to:

Collapse JASS:
call SetTerrainPathable(GetLocationX(where), GetLocationY(where), t, flag)

You should be able to just use this line of code:

Collapse JASS:
call SetTerrainPathable(x, y, PATHING_TYPE_AMPHIBIOUSPATHING, false)
01-27-2007, 04:19 AM#5
Mythic Fr0st
You were right, thanks (second one worked) let me test now! woo

omg, it still only covers 1/3rd of a 64 * 64 map, it needs to cover the entire thing

how else could I do this
01-27-2007, 04:19 AM#6
Ammorth
Thats what I was getting at. Most natives take x,y instead of a point. So the point is not required anymore and no more leaks.
01-27-2007, 04:30 AM#7
The_AwaKening
Sounds like the loop is just running too many times. Maybe try seperating it into 3 or 4 loops seperated be a triggersleepaction(0).

Collapse JASS:
function Trig_Remove_All_Pathing_Actions takes nothing returns nothing
 local real x_start
 local real y_start
 local real x
 local real y
 local real x_end
 local real y_end
 local rect aodt = GetPlayableMapRect()
    set y_end = GetRectMaxY(aodt)
    set x_end = GetRectMaxX(aodt)
    set y_start = GetRectMinY(aodt)
    set x_start = GetRectMinX(aodt)
    set x = x_start
    set y = y_start
    loop
        exitwhen x > x_end/3
        call SetTerrainPathable(x, y, PATHING_TYPE_AMPHIBIOUSPATHING, false )
        set y = y + 32
        if y > y_end then
            set x = x + 32
            set y = y_start
        endif
    endloop
    call TriggerSleepAction(.01)
    loop
        exitwhen x > x_end/2
        call SetTerrainPathable(x, y, PATHING_TYPE_AMPHIBIOUSPATHING, false )
        set y = y + 32
        if y > y_end then
            set x = x + 32
            set y = y_start
        endif
    endloop
    call TriggerSleepAction(.01)
    loop
        exitwhen x > x_end
        call SetTerrainPathable(x, y, PATHING_TYPE_AMPHIBIOUSPATHING, false )
        set y = y + 32
        if y > y_end then
            set x = x + 32
            set y = y_start
        endif
    endloop
 set aodt = null
endfunction

//===========================================================================
function InitTrig_Remove_All_Pathing takes nothing returns nothing
    set gg_trg_Remove_All_Pathing = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Remove_All_Pathing, function Trig_Remove_All_Pathing_Actions )
endfunction

I'm not sure if that will do it, but it's worth a try.
01-27-2007, 04:37 AM#8
Mythic Fr0st
Thanks, didnt do a thing though:( exactly the same
01-27-2007, 04:54 AM#9
The_AwaKening
Eh, last attempt. I should have given this to you the first time:

Collapse JASS:
function Trig_Remove_All_Pathing_Actions takes nothing returns nothing
 local real x_start
 local real y_start
 local real x
 local real y
 local real x_end
 local real y_end
 local rect aodt = GetPlayableMapRect()
    set y_end = GetRectMaxY(aodt)
    set x_end = GetRectMaxX(aodt)
    set y_start = GetRectMinY(aodt)
    set x_start = GetRectMinX(aodt)
    set x = x_start
    set y = y_start
    loop
        exitwhen x > x_end
        loop
            exitwhen y > y_end
            call SetTerrainPathable(x, y, PATHING_TYPE_AMPHIBIOUSPATHING, false )
            set y = y + 32
        endloop
        set x = x + 32
        set y = y_start
        call TriggerSleepAction(.01)
    endloop
 set aodt = null
endfunction

//===========================================================================
function InitTrig_Remove_All_Pathing takes nothing returns nothing
    set gg_trg_Remove_All_Pathing = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Remove_All_Pathing, function Trig_Remove_All_Pathing_Actions )
endfunction

This way you are alternating loops with a 1/4 second wait. If that doesn't do it, then maybe it is a different problem.

Edit... Changed the wait from (.25) to (.01). I tested by the way, and it works fine on my map, but it takes some time. I ran it in the map init, and used a test trigger to check how many loops it had run, and it continued building up for 20 seconds into the game before it ended.

Just copy exactly what I have and it will work for you.
01-27-2007, 05:23 AM#10
Mythic Fr0st
works great thanks

^_^