| 11-05-2004, 06:38 PM | #1 |
anyone have an idea why this leaks? Code:
function UpdateCamera takes nothing returns nothing local real angle = Angle() local location unitLocation = GetUnitLoc(Samus()) local location offsetLocation = OffsetLocation(unitLocation, ( 500.00 * CosBJ(angle) ), ( 500.00 * SinBJ(angle) )) call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ANGLE_OF_ATTACK, 330.00, 0 ) call PanCameraToTimedLocForPlayer( Player(0), offsetLocation, 0.10 ) call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ROTATION, angle, 0.10 ) call RemoveLocation(unitLocation) call RemoveLocation(offsetLocation) set unitLocation = null set offsetLocation = null endfunction |
| 11-05-2004, 09:14 PM | #2 |
The player variables are leaking. other than that you are fine. |
| 11-05-2004, 09:45 PM | #3 |
player vars dont leak.. do they? and how can you tell it leaks? if player vars do leak it would probably be so small that you wouldnt notice unless itwere in a massive loop. oh or a .01 periodic event.. it could be your Angle() function. or Samus() but i highly doubt the latter. it probably just returns the unit id. |
| 11-06-2004, 02:34 PM | #4 |
yeah that is a .01 event im gonna go with that because after a while the game is unplayable thx. |
| 11-06-2004, 05:49 PM | #5 |
why wouldn't players leak? you're creating them with a function that returns a player, and never cleaning it up. try making a constant variable, set it equal to Player(0), use that, and see if the leak stops. |
| 11-06-2004, 09:13 PM | #6 |
yeah but players dont create a (virtualy) physical object. but thats a pretty crappy example, because functions that return units dont leak. what your saying, is like saying I2S(5+23) leaks. |
| 11-07-2004, 12:56 AM | #7 |
well, strings are weird. but i'm saying that this would leak: call DoStuffAtLocation (Location(whatever args the location creation function takes)) player extends handle, so it should leak too. |
| 11-07-2004, 02:43 AM | #8 |
There are many things that are derived from handle that still will not necessarily leak. I think the reason is that for all handle objects, that only have a limited value range, not a new object is created but a reference to the existing object returned. There is a pretty easy way to find out. Use Player in a loop, convert the return value to integer with the return bug and look if the value changes. |
| 11-07-2004, 09:55 PM | #9 |
Hi , players and all the handles that use Convert(insert type) native functions, DON'T LEAK AT ALL . |
| 11-08-2004, 01:25 AM | #10 |
Code:
function Trig_Pushed_Key_Events_Actions takes nothing returns nothing
local unit samus
local real defaultMoveSpeed
local real angle
local location unitLocation
local location moveToLoc
//call UpdateCamera()
if((UpArrowPressed() or DownArrowPressed() or RightArrowPressed() or LeftArrowPressed()) and not(IsHopping()) ) then
set samus = Samus()
set angle = Angle()
set defaultMoveSpeed = GetUnitDefaultMoveSpeed( samus )
set unitLocation = GetUnitLoc(samus)
if ( LeftArrowPressed() ) then
call SetAngle(ModuloReal(( angle + 1.00 ), 360.00))
call IssueImmediateOrderBJ( samus, "stop" )
endif
if ( RightArrowPressed() ) then
call SetAngle(ModuloReal(( angle + 359.00 ), 360.00))
call IssueImmediateOrderBJ( samus, "stop" )
endif
if ( UpArrowPressed() and (GetUnitCurrentOrder(samus) != String2OrderIdBJ("move") ) ) then
set moveToLoc = PolarProjectionBJ(unitLocation, 200.00, angle)
call SetUnitMoveSpeed( samus, defaultMoveSpeed )
call IssuePointOrderLocBJ( samus, "move", moveToLoc )
endif
if ( DownArrowPressed() and (GetUnitCurrentOrder(samus) != String2OrderIdBJ("move") ) ) then
call SetUnitAnimation( gg_unit_H600_0000, "Walk" )
call slideUnit(samus, .1, .1, ModuloReal(( angle + 180.00 ), 360.00) )
//call SetUnitAnimation( samus, "walk" )
endif
endif
call SetUnitFacingTimed( samus, angle, 0.10 )
call RemoveLocation(unitLocation)
call RemoveLocation(moveToLoc)
set unitLocation = null
set moveToLoc = null
endfunction
//===========================================================================
function InitTrig_Pushed_Key_Events takes nothing returns nothing
set gg_trg_Pushed_Key_Events = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Pushed_Key_Events, 0.01 )
call TriggerAddAction( gg_trg_Pushed_Key_Events, function Trig_Pushed_Key_Events_Actions )
endfunction
what about this? i found out this is what causes the leak but I can't figure out where. |
| 11-08-2004, 01:35 AM | #11 |
heh.. yet again i think it is another function. slideUnit is the suspect this time. |
| 11-08-2004, 01:46 AM | #12 |
nah it lags even if I dont do anything |
| 11-08-2004, 06:24 PM | #13 |
that runs every 0.01 seconds + SlideUnit uses another each 0.01 seconds timer |
| 11-08-2004, 08:27 PM | #14 |
Guest | Bahamut-Neo: What do Samus() Angle() and slideUnit() do? They are X-factors in this function to an outside observer, they maybe leaking stuff. Maybe consider not using polar projections or locations at all, it looks like you are cleaning them up right but you can use GetUnitX(unit) + distance * Cos(angle * bj_DEGTORAD) and GetUnitY(unit) + distance * Sin(angle * bj_DEGTORAD) instead and no temporary handles will be created at all. |
| 11-08-2004, 09:43 PM | #15 |
Code:
function Trig_Pushed_Key_Events_Actions takes nothing returns nothing
local unit samus = Samus()
//local real defaultMoveSpeed = GetUnitDefaultMoveSpeed( samus )
local real angle = Angle()
local location unitLocation = GetUnitLoc(samus)
local location moveToLoc = GetUnitLoc(samus)
//call UpdateCamera()
//if((UpArrowPressed() or DownArrowPressed() or RightArrowPressed() or LeftArrowPressed()) and not(IsHopping()) ) then
// set samus = Samus()
// set angle = Angle()
// set defaultMoveSpeed = GetUnitDefaultMoveSpeed( samus )
//set unitLocation = GetUnitLoc(samus)
// if ( LeftArrowPressed() ) then
// call SetAngle(ModuloReal(( angle + 1.00 ), 360.00))
// call IssueImmediateOrderBJ( samus, "stop" )
// endif
// if ( RightArrowPressed() ) then
// call SetAngle(ModuloReal(( angle + 359.00 ), 360.00))
// call IssueImmediateOrderBJ( samus, "stop" )
// endif
// if ( UpArrowPressed() and (GetUnitCurrentOrder(samus) != String2OrderIdBJ("move") ) ) then
// set moveToLoc = PolarProjectionBJ(unitLocation, 200.00, angle)
// //call SetUnitMoveSpeed( samus, defaultMoveSpeed )
// call IssuePointOrderLocBJ( samus, "move", moveToLoc )
// endif
// if ( DownArrowPressed() and (GetUnitCurrentOrder(samus) != String2OrderIdBJ("move") ) ) then
// call SetUnitAnimation( gg_unit_H600_0000, "Walk" )
// call slideUnit(samus, .1, .1, ModuloReal(( angle + 180.00 ), 360.00) )
// call SetUnitAnimation( samus, "walk" )
// endif
//endif
//call SetUnitFacingTimed( samus, angle, 0.10 )
call RemoveLocation(unitLocation)
call RemoveLocation(moveToLoc)
endfunction
//===========================================================================
function InitTrig_Pushed_Key_Events takes nothing returns nothing
set gg_trg_Pushed_Key_Events = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Pushed_Key_Events, 0.01 )
call TriggerAddAction( gg_trg_Pushed_Key_Events, function Trig_Pushed_Key_Events_Actions )
endfunction
And here is the Samus() code Code:
function Samus takes nothing returns unit
return I2U(GetInt("Samus","Samus",MetroidCon()))
endfunctionnothing is happening and this is still leaking!?!?!?! this is the only trigger running wtf |
