mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-25 21:31:14 +00:00
Fixed a crash when trying to load a voxel that could not be found multiple times. Fixes #1024
Fixed a problem where voxels defined in VOXELDEF would not be found
This commit is contained in:
parent
f28a4b10a8
commit
2df6004bf0
3 changed files with 63 additions and 15 deletions
|
@ -358,9 +358,28 @@ namespace CodeImp.DoomBuilder.Data
|
|||
try
|
||||
{
|
||||
// Find in voxels directory
|
||||
string path = Path.Combine(VOXELS_DIR, Path.GetDirectoryName(name));
|
||||
string filename = FindFirstFile(path, Path.GetFileName(name), true);
|
||||
if((filename != null) && FileExists(filename))
|
||||
string filename = null;
|
||||
|
||||
// There are different places we have to look for the file, depending on how it was defined. Right now
|
||||
// there's no way to know if the definition comes from VOXELDEF or spreite replacement, so we're assuming
|
||||
// it's from VOXELDEF if there's an extension given.
|
||||
// - Auto-detect for sprite name: must be in the "voxels" directory
|
||||
// - Just given as file name without path in VOXELDEF: must be in the root directory
|
||||
// - Given as full path and file name in VOXELDEF: must be in exactly that spot
|
||||
string path = Path.GetDirectoryName(name);
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Path.GetExtension(name)))
|
||||
filename = FindFirstFile(VOXELS_DIR, Path.GetFileName(name), true);
|
||||
else
|
||||
filename = FindFirstFileWithExt("", Path.GetFileName(name), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = FindFirstFileWithExt(path, Path.GetFileName(name), false);
|
||||
}
|
||||
|
||||
if ((filename != null) && FileExists(filename))
|
||||
{
|
||||
voxellocation = location.GetDisplayName();
|
||||
return LoadFile(filename);
|
||||
|
|
|
@ -454,14 +454,41 @@ namespace CodeImp.DoomBuilder.Data
|
|||
if(voxel != null) return voxel;
|
||||
}
|
||||
|
||||
string pfilename = name.Replace('\\', '^');
|
||||
name = name.Replace('\\', '^');
|
||||
|
||||
// Find in sprites directory
|
||||
string filename = FindFirstFile(VOXELS_DIR, pfilename, true);
|
||||
if((filename != null) && FileExists(filename))
|
||||
try
|
||||
{
|
||||
voxellocation = location.GetDisplayName();
|
||||
return LoadFile(filename);
|
||||
// Find in voxels directory
|
||||
string filename = null;
|
||||
|
||||
// There are different places we have to look for the file, depending on how it was defined. Right now
|
||||
// there's no way to know if the definition comes from VOXELDEF or spreite replacement, so we're assuming
|
||||
// it's from VOXELDEF if there's an extension given.
|
||||
// - Auto-detect for sprite name: must be in the "voxels" directory
|
||||
// - Just given as file name without path in VOXELDEF: must be in the root directory
|
||||
// - Given as full path and file name in VOXELDEF: must be in exactly that spot
|
||||
string path = Path.GetDirectoryName(name);
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Path.GetExtension(name)))
|
||||
filename = FindFirstFile(VOXELS_DIR, Path.GetFileName(name), true);
|
||||
else
|
||||
filename = FindFirstFileWithExt("", Path.GetFileName(name), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = FindFirstFileWithExt(path, Path.GetFileName(name), false);
|
||||
}
|
||||
|
||||
if ((filename != null) && FileExists(filename))
|
||||
{
|
||||
voxellocation = location.GetDisplayName();
|
||||
return LoadFile(filename);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!Silent) General.ErrorLogger.Add(ErrorType.Error, e.GetType().Name + " while loading voxel \"" + name + "\" from PK3: " + e.Message);
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
|
|
|
@ -39,14 +39,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.Models
|
|||
}
|
||||
}
|
||||
|
||||
//clear unneeded data
|
||||
mde.SkinNames = null;
|
||||
mde.ModelNames = null;
|
||||
|
||||
if (mde.Model.Meshes == null || mde.Model.Meshes.Count == 0)
|
||||
{
|
||||
mde.Model = null;
|
||||
}
|
||||
mde.Model = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
//clear unneeded data
|
||||
mde.SkinNames = null;
|
||||
mde.ModelNames = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadModel(ModelData mde, List<DataReader> containers)
|
||||
|
|
Loading…
Reference in a new issue