找回密码
 点一下
查看: 6325|回复: 69

本帖将更新一些有关1.23b新系统的问题

[复制链接]
发表于 2009-6-12 09:28:58 | 显示全部楼层 |阅读模式
目前还在PTR中,其实已经出现了一些未填上的漏洞,不过blz已在着手处理。


新函数都已经放到触发编辑器里。

新对象哈希表采用2层key,分别为父key和子key,可以把父key理解作文件夹。用这个可以把key拿来编组的说。而且可以一次性清空整个哈希表也可以单独清空某个父key下的所有子key。也可以清除单个子key。简单地说父key就是子key的命名空间,别理解成双重hash表。而且hash表本身无法作为另一个hash表的元素。



  
 楼主| 发表于 2009-6-12 01:32:26 | 显示全部楼层
几个要点:

1]关于StringHash,这个函数会将参数字符串进行哈希计算,获得一个的识别码,而不是以前那种H2I出来的handle值。这样字符串得到的识别码不但是在本地图中,在任何地图中同样的字符串得到的哈希结果都是一样的。


比如
StringHash("11111111")的结果必定是1257892722

对于哈希碰撞的案例我还没研究暂时。

注意字符串的哈希结果可能是正数也可能是负数。
--------------------------------------

2]而GetHandleId获得的确实是handle值没错。
--------------------------------------

3]再就是Return Bug,Return Bug已经封了,但是有人发现有个小地方还是可以利用,不过blz已经知道了这点并进行了进一步封杀。
--------------------------------------

4]然后关于Union Bug,Union Bug已被封。现在所有的局部变量都可以正确地对全局变量进行覆盖了,不会再产生共用空间。

[trigger]
LocalVar
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Custom script:   local integer udg_i=5
        Custom script:   local unit udg_u
        Set u = Militia 0001 <gen>
        Game - Display to (All players) the text: (String(i))
        Game - Display to (All players) the text: (Name of u)
[/trigger]

[trigger]
InitVar
    Events
        Map initialization
    Conditions
    Actions
        Set i = 0
        Set u = Blood Mage 0002 <gen>
[/trigger]

[trigger]
GetVar
    Events
        Time - Elapsed game time is 5.00 seconds
    Conditions
    Actions
        Game - Display to (All players) the text: (String(i))
        Game - Display to (All players) the text: (Name of u)
[/trigger]

以上触发的意义非常明显。在1.23b的ptr中,进入地图后5秒钟内按esc,那么显示的结果是"5"和"Militia",5秒钟后程序自动输出的结果是"0"和"Blood Mage"
--------------------------------------

5]至于这个哈希表的下标上限,则完全不必担心,至少我尝试了1000000000也没出问题。

[trigger]
Save
    Events
        Map initialization
    Conditions
    Actions
        Hashtable - Create a hashtable
        Set hash = (Last created hashtable)
        Hashtable - Save Handle Of Blood Mage 0002 <gen> as 1000000000 of 1000000000 in hash
[/trigger]

[trigger]
Load
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Game - Display to (All players) the text: (Name of (Load 1000000000 of 1000000000 in hash))
[/trigger]

正确地输出了"Blood Mage"
--------------------------------------

6]关于同一哈希表中相同key的覆盖规则


这里存在一个命名空间问题。你别看这里函数很多。不过哈希表里的对象的命名空间总共就五类。

Integer
Real                        
Boolean                    
String                    
Handle   


所有的handle都属于handle。
以上五类对象,键值相同也不会有影响。然而在handle类本身细分的类型里面,各种对象是会相互覆盖的。比如你用SaveUnitHandle在[1,1]存了个单位,下次又用SaveLightningHandle在[1,1]存了个闪电效果,那么你去读[1,1]的时候是读不出那个单位的,因为已经被覆盖掉了。只能读出一个闪电效果。而且这个哈希表是类型安全的。因此你用LoadUnitHandle去读这个[1,1]的时候,得到的结果是null,而不是把[1,1]位置的闪电效果handle值返回给你。

