fix bug with rtlights not being imported from the map sometimes (caused
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 25 Feb 2008 07:48:46 +0000 (07:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 25 Feb 2008 07:48:46 +0000 (07:48 +0000)
by previous level having a lot of lights, exposing a bug in
Mem_ExpandableArray_IndexRange)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8127 d7cf8633-e32d-0410-b094-e92efae38249

zone.c

diff --git a/zone.c b/zone.c
index 175b25a..e6a51f5 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -461,14 +461,19 @@ void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record)
 
 size_t Mem_ExpandableArray_IndexRange(memexpandablearray_t *l)
 {
-       size_t i, j, k;
-       if (!l->numarrays)
-               return 0;
-       i = l->numarrays - 1;
-       for (j = 0, k = 0;k < l->arrays[i].numflaggedrecords;j++)
-               if (l->arrays[i].allocflags[j])
-                       k++;
-       return l->numrecordsperarray * i + j;
+       size_t i, j, k, end = 0;
+       for (i = 0;i < l->numarrays;i++)
+       {
+               for (j = 0, k = 0;k < l->arrays[i].numflaggedrecords;j++)
+               {
+                       if (l->arrays[i].allocflags[j])
+                       {
+                               end = l->numrecordsperarray * i + j + 1;
+                               k++;
+                       }
+               }
+       }
+       return end;
 }
 
 void *Mem_ExpandableArray_RecordAtIndex(memexpandablearray_t *l, size_t index)