|
发表于 2006-5-30 14:23:49
|
显示全部楼层
从我自己得到的一些错误得出的结论:
GetLocalPlayer()后不要涉及实际handle或与此相关的操作或赋值(指这些操作可能影响到handle本身是否存在/清除),不同的玩家可能因此造成内存中数据的脱节而引起断线;
比较隐蔽的如TriggerCondition,Filter,Boolexpr等(基类型同为handle),
还有,bj中LocalPlayer()的用法未必都是正确的,最近的一个例子:
[jass]
function SelectGroupBJEnum takes nothing returns nothing
call SelectUnit( GetEnumUnit(), true )
endfunction
function SelectGroupForPlayerBJ takes group g, player whichPlayer returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
call ForGroup( g, function SelectGroupBJEnum )
endif
endfunction[/jass]
比较特殊的,调用code(ForGroup)的异步导致DisSyn,我以为如果是LocalPlayer判断放到SelectGroupBJEnum就应该好了:
[jass]
function SelectGroupBJEnum takes nothing returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SelectUnit( GetEnumUnit(), true )
endif
endfunction
function SelectGroupForPlayerBJ takes group g, player whichPlayer returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ClearSelection()
endif
call ForGroup( g, function SelectGroupBJEnum )
endfunction[/jass]
对于那个特效的本地显示还是有点匪夷所思,
[jass]native AddSpecialEffect takes string modelName, real x, real y returns effect[/jass]
如果是modelName为空而还能正常返回effect(非null值),那么象CreateUnit如果用的不同的Id是不是也一样可行呢. |
|