找回密码
 点一下
查看: 2394|回复: 8

多人连线中出现DisSyn错误(解决)

[复制链接]
发表于 2006-5-23 16:10:02 | 显示全部楼层 |阅读模式
地图出现了联机不同步而出错,经过分析,锁定在以下部分:
[jass]local location flyloc=GetUnitLoc(gg_unit_Udre_0186)
local group batgroup=CreateGroup()
local integer i=0
if GetUnitState(gg_unit_Udre_0186,UNIT_STATE_MANA)<100 then
if GetLocalPlayer()==udg_EvilPlayer then
    call ClearTextMessages()
    call PlaySoundBJ( error )
endif
call DestroyGroup(batgroup)
call RemoveLocation(flyloc)
call DisplayTextToPlayer( udg_EvilPlayer, 0.70, -0.10, "|cffcccc00浣??榄???间?瓒宠?浣??????????r" )
set flyloc=null
set batgroup=null
return
endif
//==================以下是可疑部分==========
call DisableTrigger(GetTriggeringTrigger())
set udg_Boolean7=true
call SetUnitOwner(gg_unit_Udre_0186,Player(PLAYER_NEUTRAL_PASSIVE),false)
loop
exitwhen i>(GetUnitStateSwap(UNIT_STATE_LIFE,gg_unit_Udre_0186)/190)
call GroupAddUnit(batgroup,CreateUnitAtLoc(Player(10),'ugar',flyloc,GetRandomDirectionDeg()))
set i=i+1
endloop
call KillUnit(gg_unit_Udre_0186)
call SelectGroupForPlayerBJ(batgroup,udg_EvilPlayer)
call DestroyGroup(batgroup)
call RemoveLocation(flyloc)
//=======================================================
call TriggerSleepAction(4.00)
call SetUnitOwner(gg_unit_Udre_0186,Player(10),true)
call TriggerSleepAction(4.00)
call EnableTrigger(gg_trg_BatToDraculaform)
set flyloc=null
set batgroup=null[/jass]

[ 本帖最后由 kook 于 2006-5-27 13:33 编辑 ]
发表于 2006-5-23 17:12:06 | 显示全部楼层
是不是loop次数太多了?
回复

使用道具 举报

 楼主| 发表于 2006-5-23 17:56:09 | 显示全部楼层
不会,单人测试时完全正常的,数目也符合,多人就发生掉线
回复

使用道具 举报

发表于 2006-5-23 18:09:44 | 显示全部楼层
应该是loop次数太多
每个玩家的配置不一,执行时间也不一样,所以有些玩家处理完时另外一些玩家还在处理中

[ 本帖最后由 zyl910 于 2006-5-23 18:10 编辑 ]
回复

使用道具 举报

发表于 2006-5-23 22:01:46 | 显示全部楼层
觉得这里的东西不至于造成问题
回复

使用道具 举报

 楼主| 发表于 2006-5-24 13:43:12 | 显示全部楼层
loop的次数不超过14次;而GetUnitStateSwap(UNIT_STATE_LIFE,gg_unit_Udre_0186)/190也不应该因玩家不同而出错;而复合的GroupAddUnit(batgroup,CreateUnitAtLoc(Player(10),\'ugar\',flyloc,GetRandomDirectionDeg()))负荷也不大..
剩下可能怀疑到的SelectGroupForPlayerBJ.
回复

使用道具 举报

发表于 2006-5-24 16:25:20 | 显示全部楼层
有时同时关掉一大堆触发器都会引起掉线(甚至一个都可能)……这类东西还是多加几个PolledWait比较好。
回复

使用道具 举报

发表于 2006-5-25 12:00:02 | 显示全部楼层
Blizzard.j中SelectGroupForPlayerBJ的源代码:
[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]



试一试不用group,直接调用SelectUnit
回复

使用道具 举报

 楼主| 发表于 2006-5-27 13:35:30 | 显示全部楼层
测试得出结果:正是local player下对组操作那个codeback不一致出的错
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 21:02 , Processed in 0.049621 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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