Skip to content

Commit

Permalink
Trying to fix the texture loader
Browse files Browse the repository at this point in the history
StollD committed Jul 28, 2018
1 parent c779974 commit 0689df0
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Kopernicus.OnDemand/OnDemandStorage.cs
Original file line number Diff line number Diff line change
@@ -355,8 +355,8 @@ public static Texture2D LoadTexture(String path, Boolean compress, Boolean uploa
if (File.Exists(path))
{
Boolean uncaught = true;
try
{
// try
// {
if (path.ToLower().EndsWith(".dds"))
{
// Borrowed from stock KSP 1.0 DDS loader (hi Mike!)
@@ -423,15 +423,16 @@ public static Texture2D LoadTexture(String path, Boolean compress, Boolean uploa
{
try
{
byte[] data = LoadRestOfReader(binaryReader);

int bpp = (int)dDSHeader.ddspf.dwRGBBitCount;
int colors = (int)Math.Pow(2, bpp);
int width = (int)dDSHeader.dwWidth;
int height = (int)dDSHeader.dwHeight;
int height = (int)dDSHeader.dwHeight;
long length = new FileInfo(path).Length;

if (data.Length == width * height * bpp / 8 + 4 * colors)
if (length == width * height * bpp / 8 + 4 * colors)
{
byte[] data = LoadRestOfReader(binaryReader);

Color[] palette = new Color[colors];
Color[] image = new Color[width * height];

@@ -527,12 +528,12 @@ public static Texture2D LoadTexture(String path, Boolean compress, Boolean uploa
if (upload)
map.Apply(false, unreadable);
}
}
catch (Exception ex)
{
uncaught = false;
Debug.Log("[Kopernicus]: failed to load " + path + " with exception " + ex.Message);
}
// }
// catch (Exception ex)
// {
// uncaught = false;
// Debug.Log("[Kopernicus]: failed to load " + path + " with exception " + ex.Message);
// }
if (map == null && uncaught)
{
Debug.Log("[Kopernicus]: failed to load " + path);

0 comments on commit 0689df0

Please sign in to comment.