System LeakLess

SerraAvenger

Cuz I can
Reaction score
234
+GUI LeakLess

What is it?
This is a library that fixes Group/Force/Lightning/Location leaks!
The Key is that stuff will be put on a "remove-this list" once it has been used by a BJ/native in the map (all GUI functions not introduced by EGUI are such functions)...
That list will be cleared every n (default:20) seconds.


What is so special about this?


Your code will be slightly slower, but you will no longer need to care about leak removal!
In the beta, Location, Group, Force and Lightning leaks will be fixed every 20 seconds...
In the testmap, that will happen every 2 seconds so you can actually see it happen.

Requires?
JassPack NewGen

How to import?
Just import this code in a custom script section of your map.

How to use?
It does all by itself.
UNLESS you want to keep Locations / Groups!

"call MakeHandlePermanent( udg_VarName, true)"

The Code
This is just for looking at! If you want to import the code into your map, I suggest using the attached txt file!

JASS:
library LeakLess initializer INIT
globals
    private constant real CLEAN_INTERVAL = 20 // Decides how often leaks will be fixed.
    boolean FixLeaks = true // Whether locations and groups are created temporary or not.
    private constant trigger LeakFixTrigger = CreateTrigger()
    private constant hashtable SecureTable = InitHashtable()
    
    private constant integer ON_LIST = 0
    private constant integer SAFE = 1
endglobals

//! textmacro LeakFix_Cleaner takes TYPE, DESTROYER
globals
    private integer Index = -1
    private $TYPE$ array Data
    private boolean Initialized = false
endglobals

private function CleanHandles takes nothing returns nothing
    local $TYPE$ h
    loop
        exitwhen Index == -1
        set h = Data[ Index ]
        call SetHandle( h, ON_LIST, false )
        if not IsHandle( h, SAFE ) then
            call $DESTROYER$( h )
        endif
        set Index = Index - 1
    endloop
    set h = null
endfunction


private function Write takes $TYPE$ data returns nothing    
    if not Initialized then
        set Initialized = true
        call TriggerAddAction( LeakFixTrigger, function CleanHandles  )
    endif
    if not ( IsHandle( data, ON_LIST ) or IsHandle( data, SAFE ) ) then
        set Index = Index + 1
        set Data[ Index ] = data
        call SetHandle( data, ON_LIST, true )
    endif
endfunction
//! endtextmacro


private function IsHandle takes handle h, integer what returns boolean
    return LoadBoolean( SecureTable, GetHandleId( h ), what )
endfunction

private function SetHandle takes handle h, integer what, boolean is returns nothing
    call SaveBoolean( SecureTable, GetHandleId( h ), what, is )
endfunction

function MakeHandlePermanent takes handle h, boolean is returns nothing
    call SetHandle( h, SAFE, is )
endfunction

private function INIT takes nothing returns nothing
    call TriggerRegisterTimerEvent( LeakFixTrigger, CLEAN_INTERVAL, true )
