找回密碼
 註冊
搜索
熱搜: 活動 交友 discuz
查看: 1564|回覆: 0

[轉貼] Timer Stack (JASS)

[複製鏈接]
發表於 2007-4-18 13:41:08 | 顯示全部樓層 |閲讀模式
 
以下為原帖連接:
http://forums.wasabistudio.ca/viewtopic.php?t=8404

 
這個是在國外網站看到的,稍微修改就貼過來了。

它主要就是重複利用計時器物件,以節省資源,另外也可以省去 set timer=null 這清空動作。

要使用這些函數,把CreateTimer換成NewTimer,DestroyTimer換成ReleaseTimer。

  1. //==========================================================================================
  2. function NewTimer takes nothing returns timer
  3.     if (udg_tsnum==0) then
  4.         return CreateTimer()
  5.     endif
  6. set udg_tsnum=udg_tsnum-1
  7. return udg_tstimer[udg_tsnum]
  8. endfunction
  9. //==========================================================================================
  10. function ReleaseTimer takes timer t returns nothing
  11.     call PauseTimer(t)
  12.     if (udg_tsnum==8191) then
  13.         debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
  14.         //stack is full, the map already has much more troubles than the chance of bug
  15.         call DestroyTimer(t)
  16.     else
  17.         set udg_tstimer[udg_tsnum]=t
  18.         set udg_tsnum=udg_tsnum+1
  19.     endif   
  20. endfunction
  21. //==========================================================================================
複製代碼

 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Checking the Pageranks

Archiver|手機版|小黑屋|WEO

GMT+8, 2026-7-29 10:52 PM , Processed in 0.020798 second(s), 18 queries .

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表