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.
This commit is contained in:
Misa 2021-09-11 23:15:34 -07:00
parent 2991b2341a
commit a10342f5e6
3 changed files with 14 additions and 12 deletions

View File

@ -1,5 +1,7 @@
#include "BlockV.h"
#include <SDL_stdinc.h>
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;

View File

@ -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;

View File

@ -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 = "";
}