一个例子

[trigger]
ha
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Hashtable - Create a hashtable
        Set hash = (Last created hashtable)
        -------- 保存 --------
        Hashtable - Save 123.00 as 1 of 1 in hash
        Hashtable - Save True as 1 of 1 in hash
        Hashtable - Save 3 as 1 of 1 in hash
        Hashtable - Save str as 1 of 1 in hash
        Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
        Hashtable - Save Handle Of(Last created lightning effect) as 1 of 1 in hash
        Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
        Hashtable - Save Handle Of(Last created unit) as 1 of 1 in hash
        Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
        Hashtable - Save Handle Of(Last created lightning effect) as 1 of 1 in hash
        -------- 读取 --------
        Game - Display to (All players) the text: (String((Load 1 of 1 from hash)))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Load 1 of 1 from hash) Equal to True
            Then - Actions
                Game - Display to (All players) the text: True
            Else - Actions
                Game - Display to (All players) the text: False
        Game - Display to (All players) the text: (String((Load 1 of 1 from hash)))
        Game - Display to (All players) the text: (Load 1 of 1 from hash)
        Game - Display to (All players) the text: (Name of (Load 1 of 1 in hash))
[/trigger]


以上触发器运行结果
123.000
True
3
str
可见前头四个互不影响,而Unit被后面那个Lighting给覆盖掉了。那个light是否创建成功根本无所谓。因为哈希表里这项元素已经被指定为light,于是用LoadUnitHandle去取是没用的。
回复

使用道具 举报

 楼主| 发表于 2009-6-12 01:32:39 | 显示全部楼层
占楼again
回复

使用道具 举报

发表于 2009-6-12 01:36:46 | 显示全部楼层
地板观望
回复

使用道具 举报

发表于 2009-6-12 01:39:39 | 显示全部楼层
能不能贴下新函数的声明
回复

使用道具 举报

 楼主| 发表于 2009-6-12 01:45:51 | 显示全部楼层
[jass]
native StringHash takes string s returns integer
native GetHandleId takes handle h returns integer

native  InitHashtable    takes nothing returns hashtable

