• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Small Code Snippets

Level 1
Joined
Jun 18, 2008
Messages
6
>Because then you don't have to declare a local, create the group, destroy the group, and null the local.

I suppose, but it's not like it'd make a difference. It just makes it easier to implement, since you just paste it in and don't have to track a variable.

>The biggest problem with this method is the horribly long parameter list.

Here, with smaller functions:

JASS:
//***************************
//----GetUnitSomewhere by Quraji----
//***************************
//
//  To use in your map simply paste this whole code into your custom script
//  section, or an empty trigger (above all functions that will use this code)
//
//
//  Contains two functions:
//
//  SubtractGroupFromGroup takes group source, group todestroy...
//  This function removes all units in a reference group (todestroy)from a
//  source group (source).
//  You must include it for GetUnitSomewhere(), but also feel free to use it for 
//  other functions
//
//
//
//  GetUnitSomewhere takes real sourceX, real sourceY, real range, boolean outsiderange, boolean nearest, boolean considerdead, boolexpr cond returns unit
//  Don't let the number of parameters scare you, this is easy to use. This
//  function allows you to select the nearest or farthest unit inside or outside
//  a designated circle.
//
//  Parameters:
//
//  real sourceX and real sourceY
//  these are the X and Y coordinates of the point at the center of the area
//  to be considered.
//
//  real range
//  this is the range of the function, or the radius of the area to be considered
//  (a circle).
//
//  boolean outsiderange
//  if false, the function will consider units inside the circle, if true it will
//  consider all units selected BUT the ones in the circle.
//  (remember that the circle's radius is decided by the range parameter)
//
//  boolean nearest
//  if true, the function will select the nearest unit to the center point inside
//  the area to be considered (as you'd expect a normal GetClosestUnit()
//  function to do. if false, however, it will select the farthest unit
//
//  boolean considerdead
//  if false the function will ignore dead units.
//  (leave this at false unless you need the function to select recently killed
//  units)
//
//  boolexpr cond
//  finally, this is where you add your own conditions if you need them by
//  using a boolexpr.  
//
//
//  Extra feature:
//
//  This function sets the bj_lastHauntedGoldMine game variable to the unit
//  it selects, as well as returning the unit. This enables JASS users to use
//  the function as normal, but provides a convenience for GUI users, as they
//  can simply select the unit from the drop down menu for any unit field by
//  selecting "Last Haunted Gold Mine". This also allows all variables to be
//  nulled.
//**********************

function SubtractGroupFromGroup takes group source, group todestroy returns group
 local unit current

   loop
    set current = FirstOfGroup(todestroy)
     exitwhen current==null

       call GroupRemoveUnit(source, current)
       call GroupRemoveUnit(todestroy, current)
   endloop
  
   set current = null
   return source    
endfunction   

                                                                                            
function GetUnitSomewhere takes real sourceX, real sourceY, real range, boolean outsiderange, boolean nearest, boolean considerdead, boolexpr cond returns unit
 local group g=CreateGroup()
 local group tempg=CreateGroup()
 local unit current 
 local unit winner
 local real currentX
 local real currentY
 local real dist
 
   call GroupEnumUnitsInRange(g,sourceX,sourceY,range,cond)
   
   if not nearest then
     set range=.0
   endif  
     
   if outsiderange then
   
     call GroupEnumUnitsInRect(tempg,bj_mapInitialPlayableArea,cond)
     set g = SubtractGroupFromGroup(tempg,g) 
      
   endif
     
   loop
                          
    set current=FirstOfGroup(g)
     exitwhen current==null   
      
       if GetWidgetLife(current)>0.405 or considerdead then
       
         set currentX=GetWidgetX(current)-sourceX                   
         set currentY=GetWidgetY(current)-sourceY                   
         set dist=SquareRoot(currentX*currentX+currentY*currentY)
       
         if outsiderange then
           set range=dist
           set outsiderange = not outsiderange
         endif  
           
         if (nearest and dist<=range) or (not nearest and dist>=range) then 
                    
           set winner=current
           set range=dist 
                    
         endif   
  
       endif
                
     call GroupRemoveUnit(g,current)
   endloop 
     
     call DestroyGroup(g) 
     call DestroyGroup(tempg)

     set tempg=null                   
     set g=null          
     set current=null
     
     set bj_lastHauntedGoldMine=winner   
     set winner=null 
       
   return bj_lastHauntedGoldMine        
