找回密码
 点一下
查看: 1379|回复: 2

关于在hash系统下,数据同步(是否要同步,然后如何实现)问题

[复制链接]
发表于 2011-8-21 13:18:11 | 显示全部楼层 |阅读模式
我为了判断游戏是在游戏,还是在录像回放的状态下,使用了如下的J

我节选前面一部分使用,但是地图掉线情况严重

后来我发现后面一段数据同步的代码,而且是用GC系统的函数实现的

故求问如何改造成hash系统适用的格式

感谢

原帖地址:
http://bbs.islga.org/read-htm-tid-15768.html

流程大约如下:
1.找到一个存在的玩家。
2.在暂停游戏的情况下轻微调整一下这个玩家的镜头(当然,过程中玩家的操作ui是要锁住的)
3.如果镜头变化和预设的一致,则认为在游戏中,否则在录像中。原理应该是暂停游戏对录像是空白的瞬间,比如暂停游戏后聊天,在录像里表现出来的是那些聊天记录是瞬间一起出来的。
4.以上的数据用的是本地玩家,故需要同步,使用syn函数。不是说syn是将主机数据同步么。。何解?如果选择的是所有存在的玩家,不用同步也是可以的吧。

[jass]//-> IsInGame created by PandaMine with help from Captain Griffein
//This function is what makes it possible for the system not to break replays,
//simply put if your actually playing the game, this function will return false.
//It will return true if the game is being viewed in a replay

function AMHS_GetSyncedCameraX takes player p returns real
local real output = 99999999
if GetLocalPlayer() == p then
set output = GetCameraTargetPositionX()
endif
return output
endfunction

function AMHS_GetSyncedCameraY takes player p returns real
local real output = 99999999
if GetLocalPlayer() == p then
set output = GetCameraTargetPositionY()
endif
return output
endfunction

function AMHS_IsInGame takes nothing returns boolean
local integer counter = 1
local real currentx
local real currenty
local real x
local real y
local integer validplayer
set udg_AMHS_InGameOutPut = false

//Need to find the a valid player

      loop
            exitwhen counter > 12
            if GetPlayerSlotState(Player(counter - 1)) == PLAYER_SLOT_STATE_PLAYING and (GetPlayerController(Player(counter - 1)) == MAP_CONTROL_USER) then
                  set validplayer = counter - 1
                  set counter = 13
            endif
            set counter = counter + 1
      endloop
      
set currentx = AMHS_GetSyncedCameraX(Player(validplayer))
set currenty = AMHS_GetSyncedCameraY(Player(validplayer))

call PauseGame(true)
call TriggerSleepAction(0)

if currentx != 99999999 and currenty != 99999999 then
call SetCameraPositionForPlayer(Player(validplayer),currentx+1,currenty + 1)
endif

call TriggerSleepAction(0)
call PauseGame(false)

set x = AMHS_GetSyncedCameraX(Player(validplayer))
if GetLocalPlayer() == Player(validplayer) then
if x == currentx + 1 then
set udg_AMHS_InGameOutPut = true
else
set udg_AMHS_InGameOutPut = false
endif
endif
if x != 99999999 then
call SetCameraPositionForPlayer(Player(validplayer),currentx,currenty)
endif
set counter = 0
set x = 0
set y = 0
set currentx = 0
set currenty = 0
set validplayer = 0
return udg_AMHS_InGameOutPut
endfunction

function AMHS_ReplayEngine takes nothing returns nothing
local gamecache cache
call FlushGameCache(InitGameCache("cache"))
set cache = InitGameCache("cache")
call EnableUserControl(false)
call TriggerSleepAction(.0)
// sync the value for all players
call StoreBoolean(cache,"sync","1",AMHS_IsInGame())
call TriggerSyncStart()
call SyncStoredBoolean(cache,"sync","1")
call TriggerSyncReady()
set udg_AMHS_InGame = GetStoredBoolean(cache,"sync","1")
call EnableUserControl(true)
call FlushGameCache(cache)
set cache = null
endfunction[/jass]
发表于 2011-8-21 21:10:11 | 显示全部楼层
还是不是很理解怎么编剧Jass啊
可能会有错误
还是继续等待LX的大人
  1. function AMHS_ReplayEngine takes nothing returns nothing
  2. local hashtable ht
  3. call FlushParentHashtable(InitHashtable())
  4. set ht = InitHashtable()
  5. call EnableUserControl(false)
  6. call TriggerSleepAction(.0)
  7. // sync the value for all players
  8. call SaveBoolean(ht, StringHash("sync"), 1, AMHS_IsInGame() )
  9. call TriggerSyncStart()
  10. call LoadBoolean(ht,StringHash("sync"),1)
  11. call TriggerSyncReady()
  12. set udg_AMHS_InGame = LoadBoolean(ht,StringHash("sync"),1)
  13. call EnableUserControl(true)
  14. call FlushParentHashtable(ht)
  15. set ht = null
  16. endfunction
复制代码
回复

使用道具 举报

 楼主| 发表于 2011-8-26 19:32:15 | 显示全部楼层
真心求教导
先感谢了

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 06:44 , Processed in 0.036328 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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