hch
昨天 c05477efb36f5e06012209c995e0e3b60beb58da
0312 修复请求不到战报后无法主线战斗异常只能重登的问题
2个文件已修改
31 ■■■■ 已修改文件
Main/System/Settlement/BattleSettlementManager.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Utility/HttpRequestEx.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Settlement/BattleSettlementManager.cs
@@ -231,10 +231,10 @@
            assetVersionUrl = $"{url}/S{serverID}/{date}/{PlayerDatas.Instance.baseData.PlayerID}/{mapID}/{guid}.tfr";
        }
        Debug.Log($"请求战报: {assetVersionUrl}");
        HttpRequestEx.UnityWebRequestTurnFightGet(assetVersionUrl, guid, 3, OnGetTurnFightData);
        HttpRequestEx.UnityWebRequestTurnFightGet(assetVersionUrl, guid, mapID, 3, OnGetTurnFightData);
    }
    void OnGetTurnFightData(bool _ok, string guid, byte[] _result)
    void OnGetTurnFightData(bool _ok, string guid, int mapID, byte[] _result)
    {
        if (_ok)
        {
@@ -244,6 +244,10 @@
        {
            Debug.Log($"请求战报失败");
            UIManager.Instance.CloseWindow<MapLoadingWin>();
            if (mapID == 2)
            {
                 AutoFightModel.Instance.isPause = false;
            }
        }
    }
Main/Utility/HttpRequestEx.cs
@@ -9,42 +9,37 @@
    //回合战报
    public static void UnityWebRequestTurnFightGet(string _url, string guid, int timeout = 5, Action<bool, string, byte[]> _result = null)
    public static void UnityWebRequestTurnFightGet(string _url, string guid, int mapID, int timeout = 5, Action<bool, string, int, byte[]> _result = null)
    {
        GetTurnFightData(_url, guid, timeout, _result).Forget();
        GetTurnFightData(_url, guid, mapID, timeout, _result).Forget();
    }
    static async UniTask GetTurnFightData(string remoteURL, string guid, int timeout, Action<bool, string, byte[]> _result = null)
    static async UniTask GetTurnFightData(string remoteURL, string guid, int mapID, int timeout, Action<bool, string,int, byte[]> _result = null)
    {
        UnityWebRequest request = UnityWebRequest.Get(remoteURL);
        request.timeout = timeout;
        try
        {
            UnityWebRequest request = UnityWebRequest.Get(remoteURL);
            request.timeout = timeout;
            await request.SendWebRequest();
            if (request.isDone)
            {
                if (request.result == UnityWebRequest.Result.Success)
                {
                    _result(true, guid, request.downloadHandler.data);
                    _result(true, guid, mapID, request.downloadHandler.data);
                }
                else
                {
                    Debug.LogError("GetDataBEx 失败 " + request.result.ToString());
                    _result(false, guid, null);
                    _result(false, guid, mapID, null);
                }
            }
        }
        catch (Exception ex)
        {
            _result(false, guid, null);
            _result(false, guid, mapID, null);
            Debug.LogError($"GetDataBEx 异常 - URL: {remoteURL}, Exception: {ex.Message}");
        }
        finally
        {
            request.Dispose();
        }
    }