From 5e4f0559c455e851135a78596efe9090e287fb25 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 27 Jan 2023 17:15:03 +0100 Subject: [PATCH] - [FIX] Crash if map() used without map surface assigned - [FIX] Crash on restart, system surfaces not finalized properly (Cacaus crash maybe solved?) --- mini.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mini.cpp b/mini.cpp index fd69ab0..68ec0c5 100644 --- a/mini.cpp +++ b/mini.cpp @@ -344,6 +344,7 @@ int main(int argc,char*argv[]){ Mix_Quit(); for (int i=0;i<10;++i) freesurf(i); + dest_surface = source_surface = map_surface = NULL; destroyDisplay(); SDL_Quit(); } @@ -859,6 +860,7 @@ void mset(int celx, int cely, uint8_t snum) { } void map(int celx, int cely, int sx, int sy, uint8_t celw, uint8_t celh, uint8_t layer) { + if (map_surface==NULL) return; //if (celw <= 0 || celh <= 0 || celw >= TILES_WIDTH || celh >= TILES_HEIGHT) return; sx -= ds::cam[0]; sy -= ds::cam[1]; if (sx+celw*8 < ds::clp[0] || sx > ds::clp[2] || sy+celh*8 < ds::clp[1] || sy > ds::clp[3]) return;