From e938bfdb57fd9ee2b672d7ee2b9762adfa9ee63f Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 17 May 2020 17:05:07 -0700 Subject: [PATCH] Refactor areamap initialization to not use strings Instead, the data is held in a const int array, which is directly loaded into areamap. --- desktop_version/src/Map.cpp | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 7191f3ea..f8938ed6 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -88,28 +88,30 @@ mapclass::mapclass() resetnames(); //Areamap starts at 100,100 and extends 20x20 - std::vector tmap; - tmap.push_back("1,2,2,2,2,2,2,2,0,3,0,0,0,4,4,4,4,4,4,4"); - tmap.push_back("1,2,2,2,2,2,2,0,0,3,0,0,0,0,4,4,4,4,4,4"); - tmap.push_back("0,1,0,0,2,0,0,0,0,3,0,0,0,0,4,4,4,4,4,4"); - tmap.push_back("0,0,0,0,2,0,0,0,0,3,0,0,5,5,5,5,4,4,4,4"); - tmap.push_back("0,0,2,2,2,0,0,0,0,3,11,11,5,5,5,5,0,0,0,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,5,5,5,5,5,5,0,0,0,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,5,5,5,5,5,5,5,0,0,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,5,5,5,5,5,5,5,5,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,0,0,0,5,5,5,5,5,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,11,3,0,0,0,5,5,5,5,5,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,0,0,0,5,5,5,5,5,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,0,5,5,5,5,5,5,5,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,0,5,5,5,5,5,5,0,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,0,5,5,5,5,5,5,0,5,0"); - tmap.push_back("0,0,0,0,0,0,0,0,0,3,0,5,5,0,0,0,0,0,5,0"); - tmap.push_back("0,0,0,0,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0"); - tmap.push_back("0,0,2,2,2,2,2,2,0,3,0,0,0,0,0,0,0,0,0,0"); - tmap.push_back("0,2,2,2,2,2,2,2,0,3,0,0,0,0,0,0,0,0,0,0"); - tmap.push_back("2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0"); - tmap.push_back("2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0"); - fillareamap(tmap); + const int tmap[] = { + 1,2,2,2,2,2,2,2,0,3,0,0,0,4,4,4,4,4,4,4, + 1,2,2,2,2,2,2,0,0,3,0,0,0,0,4,4,4,4,4,4, + 0,1,0,0,2,0,0,0,0,3,0,0,0,0,4,4,4,4,4,4, + 0,0,0,0,2,0,0,0,0,3,0,0,5,5,5,5,4,4,4,4, + 0,0,2,2,2,0,0,0,0,3,11,11,5,5,5,5,0,0,0,0, + 0,0,0,0,0,0,0,0,0,3,5,5,5,5,5,5,0,0,0,0, + 0,0,0,0,0,0,0,0,0,3,5,5,5,5,5,5,5,0,0,0, + 0,0,0,0,0,0,0,0,0,3,5,5,5,5,5,5,5,5,5,0, + 0,0,0,0,0,0,0,0,0,3,0,0,0,5,5,5,5,5,5,0, + 0,0,0,0,0,0,0,0,11,3,0,0,0,5,5,5,5,5,5,0, + 0,0,0,0,0,0,0,0,0,3,0,0,0,5,5,5,5,5,5,0, + 0,0,0,0,0,0,0,0,0,3,0,5,5,5,5,5,5,5,5,0, + 0,0,0,0,0,0,0,0,0,3,0,5,5,5,5,5,5,0,5,0, + 0,0,0,0,0,0,0,0,0,3,0,5,5,5,5,5,5,0,5,0, + 0,0,0,0,0,0,0,0,0,3,0,5,5,0,0,0,0,0,5,0, + 0,0,0,0,0,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0, + 0,0,2,2,2,2,2,2,0,3,0,0,0,0,0,0,0,0,0,0, + 0,2,2,2,2,2,2,2,0,3,0,0,0,0,0,0,0,0,0,0, + 2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0, + 2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0, + }; + areamap.clear(); + areamap.insert(areamap.end(), tmap, tmap+400); } int mapclass::RGB(int red,int green,int blue)