endfunction 

function GetUnitSomewhereEx takes real x, real y, real range returns unit
  return GetUnitSomewhere(x,y,range,false,true,false,null)
endfunction

function GetUnitSomewhereExCond takes real x, real y, real range, boolexpr cond returns unit
  return GetUnitSomewhere(x,y,range,false,true,false,cond)
endfunction


I don't see how Silv's function is better. Ours are basically the same except mine does more. I can see where mine might look large and sloppy but it's very fast, especially if you use the range parameter to cut down the number of possible units to consider (much better to group units in, say, a 1000 distance than to pick out of the whole map).
 
Level 1
Joined
Jun 18, 2008
Messages
6
>It makes a huge difference in a processor-heavy map.

I think the difference would be negligible. You could argue that I should just inline the SubtractGroupFromGroup function to avoid a function call, but other than that I doubt you'd ever find a situation where the difference between a global and this way would have any significance. Due to this, I chose to not use a global so it would be a bit easier to use.

>Yours does no more, in fact, since the good old boolexpr can take care of all the conditions.

Actually, there is no easy way for a boolexpr to switch the search from the nearest unit to the farthest one. Same with searching inside the circle or outside of it. Also, I included considerdead as a quick way to tell whether or not you want the function to return dead units, without creating a boolexpr.

If you look at Silv's function remembering that units are not removed until their body decays some time after they die, you can see how that might mess things up. Imagine using the function trying to find a target for a spell and coming up with dead units.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
I think the difference would be negligible. You could argue that I should just inline the SubtractGroupFromGroup function to avoid a function call, but other than that I doubt you'd ever find a situation where the difference between a global and this way would have any significance. Due to this, I chose to not use a global so it would be a bit easier to use.
Well, I'm talking about situations where every .04 (or so) seconds, you're processing moving hundreds of units.

It may sound crazy, but there are legitimate reasons for doing it, and it can be made to run smooth.

Actually, there is no easy way for a boolexpr to switch the search from the nearest unit to the farthest one.
Fair enough.

Same with searching inside the circle or outside of it.
A simple filter range check.

Also, I included considerdead as a quick way to tell whether or not you want the function to return dead units, without creating a boolexpr.
Most of the time, extra parameters are annoying, and null boolexprs can cause problems anyways.

If you look at Silv's function remembering that units are not removed until their body decays some time after they die, you can see how that might mess things up. Imagine using the function trying to find a target for a spell and coming up with dead units.
It assumes the people debug, and think a bit, but meh.

If you really want you could talk with Silv and "hybridize" your functions, but having a duplicate which has no significant bonuses over disadvantages (it has more of both) is kind've pointless.
 
Level 1
Joined
Jun 18, 2008
Messages
6
>>A simple filter range check.
Big DUH! here, I can't believe I overlooked this.

Here's a newer, faster version. Thanks to you pointing out the obvious, I eliminated an unnecessary group, group handling, and an unnecessary function. Also fixed the boolexpr leak, and includes the simpler function calls with less parameters.


