From a883f37b9d67c57bc336812bf83ee85c363f8931 Mon Sep 17 00:00:00 2001 From: Misha Date: Wed, 28 Jun 2023 18:15:42 +0300 Subject: [PATCH] address review --- .editorconfig | 5 ++++- LEGO1/legobackgroundcolor.cpp | 9 ++++----- LEGO1/legobackgroundcolor.h | 8 ++++++-- LEGO1/legoutil.cpp | 2 +- LEGO1/mxbackgroundcolor.cpp | 22 ---------------------- LEGO1/mxbackgroundcolor.h | 22 ---------------------- LEGO1/mxstringvariable.cpp | 22 ++++++++++++++++++++++ LEGO1/mxstringvariable.h | 20 ++++++++++++++++++++ isle.mak | 16 ++++++++-------- 9 files changed, 65 insertions(+), 61 deletions(-) delete mode 100644 LEGO1/mxbackgroundcolor.cpp delete mode 100644 LEGO1/mxbackgroundcolor.h create mode 100644 LEGO1/mxstringvariable.cpp create mode 100644 LEGO1/mxstringvariable.h diff --git a/.editorconfig b/.editorconfig index 86af9d49..4cc30192 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,6 @@ +root = true [*.{cpp,h}] indent_style = space -indent_size = 2 \ No newline at end of file +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true \ No newline at end of file diff --git a/LEGO1/legobackgroundcolor.cpp b/LEGO1/legobackgroundcolor.cpp index 83683a82..6a9f6a22 100644 --- a/LEGO1/legobackgroundcolor.cpp +++ b/LEGO1/legobackgroundcolor.cpp @@ -16,8 +16,7 @@ LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorStri // OFFSET: LEGO1 0x1003c070 void LegoBackgroundColor::SetColorString(const char *colorString) { - - m_colorString.operator=(colorString); + m_name = colorString; m_colorString.ToLowerCase(); float converted_r; @@ -28,7 +27,7 @@ void LegoBackgroundColor::SetColorString(const char *colorString) if (videomanager && colorString) { int length = strlen(colorString) + 1; - char *colorStringCopy = (char *)malloc(length); + char *colorStringCopy = new char[length]; strcpy(colorStringCopy, colorString); char *colorStringSplit = strtok(colorStringCopy, Delimiter); if (!strcmp(colorStringSplit, set)) @@ -49,6 +48,6 @@ void LegoBackgroundColor::SetColorString(const char *colorString) ConvertHSVToRGB(this->h, this->s, this->v, &converted_r, &converted_g, &converted_b); videomanager->SetSkyColor(converted_r, converted_g, converted_b); } - free(colorStringCopy); + delete[] colorStringCopy; } -} \ No newline at end of file +} diff --git a/LEGO1/legobackgroundcolor.h b/LEGO1/legobackgroundcolor.h index 14030746..812e8882 100644 --- a/LEGO1/legobackgroundcolor.h +++ b/LEGO1/legobackgroundcolor.h @@ -2,12 +2,16 @@ #define LEGOBACKGROUNDCOLOR_H #include "mxstring.h" #include "mxcore.h" -#include "mxbackgroundcolor.h" -class LegoBackgroundColor : public MxBackgroundColor +#include "MxStringVariable.h" +class LegoBackgroundColor : public MxStringVariable { public: __declspec(dllexport) LegoBackgroundColor(const char *, const char *); void SetColorString(const char *colorString); +protected: + float h; + float s; + float v; }; #endif // LEGOBACKGROUNDCOLOR_H diff --git a/LEGO1/legoutil.cpp b/LEGO1/legoutil.cpp index 8614be41..58e11e8f 100644 --- a/LEGO1/legoutil.cpp +++ b/LEGO1/legoutil.cpp @@ -10,7 +10,7 @@ void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, floa double v12; double v13; if (s > 0.5f) - calc = ((1.0f - v) * s + v); // + calc = (1.0f - v) * s + v; else calc = (v + 1.0) * s; if (calc <= 0.0) diff --git a/LEGO1/mxbackgroundcolor.cpp b/LEGO1/mxbackgroundcolor.cpp deleted file mode 100644 index 5ccb11e3..00000000 --- a/LEGO1/mxbackgroundcolor.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "mxbackgroundcolor.h" -#include "mxstring.h" - -// OFFSET: LEGO1 0x1003bec0 -MxBackgroundColor::~MxBackgroundColor() -{ - - delete &m_colorString; - delete &m_name; -} - -// OFFSET: LEGO1 0x1003bea0 -MxString *MxBackgroundColor::GetColorString() -{ - return &m_colorString; -} - -// OFFSET: LEGO1 0x1003beb0 -void MxBackgroundColor::SetColorString(const char *colorString) -{ - m_colorString.operator=(colorString); -} diff --git a/LEGO1/mxbackgroundcolor.h b/LEGO1/mxbackgroundcolor.h deleted file mode 100644 index da83a355..00000000 --- a/LEGO1/mxbackgroundcolor.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef MXBACKGROUNDCOLOR_H -#define MXACKGROUNDCOLOR_H -#include "mxstring.h" -#include "mxcore.h" -class MxBackgroundColor -{ -public: - __declspec(dllexport) MxBackgroundColor(const char *, const char *); - MxBackgroundColor() {} - virtual MxString *GetColorString(); - virtual void SetColorString(const char *colorString); - virtual ~MxBackgroundColor(); - -protected: - MxString m_name; - MxString m_colorString; - float h; - float s; - float v; -}; - -#endif // MXBACKGROUNDCOLOR_H diff --git a/LEGO1/mxstringvariable.cpp b/LEGO1/mxstringvariable.cpp new file mode 100644 index 00000000..4593e303 --- /dev/null +++ b/LEGO1/mxstringvariable.cpp @@ -0,0 +1,22 @@ +#include "MxStringVariable.h" +#include "mxstring.h" + +// OFFSET: LEGO1 0x1003bec0 +MxStringVariable::~MxStringVariable() +{ + + delete &m_colorString; + delete &m_name; +} + +// OFFSET: LEGO1 0x1003bea0 +MxString *MxStringVariable::GetColorString() +{ + return &m_colorString; +} + +// OFFSET: LEGO1 0x1003beb0 +void MxStringVariable::SetColorString(const char *colorString) +{ + m_colorString = colorString; +} diff --git a/LEGO1/mxstringvariable.h b/LEGO1/mxstringvariable.h new file mode 100644 index 00000000..cd9f7b0f --- /dev/null +++ b/LEGO1/mxstringvariable.h @@ -0,0 +1,20 @@ +#ifndef MXSTRINGVARIABLE_H +#define MXSTRINGVARIABLE_H +#include "mxstring.h" +#include "mxcore.h" +//VTABLE: 0x100d74a8 +class MxStringVariable +{ +public: + __declspec(dllexport) MxStringVariable(const char *, const char *); + MxStringVariable() {} + virtual MxString *GetColorString(); + virtual void SetColorString(const char *colorString); + virtual ~MxStringVariable(); + +protected: + MxString m_name; + MxString m_colorString; +}; + +#endif // MXSTRINGVARIABLE_H diff --git a/isle.mak b/isle.mak index 53f459f0..64428816 100644 --- a/isle.mak +++ b/isle.mak @@ -62,7 +62,7 @@ CLEAN : -@erase "$(INTDIR)\legovideomanager.obj" -@erase "$(INTDIR)\mxatomid.obj" -@erase "$(INTDIR)\mxautolocker.obj" - -@erase "$(INTDIR)\mxbackgroundcolor.obj" + -@erase "$(INTDIR)\MxStringVariable.obj" -@erase "$(INTDIR)\mxcore.obj" -@erase "$(INTDIR)\mxcriticalsection.obj" -@erase "$(INTDIR)\mxdsfile.obj" @@ -146,7 +146,7 @@ LINK32_OBJS= \ "$(INTDIR)\legovideomanager.obj" \ "$(INTDIR)\mxatomid.obj" \ "$(INTDIR)\mxautolocker.obj" \ - "$(INTDIR)\mxbackgroundcolor.obj" \ + "$(INTDIR)\MxStringVariable.obj" \ "$(INTDIR)\mxcore.obj" \ "$(INTDIR)\mxcriticalsection.obj" \ "$(INTDIR)\mxdsfile.obj" \ @@ -196,7 +196,7 @@ CLEAN : -@erase "$(INTDIR)\legovideomanager.obj" -@erase "$(INTDIR)\mxatomid.obj" -@erase "$(INTDIR)\mxautolocker.obj" - -@erase "$(INTDIR)\mxbackgroundcolor.obj" + -@erase "$(INTDIR)\MxStringVariable.obj" -@erase "$(INTDIR)\mxcore.obj" -@erase "$(INTDIR)\mxcriticalsection.obj" -@erase "$(INTDIR)\mxdsfile.obj" @@ -282,7 +282,7 @@ LINK32_OBJS= \ "$(INTDIR)\legovideomanager.obj" \ "$(INTDIR)\mxatomid.obj" \ "$(INTDIR)\mxautolocker.obj" \ - "$(INTDIR)\mxbackgroundcolor.obj" \ + "$(INTDIR)\MxStringVariable.obj" \ "$(INTDIR)\mxcore.obj" \ "$(INTDIR)\mxcriticalsection.obj" \ "$(INTDIR)\mxdsfile.obj" \ @@ -971,7 +971,7 @@ DEP_CPP_LEGOB=\ ".\LEGO1\legovideomanager.h"\ ".\LEGO1\mxatomid.h"\ ".\LEGO1\mxbackgroundaudiomanager.h"\ - ".\LEGO1\mxbackgroundcolor.h"\ + ".\LEGO1\MxStringVariable.h"\ ".\LEGO1\mxcore.h"\ ".\LEGO1\mxcriticalsection.h"\ ".\LEGO1\mxdsaction.h"\ @@ -1014,15 +1014,15 @@ DEP_CPP_LEGOB=\ ################################################################################ # Begin Source File -SOURCE=.\LEGO1\mxbackgroundcolor.cpp +SOURCE=.\LEGO1\MxStringVariable.cpp DEP_CPP_MXBAC=\ - ".\LEGO1\mxbackgroundcolor.h"\ + ".\LEGO1\MxStringVariable.h"\ ".\LEGO1\mxcore.h"\ ".\LEGO1\mxstring.h"\ ".\LEGO1\mxtypes.h"\ -"$(INTDIR)\mxbackgroundcolor.obj" : $(SOURCE) $(DEP_CPP_MXBAC) "$(INTDIR)" +"$(INTDIR)\MxStringVariable.obj" : $(SOURCE) $(DEP_CPP_MXBAC) "$(INTDIR)" $(CPP) $(CPP_PROJ) $(SOURCE)