From 2e37001881eab8932dafcfd345fd9bb641bb70f4 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sun, 31 Jan 2021 01:19:25 +0100 Subject: fix UB and new renderer crashes --- src/render/Renderer.cpp | 4 ++++ src/rw/VisibilityPlugins.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 8c4714fb..dfbc02d7 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1394,6 +1394,10 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL void CRenderer::InsertEntityIntoList(CEntity *ent) { +#ifdef FIX_BUGS + if (!ent->m_rwObject) return; +#endif + #ifdef NEW_RENDERER // TODO: there are more flags being checked here if(gbNewRenderer && (ent->IsVehicle() || ent->IsPed())) diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index bdde5e33..3a303194 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -96,6 +96,10 @@ CVisibilityPlugins::InitAlphaEntityList(void) bool CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) { +#ifdef FIX_BUGS + if (!e->m_rwObject) return true; +#endif + AlphaObjectInfo item; item.entity = e; item.sort = dist; -- cgit v1.2.3