JASS:
//***************************
//----GetUnitSomewhere by Quraji----
//***************************
//
//  To use in your map simply paste this whole code into your custom script
//  section, or an empty trigger (above all functions that will use this code)
//
//
//  Contains one main function:
//
//
//  GetUnitSomewhere takes real sourceX, real sourceY, real range, boolean outsiderange, boolean nearest, boolean considerdead, boolexpr cond returns unit
//  Don't let the number of parameters scare you, this is easy to use. This
//  function allows you to select the nearest or farthest unit inside or outside
//  a designated circle.
//
//  Parameters:
//
//  real sourceX and real sourceY
//  these are the X and Y coordinates of the point at the center of the area
//  to be considered.
//
//  real range
//  this is the range of the function, or the radius of the area to be considered
//  (a circle).
//
//  boolean outsiderange
//  if false, the function will consider units inside the circle, if true it will
//  consider all units selected BUT the ones in the circle.
//  (remember that the circle's radius is decided by the range parameter)
//
//  boolean nearest
//  if true, the function will select the nearest unit to the center point inside
//  the area to be considered (as you'd expect a normal GetClosestUnit()
//  function to do. if false, however, it will select the farthest unit
//
//  boolean considerdead
//  if false the function will ignore dead units.
//  (leave this at false unless you need the function to select recently killed
//  units)
//
//  boolexpr cond
//  finally, this is where you add your own conditions if you need them by
//  using a boolexpr.  
//
//
//  Extra feature:
//
//  This function sets the bj_lastHauntedGoldMine game variable to the unit
//  it selects, as well as returning the unit. This enables JASS users to use
//  the function as normal, but provides a convenience for GUI users, as they
//  can simply select the unit from the drop down menu for any unit field by
//  selecting "Last Haunted Gold Mine". This also allows all variables to be
//  nulled.
//**********************

function ReturnTrue takes nothing returns boolean
  return true
endfunction
                                                                                           
function GetUnitSomewhere takes real sourceX, real sourceY, real range, boolean outsiderange, boolean nearest, boolean considerdead, boolexpr cond returns unit
 local group g=CreateGroup()
 local unit current 
 local unit winner
 local real currentX
 local real currentY
 local real dist
 local real rangeorig = range
 
   if outsiderange then
     call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,cond)
   else  
     call GroupEnumUnitsInRange(g,sourceX,sourceY,range,cond)
   endif
   
   if not nearest then
     set range=.0
   endif  

   loop
                          
    set current=FirstOfGroup(g)
     exitwhen current==null   
      
       if GetWidgetLife(current)>0.405 or considerdead then
       
         set currentX=GetWidgetX(current)-sourceX                   
         set currentY=GetWidgetY(current)-sourceY                   
         set dist=SquareRoot(currentX*currentX+currentY*currentY)
         
         if outsiderange then
           set range=dist
           set outsiderange = not outsiderange
         endif
       
         if (outsiderange and (dist > rangeorig)) or outsiderange == false then 
           
           if (nearest and dist<=range) or (not nearest and dist>=range) then 
                    
             set winner=current
             set range=dist 
                    
           endif   
  
         endif
         
       endif
                
     call GroupRemoveUnit(g,current)
   endloop 
     
     call DestroyGroup(g) 
                
     set g=null          
     set current=null
     
     set bj_lastHauntedGoldMine=winner   
     set winner=null 
       
   return bj_lastHauntedGoldMine        
endfunction 

function GetUnitSomewhereEx takes real x, real y, real range returns unit
  return GetUnitSomewhere(x,y,range,false,true,false, Condition(function ReturnTrue))
endfunction

function GetUnitSomewhereExCond takes real x, real y, real range, boolexpr cond returns unit
  return GetUnitSomewhere(x,y,range,false,true,false,cond)
endfunction



Advantages of this function over others:

Easy to specify targetting of the nearest unit, or the farthest.
Easy to specify targetting of units inside or outside the specified range.
A boolexpr can be added
No Globals required, useable as is.
 
Level 1
Joined
Jun 18, 2008
Messages
6
>>Since you're using bj_lastHauntedGoldMine anyways, you may as well replace the local completely.

I would but some might not want to tamper with that variable, and may wish to just return the local instead (I forgot to include a commented "return winner")

>>Also, the initial check for outsiderange should really be outside the loop - it will only run once either way, and this saves checks.

Yes, but it needs dist to have a value. I could move it outside the loop but I'd have to copy the code for finding the distance and move that outside the loop as well, and this looks cleaner :p

Here's the new code for the sake of keeping it whole (all I added was the commented line)


