From 201b2355f8feb17322d8acf7222282eeb78a3e68 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 25 Feb 2008 07:48:46 +0000 Subject: [PATCH] fix bug with rtlights not being imported from the map sometimes (caused 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 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/zone.c b/zone.c index 175b25a6..e6a51f5b 100644 --- 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) -- 2.39.2