找回密码
 点一下
查看: 2174|回复: 4

关于玩家所选择单位

[复制链接]
发表于 2006-12-25 14:48:53 | 显示全部楼层 |阅读模式
如果不先call SyncSelections()
直接用GroupEnumUnitsSelected函数会不会导致玩家掉线?

有条件的帮测试下,谢了
 楼主| 发表于 2006-12-25 15:25:05 | 显示全部楼层
补充下:
比如
if GetLocalPlayer()==Player(0) then
    call SelectUnit(u,true)
endif
这是很普遍的玩家选择单位函数,而选择动作是只对玩家1进行的
那么对不同玩家而言,如果函数本身并不会进行同步的话,用GroupEnumUnitsSelected(g,Player(0),null)的返回值就是不同的
同样,对于玩家选择单位事件的触发也是一样
回复

使用道具 举报

发表于 2006-12-25 17:37:04 | 显示全部楼层
会的,对指定玩家选取单位组:
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

以前的修正方案是

function SelectGroupBJEnum takes nothing returns nothing
    if (GetLocalPlayer() == whichPlayer) then
    call SelectUnit( GetEnumUnit(), true )
   endif
endfunction

function SelectGroupForPlayerBJ takes group g, player whichPlayer returns nothing
         if (GetLocalPlayer() == whichPlayer) then
               call ClearSelection()
        endif
        call ForGroup( g, function SelectGroupBJEnum )
endfunction

至于加call SyncSelections()的作用就不知道了。
回复

使用道具 举报

 楼主| 发表于 2006-12-25 23:06:26 | 显示全部楼层
经测试选择单位不会引起不同步掉线问题

楼上的代码如果会掉线猜测应该是LocalPlayer环境与ForGroup的冲突
回复

使用道具 举报

 楼主| 发表于 2006-12-25 23:08:39 | 显示全部楼层
就是说
if GetLocalPlayer()==Player(0) then
  call SelectUnit(u,true)
endif

然后对于玩家1选择的单位,所有玩家都能返回同一值
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 17:03 , Processed in 0.228521 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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