aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AssetLoader
diff options
context:
space:
mode:
authorJohn Hurliman2009-11-05 13:10:58 -0800
committerJohn Hurliman2009-11-05 13:10:58 -0800
commitafef1ac191d32e9c1514c294b17e404b1d4ae217 (patch)
treec390ef81c9c30922c2e95e32844832919884fd9c /OpenSim/Framework/AssetLoader
parentApplying #4332, optional packet statistics logging (diff)
downloadopensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.zip
opensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.tar.gz
opensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.tar.bz2
opensim-SC_OLD-afef1ac191d32e9c1514c294b17e404b1d4ae217.tar.xz
Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen
Diffstat (limited to 'OpenSim/Framework/AssetLoader')
-rw-r--r--OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs21
1 files changed, 12 insertions, 9 deletions
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
index a394b1a..9497a2e 100644
--- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
+++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
@@ -43,18 +43,15 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 protected static AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage) 46 protected static AssetBase CreateAsset(string assetIdStr, string name, string path, sbyte type)
47 { 47 {
48 AssetBase asset = new AssetBase( 48 AssetBase asset = new AssetBase(new UUID(assetIdStr), name, type);
49 new UUID(assetIdStr),
50 name
51 );
52 49
53 if (!String.IsNullOrEmpty(path)) 50 if (!String.IsNullOrEmpty(path))
54 { 51 {
55 //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path); 52 //m_log.InfoFormat("[ASSETS]: Loading: [{0}][{1}]", name, path);
56 53
57 LoadAsset(asset, isImage, path); 54 LoadAsset(asset, path);
58 } 55 }
59 else 56 else
60 { 57 {
@@ -64,8 +61,14 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
64 return asset; 61 return asset;
65 } 62 }
66 63
67 protected static void LoadAsset(AssetBase info, bool image, string path) 64 protected static void LoadAsset(AssetBase info, string path)
68 { 65 {
66 bool image =
67 (info.Type == (sbyte)AssetType.Texture ||
68 info.Type == (sbyte)AssetType.TextureTGA ||
69 info.Type == (sbyte)AssetType.ImageJPEG ||
70 info.Type == (sbyte)AssetType.ImageTGA);
71
69 FileInfo fInfo = new FileInfo(path); 72 FileInfo fInfo = new FileInfo(path);
70 long numBytes = fInfo.Length; 73 long numBytes = fInfo.Length;
71 if (fInfo.Exists) 74 if (fInfo.Exists)
@@ -138,10 +141,10 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
138 { 141 {
139 string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString()); 142 string assetIdStr = source.Configs[i].GetString("assetID", UUID.Random().ToString());
140 string name = source.Configs[i].GetString("name", String.Empty); 143 string name = source.Configs[i].GetString("name", String.Empty);
141 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); 144 sbyte type = (sbyte)source.Configs[i].GetInt("assetType", 0);
142 string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty)); 145 string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", String.Empty));
143 146
144 AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false); 147 AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, type);
145 148
146 newAsset.Type = type; 149 newAsset.Type = type;
147 assets.Add(newAsset); 150 assets.Add(newAsset);