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

[Solved] RegionAddRect works with non adjacent rects?

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,099
You should totally divide by zero. This way, you save valuable execution time by telling the thread it can stop at this point.

@RegionAddRect: The cells the region gains by using that function is by one cell column/row greater than the rect's actual limits at right/top.

So you should rather replace it by something like this:

JASS:
globals
    rect dummyRect = Rect(0., 0., 0., 0.)
endglobals

function RegionAddRectFixed takes region reg, rect rec returns nothing
    local real minX = GetRectMinX(rec)
    local real minY = GetRectMinY(rec)
    local real maxX = GetRectMaxX(rec) - 32
    local real maxY = GetRectMaxY(rec) - 32

    if ((maxX < minX) or (maxY < minY)) then
        return
    endif

    call SetRect(dummyRect, minX, minY, maxX, maxY)

    call RegionAddRect(reg, dummyRect)
endfunction
 
Level 16
Joined
Sep 29, 2008
Messages
366
The irony is that crashing the thread is very performance-intensive

the 3rd point is my own failed irony!..
I got some crashes trying to add non adjacents rects to a region. I believed that it was caused by something related to zero division...(those infinite errors) but my error was on region initialization

globals region myregion = CreateRegion() endglobals was my horrible fault!
 
Status
Not open for further replies.
Top