native  SaveInteger                    takes hashtable table, integer parentKey, integer childKey, integer value returns nothing
native  SaveReal                        takes hashtable table, integer parentKey, integer childKey, real value returns nothing
native  SaveBoolean                    takes hashtable table, integer parentKey, integer childKey, boolean value returns nothing
native  SaveStr                        takes hashtable table, integer parentKey, integer childKey, string value returns boolean
native  SavePlayerHandle                takes hashtable table, integer parentKey, integer childKey, player whichPlayer returns boolean
native  SaveWidgetHandle                takes hashtable table, integer parentKey, integer childKey, widget whichWidget returns boolean
native  SaveDestructableHandle            takes hashtable table, integer parentKey, integer childKey, destructable whichDestructable returns boolean
native  SaveItemHandle                    takes hashtable table, integer parentKey, integer childKey, item whichItem returns boolean
native  SaveUnitHandle                    takes hashtable table, integer parentKey, integer childKey, unit whichUnit returns boolean
native  SaveAbilityHandle                takes hashtable table, integer parentKey, integer childKey, ability whichAbility returns boolean
native  SaveTimerHandle                takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean
native  SaveTriggerHandle                takes hashtable table, integer parentKey, integer childKey, trigger whichTrigger returns boolean
native  SaveTriggerConditionHandle     takes hashtable table, integer parentKey, integer childKey, triggercondition whichTriggercondition returns boolean
native  SaveTriggerActionHandle        takes hashtable table, integer parentKey, integer childKey, triggeraction whichTriggeraction returns boolean
native  SaveTriggerEventHandle            takes hashtable table, integer parentKey, integer childKey, event whichEvent returns boolean
native  SaveForceHandle                takes hashtable table, integer parentKey, integer childKey, force whichForce returns boolean
native  SaveGroupHandle                takes hashtable table, integer parentKey, integer childKey, group whichGroup returns boolean
native  SaveLocationHandle                takes hashtable table, integer parentKey, integer childKey, location whichLocation returns boolean
native  SaveRectHandle                    takes hashtable table, integer parentKey, integer childKey, rect whichRect returns boolean
native  SaveBooleanExprHandle            takes hashtable table, integer parentKey, integer childKey, boolexpr whichBoolexpr returns boolean
native  SaveSoundHandle                takes hashtable table, integer parentKey, integer childKey, sound whichSound returns boolean
native  SaveEffectHandle                takes hashtable table, integer parentKey, integer childKey, effect whichEffect returns boolean
native  SaveUnitPoolHandle                takes hashtable table, integer parentKey, integer childKey, unitpool whichUnitpool returns boolean
native  SaveItemPoolHandle                takes hashtable table, integer parentKey, integer childKey, itempool whichItempool returns boolean
native  SaveQuestHandle                takes hashtable table, integer parentKey, integer childKey, quest whichQuest returns boolean
native  SaveQuestItemHandle            takes hashtable table, integer parentKey, integer childKey, questitem whichQuestitem returns boolean
native  SaveDefeatConditionHandle      takes hashtable table, integer parentKey, integer childKey, defeatcondition whichDefeatcondition returns boolean
native  SaveTimerDialogHandle            takes hashtable table, integer parentKey, integer childKey, timerdialog whichTimerdialog returns boolean
native  SaveLeaderboardHandle            takes hashtable table, integer parentKey, integer childKey, leaderboard whichLeaderboard returns boolean
native  SaveMultiboardHandle            takes hashtable table, integer parentKey, integer childKey, multiboard whichMultiboard returns boolean
native  SaveMultiboardItemHandle       takes hashtable table, integer parentKey, integer childKey, multiboarditem whichMultiboarditem returns boolean
native  SaveTrackableHandle            takes hashtable table, integer parentKey, integer childKey, trackable whichTrackable returns boolean
native  SaveDialogHandle                takes hashtable table, integer parentKey, integer childKey, dialog whichDialog returns boolean
native  SaveButtonHandle                takes hashtable table, integer parentKey, integer childKey, button whichButton returns boolean
native  SaveTextTagHandle                takes hashtable table, integer parentKey, integer childKey, texttag whichTexttag returns boolean
native  SaveLightningHandle            takes hashtable table, integer parentKey, integer childKey, lightning whichLightning returns boolean
native  SaveImageHandle                takes hashtable table, integer parentKey, integer childKey, image whichImage returns boolean
native  SaveUbersplatHandle            takes hashtable table, integer parentKey, integer childKey, ubersplat whichUbersplat returns boolean
native  SaveRegionHandle                takes hashtable table, integer parentKey, integer childKey, region whichRegion returns boolean
native  SaveFogStateHandle                takes hashtable table, integer parentKey, integer childKey, fogstate whichFogState returns boolean
native  SaveFogModifierHandle            takes hashtable table, integer parentKey, integer childKey, fogmodifier whichFogModifier returns boolean

