From 8bda7140998a004aca43658651384f1b91c84e2f Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Fri, 2 Sep 2022 16:02:50 -0400 Subject: [PATCH] Fixed crash bug in TileMap --- scripts/build.bat | 27 +++++++++++++--------- src/run_modes/editor/contents/tile_map.cpp | 17 ++++++++------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/scripts/build.bat b/scripts/build.bat index cb9f84b..3af6864 100644 --- a/scripts/build.bat +++ b/scripts/build.bat @@ -14,6 +14,7 @@ IF not exist build/ ( set "DELGUI=" set "RELEASE=" +set "DEBINFO=" If "%~1" == "r" set "RELEASE=1" If "%~2" == "r" set "RELEASE=1" @@ -21,32 +22,36 @@ If "%~2" == "r" set "RELEASE=1" If "%~1" == "g" set "DELGUI=1" If "%~2" == "g" set "DELGUI=1" +If "%~1" == "rd" set "DEBINFO=1" +If "%~2" == "rd" set "DEBINFO=1" + IF defined RELEASE ( cmake --build build/ --target ALL_BUILD --config Release -SET BUILD_ERRORLEVEL=!ERRORLEVEL! -IF NOT "!BUILD_ERRORLEVEL!"=="0" ( - echo %ESC%[91mBUILD FAILED!%ESC%[0m %BUILD_ERRORLEVEL% - EXIT /B !BUILD_ERRORLEVEL! -) - xcopy /y test_data\engine_state.json build\Release\ xcopy /y src\renderer\shaders\* build\Release\* + +) ELSE IF defined DEBINFO ( +cmake --build build/ --target ALL_BUILD --config RelWithDebInfo + +xcopy /y test_data\engine_state.json build\RelWithDebInfo\ +xcopy /y src\renderer\shaders\* build\RelWithDebInfo\* + ) ELSE ( cmake --build build/ --target ALL_BUILD --config Debug +xcopy /y test_data\engine_state.json build\Debug\ +xcopy /y src\renderer\shaders\* build\Debug\* + +) + SET BUILD_ERRORLEVEL=!ERRORLEVEL! IF NOT "!BUILD_ERRORLEVEL!"=="0" ( echo %ESC%[91mBUILD FAILED!%ESC%[0m %BUILD_ERRORLEVEL% EXIT /B !BUILD_ERRORLEVEL! ) -xcopy /y test_data\engine_state.json build\Debug\ -xcopy /y src\renderer\shaders\* build\Debug\* - -) - echo %ESC%[92mBUILD SUCCEEDED!%ESC%[0m IF defined DELGUI ( diff --git a/src/run_modes/editor/contents/tile_map.cpp b/src/run_modes/editor/contents/tile_map.cpp index 0594b58..fc91a7a 100644 --- a/src/run_modes/editor/contents/tile_map.cpp +++ b/src/run_modes/editor/contents/tile_map.cpp @@ -122,17 +122,20 @@ namespace lunarium { namespace editor int smaller_width = mSizeInTiles.Width < size.Width ? mSizeInTiles.Width : size.Width; int smaller_height = mSizeInTiles.Height < size.Height ? mSizeInTiles.Height : size.Height; - for(int i = 0; i < smaller_width; i++) + if (mpMap) { - for (int j = 0; j < smaller_height; j++) + for(int i = 0; i < smaller_width; i++) { - new_map[i][j] = mpMap[i][j]; + for (int j = 0; j < smaller_height; j++) + { + new_map[i][j] = mpMap[i][j]; + } } - } - for(int i = 0; i < mSizeInTiles.Width; i++) - { - delete[] mpMap[i]; + for(int i = 0; i < mSizeInTiles.Width; i++) + { + delete[] mpMap[i]; + } } delete[] mpMap;