From 3397f693dbd3cea54e4e1df4d09f8859c9af613e Mon Sep 17 00:00:00 2001
From: Hale Cai <339726288@qq.com>
Date: 星期日, 31 三月 2019 01:38:38 +0800
Subject: [PATCH] 382 报错保护

---
 System/AssetVersion/AssetVersionUtility.cs |  147 ++++++++++++++++++++++++++-----------------------
 1 files changed, 78 insertions(+), 69 deletions(-)

diff --git a/System/AssetVersion/AssetVersionUtility.cs b/System/AssetVersion/AssetVersionUtility.cs
index 7ca4809..1b68b8e 100644
--- a/System/AssetVersion/AssetVersionUtility.cs
+++ b/System/AssetVersion/AssetVersionUtility.cs
@@ -1,50 +1,56 @@
-锘縰sing System.Collections;
-using System.Collections.Generic;
-using System;
-using UnityEngine;
-using System.IO;
-using Snxxz.UI;
-using System.Threading;
-
-
-[XLua.LuaCallCSharp]
+锘縰sing System.Collections;
+using System.Collections.Generic;
+using System;
+using UnityEngine;
+using System.IO;
+using Snxxz.UI;
+using System.Threading;
+
+
+[XLua.LuaCallCSharp]
 public class AssetVersionUtility
-{
-    public static string assetVersionsLocalMd5 {
+{
+    public static string assetVersionsLocalMd5
+    {
         get { return LocalSave.GetString("AssetVersionsLocalMd5"); }
         set { LocalSave.SetString("AssetVersionsLocalMd5", value); }
-    }
-
-    static bool m_HasDownLoadFullAsset = LocalSave.GetBool("HasDownLoadFullAsset");
-    public static bool hasDownLoadFullAsset {
+    }
+
+    static bool m_HasDownLoadFullAsset = LocalSave.GetBool("HasDownLoadFullAsset");
+    public static bool hasDownLoadFullAsset
+    {
         get { return m_HasDownLoadFullAsset; }
         set { LocalSave.SetBool("HasDownLoadFullAsset", value); }
-    }
-
+    }
+
     static bool m_PriorAssetDownLoadDone = false;
-    public static bool priorAssetDownLoadDone {
-        get {
-            if (VersionUtility.Instance.NeedDownAsset())
+    public static bool priorAssetDownLoadDone
+    {
+        get
+        {
+            if (VersionUtility.Instance.NeedDownAsset())
             {
-                return m_PriorAssetDownLoadDone;
+                return m_PriorAssetDownLoadDone;
             }
-            else
-            {
-                return true;
+            else
+            {
+                return true;
             }
         }
     }
 
     static bool m_UnPriorAssetDownLoadDone = false;
-    public static bool unPriorAssetDownLoadDone {
-        get {
-            if (VersionUtility.Instance.NeedDownAsset())
+    public static bool unPriorAssetDownLoadDone
+    {
+        get
+        {
+            if (VersionUtility.Instance.NeedDownAsset())
             {
-                return m_UnPriorAssetDownLoadDone;
+                return m_UnPriorAssetDownLoadDone;
             }
-            else
-            {
-                return true;
+            else
+            {
+                return true;
             }
         }
     }
@@ -148,8 +154,8 @@
         }
 
         return assetVersions;
-    }
-
+    }
+
     public static AssetVersion GetAssetVersion(string assetKey)
     {
         if (assetVersions.ContainsKey(assetKey))
@@ -160,48 +166,48 @@
         {
             return null;
         }
-    }
-
+    }
+
     public static bool IsAssetValid(string assetKey)
     {
-        if (assetVersions.ContainsKey(assetKey))
-        {
-            return assetVersions[assetKey].localValid;
+        if (assetVersions.ContainsKey(assetKey))
+        {
+            return assetVersions[assetKey].localValid;
         }
         else
         {
-            if (VersionUtility.Instance.NeedDownAsset())
-            {
-                return false;
+            if (VersionUtility.Instance.NeedDownAsset())
+            {
+                return false;
             }
             else
             {
                 return true;
             }
         }
-    }
-
+    }
+
     public static bool IsSceneAssetValid(int mapId, int lineId)
     {
-        if (AssetSource.sceneFromEditor || mapId < 100)
-        {
-            return true;
+        if (AssetSource.sceneFromEditor || mapId < 100)
+        {
+            return true;
         }
 
         var dataMapId = MapUtility.GetDataMapId(mapId);
         lineId = MapUtility.GetLineId(mapId, lineId);
         var mapResConfig = MapResourcesConfig.GetConfig(dataMapId, lineId);
-        if (mapResConfig == null)
-        {
-            return false;
-        }
-
-        if (!IsAssetValid(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower())))
+        if (mapResConfig == null)
         {
-            return false;
+            return false;
         }
 
-        if (dataMapId != 10010)
+        if (!IsAssetValid(StringUtility.Contact("maps/", mapResConfig.MapResources.ToLower())))
+        {
+            return false;
+        }
+
+        if (dataMapId != 10010)
         {
             ActorShowConfig actorShowConfig = null;
             if (ActorShowConfig.GetActoreShowConfigByMapIdAndLineId(dataMapId, lineId, out actorShowConfig))
@@ -210,18 +216,21 @@
                 foreach (var item in npcs)
                 {
                     var npcConfig = NPCConfig.Get(item);
-                    var assetbundleName = StringUtility.Contact("prefab_race_", npcConfig.MODE.ToLower());
-                    if (!IsAssetValid(StringUtility.Contact("mob/", assetbundleName)))
+                    if (npcConfig != null)
                     {
-                        return false;
+                        var assetbundleName = StringUtility.Contact("prefab_race_", npcConfig.MODE.ToLower());
+                        if (!IsAssetValid(StringUtility.Contact("mob/", assetbundleName)))
+                        {
+                            return false;
+                        }
                     }
                 }
-            }
+            }
         }
 
         return true;
-    }
-
+    }
+
     public static string GetAssetFilePath(string _assetKey)
     {
         var path = string.Empty;
@@ -240,9 +249,9 @@
         }
         else
         {
-            if (Application.platform == RuntimePlatform.Android)
+            if (Application.platform == RuntimePlatform.Android)
             {
-                path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, _assetKey);
+                path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, _assetKey);
             }
             else
             {
@@ -273,13 +282,13 @@
         }
 
         return path;
-    }
-
+    }
+
     public static bool IsUnpriorAssetDownLoadOk()
     {
-        if (VersionUtility.Instance.NeedDownAsset())
-        {
-            return unPriorAssetDownLoadDone;
+        if (VersionUtility.Instance.NeedDownAsset())
+        {
+            return unPriorAssetDownLoadDone;
         }
         else
         {
@@ -288,4 +297,4 @@
     }
 
 
-}
+}

--
Gitblit v1.8.0