From b9944e86699c435058c1ed017ff33f4a990263f7 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 20 Aug 2023 22:20:12 +0200 Subject: [PATCH] port: don't crash when swapping empty rooms --- port/src/preprocess.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/port/src/preprocess.c b/port/src/preprocess.c index 76d4906ac..06a94d84d 100644 --- a/port/src/preprocess.c +++ b/port/src/preprocess.c @@ -1452,10 +1452,13 @@ void preprocessBgRoom(u8 *data, u32 ofs) { // numvertices is actually 0 in the data because fuck you const s32 numverts = ((uintptr_t) rgfx->colours - (uintptr_t) rgfx->vertices) / sizeof(Vtx); - Vtx *vertices = PD_PTR_BASEOFS(rgfx->vertices, data, ofs); - Vtx *vtx = vertices; - for (s32 i = 0; i < numverts; ++i, ++vtx) { - preprocessVtx(vtx); + Vtx *vertices = NULL; + if (rgfx->vertices) { + vertices = PD_PTR_BASEOFS(rgfx->vertices, data, ofs); + Vtx *vtx = vertices; + for (s32 i = 0; i < numverts; ++i, ++vtx) { + preprocessVtx(vtx); + } } // here's hoping that xlublocks and opablocks aren't completely separate trees