endfunction

    //-------------------- location --------------------

  scope LocationLeakFix
    //! runtextmacro LeakFix_Cleaner( "location", "RemoveLocation" )
    // Please enter functions that create the type here.
  
    private function FixAddLightningLocLeaks takes string codeName, location where1, location where2 returns nothing
        call Write( where1 )
        call Write( where2 )
    endfunction
    hook AddLightningLoc FixAddLightningLocLeaks

    private function FixAddSpecialEffectLocLeaks takes string modelName, location where returns nothing
        call Write( where )
    endfunction
    hook AddSpecialEffectLoc FixAddSpecialEffectLocLeaks

    private function FixAddSpecialEffectLocBJLeaks takes location where, string modelName returns nothing
        call Write( where )
    endfunction
    hook AddSpecialEffectLocBJ FixAddSpecialEffectLocBJLeaks

    private function FixAddSpellEffectByIdLocLeaks takes integer abilityId, effecttype t, location where returns nothing
        call Write( where )
    endfunction
    hook AddSpellEffectByIdLoc FixAddSpellEffectByIdLocLeaks

    private function FixAddSpellEffectLocLeaks takes string abilityString, effecttype t, location where returns nothing
        call Write( where )
    endfunction
    hook AddSpellEffectLoc FixAddSpellEffectLocLeaks

    private function FixAngleBetweenPointsLeaks takes location locA, location locB returns nothing
        call Write( locA )
        call Write( locB )
    endfunction
    hook AngleBetweenPoints FixAngleBetweenPointsLeaks

    private function FixCompareLocationsBJLeaks takes location A, location B returns nothing
        call Write( A )
        call Write( B )
    endfunction
    hook CompareLocationsBJ FixCompareLocationsBJLeaks

    private function FixCreateCorpseLocBJLeaks takes integer unitid, player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook CreateCorpseLocBJ FixCreateCorpseLocBJLeaks

    private function FixCreateDeadDestructableLocBJLeaks takes integer objectid, location loc, real facing, real scale, integer variation returns nothing
        call Write( loc )
    endfunction
    hook CreateDeadDestructableLocBJ FixCreateDeadDestructableLocBJLeaks

    private function FixCreateDestructableLocLeaks takes integer objectid, location loc, real facing, real scale, integer variation returns nothing
        call Write( loc )
    endfunction
    hook CreateDestructableLoc FixCreateDestructableLocLeaks

    private function FixCreateFogModifierRadiusLocLeaks takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision, boolean afterUnits returns nothing
        call Write( center )
    endfunction
    hook CreateFogModifierRadiusLoc FixCreateFogModifierRadiusLocLeaks

    private function FixCreateFogModifierRadiusLocBJLeaks takes boolean enabled, player whichPlayer, fogstate whichFogState, location center, real radius returns nothing
        call Write( center )
    endfunction
    hook CreateFogModifierRadiusLocBJ FixCreateFogModifierRadiusLocBJLeaks

    private function FixCreateFogModifierRadiusLocSimpleLeaks takes player whichPlayer, fogstate whichFogState, location center, real radius, boolean afterUnits returns nothing
        call Write( center )
    endfunction
    hook CreateFogModifierRadiusLocSimple FixCreateFogModifierRadiusLocSimpleLeaks

    private function FixCreateImageBJLeaks takes string file, real size, location where, real zOffset, integer imageType returns nothing
        call Write( where )
    endfunction
    hook CreateImageBJ FixCreateImageBJLeaks

    private function FixCreateItemLocLeaks takes integer itemId, location loc returns nothing
        call Write( loc )
    endfunction
    hook CreateItemLoc FixCreateItemLocLeaks

    private function FixCreateNUnitsAtLocLeaks takes integer count, integer unitId, player whichPlayer, location loc, real face returns nothing
        call Write( loc )
    endfunction
    hook CreateNUnitsAtLoc FixCreateNUnitsAtLocLeaks

    private function FixCreateNUnitsAtLocFacingLocBJLeaks takes integer count, integer unitId, player whichPlayer, location loc, location lookAt returns nothing
        call Write( loc )
        call Write( lookAt )
    endfunction
    hook CreateNUnitsAtLocFacingLocBJ FixCreateNUnitsAtLocFacingLocBJLeaks

    private function FixCreatePermanentCorpseLocBJLeaks takes integer style, integer unitid, player whichPlayer, location loc, real facing returns nothing
        call Write( loc )
    endfunction
    hook CreatePermanentCorpseLocBJ FixCreatePermanentCorpseLocBJLeaks

    private function FixCreateTextTagLocBJLeaks takes string s, location loc, real zOffset, real size, real red, real green, real blue, real transparency returns nothing
        call Write( loc )
    endfunction
    hook CreateTextTagLocBJ FixCreateTextTagLocBJLeaks

    private function FixCreateUbersplatBJLeaks takes location where, string name, real red, real green, real blue, real alpha, boolean forcePaused, boolean noBirthTime returns nothing
        call Write( where )
    endfunction
    hook CreateUbersplatBJ FixCreateUbersplatBJLeaks

    private function FixCreateUnitAtLocLeaks takes player id, integer unitid, location whichLocation, real face returns nothing
        call Write( whichLocation )
    endfunction
    hook CreateUnitAtLoc FixCreateUnitAtLocLeaks

    private function FixCreateUnitAtLocByNameLeaks takes player id, string unitname, location whichLocation, real face returns nothing
        call Write( whichLocation )
    endfunction
    hook CreateUnitAtLocByName FixCreateUnitAtLocByNameLeaks

    private function FixCreateUnitAtLocSaveLastLeaks takes player id, integer unitid, location loc, real face returns nothing
        call Write( loc )
    endfunction
    hook CreateUnitAtLocSaveLast FixCreateUnitAtLocSaveLastLeaks

    private function FixDefineStartLocationLocLeaks takes integer whichStartLoc, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook DefineStartLocationLoc FixDefineStartLocationLocLeaks

    private function FixDistanceBetweenPointsLeaks takes location locA, location locB returns nothing
        call Write( locA )
        call Write( locB )
    endfunction
    hook DistanceBetweenPoints FixDistanceBetweenPointsLeaks

    private function FixEnumDestructablesInCircleBJLeaks takes real radius, location loc, code actionFunc returns nothing
        call Write( loc )
    endfunction
    hook EnumDestructablesInCircleBJ FixEnumDestructablesInCircleBJLeaks

    private function FixGetLocationXLeaks takes location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetLocationX FixGetLocationXLeaks

    private function FixGetLocationYLeaks takes location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetLocationY FixGetLocationYLeaks

    private function FixGetLocationZLeaks takes location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetLocationZ FixGetLocationZLeaks

    private function FixGetRectFromCircleBJLeaks takes location center, real radius returns nothing
        call Write( center )
    endfunction
    hook GetRectFromCircleBJ FixGetRectFromCircleBJLeaks

    private function FixGetTerrainCliffLevelBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook GetTerrainCliffLevelBJ FixGetTerrainCliffLevelBJLeaks

    private function FixGetTerrainTypeBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook GetTerrainTypeBJ FixGetTerrainTypeBJLeaks

    private function FixGetTerrainVarianceBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook GetTerrainVarianceBJ FixGetTerrainVarianceBJLeaks

    private function FixGetUnitsInRangeOfLocAllLeaks takes real radius, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetUnitsInRangeOfLocAll FixGetUnitsInRangeOfLocAllLeaks

    private function FixGetUnitsInRangeOfLocMatchingLeaks takes real radius, location whichLocation, boolexpr filter returns nothing
        call Write( whichLocation )
    endfunction
    hook GetUnitsInRangeOfLocMatching FixGetUnitsInRangeOfLocMatchingLeaks

    private function FixGroupEnumUnitsInRangeOfLocLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupEnumUnitsInRangeOfLoc FixGroupEnumUnitsInRangeOfLocLeaks

    private function FixGroupEnumUnitsInRangeOfLocCountedLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupEnumUnitsInRangeOfLocCounted FixGroupEnumUnitsInRangeOfLocCountedLeaks

    private function FixGroupPointOrderByIdLocLeaks takes group whichGroup, integer order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupPointOrderByIdLoc FixGroupPointOrderByIdLocLeaks

    private function FixGroupPointOrderLocLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupPointOrderLoc FixGroupPointOrderLocLeaks

    private function FixGroupPointOrderLocBJLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupPointOrderLocBJ FixGroupPointOrderLocBJLeaks

    private function FixIsLocationFoggedToPlayerLeaks takes location whichLocation, player whichPlayer returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationFoggedToPlayer FixIsLocationFoggedToPlayerLeaks

    private function FixIsLocationInRegionLeaks takes region whichRegion, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationInRegion FixIsLocationInRegionLeaks

    private function FixIsLocationMaskedToPlayerLeaks takes location whichLocation, player whichPlayer returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationMaskedToPlayer FixIsLocationMaskedToPlayerLeaks

    private function FixIsLocationVisibleToPlayerLeaks takes location whichLocation, player whichPlayer returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationVisibleToPlayer FixIsLocationVisibleToPlayerLeaks

    private function FixIsPointBlightedBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook IsPointBlightedBJ FixIsPointBlightedBJLeaks

    private function FixIssueBuildOrderByIdLocBJLeaks takes unit whichPeon, integer unitId, location loc returns nothing
        call Write( loc )
    endfunction
    hook IssueBuildOrderByIdLocBJ FixIssueBuildOrderByIdLocBJLeaks

    private function FixIssueHauntOrderAtLocBJLeaks takes unit whichPeon, location loc returns nothing
        call Write( loc )
    endfunction
    hook IssueHauntOrderAtLocBJ FixIssueHauntOrderAtLocBJLeaks

    private function FixIssuePointOrderByIdLocLeaks takes unit whichUnit, integer order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IssuePointOrderByIdLoc FixIssuePointOrderByIdLocLeaks

    private function FixIssuePointOrderLocLeaks takes unit whichUnit, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IssuePointOrderLoc FixIssuePointOrderLocLeaks

    private function FixIssuePointOrderLocBJLeaks takes unit whichUnit, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IssuePointOrderLocBJ FixIssuePointOrderLocBJLeaks

    private function FixIsTerrainPathableBJLeaks takes location where, pathingtype t returns nothing
        call Write( where )
    endfunction
    hook IsTerrainPathableBJ FixIsTerrainPathableBJLeaks

    private function FixIsUnitInRangeLocLeaks takes unit whichUnit, location whichLocation, real distance returns nothing
        call Write( whichLocation )
    endfunction
    hook IsUnitInRangeLoc FixIsUnitInRangeLocLeaks

    private function FixMeleeFindNearestMineLeaks takes location src, real range returns nothing
        call Write( src )
    endfunction
    hook MeleeFindNearestMine FixMeleeFindNearestMineLeaks

    private function FixMeleeGetLocWithinRectLeaks takes location src, rect r returns nothing
        call Write( src )
    endfunction
    hook MeleeGetLocWithinRect FixMeleeGetLocWithinRectLeaks

    private function FixMeleeGetProjectedLocLeaks takes location src, location targ, real distance, real deltaAngle returns nothing
        call Write( src )
        call Write( targ )
    endfunction
    hook MeleeGetProjectedLoc FixMeleeGetProjectedLocLeaks

    private function FixMeleeRandomHeroLocLeaks takes player p, integer id1, integer id2, integer id3, integer id4, location loc returns nothing
        call Write( loc )
    endfunction
    hook MeleeRandomHeroLoc FixMeleeRandomHeroLocLeaks

    private function FixMeleeStartingUnitsForPlayerLeaks takes race whichRace, player whichPlayer, location loc, boolean doHeroes returns nothing
        call Write( loc )
    endfunction
    hook MeleeStartingUnitsForPlayer FixMeleeStartingUnitsForPlayerLeaks

    private function FixMeleeStartingUnitsHumanLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsHuman FixMeleeStartingUnitsHumanLeaks

    private function FixMeleeStartingUnitsNightElfLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsNightElf FixMeleeStartingUnitsNightElfLeaks

    private function FixMeleeStartingUnitsOrcLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsOrc FixMeleeStartingUnitsOrcLeaks

    private function FixMeleeStartingUnitsUndeadLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsUndead FixMeleeStartingUnitsUndeadLeaks

    private function FixMeleeStartingUnitsUnknownRaceLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsUnknownRace FixMeleeStartingUnitsUnknownRaceLeaks

    private function FixMoveLightningLocLeaks takes lightning whichBolt, location where1, location where2 returns nothing
        call Write( where1 )
        call Write( where2 )
    endfunction
    hook MoveLightningLoc FixMoveLightningLocLeaks

    private function FixMoveLocationLeaks takes location whichLocation, real newX, real newY returns nothing
        call Write( whichLocation )
    endfunction
    hook MoveLocation FixMoveLocationLeaks

    private function FixMoveRectToLocLeaks takes rect whichRect, location newCenterLoc returns nothing
        call Write( newCenterLoc )
    endfunction
    hook MoveRectToLoc FixMoveRectToLocLeaks

    private function FixOffsetLocationLeaks takes location loc, real dx, real dy returns nothing
        call Write( loc )
    endfunction
    hook OffsetLocation FixOffsetLocationLeaks

    private function FixPanCameraToLocForPlayerLeaks takes player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook PanCameraToLocForPlayer FixPanCameraToLocForPlayerLeaks

    private function FixPanCameraToTimedLocForPlayerLeaks takes player whichPlayer, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook PanCameraToTimedLocForPlayer FixPanCameraToTimedLocForPlayerLeaks

    private function FixPanCameraToTimedLocWithZForPlayerLeaks takes player whichPlayer, location loc, real zOffset, real duration returns nothing
        call Write( loc )
    endfunction
    hook PanCameraToTimedLocWithZForPlayer FixPanCameraToTimedLocWithZForPlayerLeaks

    private function FixPingMinimapLocForForceLeaks takes force whichForce, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook PingMinimapLocForForce FixPingMinimapLocForForceLeaks

    private function FixPingMinimapLocForForceExLeaks takes force whichForce, location loc, real duration, integer style, real red, real green, real blue returns nothing
        call Write( loc )
    endfunction
    hook PingMinimapLocForForceEx FixPingMinimapLocForForceExLeaks

    private function FixPingMinimapLocForPlayerLeaks takes player whichPlayer, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook PingMinimapLocForPlayer FixPingMinimapLocForPlayerLeaks

    private function FixPlaySoundAtPointBJLeaks takes sound soundHandle, real volumePercent, location loc, real z returns nothing
        call Write( loc )
    endfunction
    hook PlaySoundAtPointBJ FixPlaySoundAtPointBJLeaks

    private function FixPolarProjectionBJLeaks takes location source, real dist, real angle returns nothing
        call Write( source )
    endfunction
    hook PolarProjectionBJ FixPolarProjectionBJLeaks

    private function FixRectContainsLocLeaks takes rect r, location loc returns nothing
        call Write( loc )
    endfunction
    hook RectContainsLoc FixRectContainsLocLeaks

    private function FixRectFromCenterSizeBJLeaks takes location center, real width, real height returns nothing
        call Write( center )
    endfunction
    hook RectFromCenterSizeBJ FixRectFromCenterSizeBJLeaks

    private function FixRectFromLocLeaks takes location min, location max returns nothing
        call Write( min )
        call Write( max )
    endfunction
    hook RectFromLoc FixRectFromLocLeaks

    private function FixRegionAddCellAtLocLeaks takes region whichRegion, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook RegionAddCellAtLoc FixRegionAddCellAtLocLeaks

    private function FixRegionClearCellAtLocLeaks takes region whichRegion, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook RegionClearCellAtLoc FixRegionClearCellAtLocLeaks

    private function FixRestoreUnitLocFacingAngleBJLeaks takes string key, string missionKey, gamecache cache, player forWhichPlayer, location loc, real facing returns nothing
        call Write( loc )
    endfunction
    hook RestoreUnitLocFacingAngleBJ FixRestoreUnitLocFacingAngleBJLeaks

    private function FixRestoreUnitLocFacingPointBJLeaks takes string key, string missionKey, gamecache cache, player forWhichPlayer, location loc, location lookAt returns nothing
        call Write( loc )
        call Write( lookAt )
    endfunction
    hook RestoreUnitLocFacingPointBJ FixRestoreUnitLocFacingPointBJLeaks

    private function FixReviveHeroLocLeaks takes unit whichHero, location loc, boolean doEyecandy returns nothing
        call Write( loc )
    endfunction
    hook ReviveHeroLoc FixReviveHeroLocLeaks

    private function FixRotateCameraAroundLocBJLeaks takes real degrees, location loc, player whichPlayer, real duration returns nothing
        call Write( loc )
    endfunction
    hook RotateCameraAroundLocBJ FixRotateCameraAroundLocBJLeaks

    private function FixSetBlightLocLeaks takes player whichPlayer, location whichLocation, real radius, boolean addBlight returns nothing
        call Write( whichLocation )
    endfunction
    hook SetBlightLoc FixSetBlightLocLeaks

    private function FixSetBlightRadiusLocBJLeaks takes boolean addBlight, player whichPlayer, location loc, real radius returns nothing
        call Write( loc )
    endfunction
    hook SetBlightRadiusLocBJ FixSetBlightRadiusLocBJLeaks

    private function FixSetCameraPositionLocForPlayerLeaks takes player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook SetCameraPositionLocForPlayer FixSetCameraPositionLocForPlayerLeaks

    private function FixSetCameraQuickPositionLocLeaks takes location loc returns nothing
        call Write( loc )
    endfunction
    hook SetCameraQuickPositionLoc FixSetCameraQuickPositionLocLeaks

    private function FixSetCameraQuickPositionLocForPlayerLeaks takes player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook SetCameraQuickPositionLocForPlayer FixSetCameraQuickPositionLocForPlayerLeaks

    private function FixSetDoodadAnimationBJLeaks takes string animName, integer doodadID, real radius, location center returns nothing
        call Write( center )
    endfunction
    hook SetDoodadAnimationBJ FixSetDoodadAnimationBJLeaks

    private function FixSetFogStateRadiusLocLeaks takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision returns nothing
        call Write( center )
    endfunction
    hook SetFogStateRadiusLoc FixSetFogStateRadiusLocLeaks

    private function FixSetImagePositionBJLeaks takes image whichImage, location where, real zOffset returns nothing
        call Write( where )
    endfunction
    hook SetImagePositionBJ FixSetImagePositionBJLeaks

    private function FixSetItemPositionLocLeaks takes item whichItem, location loc returns nothing
        call Write( loc )
    endfunction
    hook SetItemPositionLoc FixSetItemPositionLocLeaks

    private function FixSetRectFromLocLeaks takes rect whichRect, location min, location max returns nothing
        call Write( min )
        call Write( max )
    endfunction
    hook SetRectFromLoc FixSetRectFromLocLeaks

    private function FixSetSoundPositionLocBJLeaks takes sound soundHandle, location loc, real z returns nothing
        call Write( loc )
    endfunction
    hook SetSoundPositionLocBJ FixSetSoundPositionLocBJLeaks

    private function FixSetTerrainPathableBJLeaks takes location where, pathingtype t, boolean flag returns nothing
        call Write( where )
    endfunction
    hook SetTerrainPathableBJ FixSetTerrainPathableBJLeaks

    private function FixSetTerrainTypeBJLeaks takes location where, integer terrainType, integer variation, integer area, integer shape returns nothing
        call Write( where )
    endfunction
    hook SetTerrainTypeBJ FixSetTerrainTypeBJLeaks

    private function FixSetTextTagPosBJLeaks takes texttag tt, location loc, real zOffset returns nothing
        call Write( loc )
    endfunction
    hook SetTextTagPosBJ FixSetTextTagPosBJLeaks

    private function FixSetUnitFacingToFaceLocTimedLeaks takes unit whichUnit, location target, real duration returns nothing
        call Write( target )
    endfunction
    hook SetUnitFacingToFaceLocTimed FixSetUnitFacingToFaceLocTimedLeaks

    private function FixSetUnitPositionLocLeaks takes unit whichUnit, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook SetUnitPositionLoc FixSetUnitPositionLocLeaks

    private function FixSetUnitPositionLocFacingBJLeaks takes unit whichUnit, location loc, real facing returns nothing
        call Write( loc )
    endfunction
    hook SetUnitPositionLocFacingBJ FixSetUnitPositionLocFacingBJLeaks

    private function FixSetUnitPositionLocFacingLocBJLeaks takes unit whichUnit, location loc, location lookAt returns nothing
        call Write( loc )
        call Write( lookAt )
    endfunction
    hook SetUnitPositionLocFacingLocBJ FixSetUnitPositionLocFacingLocBJLeaks

    private function FixSetUnitRallyPointLeaks takes unit whichUnit, location targPos returns nothing
        call Write( targPos )
    endfunction
    hook SetUnitRallyPoint FixSetUnitRallyPointLeaks

    private function FixSmartCameraPanBJLeaks takes player whichPlayer, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook SmartCameraPanBJ FixSmartCameraPanBJLeaks

    private function FixTerrainDeformationCraterBJLeaks takes real duration, boolean permanent, location where, real radius, real depth returns nothing
        call Write( where )
    endfunction
    hook TerrainDeformationCraterBJ FixTerrainDeformationCraterBJLeaks

    private function FixTerrainDeformationRandomBJLeaks takes real duration, location where, real radius, real minDelta, real maxDelta, real updateInterval returns nothing
        call Write( where )
    endfunction
    hook TerrainDeformationRandomBJ FixTerrainDeformationRandomBJLeaks

    private function FixTerrainDeformationRippleBJLeaks takes real duration, boolean limitNeg, location where, real startRadius, real endRadius, real depth, real wavePeriod, real waveWidth returns nothing
        call Write( where )
    endfunction
    hook TerrainDeformationRippleBJ FixTerrainDeformationRippleBJLeaks

    private function FixTerrainDeformationWaveBJLeaks takes real duration, location source, location target, real radius, real depth, real trailDelay returns nothing
        call Write( source )
        call Write( target )
    endfunction
    hook TerrainDeformationWaveBJ FixTerrainDeformationWaveBJLeaks

    private function FixTransmissionFromUnitTypeWithNameBJLeaks takes force toForce, player fromPlayer, integer unitId, string unitName, location loc, sound soundHandle, string message, integer timeType, real timeVal, boolean wait returns nothing
        call Write( loc )
    endfunction
    hook TransmissionFromUnitTypeWithNameBJ FixTransmissionFromUnitTypeWithNameBJLeaks

    private function FixUnitDamagePointLocLeaks takes unit whichUnit, real delay, real radius, location loc, real amount, attacktype whichAttack, damagetype whichDamage returns nothing
        call Write( loc )
    endfunction
    hook UnitDamagePointLoc FixUnitDamagePointLocLeaks

    private function FixUnitDropItemPointLocLeaks takes unit whichUnit, item whichItem, location loc returns nothing
        call Write( loc )
    endfunction
    hook UnitDropItemPointLoc FixUnitDropItemPointLocLeaks

    private function FixUnitUseItemPointLocLeaks takes unit whichUnit, item whichItem, location loc returns nothing
        call Write( loc )
    endfunction
    hook UnitUseItemPointLoc FixUnitUseItemPointLocLeaks

    private function FixWaygateSetDestinationLocBJLeaks takes unit waygate, location loc returns nothing
        call Write( loc )
    endfunction
    hook WaygateSetDestinationLocBJ FixWaygateSetDestinationLocBJLeaks

  endscope
    


    //-------------------- group --------------------

  scope GroupLeakFix
    //! runtextmacro LeakFix_Cleaner( "group", "DestroyGroup" )
    // Please enter functions that create the type here.
  
    private function FixCountUnitsInGroupLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook CountUnitsInGroup FixCountUnitsInGroupLeaks

    private function FixFirstOfGroupLeaks takes group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook FirstOfGroup FixFirstOfGroupLeaks

    private function FixForGroupLeaks takes group whichGroup, code callback returns nothing
        call Write( whichGroup )
    endfunction
    hook ForGroup FixForGroupLeaks

    private function FixForGroupBJLeaks takes group whichGroup, code callback returns nothing
        call Write( whichGroup )
    endfunction
    hook ForGroupBJ FixForGroupBJLeaks

    private function FixGetRandomSubGroupLeaks takes integer count, group sourceGroup returns nothing
        call Write( sourceGroup )
    endfunction
    hook GetRandomSubGroup FixGetRandomSubGroupLeaks

    private function FixGroupAddGroupLeaks takes group sourceGroup, group destGroup returns nothing
        call Write( sourceGroup )
        call Write( destGroup )
    endfunction
    hook GroupAddGroup FixGroupAddGroupLeaks

    private function FixGroupAddUnitLeaks takes group whichGroup, unit whichUnit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupAddUnit FixGroupAddUnitLeaks

    private function FixGroupAddUnitSimpleLeaks takes unit whichUnit, group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupAddUnitSimple FixGroupAddUnitSimpleLeaks

    private function FixGroupClearLeaks takes group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupClear FixGroupClearLeaks

    private function FixGroupEnumUnitsInRangeLeaks takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRange FixGroupEnumUnitsInRangeLeaks

    private function FixGroupEnumUnitsInRangeCountedLeaks takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRangeCounted FixGroupEnumUnitsInRangeCountedLeaks

    private function FixGroupEnumUnitsInRangeOfLocLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRangeOfLoc FixGroupEnumUnitsInRangeOfLocLeaks

    private function FixGroupEnumUnitsInRangeOfLocCountedLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRangeOfLocCounted FixGroupEnumUnitsInRangeOfLocCountedLeaks

    private function FixGroupEnumUnitsInRectLeaks takes group whichGroup, rect r, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRect FixGroupEnumUnitsInRectLeaks

    private function FixGroupEnumUnitsInRectCountedLeaks takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRectCounted FixGroupEnumUnitsInRectCountedLeaks

    private function FixGroupEnumUnitsOfPlayerLeaks takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsOfPlayer FixGroupEnumUnitsOfPlayerLeaks

    private function FixGroupEnumUnitsOfTypeLeaks takes group whichGroup, string unitname, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsOfType FixGroupEnumUnitsOfTypeLeaks

    private function FixGroupEnumUnitsOfTypeCountedLeaks takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsOfTypeCounted FixGroupEnumUnitsOfTypeCountedLeaks

    private function FixGroupEnumUnitsSelectedLeaks takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsSelected FixGroupEnumUnitsSelectedLeaks

    private function FixGroupImmediateOrderLeaks takes group whichGroup, string order returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupImmediateOrder FixGroupImmediateOrderLeaks

    private function FixGroupImmediateOrderBJLeaks takes group whichGroup, string order returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupImmediateOrderBJ FixGroupImmediateOrderBJLeaks

    private function FixGroupImmediateOrderByIdLeaks takes group whichGroup, integer order returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupImmediateOrderById FixGroupImmediateOrderByIdLeaks

    private function FixGroupPickRandomUnitLeaks takes group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPickRandomUnit FixGroupPickRandomUnitLeaks

    private function FixGroupPointOrderLeaks takes group whichGroup, string order, real x, real y returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrder FixGroupPointOrderLeaks

    private function FixGroupPointOrderByIdLeaks takes group whichGroup, integer order, real x, real y returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderById FixGroupPointOrderByIdLeaks

    private function FixGroupPointOrderByIdLocLeaks takes group whichGroup, integer order, location whichLocation returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderByIdLoc FixGroupPointOrderByIdLocLeaks

    private function FixGroupPointOrderLocLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderLoc FixGroupPointOrderLocLeaks

    private function FixGroupPointOrderLocBJLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderLocBJ FixGroupPointOrderLocBJLeaks

    private function FixGroupRemoveGroupLeaks takes group sourceGroup, group destGroup returns nothing
        call Write( sourceGroup )
        call Write( destGroup )
    endfunction
    hook GroupRemoveGroup FixGroupRemoveGroupLeaks

    private function FixGroupRemoveUnitLeaks takes group whichGroup, unit whichUnit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupRemoveUnit FixGroupRemoveUnitLeaks

    private function FixGroupRemoveUnitSimpleLeaks takes unit whichUnit, group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupRemoveUnitSimple FixGroupRemoveUnitSimpleLeaks

    private function FixGroupTargetDestructableOrderLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetDestructableOrder FixGroupTargetDestructableOrderLeaks

    private function FixGroupTargetItemOrderLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetItemOrder FixGroupTargetItemOrderLeaks

    private function FixGroupTargetOrderLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetOrder FixGroupTargetOrderLeaks

    private function FixGroupTargetOrderBJLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetOrderBJ FixGroupTargetOrderBJLeaks

    private function FixGroupTargetOrderByIdLeaks takes group whichGroup, integer order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetOrderById FixGroupTargetOrderByIdLeaks

    private function FixGroupTrainOrderByIdBJLeaks takes group g, integer unitId returns nothing
        call Write( g )
    endfunction
    hook GroupTrainOrderByIdBJ FixGroupTrainOrderByIdBJLeaks

    private function FixIsUnitGroupDeadBJLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook IsUnitGroupDeadBJ FixIsUnitGroupDeadBJLeaks

    private function FixIsUnitGroupEmptyBJLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook IsUnitGroupEmptyBJ FixIsUnitGroupEmptyBJLeaks

    private function FixIsUnitGroupInRectBJLeaks takes group g, rect r returns nothing
        call Write( g )
    endfunction
    hook IsUnitGroupInRectBJ FixIsUnitGroupInRectBJLeaks

    private function FixIsUnitInGroupLeaks takes unit whichUnit, group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook IsUnitInGroup FixIsUnitInGroupLeaks

    private function FixSelectGroupBJLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook SelectGroupBJ FixSelectGroupBJLeaks

    private function FixSelectGroupForPlayerBJLeaks takes group g, player whichPlayer returns nothing
        call Write( g )
    endfunction
    hook SelectGroupForPlayerBJ FixSelectGroupForPlayerBJLeaks

  endscope
    
  