native  LoadInteger                takes hashtable table, integer parentKey, integer childKey returns integer
native  LoadReal                    takes hashtable table, integer parentKey, integer childKey returns real
native  LoadBoolean                    takes hashtable table, integer parentKey, integer childKey returns boolean
native  LoadStr                     takes hashtable table, integer parentKey, integer childKey returns string
native  LoadPlayerHandle            takes hashtable table, integer parentKey, integer childKey returns player
native  LoadWidgetHandle            takes hashtable table, integer parentKey, integer childKey returns widget
native  LoadDestructableHandle        takes hashtable table, integer parentKey, integer childKey returns destructable
native  LoadItemHandle                takes hashtable table, integer parentKey, integer childKey returns item
native  LoadUnitHandle                takes hashtable table, integer parentKey, integer childKey returns unit
native  LoadAbilityHandle            takes hashtable table, integer parentKey, integer childKey returns ability
native  LoadTimerHandle            takes hashtable table, integer parentKey, integer childKey returns timer
native  LoadTriggerHandle            takes hashtable table, integer parentKey, integer childKey returns trigger
native  LoadTriggerConditionHandle    takes hashtable table, integer parentKey, integer childKey returns triggercondition
native  LoadTriggerActionHandle    takes hashtable table, integer parentKey, integer childKey returns triggeraction
native  LoadTriggerEventHandle        takes hashtable table, integer parentKey, integer childKey returns event
native  LoadForceHandle            takes hashtable table, integer parentKey, integer childKey returns force
native  LoadGroupHandle            takes hashtable table, integer parentKey, integer childKey returns group
native  LoadLocationHandle            takes hashtable table, integer parentKey, integer childKey returns location
native  LoadRectHandle                takes hashtable table, integer parentKey, integer childKey returns rect
native  LoadBooleanExprHandle        takes hashtable table, integer parentKey, integer childKey returns boolexpr
native  LoadSoundHandle            takes hashtable table, integer parentKey, integer childKey returns sound
native  LoadEffectHandle            takes hashtable table, integer parentKey, integer childKey returns effect
native  LoadUnitPoolHandle            takes hashtable table, integer parentKey, integer childKey returns unitpool
native  LoadItemPoolHandle            takes hashtable table, integer parentKey, integer childKey returns itempool
native  LoadQuestHandle            takes hashtable table, integer parentKey, integer childKey returns quest
native  LoadQuestItemHandle        takes hashtable table, integer parentKey, integer childKey returns questitem
native  LoadDefeatConditionHandle  takes hashtable table, integer parentKey, integer childKey returns defeatcondition
native  LoadTimerDialogHandle        takes hashtable table, integer parentKey, integer childKey returns timerdialog
native  LoadLeaderboardHandle        takes hashtable table, integer parentKey, integer childKey returns leaderboard
native  LoadMultiboardHandle        takes hashtable table, integer parentKey, integer childKey returns multiboard
native  LoadMultiboardItemHandle   takes hashtable table, integer parentKey, integer childKey returns multiboarditem
native  LoadTrackableHandle        takes hashtable table, integer parentKey, integer childKey returns trackable
native  LoadDialogHandle            takes hashtable table, integer parentKey, integer childKey returns dialog
native  LoadButtonHandle            takes hashtable table, integer parentKey, integer childKey returns button
native  LoadTextTagHandle            takes hashtable table, integer parentKey, integer childKey returns texttag
native  LoadLightningHandle        takes hashtable table, integer parentKey, integer childKey returns lightning
native  LoadImageHandle            takes hashtable table, integer parentKey, integer childKey returns image
native  LoadUbersplatHandle        takes hashtable table, integer parentKey, integer childKey returns ubersplat
native  LoadRegionHandle            takes hashtable table, integer parentKey, integer childKey returns region
native  LoadFogStateHandle            takes hashtable table, integer parentKey, integer childKey returns fogstate
native  LoadFogModifierHandle        takes hashtable table, integer parentKey, integer childKey returns fogmodifier

native  HaveSavedInteger                    takes hashtable table, integer parentKey, integer childKey returns boolean
native  HaveSavedReal                        takes hashtable table, integer parentKey, integer childKey returns boolean
native  HaveSavedBoolean                    takes hashtable table, integer parentKey, integer childKey returns boolean
native  HaveSavedString                        takes hashtable table, integer parentKey, integer childKey returns boolean
native  HaveSavedHandle                     takes hashtable table, integer parentKey, integer childKey returns boolean

native  RemoveSavedInteger                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedReal                        takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedBoolean                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedString                    takes hashtable table, integer parentKey, integer childKey returns nothing
native  RemoveSavedHandle                    takes hashtable table, integer parentKey, integer childKey returns nothing

native  FlushParentHashtable                        takes hashtable table returns nothing
native  FlushChildHashtable                    takes hashtable table, integer parentKey returns nothing

