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

[JASS] Global Regions

Status
Not open for further replies.
Level 12
Joined
Apr 27, 2008
Messages
1,228
I tried adding rects to global regions and wc3 crashed every time that was done.
(yes I am sure it was from adding a rect to a global region)
I wonder if this is normal and/or is there a way to avoid the crash while using a global region?
P.s. My region is defined in a globals vJass block.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
You assume correct.
The code is not specific, but here is an example:
JASS:
globals
    region r=CreateRegion()
endglobals
function something takes nothing returns nothing
    call RegionAddRect(r, gg_rct_rect000)
endfunction
I just wonder :)
This is easily avoidable(in my case).
But it would be good if I and anyone who saw this thread knew whether this causes problems.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Lol...
You seem to have very limited knowledge of vJass(if any).
gg_rct_rect000 is a rect created in the WE(main window; Somehow I thought that would be clear to anyone who has used rects created that way).
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Lol...
You seem to have very limited knowledge of vJass(if any).
gg_rct_rect000 is a rect created in the WE(main window; Somehow I thought that would be clear to anyone who has used rects created that way).

i had already with vJass a bug save compilation so it's not very funny xD

Oh and maybe you can't use the native CreateRegion() directly with declare the variable.
I know you can't do it for all natives functions but dunno which ones exactly.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
That may be so, but game crashes when I add the rect - if I do not add it, game does not crash.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
But maybe the region is still not created.

Did you try that :

JASS:
library MyLibrary initializer init

   globals
       region R
   endglobals

   public function init takes nothing returns nothing
      set R= CreateRegion()
   endfunction

endlibrary

function something takes nothing returns nothing
    call RegionAddRect(R, gg_rct_rect000)
endfunction
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Troll-Brain is on the same track, it is crashing when initializing a rect or a region the same time you create the global.(the rect was added for info, since that thing happend me once).

Thus, I found this to work.
JASS:
globals
    region r
endglobals

function test takes nothing returns nothing
    set r = CreateRegion()
    call RegionAddRect(r, gg_rct_rect000)
endfunction
Its kind of the same as Troll-Brain did ._. I noticed that after, sorry for that
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
So it's because you can't use the native CreateRegion and Rect the same time you create the variable.
If you really want to know why, ask blizzard.

Personally i avoid using natives in a declaration of a global variable.
I know it works for CreateTimer and CreateTrigger, but i don't want test the other natives, so i always use an initializer function.
 
Status
Not open for further replies.
Top