From 3ed3841c3a8edb5282ca5da91295f90ecde93e60 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 8 Dec 2019 12:03:50 +0800 Subject: [PATCH] Fix crash in zone_lighter, index buffer was assumed 32 bit --- code/nel/src/3d/zone_lighter.cpp | 91 +++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/code/nel/src/3d/zone_lighter.cpp b/code/nel/src/3d/zone_lighter.cpp index b17ab5f2d..5dd322cc8 100644 --- a/code/nel/src/3d/zone_lighter.cpp +++ b/code/nel/src/3d/zone_lighter.cpp @@ -2,7 +2,7 @@ // Copyright (C) 2010 Winch Gate Property Limited // // This source file has been modified by the following contributors: -// Copyright (C) 2013-2014 Jan BOON (Kaetemi) +// Copyright (C) 2013-2019 Jan BOON (Kaetemi) // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -1765,7 +1765,7 @@ void CZoneLighter::addTriangles (const CMeshBase &meshBase, const CMeshGeom &mes alphaTestThreshold)); } } - else + else if (iba.getFormat() == CIndexBuffer::Indices16) { const uint16* triIndex=(const uint16*)iba.getPtr (); uint numTri=primitive.getNumIndexes ()/3; @@ -1797,6 +1797,10 @@ void CZoneLighter::addTriangles (const CMeshBase &meshBase, const CMeshGeom &mes alphaTestThreshold)); } } + else + { + nlerror("Invalid index buffer format"); + } } } } @@ -1901,34 +1905,73 @@ void CZoneLighter::addTriangles (const CMeshBase &meshBase, const CMeshMRMGeom & // Dump triangles CIndexBufferRead iba; primitive.lock (iba); - const uint32* triIndex= (const uint32 *) iba.getPtr (); - uint numTri=primitive.getNumIndexes ()/3; - uint tri; - for (tri=0; tri