Skip to content

Commit db791fc

Browse files
committed
ecere/gfx3D/models/3DS: Fixed crashes when loading without a DisplaySystem
- NOTE: Materials still won't load properly when not supplying one
1 parent 92e0701 commit db791fc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ecere/src/gfx/3D/models/Object3DSFormat.ec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ static bool ReadFacesListChunks(FileInfo * info, Object object)
751751
count = ReadWORD(info->f);
752752
strcat(matName, name);
753753

754-
mat = displaySystem.GetMaterial(matName);
754+
mat = displaySystem ? displaySystem.GetMaterial(matName) : null;
755755
faces = info->matFaces[(uintptr)mat];
756756
if(!faces)
757757
info->matFaces[(uintptr)mat] = faces = { };
@@ -856,7 +856,7 @@ static bool ReadTriMesh(FileInfo * info, Object object)
856856
{
857857
Material mat = (Material)&m;
858858
Array<int> faces = m;
859-
if(mat.flags.translucent)
859+
if(mat && mat.flags.translucent)
860860
{
861861
mesh.primitives = renew mesh.primitives PrimitiveSingle[mesh.nPrimitives + faces.count];
862862
for(i : faces)
@@ -1170,17 +1170,17 @@ static bool ReadMap(FileInfo * info, Material mat)
11701170
bool translucent = false;
11711171
if(!mat.baseMap)
11721172
{
1173-
mat.baseMap = displaySystem.GetTexture(location);
1173+
mat.baseMap = displaySystem ? displaySystem.GetTexture(location) : null;
11741174
if(!mat.baseMap)
11751175
{
11761176
mat.baseMap = Bitmap { };
1177-
if(displaySystem.GetTexture(bumpName))
1177+
if(displaySystem && displaySystem.GetTexture(bumpName))
11781178
{
11791179
mat.bumpMap = null; // Bad bump map if it's the same as the diffuse map...
11801180
}
11811181
if(!mat.baseMap.Load(location, null, null) ||
11821182
!mat.baseMap.Convert(null, pixelFormat888, null) ||
1183-
!displaySystem.AddTexture(location, mat.baseMap))
1183+
(displaySystem && !displaySystem.AddTexture(location, mat.baseMap)))
11841184
{
11851185
delete mat.baseMap;
11861186
}
@@ -1593,7 +1593,7 @@ static bool ReadEditChunks(FileInfo * info, void * data)
15931593
Material mat;
15941594
ReadChunks(ReadMaterial, info, material);
15951595

1596-
mat = info->displaySystem.AddNamedMaterial(material.name);
1596+
mat = info->displaySystem ? info->displaySystem.AddNamedMaterial(material.name) : { };
15971597
if(mat)
15981598
{
15991599
if(material.baseMap)

0 commit comments

Comments
 (0)