diff --git a/LEGO1/legobackgroundcolor.cpp b/LEGO1/legobackgroundcolor.cpp index 9411bd09..eec569c2 100644 --- a/LEGO1/legobackgroundcolor.cpp +++ b/LEGO1/legobackgroundcolor.cpp @@ -16,35 +16,42 @@ LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorStri // OFFSET: LEGO1 0x1003c070 void LegoBackgroundColor::SetColorString(const char *colorString) { + m_colorString.operator=(colorString); m_colorString.ToLowerCase(); + + float converted_b; + float converted_g; + float converted_r; LegoVideoManager *videomanager = VideoManager(); + if (videomanager && colorString) { - char *colorStringCopy = (char *)malloc(strlen(colorString) + 1); + int length = strlen(colorString) + 1; + char *colorStringCopy = (char *)malloc(length); strcpy(colorStringCopy, colorString); char *colorStringSplit = strtok(colorStringCopy, Delimiter); if (!strcmp(colorStringSplit, set)) { // set it - char *red = strtok(0, Delimiter); - if (red) - r = atoi(red) * 0.01; + + //TODO: I think this is in BGR because of the order of local variables char *blue = strtok(0, Delimiter); if (blue) b = atoi(blue) * 0.01; char *green = strtok(0, Delimiter); if (green) g = atoi(green) * 0.01; + char *red = strtok(0, Delimiter); + if (red) + r = atoi(red) * 0.01; } else if (!strcmp(colorStringSplit, reset)) { // reset it - float converted_r; - float converted_b; - float converted_g; - ConvertColor(this->r, this->g, this->b, &converted_r, &converted_g, &converted_b); - videomanager->SetSkyColor(converted_r, converted_g, converted_b); + + ConvertColor(this->b, this->g, this->r, &converted_b, &converted_g, &converted_r); + videomanager->SetSkyColor(converted_b, converted_g, converted_r); } free(colorStringCopy); } diff --git a/LEGO1/legobackgroundcolor.h b/LEGO1/legobackgroundcolor.h index fb53ece2..15efb3e4 100644 --- a/LEGO1/legobackgroundcolor.h +++ b/LEGO1/legobackgroundcolor.h @@ -7,7 +7,12 @@ class LegoBackgroundColor : public MxBackgroundColor { public: __declspec(dllexport) LegoBackgroundColor(const char *, const char *); - void SetColorString(const char* colorString); + void SetColorString(const char *colorString); + +protected: + float b; + float g; + float r; }; #endif // LEGOBACKGROUNDCOLOR_H diff --git a/LEGO1/mxbackgroundcolor.cpp b/LEGO1/mxbackgroundcolor.cpp index 2f22077f..3650bfe5 100644 --- a/LEGO1/mxbackgroundcolor.cpp +++ b/LEGO1/mxbackgroundcolor.cpp @@ -1,6 +1,12 @@ #include "mxbackgroundcolor.h" #include "mxstring.h" +// OFFSET: LEGO1 0x1003bec0 +MxBackgroundColor::~MxBackgroundColor() +{ + m_colorString.~MxString(); + m_name.~MxString(); +} // OFFSET: LEGO1 0x1003bea0 MxString* MxBackgroundColor::GetColorString() diff --git a/LEGO1/mxbackgroundcolor.h b/LEGO1/mxbackgroundcolor.h index 4f7d8a6e..3038ef24 100644 --- a/LEGO1/mxbackgroundcolor.h +++ b/LEGO1/mxbackgroundcolor.h @@ -9,12 +9,10 @@ class MxBackgroundColor MxBackgroundColor(){} virtual MxString* GetColorString(); virtual void SetColorString(const char* colorString); + virtual ~MxBackgroundColor(); protected: MxString m_name; MxString m_colorString; - float r; - float g; - float b; }; #endif // MXBACKGROUNDCOLOR_H