From a10342f5e65d73febd918428f03b10831cfee466 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 11 Sep 2021 23:15:34 -0700 Subject: [PATCH] Replace `setblockcolour()` argument with `const char*` There's no reason it needs to be an std::string here. Although, realistically, we should be using an enum instead of string-typing, but, eh, that can be fixed later. --- desktop_version/src/BlockV.cpp | 22 ++++++++++++---------- desktop_version/src/BlockV.h | 2 +- desktop_version/src/Entity.cpp | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/desktop_version/src/BlockV.cpp b/desktop_version/src/BlockV.cpp index 467f2c36..4ce525a2 100644 --- a/desktop_version/src/BlockV.cpp +++ b/desktop_version/src/BlockV.cpp @@ -1,5 +1,7 @@ #include "BlockV.h" +#include + blockclass::blockclass(void) { clear(); @@ -37,57 +39,57 @@ void blockclass::rectset(const int xi, const int yi, const int wi, const int hi) rect.h = hi; } -void blockclass::setblockcolour( std::string col ) +void blockclass::setblockcolour(const char* col) { - if (col == "cyan") + if (SDL_strcmp(col, "cyan") == 0) { r = 164; g = 164; b = 255; } - else if (col == "red") + else if (SDL_strcmp(col, "red") == 0) { r = 255; g = 60; b = 60; } - else if (col == "green") + else if (SDL_strcmp(col, "green") == 0) { r = 144; g = 255; b = 144; } - else if (col == "yellow") + else if (SDL_strcmp(col, "yellow") == 0) { r = 255; g = 255; b = 134; } - else if (col == "blue") + else if (SDL_strcmp(col, "blue") == 0) { r = 95; g = 95; b = 255; } - else if (col == "purple") + else if (SDL_strcmp(col, "purple") == 0) { r = 255; g = 134; b = 255; } - else if (col == "white") + else if (SDL_strcmp(col, "white") == 0) { r = 244; g = 244; b = 244; } - else if (col == "gray") + else if (SDL_strcmp(col, "gray") == 0) { r = 174; g = 174; b = 174; } - else if (col == "orange") + else if (SDL_strcmp(col, "orange") == 0) { r = 255; g = 130; diff --git a/desktop_version/src/BlockV.h b/desktop_version/src/BlockV.h index 6753f913..8fa52bb0 100644 --- a/desktop_version/src/BlockV.h +++ b/desktop_version/src/BlockV.h @@ -12,7 +12,7 @@ public: void rectset(const int xi, const int yi, const int wi, const int hi); - void setblockcolour(std::string col); + void setblockcolour(const char* col); public: //Fundamentals SDL_Rect rect; diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 3d7c8d7e..a131eca9 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -1078,7 +1078,7 @@ void entityclass::createblock( int t, int xp, int yp, int w, int h, int trig /*= if (customactivitycolour != "") { - block.setblockcolour(customactivitycolour); + block.setblockcolour(customactivitycolour.c_str()); customactivitycolour = ""; }