JASS:
//***************************
//----GetUnitSomewhere by Quraji----
//***************************
//
//  To use in your map simply paste this whole code into your custom script
//  section, or an empty trigger (above all functions that will use this code)
//  
//  (feel free to omit this section from your code, I only ask credit if
//  you copy this function for your own system/submitted code, no credits
//  needed if you use it in a map)
//
//  Contains one main function:
//
//
//  GetUnitSomewhere takes real sourceX, real sourceY, real range, boolean outsiderange, boolean nearest, boolean considerdead, boolexpr cond returns unit
//  Don't let the number of parameters scare you, this is easy to use. This
//  function allows you to select the nearest or farthest unit inside or outside
//  a designated circle.
//
//  Parameters:
//
//  real sourceX and real sourceY
//  these are the X and Y coordinates of the point at the center of the area
//  to be considered.
//
//  real range
//  this is the range of the function, or the radius of the area to be considered
//  (a circle).
//
//  boolean outsiderange
//  if false, the function will consider units inside the circle, if true it will
//  consider all units selected BUT the ones in the circle.
//  (remember that the circle's radius is decided by the range parameter)
//
//  boolean nearest
//  if true, the function will select the nearest unit to the center point inside
//  the area to be considered (as you'd expect a normal GetClosestUnit()
//  function to do. if false, however, it will select the farthest unit
//
//  boolean considerdead
//  if false the function will ignore dead units.
//  (leave this at false unless you need the function to select recently killed
//  units)
//
//  boolexpr cond
//  finally, this is where you add your own conditions if you need them by
//  using a boolexpr. if you don't, pass "Condition(function ReturnTrue)"
//
//  function GetUnitSomewhereEx takes real x, real y, real range returns unit
//  A simplified version, returns a non-dead unit within range
//
//  function GetUnitSomewhereExCond takes real x, real y, real range, boolexpr cond returns unit
//  A simplified version, returns a non-dead unit within range, matching condition
//
//  Extra feature:
//
//  This function sets the bj_lastHauntedGoldMine game variable to the unit
//  it selects, as well as returning the unit. This enables JASS users to use
//  the function as normal, but provides a convenience for GUI users, as they
//  can simply select the unit from the drop down menu for any unit field by
//  selecting "Last Haunted Gold Mine". This also allows all variables to be
//  nulled. If you wish this variable not to be tampered with, uncomment the
//  "return winner" line of code at the bottom of the function.
//**********************

function ReturnTrue takes nothing returns boolean
  return true
endfunction
                                                                                           
function GetUnitSomewhere takes real sourceX, real sourceY, real range, boolean outsiderange, boolean nearest, boolean considerdead, boolexpr cond returns unit
 local group g=CreateGroup()
 local unit current
 local unit winner
 local real currentX
 local real currentY
 local real dist
 local real rangeorig = range
 
   if outsiderange then
     call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,cond)
   else  
     call GroupEnumUnitsInRange(g,sourceX,sourceY,range,cond)
   endif
   
   if not nearest then
     set range=.0
   endif  

   loop
                         
    set current=FirstOfGroup(g)
     exitwhen current==null  
     
       if GetWidgetLife(current)>0.405 or considerdead then
       
         set currentX=GetWidgetX(current)-sourceX                  
         set currentY=GetWidgetY(current)-sourceY                  
         set dist=SquareRoot(currentX*currentX+currentY*currentY)
         
         if outsiderange then
           set range=dist
           set outsiderange = not outsiderange
         endif
       
         if (outsiderange and (dist > rangeorig)) or outsiderange == false then
           
           if (nearest and dist<=range) or (not nearest and dist>=range) then
                   
             set winner=current
             set range=dist
                   
           endif  
 
         endif
         
       endif
               
     call GroupRemoveUnit(g,current)
   endloop
     
     call DestroyGroup(g)
               
     set g=null          
     set current=null
     
     //return winner
     //uncomment above line if you wish bj_lastHauntedGoldMine to remain
     //untampered with
     
     set bj_lastHauntedGoldMine=winner 
     set winner=null
       
   return bj_lastHauntedGoldMine        
endfunction

function GetUnitSomewhereEx takes real x, real y, real range returns unit
  return GetUnitSomewhere(x,y,range,false,true,false, Condition(function ReturnTrue))
endfunction