endlibrary



Special Thanks
Vexorian... hook is awesome.
The SciTe developers & the ruby interpreter
The internet


Q&A
Q: Does this work with EGUI?
A: Well... Not all leaks might be removed...

Q: Cannot I just use EGUI?
A: EGUI does not automatically remove memory leaks.


Q: Does this make GUIers lazy?
A: No. It just makes them productive and more creative.

Q: Is this slow?
A: Well... It's slower than removing stuff manuable, but faster than not removing it at all.

Q: Does this leak?
A: You get leaks if you just create Locations without using them.

Q: How do I install this?
A: Press Alt-F4. That will automatically install all files needed. Alternatively, read the thread.
 

Attachments

  • LeakLess DEMO MAP.w3x
    65.5 KB · Views: 259
  • LeakLessII.txt
    50.1 KB · Views: 295

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Can't it beat up locations that are still needed?, for example in a periodic trigger, you need to calculate AngleBetweenPoints, and it's removed because "X" trigger need a location too and is generated while the periodic trigger.
 

SerraAvenger

Cuz I can
Reaction score
234
Can't it beat up locations that are still needed?, for example in a periodic trigger, you need to calculate AngleBetweenPoints, and it's removed because "X" trigger need a location too and is generated while the periodic trigger.

Yes, that is true.
It can only create temporary locations and groups
(see first sentence of this thread ;) )