[/jass]
回复

使用道具 举报

发表于 2009-6-12 01:52:26 | 显示全部楼层
看起来和GC差不多啊,暴雪不会是把GC重新包装下就成HT了吧
回复

使用道具 举报

 楼主| 发表于 2009-6-12 02:45:37 | 显示全部楼层
我把板凳楼留给你们的提问。有啥问题或者需要我帮忙测试的在这里回帖好了。我会回答后统一放到板凳楼里的。
回复

使用道具 举报

发表于 2009-6-12 03:10:14 | 显示全部楼层
SaveInteger
SaveReal
SaveBoolean
这3个 没有返回值  是不是
Load时 可以取到 0 0.0 false之类默认值
而其他Load 没有存的 会卡住


忘了问下。。。。

这个hashtable  存取 效率 对比缓存  怎么样。。
回复

使用道具 举报

发表于 2009-6-12 03:12:22 | 显示全部楼层
RemoveSavedHandle
而这个..

如果
LoadPlayerHandle
LoadWidgetHandle
存了2个数据 按一样的键值 会怎么样

RemoveSavedHandle 时 会怎么样











我突然想到个很猥琐的hash方法.
然后这个1.23也被禁止了..

[jass]
constant function H2I takes handle h returns integer
return h
return 174
endfunction
constant function S2HI takes string i returns integer
return i
return 0
endfunction
function GetH2i takes handle h returns integer
return S2HI(I2S(H2I(h)))
endfunction[/jass]

现在流行的hash方式是  取余数
取余数还是出现冲突 还要冲突处理..

而字符串 表 一般人不会超过1千
魔兽字符串表 不会记录重复
所以这个方法 得到1个不重复的序号 而且每个handle固定1个.

..不过1.23也无用..也用不着..
=_=
回复

使用道具 举报

 楼主| 发表于 2009-6-12 03:35:23 | 显示全部楼层
我正想说明这事儿

这里存在一个命名空间问题。你别看这里函数很多。不过哈希表里的对象命名空间总共就五类。

Integer
Real                        
Boolean                    
String                    
Handle   


所有的handle都属于handle
以上五类对象,键值相同也不会有影响。然而在handle类本身细分的类型里面,各种对象是会相互覆盖的。比如你用SaveUnitHandle在[1,1]存了个单位,下次又用SaveLightningHandle在[1,1]存了个闪电效果,那么你去读[1,1]的时候是读不出那个单位的,因为已经被覆盖掉了。只能读出一个闪电效果。而且这个哈希表是类型安全的。因此你用LoadUnitHandle去读这个[1,1]的时候,得到的结果是null,而不是把[1,1]位置的闪电效果handle值返回给你。

一个例子

[trigger]
ha
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Hashtable - Create a hashtable
        Set hash = (Last created hashtable)
        -------- 保存 --------
        Hashtable - Save 123.00 as 1 of 1 in hash
        Hashtable - Save True as 1 of 1 in hash
        Hashtable - Save 3 as 1 of 1 in hash
        Hashtable - Save str as 1 of 1 in hash
        Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
        Hashtable - Save Handle Of(Last created lightning effect) as 1 of 1 in hash
        Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
        Hashtable - Save Handle Of(Last created unit) as 1 of 1 in hash
        Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
        Hashtable - Save Handle Of(Last created lightning effect) as 1 of 1 in hash
        -------- 读取 --------
        Game - Display to (All players) the text: (String((Load 1 of 1 from hash)))  这个是实数转字符串
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Load 1 of 1 from hash) Equal to True
            Then - Actions
                Game - Display to (All players) the text: True
            Else - Actions
                Game - Display to (All players) the text: False
        Game - Display to (All players) the text: (String((Load 1 of 1 from hash))) 这个是整数转字符串,虽然看起来一样
        Game - Display to (All players) the text: (Load 1 of 1 from hash)
        Game - Display to (All players) the text: (Name of (Load 1 of 1 in hash))
