From 6f499abef0dd2744d1a9a28a0196148bbbf01094 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 10 Sep 2021 16:55:27 -0700 Subject: [PATCH] Fix platv values outside map size being saved as 67372036 If the map size was less than 20x20, platv values outside the map would end up being saved as 67372036. This happens because SDL_memset() operates on the byte level, and not the multi-byte level. So it takes only the lower 8 bits of 4 and repeats it for each byte in each integer, creating 67372036. --- desktop_version/src/CustomLevels.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 3fccdd8b..58c359e6 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -1366,7 +1366,10 @@ bool customlevelclass::save(const std::string& _path) msg = xml::update_element_delete_contents(data, "levelMetaData"); int temp_platv[numrooms]; - SDL_memset(temp_platv, 4 /* default */, sizeof(temp_platv)); + for (size_t i = 0; i < SDL_arraysize(temp_platv); ++i) + { + temp_platv[i] = 4; /* default */ + } if (mapwidth < maxwidth) {