From 8af37bc693d3a984639af902f6a3a509e084404b Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 2 Aug 2020 21:15:58 -0700 Subject: [PATCH] Remove zeroed arrays from tower functions in M&P This removes the arrays of zeroes that still take up space in the binary. It doesn't seem like the compiler optimizes or compresses these zeroes anyway, so just remove them instead, and make load()/loadminitower()/loadminitower2() no-op functions. The minitower/contents arrays are already initialized zeroed-out, anyway, so there's no need to keep these other arrays around. This saves exactly 72 kilobytes of memory and binary size. --- desktop_version/src/Tower.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/desktop_version/src/Tower.cpp b/desktop_version/src/Tower.cpp index ee6003a0..e29fd60a 100644 --- a/desktop_version/src/Tower.cpp +++ b/desktop_version/src/Tower.cpp @@ -197,11 +197,9 @@ void towerclass::loadminitower1() 12,12,12,12,12,12,12,12,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12, 12,12,12,12,12,12,12,12,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12, }; -#else - static const short tmap[100*40] = {0}; -#endif SDL_memcpy(minitower, tmap, sizeof(minitower)); +#endif } void towerclass::loadminitower2() @@ -309,11 +307,9 @@ void towerclass::loadminitower2() 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,21,28,28,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12, 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,21,28,28,0,0,0,0,0,0,0,0,0,20,12,12,12,12,12, }; -#else - static const short tmap[100*40] = {0}; -#endif SDL_memcpy(minitower, tmap, sizeof(minitower)); +#endif } @@ -1151,9 +1147,7 @@ void towerclass::loadmap() 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, }; -#else - static const short tmap[700*40] = {0}; -#endif SDL_memcpy(contents, tmap, sizeof(contents)); +#endif }