[/trigger]


以上触发器运行结果
123.000
True
3
str
可见前头四个互不影响,而Unit被后面那个Lighting给覆盖掉了。那个light是否创建成功根本无所谓。因为哈希表里这项元素已经被指定为light,于是用LoadUnitHandle去取是没用的。
回复

使用道具 举报

 楼主| 发表于 2009-6-12 03:48:12 | 显示全部楼层
--------------------------------------------------------------------------
  WARCRAFT III: THE FROZEN THRONE VERSION HISTORY
--------------------------------------------------------------------------

--------------------------------------------------------------------------
Patch 1.23b
--------------------------------------------------------------------------

PC WORLD EDITOR CHANGES

- Added new JASS hash table functions to replace the lost functionality from
   fixing unsafe type casting.
   - Hash Table - Save Item Handle
   - Hash Table - Save Unit Handle
   - ...
   - Hash Table - Load Item Handle
   - Hash Table - Load Unit Handle
   - ...
   - Hash Table - Get Handle ID

FIXES

- Fixed an exploit related to unsafe type casting that allowed users to
   execute arbitrary code in maps.
- Fixed the JASS unsafe type casting exploit ("return bug").
- Fixed several World Editor crashes.
回复

使用道具 举报

发表于 2009-6-12 04:11:40 | 显示全部楼层
这个hashtable  存取 效率 对比缓存  怎么样。。
回复

使用道具 举报

 楼主| 发表于 2009-6-12 04:31:24 | 显示全部楼层
那个要比起来还稍微有点麻烦~~你有没什么好点的比较措施?~~
回复

使用道具 举报

发表于 2009-6-12 04:50:19 | 显示全部楼层
new WE 里的japi有堆不错的函数
//Measure wall clock elapsed time
native StopWatchCreate    takes nothing returns integer
native StopWatchMark    takes integer obj returns real
native StopWatchDestroy    takes integer obj returns nothing

这个计时很精确。。。不会受触发器影响 (魔兽那 多久。。都显示0。。)以前测试hash用这个。。
1。23 这个肯定无法用了。。




那。。写个计时器间隔时间循环大量操作。。看看哪个每秒操作次数更高 而不会卡?。。。。。似乎很窘。。
回复

使用道具 举报

发表于 2009-6-12 06:14:44 | 显示全部楼层
卧槽,还可以这样。。。
    private function C2I2 takes code c returns integer
        return c
        call DoNothing()
        return 0
    endfunction
    function C2I takes code c returns integer
        return S2I(I2S(C2I2(c)))
    endfunction
    private function I2CH takes integer i returns code
        return i
        call DoNothing()
        return null
    endfunction
    private function C2C takes code c returns code
        return c
        call DoNothing()
        return null
    endfunction
    function I2C takes integer i returns code
        return C2C(I2CH(i))
        call DoNothing()
        return null
    endfunction
回复

使用道具 举报

发表于 2009-6-12 07:15:22 | 显示全部楼层
这样的话,1.23b岂不是运行不了现今的所有RPG了
除了极少的图
都用了returnbug或者unionbug
这样的话……
1.23b也就没有什么意义了
回复

使用道具 举报

 楼主| 发表于 2009-6-12 07:43:52 | 显示全部楼层
引用第15楼thewisp1于2009-06-12 06:14发表的  :
卧槽,还可以这样。。。
    private function C2I2 takes code c returns integer
        return c
        call DoNothing()
        return 0
.......


你这个多半是wc3c上抄来的。BN上已经有补丁了。参照我说的第二条。
回复

使用道具 举报

发表于 2009-6-12 07:47:11 | 显示全部楼层
int I2U(int handlevalue){return handlevalue;}
恩恩... 我实在太懒了...
回复

使用道具 举报

发表于 2009-6-12 07:48:12 | 显示全部楼层
呃。。 是int __cdecl I2U(int handlevalue){return handlevalue;}
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 04:45 , Processed in 0.102416 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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