• 🏆 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] [Jass] how to write this in jass? I'm removing leaks

Status
Not open for further replies.
Level 7
Joined
Nov 18, 2012
Messages
312
is there any ways to set camera bounds to rect on jass
or do we have to use
JASS:
call SetCameraBoundsToRectForPlayerBJ( Player(0), gg_rct_RegionStartMask )
call SetCameraBounds(-16096.00, 10656.00, -13600.00, 11840.00, -16096.00, 11840.00, -13600.00, 10656.00)

I have changed the sound to music
JASS:
call PlaySoundAtPointBJ( gg_snd_Wintergatan, 100, GetPlayerStartLocationLoc(Player(0)), 0 )
call PlayMusic("Wintergatan.mp3")
What are the difference?
I want it to be played at the hosting screen tho, will this do it?

anddd did i change this right
JASS:
call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, gg_rct_RegionStartCharacters )
call FogModifierStart( CreateFogModifierRect(Player(i),FOG_OF_WAR_VISIBLE,gg_rct_RegionStartCharacters,false,false))

call SetCameraTargetControllerNoZForPlayer( Player(0), GetTriggerUnit(), 0, 0, true )
call SetCameraTargetController(GetTriggerUnit(),0,0,true)
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,040
Using a BJ function (something found in Blizzard.j rather than common.j) is not a "leak" of any kind, and in fact it's not necessarily bad! Here and there some of the BJs might leak a handle but on the whole the only thing they consistently do wrong is forget to nullify their pointers at the end of functions. Honestly I'm unsure whether that's something you even need to do anymore, as I've seen a lot of people not nullifying.

The real reason you want to avoid BJs is that they generally tend to just be wrappers for common.j functions. So instead of a line being one function call it's actually 2 (or more). This matters if the code that's calling BJs runs frequently or loops a lot, but for anything that runs infrequently you can use them with no downside. Some of them are quite useful and can save you time when writing code; I personally use TriggerRegisterAnyUnitEventBJ() and BJDebugMsg() a bunch.

With that in mind, you can probably just use that CameraBoundsToRect function or do:
JASS:
local react r = bj_playableMapArea //or whatever
local real mx = GetRectMinX(r)
local real Mx = GetRectMaxX(r)
local real my = GetRectMinY(r)
local real My = GetRectMaxY(r)
call SetCameraBounds(mx, my, Mx, my, Mx, MY, mx, My)
//Not sure about the correct order but I went counter clockwise from bottom left
Though that's probably just what CameraBoundsToRect does internally. You can look up any Blizzard.j function in Blizzard.j to see how they coded it and evaluate whether or not you should use it for your purposes. This will also show you how to replace BJs with calls to whatever common.j functions those BJs themselves call.
 
Level 7
Joined
Nov 18, 2012
Messages
312
I thought all Bjs leak handles.
I have no intention to look at Blizzard.j since I don't even know where to find it
probably when i see red ink on JNGP i feel irritated and want to fix to purple ones..

The camera bound, I need to remove them. how do i do that?
I used this directly
call SetCameraBounds(mx, my, Mx, my, Mx, MY, mx, My)

Although I think i know it.. Add local reals?
Argh I'm so lazy


WILL local RECT leak.. damn i've no idea how to remove
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,208
I thought all Bjs leak handles.
Only some do due to the local declared local handle variable reference counter leak on return bug.
I have no intention to look at Blizzard.j since I don't even know where to find it
In the patch mpq. Use MPQEdit to extract it.
Although I think i know it.. Add local reals?
You can usee constants and functions as arguments for the function.
WILL local RECT leak.. damn i've no idea how to remove
Use the rect destructor, RemoveRect(rect), when the rect reaches the end of its useful life and null the local declared local rect variable before function return.

JASS:
native RemoveRect takes rect whichRect returns nothing
 
Level 7
Joined
Nov 18, 2012
Messages
312
oh my gosh now my map can't be hosted anymore.. and it is reporting error
unable to find textmacro "optional

JASS:
struct TableArray extends array
  
    //Returns a new TableArray to do your bidding. Simply use:
    //
    //    local TableArray ta = TableArray[array_size]
    //
    static method operator [] takes integer array_size returns TableArray
        local Table a = dex.size[array_size] //Get the unique recycle list for this array size
        local TableArray this = a[0]         //The last-destroyed TableArray that had this array size
      
        debug if array_size <= 0 then
            debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
            debug return 0
        debug endif
      
        if this == 0 then
            set less = less - array_size
            set this = less
        else
            set a[0] = a[this]  //Set the last destroyed to the last-last destroyed
            call a.remove(this) //Clear hash memory
        endif
      
        set dex.size[this] = array_size //This remembers the array size
        return this
    endmethod
  
    //Returns the size of the TableArray
    method operator size takes nothing returns integer
        return dex.size[this]
    endmethod
  
    //da[integer a].unit[integer b] = unit u
    //da[integer a][integer c] = integer d
    //
    //Inline-friendly when not running in debug mode
    //
    method operator [] takes integer key returns Table
        static if DEBUG_MODE then
            local integer i = this.size
            if i == 0 then
                call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
                return 0
            elseif key < 0 or key >= i then
                call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
                return 0
            endif
        endif
        return this + key
    endmethod
  
    //Destroys a TableArray without flushing it; assumed you'd call .flush()
    //if you want it flushed too. This is public so that if you are flushing
    //instances the whole time you don't waste efficiency when disposing the
    //TableArray.
    //
    method destroy takes nothing returns nothing
        local Table a = dex.size[this.size]
      
        debug if this.size <= 0 then
            debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
            debug return
        debug endif
      
        if a == 0 then
            //Create an array to index recycled instances with their array size
            set a = Table.create()
            set dex.size[this.size] = a
        endif
      
        call dex.size.remove(this) //Clear the array size from hash memory
      
        set a[this] = a[0]
        set a[0] = this
    endmethod
  
    //All you need to know about this one is that it won't hit the op limit.
    private static method clean takes Table a, integer end returns nothing
        local integer i = a + 5000
        if i < end then
            call clean.evaluate(i, end)
            set end = i
        endif
        loop
            call a.flush()
            set a = a + 1
            exitwhen a == end
        endloop       //it points at THIS LINE  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    endmethod

This is from Table lib
but it isn't reporting error before that

I think something is wrong with the compiler..
After I save map, then the map becomes not playable
 
Status
Not open for further replies.
Top