diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..86af9d49 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +[*.{cpp,h}] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/LEGO1/legobackgroundcolor.cpp b/LEGO1/legobackgroundcolor.cpp index f913b8e9..9411bd09 100644 --- a/LEGO1/legobackgroundcolor.cpp +++ b/LEGO1/legobackgroundcolor.cpp @@ -1,48 +1,51 @@ #include "legobackgroundcolor.h" #include "legoomni.h" #include "legoutil.h" -const char* Delimiter = "\t"; +#include "legovideomanager.h" +const char *Delimiter = "\t"; +const char *set = "set"; +const char *reset = "reset"; // OFFSET: LEGO1 0x1003bfb0 -LegoBackgroundColor::LegoBackgroundColor(const char* name, const char* colorString) +LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorString) { this->m_name.operator=(name); this->m_name.ToUpperCase(); SetColorString(colorString); } - // OFFSET: LEGO1 0x1003c070 -void LegoBackgroundColor::SetColorString(const char* colorString) +void LegoBackgroundColor::SetColorString(const char *colorString) { m_colorString.operator=(colorString); m_colorString.ToLowerCase(); - if (colorString == NULL) + LegoVideoManager *videomanager = VideoManager(); + if (videomanager && colorString) { - return; - } - char* colorStringCopy = (char*)malloc(strlen(colorString) + 1); - strcpy(colorStringCopy, colorString); - char* colorStringSplit = strtok(colorStringCopy, Delimiter); - if(!strcmp(colorStringSplit, "set")) - { - //set it - char* red = strtok(0, Delimiter); - if(red) - r = (double)atoi(red)*0.01; - char* blue = strtok(0, Delimiter); - if(blue) - b = (double)atoi(blue)*0.01; - char* green = strtok(0, Delimiter); - if(green) - g = (double)atoi(green)*0.01; - } - else if(!strcmp(colorStringSplit, "reset")) - { - //reset it - float converted_b; - float converted_g; - float converted_r; - ConvertColor(this->r,this->g,this->b,&converted_r,&converted_g,&converted_b); - VideoManager()->SetSkyColor(converted_r,converted_g,converted_b); + char *colorStringCopy = (char *)malloc(strlen(colorString) + 1); + 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; + char *blue = strtok(0, Delimiter); + if (blue) + b = atoi(blue) * 0.01; + char *green = strtok(0, Delimiter); + if (green) + g = atoi(green) * 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); + } + free(colorStringCopy); } } \ No newline at end of file diff --git a/LEGO1/mxbackgroundcolor.cpp b/LEGO1/mxbackgroundcolor.cpp index da55ccff..2f22077f 100644 --- a/LEGO1/mxbackgroundcolor.cpp +++ b/LEGO1/mxbackgroundcolor.cpp @@ -11,5 +11,5 @@ MxString* MxBackgroundColor::GetColorString() // OFFSET: LEGO1 0x1003beb0 void MxBackgroundColor::SetColorString(const char* colorString) { - this->m_colorString.operator=(colorString); + m_colorString.operator=(colorString); }