Timer Stack (JASS)
以下為原帖連接:
http://forums.wasabistudio.ca/viewtopic.php?t=8404
這個是在國外網站看到的,稍微修改就貼過來了。
它主要就是重複利用計時器物件,以節省資源,另外也可以省去 set timer=null 這清空動作。
要使用這些函數,把CreateTimer換成NewTimer,DestroyTimer換成ReleaseTimer。
//==========================================================================================
function NewTimer takes nothing returns timer
if (udg_tsnum==0) then
return CreateTimer()
endif
set udg_tsnum=udg_tsnum-1
return udg_tstimer
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
call PauseTimer(t)
if (udg_tsnum==8191) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
set udg_tstimer=t
set udg_tsnum=udg_tsnum+1
endif
endfunction
//==========================================================================================
頁:
[1]

