From 36b35e85f3fc067d0a8316b15bbb4cee91a5d0de Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Oct 2014 12:06:00 +0200 Subject: [PATCH] - fixed: overflow checks for dynamic light buffer were not correct. --- src/gl/dynlights/gl_lightbuffer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index a5b6ee9de..1f105b4ea 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -132,7 +132,7 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (totalsize <= 1) return -1; - if (mIndex + totalsize > mBufferSize) + if (mIndex + totalsize > mBufferSize/4) { // reallocate the buffer with twice the size unsigned int newbuffer; @@ -173,6 +173,13 @@ int FLightBuffer::UploadLights(FDynLightData &data) if (mBufferPointer == NULL) return -1; copyptr = mBufferPointer + mIndex * 4; + static unsigned int lastindex = 0; + if (mIndex > lastindex) + { + Printf("Light index: %d, size: %d\n", mIndex, totalsize); + lastindex = mIndex; + } + float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; memcpy(©ptr[0], parmcnt, 4 * sizeof(float));