找回密码
 点一下
查看: 1351|回复: 2

vjass 的有关问题【已解决】

[复制链接]
发表于 2009-3-3 19:50:18 | 显示全部楼层 |阅读模式
interface unitsx
    method life takes unit u returns real
    method maxlife takes unit u returns real
    method mana takes unit u returns real
    method maxmana takes unit u returns real
    method lv takes unit u returns integer
    method strt takes unit u returns integer
    method strf takes unit u returns integer
    method agit takes unit u returns integer
    method agif takes unit u returns integer
    method intt takes unit u returns integer
    method intf takes unit u returns integer
endinterface

struct Unit extends unitsx
    method life takes unit u returns real
        return GetUnitStateSwap(UNIT_STATE_LIFE, u)
    endmethod
    method maxlife takes unit u returns real
        return GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u)
    endmethod
    method mana takes unit u returns real
        return GetUnitStateSwap(UNIT_STATE_MANA, u)
    endmethod
    method maxmana takes unit u returns real
        return GetUnitStateSwap(UNIT_STATE_MAX_MANA, u)
    endmethod
    method lv takes unit u returns integer
        return  GetHeroLevel(u)
    endmethod
    method strt takes unit u returns integer
        return  GetHeroStr(u,true)
    endmethod
    method strf takes unit u returns integer
        return  GetHeroStr(u,false)
    endmethod
    method agit takes unit u returns integer
        return  GetHeroAgi(u,true)
    endmethod
    method agif takes unit u returns integer
        return  GetHeroAgi(u,false)
    endmethod
    method intt takes unit u returns integer
        return  GetHeroInt(u,true)
    endmethod
    method intf takes unit u returns integer
        return  GetHeroInt(u,false)
    endmethod
endstruct

地图初始化时
globals
    unitsx rs
endglobals
set rs = Unit.create()

然后我一直使用
call BJDebugMsg(R2S(rs.intt(GetAttacker())))
不用call rs.destory()
会有内存泄露吗?
发表于 2009-3-4 13:09:44 | 显示全部楼层
不会。(这主要是因为你只用一个struct的实例,如果要实现动态实例,请使用create和destroy)
回复

使用道具 举报

 楼主| 发表于 2009-3-4 19:31:46 | 显示全部楼层
谢啦
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-22 14:48 , Processed in 0.086394 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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