@@ -173,8 +173,6 @@ void CClientStreamer::SetDimension(unsigned short usDimension)
173173
174174 if (element->IsStreamedIn ())
175175 m_ToStreamOut.push_back (element);
176- else if (sector->IsActivated ())
177- m_ActiveElements.remove (element);
178176 }
179177 }
180178 }
@@ -188,11 +186,9 @@ void CClientStreamer::SetDimension(unsigned short usDimension)
188186 return ;
189187
190188 auto iter = m_outsideCurrentDimensionElements.begin ();
191- bool isLast = false ;
192- do
193- {
194- isLast = *iter == lastOutsideElement;
195189
190+ while (*iter != lastOutsideElement)
191+ {
196192 CClientStreamElement* element = *iter;
197193 if (element->GetDimension () == usDimension)
198194 {
@@ -203,7 +199,7 @@ void CClientStreamer::SetDimension(unsigned short usDimension)
203199 {
204200 iter++;
205201 }
206- } while (!isLast);
202+ }
207203}
208204
209205CClientStreamSectorRow* CClientStreamer::FindOrCreateRow (CVector& vecPosition, CClientStreamSectorRow* pSurrounding)
@@ -335,10 +331,7 @@ void CClientStreamer::AddElement(CClientStreamElement* pElement)
335331void CClientStreamer::RemoveElement (CClientStreamElement* pElement)
336332{
337333 if (pElement->GetStreamSector ())
338- {
339334 RemoveElementFromSectors (pElement);
340- m_ActiveElements.remove (pElement);
341- }
342335 else
343336 m_outsideCurrentDimensionElements.remove (pElement);
344337}
@@ -426,10 +419,6 @@ void CClientStreamer::Restream(bool bMovedFar)
426419 // Stream out 1 of them per frame
427420 pElement->InternalStreamOut ();
428421 iMaxOut--;
429-
430- CClientStreamSector* streamSector = pElement->GetStreamSector ();
431- if (!streamSector || !streamSector->IsActivated () || !ShouldElementBeVisibleInCurrentDimension (pElement))
432- m_ActiveElements.remove (pElement);
433422 }
434423 m_ToStreamOut.remove (pElement);
435424
@@ -453,12 +442,6 @@ void CClientStreamer::Restream(bool bMovedFar)
453442 // Is this element streamed in?
454443 if (pElement->IsStreamedIn ())
455444 {
456- if (!ShouldElementBeVisibleInCurrentDimension (pElement))
457- {
458- m_ToStreamOut.push_back (pElement);
459- continue ;
460- }
461-
462445 if (IS_VEHICLE (pElement))
463446 {
464447 CClientVehicle* pVehicle = DynamicCast<CClientVehicle>(pElement);
@@ -718,6 +701,10 @@ void CClientStreamer::OnElementEnterSector(CClientStreamElement* pElement, CClie
718701 }
719702 else
720703 {
704+ // Should we deactivate the element?
705+ if (pPreviousSector && pPreviousSector->IsActivated ())
706+ m_ActiveElements.remove (pElement);
707+
721708 // Should we activate this sector?
722709 if (pSector->IsExtra () && (m_pSector->IsMySurroundingSector (pSector) || m_pSector == pSector))
723710 {
@@ -726,19 +713,17 @@ void CClientStreamer::OnElementEnterSector(CClientStreamElement* pElement, CClie
726713 }
727714 // If we're in a deactivated sector and streamed in, stream us out
728715 else if (pElement->IsStreamedIn ())
716+ {
729717 m_ToStreamOut.push_back (pElement);
730- else if (pPreviousSector && pPreviousSector->IsActivated ())
731- m_ActiveElements.remove (pElement);
718+ }
732719 }
733720 }
734- else
721+ else if (pPreviousSector && pPreviousSector-> IsActivated ())
735722 {
736- if (pElement->IsStreamedIn ())
737- m_ToStreamOut.push_back (pElement);
738- else if (pPreviousSector && pPreviousSector->IsActivated ())
739- m_ActiveElements.remove (pElement);
723+ // The element was removed from sectors.
724+ // Remove it from active elements too.
725+ m_ActiveElements.remove (pElement);
740726 }
741-
742727 pElement->SetStreamSector (pSector);
743728}
744729
0 commit comments