• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] RegionAddRect works with non adjacent rects?

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,097
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 15
Joined
Sep 29, 2008
Messages
364
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