From 142db71cb95a0d82138247a1df1873ab2607c39d Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 15 Sep 2020 00:07:10 +0100 Subject: [PATCH] Move sanity checks to Draw.cpp There, no need to keep track of a bunch of duplicate sanity checks --- src/Draw.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Draw.cpp b/src/Draw.cpp index 022650b4..3b1ea3c5 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -412,6 +412,9 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem void BackupSurface(SurfaceID surf_no, const RECT *rect) { + if (surf[surf_no] == NULL) + return; + static RenderBackend_Rect rcSet; // TODO - Not the original variable name rcSet.left = rect->left * mag; rcSet.top = rect->top * mag; @@ -427,6 +430,9 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect) void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency { + if (surf[surf_no] == NULL) + return; + static RenderBackend_Rect rcWork; rcWork.left = rect->left; @@ -466,6 +472,9 @@ void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency { + if (surf[surf_no] == NULL) + return; + static RenderBackend_Rect rcWork; rcWork.left = rect->left; @@ -505,6 +514,9 @@ void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su void Surface2Surface(int x, int y, const RECT *rect, SurfaceID to, SurfaceID from) { + if (surf[to] == NULL || surf[from] == NULL) + return; + static RenderBackend_Rect rcWork; rcWork.left = rect->left * mag; @@ -546,6 +558,9 @@ void CortBox(const RECT *rect, unsigned long col) void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no) { + if (surf[surf_no] == NULL) + return; + static RenderBackend_Rect rcSet; // TODO - Not the original variable name rcSet.left = rect->left * mag; rcSet.top = rect->top * mag; @@ -700,6 +715,9 @@ void PutText(int x, int y, const char *text, unsigned long color) void PutText2(int x, int y, const char *text, unsigned long color, SurfaceID surf_no) { + if (surf[surf_no] == NULL) + return; + DrawText(font, surf[surf_no], x * mag, y * mag, color, text); }