@@ -173,6 +173,8 @@ void CClientStreamer::SetDimension(unsigned short usDimension)
173
173
174
174
if (element->IsStreamedIn ())
175
175
m_ToStreamOut.push_back (element);
176
+ else if (sector->IsActivated ())
177
+ m_ActiveElements.remove (element);
176
178
}
177
179
}
178
180
}
@@ -186,9 +188,11 @@ void CClientStreamer::SetDimension(unsigned short usDimension)
186
188
return ;
187
189
188
190
auto iter = m_outsideCurrentDimensionElements.begin ();
189
-
190
- while (*iter != lastOutsideElement)
191
+ bool isLast = false ;
192
+ do
191
193
{
194
+ isLast = *iter == lastOutsideElement;
195
+
192
196
CClientStreamElement* element = *iter;
193
197
if (element->GetDimension () == usDimension)
194
198
{
@@ -199,7 +203,7 @@ void CClientStreamer::SetDimension(unsigned short usDimension)
199
203
{
200
204
iter++;
201
205
}
202
- }
206
+ } while (!isLast);
203
207
}
204
208
205
209
CClientStreamSectorRow* CClientStreamer::FindOrCreateRow (CVector& vecPosition, CClientStreamSectorRow* pSurrounding)
@@ -331,7 +335,10 @@ void CClientStreamer::AddElement(CClientStreamElement* pElement)
331
335
void CClientStreamer::RemoveElement (CClientStreamElement* pElement)
332
336
{
333
337
if (pElement->GetStreamSector ())
338
+ {
334
339
RemoveElementFromSectors (pElement);
340
+ m_ActiveElements.remove (pElement);
341
+ }
335
342
else
336
343
m_outsideCurrentDimensionElements.remove (pElement);
337
344
}
@@ -419,6 +426,10 @@ void CClientStreamer::Restream(bool bMovedFar)
419
426
// Stream out 1 of them per frame
420
427
pElement->InternalStreamOut ();
421
428
iMaxOut--;
429
+
430
+ CClientStreamSector* streamSector = pElement->GetStreamSector ();
431
+ if (!streamSector || !streamSector->IsActivated () || !ShouldElementBeVisibleInCurrentDimension (pElement))
432
+ m_ActiveElements.remove (pElement);
422
433
}
423
434
m_ToStreamOut.remove (pElement);
424
435
@@ -442,6 +453,12 @@ void CClientStreamer::Restream(bool bMovedFar)
442
453
// Is this element streamed in?
443
454
if (pElement->IsStreamedIn ())
444
455
{
456
+ if (!ShouldElementBeVisibleInCurrentDimension (pElement))
457
+ {
458
+ m_ToStreamOut.push_back (pElement);
459
+ continue ;
460
+ }
461
+
445
462
if (IS_VEHICLE (pElement))
446
463
{
447
464
CClientVehicle* pVehicle = DynamicCast<CClientVehicle>(pElement);
@@ -701,10 +718,6 @@ void CClientStreamer::OnElementEnterSector(CClientStreamElement* pElement, CClie
701
718
}
702
719
else
703
720
{
704
- // Should we deactivate the element?
705
- if (pPreviousSector && pPreviousSector->IsActivated ())
706
- m_ActiveElements.remove (pElement);
707
-
708
721
// Should we activate this sector?
709
722
if (pSector->IsExtra () && (m_pSector->IsMySurroundingSector (pSector) || m_pSector == pSector))
710
723
{
@@ -713,17 +726,19 @@ void CClientStreamer::OnElementEnterSector(CClientStreamElement* pElement, CClie
713
726
}
714
727
// If we're in a deactivated sector and streamed in, stream us out
715
728
else if (pElement->IsStreamedIn ())
716
- {
717
729
m_ToStreamOut.push_back (pElement);
718
- }
730
+ else if (pPreviousSector && pPreviousSector->IsActivated ())
731
+ m_ActiveElements.remove (pElement);
719
732
}
720
733
}
721
- else if (pPreviousSector && pPreviousSector-> IsActivated ())
734
+ else
722
735
{
723
- // The element was removed from sectors.
724
- // Remove it from active elements too.
725
- m_ActiveElements.remove (pElement);
736
+ if (pElement->IsStreamedIn ())
737
+ m_ToStreamOut.push_back (pElement);
738
+ else if (pPreviousSector && pPreviousSector->IsActivated ())
739
+ m_ActiveElements.remove (pElement);
726
740
}
741
+
727
742
pElement->SetStreamSector (pSector);
728
743
}
729
744
0 commit comments