-- Current Client metadata: ChallengePeakModule exposes CurrentPeakGroupID and -- SendModuleInitRequest() requests the round/group catalog. The similarly named -- SendGetChallengePeakDataRequest() requests the current run, not the catalog. -- Request real server data; never set a -- private group field, fake a response, remap a room or close a running mode. do local function synchronize() local data=_G.__GAC_AA_ROUND_REFRESH if not data or data.deferred or not data.desired_group or data.desired_group==0 then return end local flags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),60) local manager=CS.RPG.Client.GlobalVars.s_GamePhaseManager local phase=manager and typeof(CS.RPG.Client.GamePhaseManager):GetField('_CurrentPhase',flags):GetValue(manager) if not phase or typeof(CS.RPG.Client.BattleGamePhase):IsInstanceOfType(phase) then return end local modules=CS.RPG.Client.GlobalVars.s_ModuleManager local module=modules and modules.ChallengePeakModule if not module then return end local state=_G.__GAC_AA_ROUND_REFRESH_STATE if not state or state.module~=module or state.adapter~='module-init-v2' then state={module=module,adapter='module-init-v2'};_G.__GAC_AA_ROUND_REFRESH_STATE=state end local current=module.CurrentPeakGroupID -- Wait for the native login initialization request; do not duplicate it. if not current or current==0 then return end if current==data.desired_group then if state.applied~=data.revision then CS.UnityEngine.Debug.Log('[GAC_AA_ROUND_SYNC] applied group='..current) end state.applied=data.revision;state.pending=nil;return end if state.pending then -- A changed native group proves that the previous request completed. If -- Srtool changed again while it was pending, now request the latest choice. if current==state.pending.from then return end state.pending=nil end if state.requested==data.revision then return end -- Native methods are not consistently exposed as Lua functions by xLua. -- Resolve this exact observed zero-argument method on the live module type. local sender=module:GetType():GetMethod('SendModuleInitRequest',flags) if not sender or sender:GetParameters().Length~=0 then error('observed AA refresh API is unavailable') end -- No known in-flight query is exposed by this module. Send once and wait -- for its actual CurrentPeakGroupID change, instead of flooding retries. local args=CS.System.Array.CreateInstance(typeof(CS.System.Object),0) local invokeFlags=CS.System.Enum.ToObject(typeof(CS.System.Reflection.BindingFlags),0) sender:Invoke(module,invokeFlags,nil,args,nil) state.requested=data.revision state.pending={from=current,desired=data.desired_group} CS.UnityEngine.Debug.Log('[GAC_AA_ROUND_SYNC] requested group='..data.desired_group..' previous='..current) end local ok,err=pcall(synchronize) if not ok then local message=tostring(err) if _G.__GAC_AA_ROUND_REFRESH_ERROR~=message then _G.__GAC_AA_ROUND_REFRESH_ERROR=message CS.UnityEngine.Debug.Log('[GAC_AA_ROUND_SYNC] ERROR '..message) end end end