function GetUnitSomewhereExCond takes real x, real y, real range, boolexpr cond returns unit
  return GetUnitSomewhere(x,y,range,false,true,false,cond)
endfunction



So, how does this get approved or whatever?
 
Level 12
Joined
Aug 20, 2007
Messages
866
I haven't been able to get on the computer for a while, but I having been working on some spells & systems for maybe 6 hours a day for the past few weeks, learning and debugging all kinds of ideas that I believe have been done before

The code for the various code snippets comes out to about 2000 lines of code, and the spells comes out to around 1000 (15 spells)

I am going to put it into a spell map, but because most of it is small snippets, it would seem appropriate, except most of it runs off of systems incorporated into it ><

I wanted to post it all up, and anybody who thinks they can optimize the functions, or want to flat out remove the function, they could

Oh, and the last awful part is that it is all run with global arrays, because I hate vJASS (gives me a huge headache whenever I try to read it)

I've already made a little 'Paste Me' trigger for quickly transferring the variables, but I still need to make a little global block for vJASS

//

Uhh...... I was reading about this GetClosestUnit predicament, I don't know a hell of alot about memory usage of each piece of syntax, but for me, I/O stream tends to be quite laggy, and all of the systems I work with are optimized to use as few if/thens as possible

To avoid using all those booleans, simply add a little comment aforehand about considering dead units, make another identical functions for closest/farthest units

And instead of worrying about insides, outsides, radiuses, and boolexprs, make one of the parameters a group, that way the user can specify exactly which group the closest/farthest unit will be returned from

You should probably add a little note about the group being cleared due to the customizable loop syntax
 
Level 12
Joined
Feb 23, 2007
Messages
1,030
JASS:
function GameTimerCount takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer c = GetHandleInt(t,"c")+1
local string s
local string m
local string h
    if ModuloInteger(c, 60) < 10 then
        set s = "0"+I2S(ModuloInteger(c,60))
    else
        set s = I2S(ModuloInteger(c,60))
    endif
    if ModuloInteger((c/60),60) < 10 then
        set m = "0"+I2S(ModuloInteger((c/60),60))
    else
        set m = I2S(ModuloInteger((c/60),60))
    endif
    
    set h = I2S(c/3600)
    call SetHandleInt(t,"c",c)
    call MultiboardSetItemValueBJ(udg_Timer, 1, 1, (h+(":"+(m+(":"+s)))))
set t = null
set s = null
set m = null
set h = null
endfunction

function GameTimerActions takes nothing returns nothing
local timer t = CreateTimer()
local integer c = 0
    call SetHandleInt(t,"c",c)
    call TimerStart(t, 1.00, true, function GameTimerCount)
    call DestroyTrigger(GetTriggeringTrigger())
set t = null
endfunction

//===========================================================================
function InitTrig_GameTimer takes nothing returns nothing
local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventSingle(t, 0)
    call TriggerAddAction(t, function GameTimerActions)
set t = null
endfunction