For permanent ones you still need to use the normal functions and remove them yourself.

If I manage to do the program I wrote about (I think I won't - it should crash most maps), I will add a global function that can make the next locations that are created behave permanent or not.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
Well, the way I tought it was working is: You implent the trigger in your Trigger Editor, and it will remove each location not removed.

What would be nice is if you could add an expiration timer to a location like
JASS:

local location tloc = GetSpellTargetLoc()
call AddPointExpirationTimer( tloc, 0.50)


native AddPointExpirationTimer takes location point, real time, returns boolean.

Would be nice.
 

SerraAvenger

Cuz I can
Reaction score
234
Well, the way I tought it was working is: You implent the trigger in your Trigger Editor, and it will remove each location not removed.
I was thinking about a program that will use a modificated GUI (code generated) to let that happen.

The problem is just that you would need to get this system's code into all your maps in order to get it working... If you didn't, maps should automatically crash.

I didn't try out, though.

What would be nice is if you could add an expiration timer to a location like
JASS:

local location tloc = GetSpellTargetLoc()
call AddPointExpirationTimer( tloc, 0.50)


function AddPointExpirationTimer takes location point, real time, returns boolean.

Would be nice.

Actually, for that you can easily use the textmacro in the timedhandles system.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I don't get the usefulness of this, that's not really friendly users for gui users, and if you already use jass, you should avoid using locations anyway.

The only case you really need to create a location is to get the z of a point, and you can use one static point and use MoveLocation.
 

SerraAvenger

Cuz I can
Reaction score
234
The idea was to change the GUI actions using a tiny program.

I'm just this far now:

Getting the path to the Warcraft 3 installation
Getting the path to the UI folders I am changing ( TriggerData and TriggerStrings )
Opening the files
Replacing all old functions with their leakless pendants


Still missing:
Adding a function that switches between permanent locations / groups and temporary ones.
Creating a GUI.


And I have to know whether it will or will not crash the WE If I do so.
I just wanted to get a little bit of feedback on the code : )
 

