本帖将更新一些有关1.23b新系统的问题
目前还在PTR中,其实已经出现了一些未填上的漏洞,不过blz已在着手处理。新函数都已经放到触发编辑器里。
新对象哈希表采用2层key,分别为父key和子key,可以把父key理解作文件夹。用这个可以把key拿来编组的说。而且可以一次性清空整个哈希表也可以单独清空某个父key下的所有子key。也可以清除单个子key。简单地说父key就是子key的命名空间,别理解成双重hash表。而且hash表本身无法作为另一个hash表的元素。
几个要点:
1]关于StringHash,这个函数会将参数字符串进行哈希计算,获得一个的识别码,而不是以前那种H2I出来的handle值。这样字符串得到的识别码不但是在本地图中,在任何地图中同样的字符串得到的哈希结果都是一样的。
比如
StringHash("11111111")的结果必定是1257892722
对于哈希碰撞的案例我还没研究暂时。
注意字符串的哈希结果可能是正数也可能是负数。
--------------------------------------
2]而GetHandleId获得的确实是handle值没错。
--------------------------------------
3]再就是Return Bug,Return Bug已经封了,但是有人发现有个小地方还是可以利用,不过blz已经知道了这点并进行了进一步封杀。
--------------------------------------
4]然后关于Union Bug,Union Bug已被封。现在所有的局部变量都可以正确地对全局变量进行覆盖了,不会再产生共用空间。
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)
InitVar
Events
Map initialization
Conditions
Actions
Set i = 0
Set u = Blood Mage 0002 <gen>
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)
以上触发的意义非常明显。在1.23b的ptr中,进入地图后5秒钟内按esc,那么显示的结果是"5"和"Militia",5秒钟后程序自动输出的结果是"0"和"Blood Mage"
--------------------------------------
5]至于这个哈希表的下标上限,则完全不必担心,至少我尝试了1000000000也没出问题。
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
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))
正确地输出了"Blood Mage"
--------------------------------------
6]关于同一哈希表中相同key的覆盖规则
这里存在一个命名空间问题。你别看这里函数很多。不过哈希表里的对象的命名空间总共就五类。
Integer
Real
Boolean
String
Handle
所有的handle都属于handle。
以上五类对象,键值相同也不会有影响。然而在handle类本身细分的类型里面,各种对象是会相互覆盖的。比如你用SaveUnitHandle在存了个单位,下次又用SaveLightningHandle在存了个闪电效果,那么你去读的时候是读不出那个单位的,因为已经被覆盖掉了。只能读出一个闪电效果。而且这个哈希表是类型安全的。因此你用LoadUnitHandle去读这个的时候,得到的结果是null,而不是把位置的闪电效果handle值返回给你。
一个例子
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))
以上触发器运行结果
123.000
True
3
str
可见前头四个互不影响,而Unit被后面那个Lighting给覆盖掉了。那个light是否创建成功根本无所谓。因为哈希表里这项元素已经被指定为light,于是用LoadUnitHandle去取是没用的。 占楼again 地板观望 能不能贴下新函数的声明
native StringHash takes string s returns integer
native GetHandleId takes handle h returns integer
nativeInitHashtable takes nothing returns hashtable
nativeSaveInteger takes hashtable table, integer parentKey, integer childKey, integer value returns nothing
nativeSaveReal takes hashtable table, integer parentKey, integer childKey, real value returns nothing
nativeSaveBoolean takes hashtable table, integer parentKey, integer childKey, boolean value returns nothing
nativeSaveStr takes hashtable table, integer parentKey, integer childKey, string value returns boolean
nativeSavePlayerHandle takes hashtable table, integer parentKey, integer childKey, player whichPlayer returns boolean
nativeSaveWidgetHandle takes hashtable table, integer parentKey, integer childKey, widget whichWidget returns boolean
nativeSaveDestructableHandle takes hashtable table, integer parentKey, integer childKey, destructable whichDestructable returns boolean
nativeSaveItemHandle takes hashtable table, integer parentKey, integer childKey, item whichItem returns boolean
nativeSaveUnitHandle takes hashtable table, integer parentKey, integer childKey, unit whichUnit returns boolean
nativeSaveAbilityHandle takes hashtable table, integer parentKey, integer childKey, ability whichAbility returns boolean
nativeSaveTimerHandle takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean
nativeSaveTriggerHandle takes hashtable table, integer parentKey, integer childKey, trigger whichTrigger returns boolean
nativeSaveTriggerConditionHandle takes hashtable table, integer parentKey, integer childKey, triggercondition whichTriggercondition returns boolean
nativeSaveTriggerActionHandle takes hashtable table, integer parentKey, integer childKey, triggeraction whichTriggeraction returns boolean
nativeSaveTriggerEventHandle takes hashtable table, integer parentKey, integer childKey, event whichEvent returns boolean
nativeSaveForceHandle takes hashtable table, integer parentKey, integer childKey, force whichForce returns boolean
nativeSaveGroupHandle takes hashtable table, integer parentKey, integer childKey, group whichGroup returns boolean
nativeSaveLocationHandle takes hashtable table, integer parentKey, integer childKey, location whichLocation returns boolean
nativeSaveRectHandle takes hashtable table, integer parentKey, integer childKey, rect whichRect returns boolean
nativeSaveBooleanExprHandle takes hashtable table, integer parentKey, integer childKey, boolexpr whichBoolexpr returns boolean
nativeSaveSoundHandle takes hashtable table, integer parentKey, integer childKey, sound whichSound returns boolean
nativeSaveEffectHandle takes hashtable table, integer parentKey, integer childKey, effect whichEffect returns boolean
nativeSaveUnitPoolHandle takes hashtable table, integer parentKey, integer childKey, unitpool whichUnitpool returns boolean
nativeSaveItemPoolHandle takes hashtable table, integer parentKey, integer childKey, itempool whichItempool returns boolean
nativeSaveQuestHandle takes hashtable table, integer parentKey, integer childKey, quest whichQuest returns boolean
nativeSaveQuestItemHandle takes hashtable table, integer parentKey, integer childKey, questitem whichQuestitem returns boolean
nativeSaveDefeatConditionHandle takes hashtable table, integer parentKey, integer childKey, defeatcondition whichDefeatcondition returns boolean
nativeSaveTimerDialogHandle takes hashtable table, integer parentKey, integer childKey, timerdialog whichTimerdialog returns boolean
nativeSaveLeaderboardHandle takes hashtable table, integer parentKey, integer childKey, leaderboard whichLeaderboard returns boolean
nativeSaveMultiboardHandle takes hashtable table, integer parentKey, integer childKey, multiboard whichMultiboard returns boolean
nativeSaveMultiboardItemHandle takes hashtable table, integer parentKey, integer childKey, multiboarditem whichMultiboarditem returns boolean
nativeSaveTrackableHandle takes hashtable table, integer parentKey, integer childKey, trackable whichTrackable returns boolean
nativeSaveDialogHandle takes hashtable table, integer parentKey, integer childKey, dialog whichDialog returns boolean
nativeSaveButtonHandle takes hashtable table, integer parentKey, integer childKey, button whichButton returns boolean
nativeSaveTextTagHandle takes hashtable table, integer parentKey, integer childKey, texttag whichTexttag returns boolean
nativeSaveLightningHandle takes hashtable table, integer parentKey, integer childKey, lightning whichLightning returns boolean
nativeSaveImageHandle takes hashtable table, integer parentKey, integer childKey, image whichImage returns boolean
nativeSaveUbersplatHandle takes hashtable table, integer parentKey, integer childKey, ubersplat whichUbersplat returns boolean
nativeSaveRegionHandle takes hashtable table, integer parentKey, integer childKey, region whichRegion returns boolean
nativeSaveFogStateHandle takes hashtable table, integer parentKey, integer childKey, fogstate whichFogState returns boolean
nativeSaveFogModifierHandle takes hashtable table, integer parentKey, integer childKey, fogmodifier whichFogModifier returns boolean
nativeLoadInteger takes hashtable table, integer parentKey, integer childKey returns integer
nativeLoadReal takes hashtable table, integer parentKey, integer childKey returns real
nativeLoadBoolean takes hashtable table, integer parentKey, integer childKey returns boolean
nativeLoadStr takes hashtable table, integer parentKey, integer childKey returns string
nativeLoadPlayerHandle takes hashtable table, integer parentKey, integer childKey returns player
nativeLoadWidgetHandle takes hashtable table, integer parentKey, integer childKey returns widget
nativeLoadDestructableHandle takes hashtable table, integer parentKey, integer childKey returns destructable
nativeLoadItemHandle takes hashtable table, integer parentKey, integer childKey returns item
nativeLoadUnitHandle takes hashtable table, integer parentKey, integer childKey returns unit
nativeLoadAbilityHandle takes hashtable table, integer parentKey, integer childKey returns ability
nativeLoadTimerHandle takes hashtable table, integer parentKey, integer childKey returns timer
nativeLoadTriggerHandle takes hashtable table, integer parentKey, integer childKey returns trigger
nativeLoadTriggerConditionHandle takes hashtable table, integer parentKey, integer childKey returns triggercondition
nativeLoadTriggerActionHandle takes hashtable table, integer parentKey, integer childKey returns triggeraction
nativeLoadTriggerEventHandle takes hashtable table, integer parentKey, integer childKey returns event
nativeLoadForceHandle takes hashtable table, integer parentKey, integer childKey returns force
nativeLoadGroupHandle takes hashtable table, integer parentKey, integer childKey returns group
nativeLoadLocationHandle takes hashtable table, integer parentKey, integer childKey returns location
nativeLoadRectHandle takes hashtable table, integer parentKey, integer childKey returns rect
nativeLoadBooleanExprHandle takes hashtable table, integer parentKey, integer childKey returns boolexpr
nativeLoadSoundHandle takes hashtable table, integer parentKey, integer childKey returns sound
nativeLoadEffectHandle takes hashtable table, integer parentKey, integer childKey returns effect
nativeLoadUnitPoolHandle takes hashtable table, integer parentKey, integer childKey returns unitpool
nativeLoadItemPoolHandle takes hashtable table, integer parentKey, integer childKey returns itempool
nativeLoadQuestHandle takes hashtable table, integer parentKey, integer childKey returns quest
nativeLoadQuestItemHandle takes hashtable table, integer parentKey, integer childKey returns questitem
nativeLoadDefeatConditionHandletakes hashtable table, integer parentKey, integer childKey returns defeatcondition
nativeLoadTimerDialogHandle takes hashtable table, integer parentKey, integer childKey returns timerdialog
nativeLoadLeaderboardHandle takes hashtable table, integer parentKey, integer childKey returns leaderboard
nativeLoadMultiboardHandle takes hashtable table, integer parentKey, integer childKey returns multiboard
nativeLoadMultiboardItemHandle takes hashtable table, integer parentKey, integer childKey returns multiboarditem
nativeLoadTrackableHandle takes hashtable table, integer parentKey, integer childKey returns trackable
nativeLoadDialogHandle takes hashtable table, integer parentKey, integer childKey returns dialog
nativeLoadButtonHandle takes hashtable table, integer parentKey, integer childKey returns button
nativeLoadTextTagHandle takes hashtable table, integer parentKey, integer childKey returns texttag
nativeLoadLightningHandle takes hashtable table, integer parentKey, integer childKey returns lightning
nativeLoadImageHandle takes hashtable table, integer parentKey, integer childKey returns image
nativeLoadUbersplatHandle takes hashtable table, integer parentKey, integer childKey returns ubersplat
nativeLoadRegionHandle takes hashtable table, integer parentKey, integer childKey returns region
nativeLoadFogStateHandle takes hashtable table, integer parentKey, integer childKey returns fogstate
nativeLoadFogModifierHandle takes hashtable table, integer parentKey, integer childKey returns fogmodifier
nativeHaveSavedInteger takes hashtable table, integer parentKey, integer childKey returns boolean
nativeHaveSavedReal takes hashtable table, integer parentKey, integer childKey returns boolean
nativeHaveSavedBoolean takes hashtable table, integer parentKey, integer childKey returns boolean
nativeHaveSavedString takes hashtable table, integer parentKey, integer childKey returns boolean
nativeHaveSavedHandle takes hashtable table, integer parentKey, integer childKey returns boolean
nativeRemoveSavedInteger takes hashtable table, integer parentKey, integer childKey returns nothing
nativeRemoveSavedReal takes hashtable table, integer parentKey, integer childKey returns nothing
nativeRemoveSavedBoolean takes hashtable table, integer parentKey, integer childKey returns nothing
nativeRemoveSavedString takes hashtable table, integer parentKey, integer childKey returns nothing
nativeRemoveSavedHandle takes hashtable table, integer parentKey, integer childKey returns nothing
nativeFlushParentHashtable takes hashtable table returns nothing
nativeFlushChildHashtable takes hashtable table, integer parentKey returns nothing
看起来和GC差不多啊,暴雪不会是把GC重新包装下就成HT了吧 我把板凳楼留给你们的提问。有啥问题或者需要我帮忙测试的在这里回帖好了。我会回答后统一放到板凳楼里的。 SaveInteger
SaveReal
SaveBoolean
这3个 没有返回值是不是
Load时 可以取到 0 0.0 false之类默认值
而其他Load 没有存的 会卡住
忘了问下。。。。
这个hashtable存取 效率 对比缓存怎么样。。 RemoveSavedHandle
而这个..
如果
LoadPlayerHandle
LoadWidgetHandle
存了2个数据 按一样的键值 会怎么样
RemoveSavedHandle 时 会怎么样
我突然想到个很猥琐的hash方法.
然后这个1.23也被禁止了..
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
现在流行的hash方式是取余数
取余数还是出现冲突 还要冲突处理..
而字符串 表 一般人不会超过1千
魔兽字符串表 不会记录重复
所以这个方法 得到1个不重复的序号 而且每个handle固定1个.
..不过1.23也无用..也用不着..
=_= 我正想说明这事儿
这里存在一个命名空间问题。你别看这里函数很多。不过哈希表里的对象命名空间总共就五类。
Integer
Real
Boolean
String
Handle
所有的handle都属于handle
以上五类对象,键值相同也不会有影响。然而在handle类本身细分的类型里面,各种对象是会相互覆盖的。比如你用SaveUnitHandle在存了个单位,下次又用SaveLightningHandle在存了个闪电效果,那么你去读的时候是读不出那个单位的,因为已经被覆盖掉了。只能读出一个闪电效果。而且这个哈希表是类型安全的。因此你用LoadUnitHandle去读这个的时候,得到的结果是null,而不是把位置的闪电效果handle值返回给你。
一个例子
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))
以上触发器运行结果
123.000
True
3
str
可见前头四个互不影响,而Unit被后面那个Lighting给覆盖掉了。那个light是否创建成功根本无所谓。因为哈希表里这项元素已经被指定为light,于是用LoadUnitHandle去取是没用的。 --------------------------------------------------------------------------
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. 这个hashtable存取 效率 对比缓存怎么样。。 那个要比起来还稍微有点麻烦~~你有没什么好点的比较措施?~~ 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 这个肯定无法用了。。
那。。写个计时器间隔时间循环大量操作。。看看哪个每秒操作次数更高 而不会卡?。。。。。似乎很窘。。 卧槽,还可以这样。。。
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 这样的话,1.23b岂不是运行不了现今的所有RPG了
除了极少的图
都用了returnbug或者unionbug
这样的话……
1.23b也就没有什么意义了 引用第15楼thewisp1于2009-06-12 06:14发表的:
卧槽,还可以这样。。。
private function C2I2 takes code c returns integer
return c
call DoNothing()
return 0
....... http://bbs.islga.org/images/back.gif
你这个多半是wc3c上抄来的。BN上已经有补丁了。参照我说的第二条。 int I2U(int handlevalue){return handlevalue;}
恩恩... 我实在太懒了... 呃。。 是int __cdecl I2U(int handlevalue){return handlevalue;}