This displays how long the game has been going on a multiboard. (Doesn't include paused time.
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
Offtopic - Does that mean the HandleVars system leaks everytime it is called? (Due to using the strings for the calls)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
JASS:
function UnlockCameraForPlayer takes player p returns nothing // when will it be inlined xD
    if p== GetLocalPlayer() then
        call PanCameraTo(GetCameraTargetPositionX(),GetCameraTargetPositionY())
    endif
endfunction

I post this really short and easy function, because it seems that some people do not know this trick to unlock a camera on an unit, whether they are competent or not.

This function should be inlined, i hope Vexorian will allow that in a next version of jasshelper.
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
JASS:
function UnlockCameraForPlayer takes player p returns nothing // when will it be inlined xD
    if p== GetLocalPlayer() then
        call PanCameraTo(GetCameraTargetPositionX(),GetCameraTargetPositionY())
    endif
endfunction

I post this really short and easy function, because it seems that some people do not know this trick to unlock a camera on an unit, whether they are competent or not.

This function should be inlined, i hope Vexorian will allow that in a next version of jasshelper.

Yeah, I think there is some kind of inlining system

I think all functions should be in-lined using a map optimizer, I don't know if it will be too good on the textsize..... but it would significantly increase gamespeed (at least, any functions that take + return something)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
@Herman :
All functions with one line are inlined with jasshelper since the version 0.9.A.0.
By default, but you can add nooptimize if you don't want it

But i don't think all functions should be inlined.
We don't need the fastest way all the time. And the script will be bigger for quite nothing.
 
SetTerrainTypeRect()

JASS:
function SetTerrainTypeRect takes rect r, integer terrain returns nothing
    local real x = GetRectMinX( r )
    local real y = GetRectMinY( r )
    local real endx = GetRectMaxX( r )
    local real endy = GetRectMaxY( r )
    loop
        exitwhen y >= endy
        loop
            exitwhen x >= endx
            call SetTerrainType( x, y, terrain, -1, 1, 0 )
            set x = x + 128
        endloop
        set x = GetRectMinX( r )
        set y = y + 128
    endloop
endfunction

A small convenience function I wrote which fills a rect with a terrain type.

Usage:

JASS:
call SetTerrainTypeRect( bj_mapInitialPlayableArea, 'Oaby' ) //Fills the entire map with an 'abyss' texture

Edit:
It seems the post below this is correct, I changed it now. Each 'square' on the map is actually 128x128. Thanks Troll-Brain. Updated.
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
JASS:
function SetTerrainTypeRect takes rect r, integer terrain returns nothing
    local real x = GetRectMinX( r )
    local real y = GetRectMinY( r )
    local real endx = GetRectMaxX( r )
    local real endy = GetRectMaxY( r )
    loop
        exitwhen y >= endy
        loop
            exitwhen x >= endx
            call SetTerrainType( x, y, terrain, -1, 1, 0 )
            set x = x + 128
        endloop
        set x = GetRectMinX( r )
        set y = y + 128
    endloop
endfunction

A small convenience function I wrote which fills a rect with a terrain type.

Usage:

JASS:
call SetTerrainTypeRect( bj_mapInitialPlayableArea, 'Oaby' ) //Fills the entire map with an 'abyss' texture

Edit:
It seems the post below this is correct, I changed it now. Each 'square' on the map is actually 128x128. Thanks Troll-Brain. Updated.

That was a good, useful idea, +rep
 
Level 12
Joined
Aug 20, 2007
Messages
866
Basically if a function reach it, then the function is stopped and the trigger which call it as well.
You will reach the limit op if you need to much time to execute it, like your example.

Not my example, so that could also be considered a thread crash?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The function main is the function generated by the world editor.
It's the function which is run the first and call all the others init.
Btw it can be custom easily with the jasshelper.

function main() -> InitBlizzard() ->InitMapRects()

JASS:
function InitMapRects takes nothing returns nothing
    set bj_mapInitialPlayableArea = Rect(GetCameraBoundMinX()-GetCameraMargin(CAMERA_MARGIN_LEFT), GetCameraBoundMinY()-GetCameraMargin(CAMERA_MARGIN_BOTTOM), GetCameraBoundMaxX()+GetCameraMargin(CAMERA_MARGIN_RIGHT), GetCameraBoundMaxY()+GetCameraMargin(CAMERA_MARGIN_TOP))
    set bj_mapInitialCameraBounds = GetCurrentCameraBoundsMapRectBJ()
endfunction

common.j said:
//===================================================
// Camera Margin constants for use with GetCameraMargin
//===================================================

constant integer CAMERA_MARGIN_LEFT = 0
constant integer CAMERA_MARGIN_RIGHT = 1
constant integer CAMERA_MARGIN_TOP = 2
constant integer CAMERA_MARGIN_BOTTOM = 3

For the smallest map possible, 32*32 :
war3map.j of a 32*32 map said:
function main takes nothing returns nothing
call SetCameraBounds(- 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT) , - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) , 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT) , 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP) , - 1280.0 + GetCameraMargin(CAMERA_MARGIN_LEFT) , 1024.0 - GetCameraMargin(CAMERA_MARGIN_TOP) , 1280.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT) , - 1536.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))

So calculate yourself how many iterations your loop will do, it's pretty huge...
 
Top