From c72300d51fe82d905497880c28a9cf1b02709753 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Wed, 17 Feb 2021 14:02:30 +0000 Subject: [PATCH] Fix crash when using LOBOT with certain sti size and offset (by Asdow). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8938 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/structure.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/TileEngine/structure.cpp b/TileEngine/structure.cpp index d9219e49..7ddedbb8 100644 --- a/TileEngine/structure.cpp +++ b/TileEngine/structure.cpp @@ -2438,7 +2438,10 @@ BOOLEAN AddZStripInfoToVObject( HVOBJECT hVObject, STRUCTURE_FILE_REF * pStructu // MemAlloc returns a NULL pointer which the code would interpret as // allocation failing because of no memory. // I hope this is OK, I don't entirely understand what is done here... - if (pCurr->ubNumberOfZChanges > 0) + // (ASDOW): Commented out the added conditional, because with an unlucky combination of sti image width and offset, eg 9x16 with x offset of -15 + // pCurr->pbZChange would be null, which then crashes the game inside the blitting functions when dereferencing a nullptr + // With Bio experiencing crashes causing him to add the check, I don't know if this is just kicking the can down the road. +// if (pCurr->ubNumberOfZChanges > 0) { pCurr->pbZChange = (INT8 *)MemAlloc(pCurr->ubNumberOfZChanges); if (pCurr->pbZChange == NULL) @@ -2480,10 +2483,10 @@ BOOLEAN AddZStripInfoToVObject( HVOBJECT hVObject, STRUCTURE_FILE_REF * pStructu pCurr->bInitialZChange = -(ubNumDecreasing); } } - else - { - pCurr->pbZChange = NULL; - } +// else +// { +// pCurr->pbZChange = NULL; +// } } } }