找回密码
 点一下
查看: 1414|回复: 1

一个非常简单的堆栈代码(供参考)

[复制链接]
发表于 2009-9-27 09:10:19 | 显示全部楼层 |阅读模式
[jass]    integer  array              SYS_BlotStack
    integer                     SYS_BlotTop = 8191
    integer                     SYS_BlotIndex

    unit     array              SYS_Blot
    integer  array              SYS_BlotCode
    integer  array              SYS_BlotData_I00
    integer  array              SYS_BlotData_I01
    integer  array              SYS_BlotData_I02
    integer  array              SYS_BlotData_I03
    integer  array              SYS_BlotData_I04

//=========================================
function FlushBlotData takes integer index returns nothing
    set SYS_Blot[index] = null
    set SYS_BlotCode[index] = 0
    set SYS_BlotData_I00[index] = 0
    set SYS_BlotData_I01[index] = 0
    set SYS_BlotData_I02[index] = 0
    set SYS_BlotData_I03[index] = 0
    set SYS_BlotData_I04[index] = 0
endfunction

function ReleaseBlot takes unit b returns nothing
    local integer bIndex = GetUnitUserData(b)
    set SYS_BlotStack[SYS_BlotTop] = bIndex
    set SYS_BlotTop = SYS_BlotTop + 1
    call FlushBlotData(bIndex)
endfunction

function InitBlot takes unit u,real tInv returns integer
    local integer bIndex
    if(SYS_BlotStack[SYS_BlotTop]==null)then
        set SYS_BlotStack[SYS_BlotTop] = SYS_BlotTop
        set bIndex = SYS_BlotTop
    else
        set bIndex = SYS_BlotStack[SYS_BlotTop]
    endif
    set SYS_BlotTop = SYS_BlotTop - 1
    call FlushBlotData(bIndex)
    set SYS_Blot[bIndex] = u
    return bIndex
endfunction[/jass]

评分

参与人数 1威望 +10 收起 理由
血戮魔动冰 + 10

查看全部评分

发表于 2009-9-27 12:01:42 | 显示全部楼层
虽然看起来很简洁
不过对于我这种纯踢er来说还是看不懂
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-2 09:13 , Processed in 0.259492 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表