@@ -314,7 +314,7 @@ CELL_DATA* CDriver2LevelRegion::GetCellData(int num) const
314314}
315315
316316// cell iterator
317- PACKED_CELL_OBJECT* CDriver2LevelRegion::StartIterator (CELL_ITERATOR * iterator, int cellNumber) const
317+ PACKED_CELL_OBJECT* CDriver2LevelRegion::StartIterator (CELL_ITERATOR_D2 * iterator, int cellNumber) const
318318{
319319 ushort cell_ptr = m_cellPointers[cellNumber];
320320
@@ -341,14 +341,32 @@ PACKED_CELL_OBJECT* CDriver2LevelRegion::StartIterator(CELL_ITERATOR* iterator,
341341 iterator->nearCell .z = (cellz - (mapInfo.cells_down / 2 ))* mapInfo.cell_size ;
342342
343343 // get the packed cell data start and near cell
344- CELL_DATA& cell = m_cells[cell_ptr];
344+ CELL_DATA* cell = & m_cells[cell_ptr];
345345
346- if (cell.num & 0x4000 ) // FIXME: other objects are flagged with 0x8000 etc
347- return nullptr ;
346+ int drawValue = iterator->drawValue ;
348347
349- PACKED_CELL_OBJECT* ppco = GetCellObject (cell.num & 0x3fff );
348+ if (drawValue != -1 )
349+ {
350+ if (drawValue == 0 )
351+ {
352+ if (cell->num & 0x4000 )
353+ return nullptr ;
354+ }
355+ else
356+ {
357+ cell++;
358+ while (cell->num != (drawValue | 0x4000 ))
359+ {
360+ if (cell->num & 0x8000 )
361+ return nullptr ;
362+
363+ cell++;
364+ }
365+ }
366+ }
350367
351- iterator->pcd = &cell;
368+ PACKED_CELL_OBJECT* ppco = GetCellObject (cell->num & 0x3fff );
369+ iterator->pcd = cell;
352370
353371 if (ppco->value == 0xffff && (ppco->pos .vy & 1 ))
354372 ppco = ((CDriver2LevelMap*)m_owner)->GetNextPackedCop (iterator);
@@ -527,7 +545,7 @@ int CDriver2LevelMap::MapHeight(const VECTOR_NOPAD& position) const
527545// -------------------------------------------------------------
528546// returns first cell object of cell
529547// -------------------------------------------------------------
530- PACKED_CELL_OBJECT* CDriver2LevelMap::GetFirstPackedCop (CELL_ITERATOR * iterator, int cellx, int cellz) const
548+ PACKED_CELL_OBJECT* CDriver2LevelMap::GetFirstPackedCop (CELL_ITERATOR_D2 * iterator, int cellx, int cellz) const
531549{
532550 // lookup region
533551 const int region_x = cellx / m_mapInfo.region_size ;
@@ -560,14 +578,33 @@ PACKED_CELL_OBJECT* CDriver2LevelMap::GetFirstPackedCop(CELL_ITERATOR* iterator,
560578 iterator->nearCell .z = (cellz - (m_mapInfo.cells_down / 2 )) * m_mapInfo.cell_size ;
561579
562580 // get the packed cell data start and near cell
563- CELL_DATA& cell = region.m_cells [cell_ptr];
581+ CELL_DATA* cell = & region.m_cells [cell_ptr];
564582
565- if (cell.num & 0x4000 ) // FIXME: other objects are flagged with 0x8000 etc
566- return nullptr ;
583+ int drawValue = iterator->drawValue ;
584+
585+ if (drawValue != -1 )
586+ {
587+ if (drawValue == 0 )
588+ {
589+ if (cell->num & 0x4000 )
590+ return nullptr ;
591+ }
592+ else
593+ {
594+ cell++;
595+ while (cell->num != (drawValue | 0x4000 ))
596+ {
597+ if (cell->num & 0x8000 )
598+ return nullptr ;
599+
600+ cell++;
601+ }
602+ }
603+ }
567604
568- PACKED_CELL_OBJECT* ppco = region.GetCellObject (cell. num & 0x3fff );
605+ PACKED_CELL_OBJECT* ppco = region.GetCellObject (cell-> num & 0x3fff );
569606
570- iterator->pcd = & cell;
607+ iterator->pcd = cell;
571608
572609 if (ppco->value == 0xffff && (ppco->pos .vy & 1 ))
573610 ppco = GetNextPackedCop (iterator);
@@ -580,7 +617,7 @@ PACKED_CELL_OBJECT* CDriver2LevelMap::GetFirstPackedCop(CELL_ITERATOR* iterator,
580617// -------------------------------------------------------------
581618// iterates cell objects
582619// -------------------------------------------------------------
583- PACKED_CELL_OBJECT* CDriver2LevelMap::GetNextPackedCop (CELL_ITERATOR * iterator) const
620+ PACKED_CELL_OBJECT* CDriver2LevelMap::GetNextPackedCop (CELL_ITERATOR_D2 * iterator) const
584621{
585622 ushort num;
586623 PACKED_CELL_OBJECT* ppco;
@@ -592,7 +629,7 @@ PACKED_CELL_OBJECT* CDriver2LevelMap::GetNextPackedCop(CELL_ITERATOR* iterator)
592629 iterator->pcd ++;
593630 num = iterator->pcd ->num ;
594631
595- if (num & 0x4000 ) // FIXME: other objects are flagged with 0x8000 etc
632+ if (iterator-> drawValue != - 1 && num & 0x4000 )
596633 return nullptr ;
597634
598635 ppco = iterator->region ->GetCellObject (num & 0x3fff );
0 commit comments