XGM Forum
Сайт - Статьи - Проекты - Ресурсы - Блоги

Форуме в режиме ТОЛЬКО ЧТЕНИЕ. Вы можете задать вопросы в Q/A на сайте, либо создать свой проект или ресурс.
Вернуться   XGM Forum > Warcraft> Академия: форум для вопросов> Jass
Ник
Пароль
Войти через VK в один клик
Сайт использует только имя.

Закрытая тема
 
Anime666

offline
Опыт: 129
Активность:
Помогите оптимизировать код
Вообщем варик жрёт память, обратно не возвращает!
мб хендлы обнулять надо???
function SFRCondition takes nothing returns boolean
    if ( not ( GetItemTypeId(GetManipulatedItem()) == 'I000' ) ) then
        return false
    endif
    return true
endfunction

function SFRCheckPlayer takes nothing returns boolean
    local timer t=GetExpiredTimer()
    local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
    if GetOwningPlayer(tcu) != GetOwningPlayer(GetFilterUnit()) then
    set tcu=null
    set t=null
    return true
    else
    set tcu=null
    set t=null
    return false
    endif
endfunction

function SFRPickUnits takes nothing returns boolean
    local timer t=GetExpiredTimer()
    local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
    if ( not ( CountUnitsInGroup(GetUnitsInRangeOfLocMatching(150.00, GetUnitLoc(tcu), Condition(function SFRCheckPlayer))) > 0 ) ) then
        set tcu=null
    set t=null
    return false
    endif
    set tcu=null
    set t=null
    return true
endfunction

function SFRActionsForPickedUnits takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
    call UnitDamageTargetBJ( tcu, GetEnumUnit(), 50.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_UNIVERSAL )
    set tcu=null
    set t=null
endfunction


function SFRMove_Unit takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local unit ccu=LoadUnitHandle(udg_Hash,GetHandleId(t),0)
    local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
    local location cup=LoadLocationHandle(udg_Hash, GetHandleId(t), 2)
    local real cspeed=LoadReal(udg_Hash,GetHandleId(t),4)
    local real cangle=LoadReal(udg_Hash,GetHandleId(t),5)
    local real distance=LoadReal(udg_Hash,GetHandleId(t),7)
    local real ccangle2
    local location cUnitPoint=GetUnitLoc(tcu)
    local location cUnitTempPoint=PolarProjectionBJ(cUnitPoint,cspeed,cangle)
    set cangle = GetUnitFacing(tcu)-GetRandomReal(85,95)
    call SetUnitPositionLoc( tcu, cUnitTempPoint )
    set distance=distance-10
    if distance<=0 or SFRPickUnits() then
        call ForGroupBJ( GetUnitsInRangeOfLocMatching(150.00, GetUnitLoc(tcu), Condition(function SFRCheckPlayer)), function SFRActionsForPickedUnits )
        call DestroyEffect(AddSpecialEffectLoc("Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl&quo​t;,cUnitTempPoint))
        call RemoveUnit(tcu)
        call FlushChildHashtable(udg_Hash, GetHandleId(t))
        call DestroyTimer(t)
    endif

    call SaveReal(udg_Hash, GetHandleId(t), 4, cspeed)
    call SaveReal(udg_Hash, GetHandleId(t), 7, distance)
    call SaveReal(udg_Hash, GetHandleId(t), 5, cangle)
    call RemoveLocation(cUnitTempPoint)
    call RemoveLocation(cUnitPoint)
    call RemoveLocation(cup)
    set t=null
    set ccu=null
    set distance=0
    set tcu=null
    set cup=null
    set cUnitTempPoint=null
    set cUnitPoint=null
    set cangle=0
    set ccangle2=0
endfunction

function SFRActions takes nothing returns nothing
    local timer t=CreateTimer()
    local unit ccu=GetTriggerUnit()
    local unit tcu
    local location cup=GetUnitLoc(ccu)
    local real cspeed=25
    local real distance=500
    local real cangle=GetUnitFacing(ccu)-GetRandomReal(85,95)
    call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(ccu), GetUnitLoc(ccu), GetUnitFacing(ccu) )
    set tcu=GetLastCreatedUnit()
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",​cup))
    call SaveUnitHandle(udg_Hash, GetHandleId(t), 0, ccu)
    call SaveUnitHandle(udg_Hash, GetHandleId(t), 1, tcu)
    call SaveLocationHandle(udg_Hash, GetHandleId(t), 2, cup)
    call SaveReal(udg_Hash, GetHandleId(t), 4, cspeed)
    call SaveReal(udg_Hash, GetHandleId(t), 5, cangle)
    call SaveReal(udg_Hash, GetHandleId(t), 7, distance)
    call SetUnitPathing( tcu, false )
    call TimerStart(t, 0.025, true, function SFRMove_Unit)
    set t=null
    set ccu=null
    set distance=0
    set cspeed=0
    set cangle=0
    set tcu=null
    call RemoveLocation(cup)
    set cup=null
endfunction

function InitTrig_ShipFireRight takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddCondition( t, Condition( function SFRCondition) )
    call TriggerAddAction( t, function SFRActions )
    set t=null
endfunction

Отредактировано Anime666, 23.10.2010 в 15:29.
Старый 23.10.2010, 15:20
16GB
GhostOne User
offline
Опыт: 60,317
Активность:
if ( not ( CountUnitsInGroup(GetUnitsInRangeOfLocMatching(150.00, GetUnitLoc(tcu), Condition(function SFRCheckPlayer))) > 0 ) ) then
здесь сразу точка и группа не удаляется
Старый 23.10.2010, 17:08
Anime666

offline
Опыт: 129
Активность:
~16GB:
if ( not ( CountUnitsInGroup(GetUnitsInRangeOfLocMatching(150.00, GetUnitLoc(tcu), Condition(function SFRCheckPlayer))) > 0 ) ) then
здесь сразу точка и группа не удаляется
я уже понял, прочитал сейчас статью xgm.ru/project.php?id=100&page=optimisations про утечки тему закрываем
Старый 23.10.2010, 17:34
Закрытая тема

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы можете скачивать файлы

BB-коды Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход



Часовой пояс GMT +3, время: 03:32.