Azlier

Old World Ghost
Reaction score
461
Well, what bothers me most is that your test script leaks. :p
 

Azlier

Old World Ghost
Reaction score
461
Yes, but still. A system called LeakLess that leaks. (Test script, anyway) Good to see that you fixed it, though.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
And how could you make a difference between a location which the reference (handle) was lost and need to be destroyed like a garbage collector, and between a location which can't be destroyed.

For example many gui users use "center of region", which is in fact a rect, but nervermind.
Most of the time they don't change this rect (move,change the size) during the game, so at the init at the map they set a location variable to this location.

At least i did it before switching to (v)Jass.

Sure you could add an argument to your functions, but that's become really really ugly, doesn't it ?
 

SerraAvenger

Cuz I can
Reaction score
234
I will add a global function that can make the next locations that are created behave permanent or not.

just like
Trigger:
  • Map Init
    • Game - Treat locations/groups as permanent
    • Set MapCenter = Location( 0 , 0 )
    • Game - Treat locations/groups as temporary
 

SerraAvenger

Cuz I can
Reaction score
234
bump, this time with tiny backing program : )
@Admins/Mods:
- Do I have to release the sourcecode of that program? Wouldn't be a problem for me, but I'm currently to lazy to do it...
- Is there any way I can upload my file directly to thehelper? It is (as a 7zip) 3.0 MB, which is above the limit...

Thanks in Advance, Serra
 

Twisty

New Member
Reaction score
0
i have a problem with this :S im a GUI user and would love to use this :D! buuuut when i open it, there just comes a cmd window that writes something and then closes again, it goes very fast so i dont got enough time to read it. help please?
 

SerraAvenger

Cuz I can
Reaction score
234
i have a problem with this :S im a GUI user and would love to use this :D! buuuut when i open it, there just comes a cmd window that writes something and then closes again, it goes very fast so i dont got enough time to read it. help please?

Do you use windows vista?
Could you perhaps try to run this tool from the command line?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top