address review

This commit is contained in:
Misha 2023-06-28 18:15:42 +03:00
parent a919eeb7f4
commit a883f37b9d
9 changed files with 65 additions and 61 deletions

View file

@ -1,3 +1,6 @@
root = true
[*.{cpp,h}] [*.{cpp,h}]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

View file

@ -16,8 +16,7 @@ LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorStri
// OFFSET: LEGO1 0x1003c070 // OFFSET: LEGO1 0x1003c070
void LegoBackgroundColor::SetColorString(const char *colorString) void LegoBackgroundColor::SetColorString(const char *colorString)
{ {
m_name = colorString;
m_colorString.operator=(colorString);
m_colorString.ToLowerCase(); m_colorString.ToLowerCase();
float converted_r; float converted_r;
@ -28,7 +27,7 @@ void LegoBackgroundColor::SetColorString(const char *colorString)
if (videomanager && colorString) if (videomanager && colorString)
{ {
int length = strlen(colorString) + 1; int length = strlen(colorString) + 1;
char *colorStringCopy = (char *)malloc(length); char *colorStringCopy = new char[length];
strcpy(colorStringCopy, colorString); strcpy(colorStringCopy, colorString);
char *colorStringSplit = strtok(colorStringCopy, Delimiter); char *colorStringSplit = strtok(colorStringCopy, Delimiter);
if (!strcmp(colorStringSplit, set)) 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); ConvertHSVToRGB(this->h, this->s, this->v, &converted_r, &converted_g, &converted_b);
videomanager->SetSkyColor(converted_r, converted_g, converted_b); videomanager->SetSkyColor(converted_r, converted_g, converted_b);
} }
free(colorStringCopy); delete[] colorStringCopy;
} }
} }

View file

@ -2,12 +2,16 @@
#define LEGOBACKGROUNDCOLOR_H #define LEGOBACKGROUNDCOLOR_H
#include "mxstring.h" #include "mxstring.h"
#include "mxcore.h" #include "mxcore.h"
#include "mxbackgroundcolor.h" #include "MxStringVariable.h"
class LegoBackgroundColor : public MxBackgroundColor class LegoBackgroundColor : public MxStringVariable
{ {
public: public:
__declspec(dllexport) LegoBackgroundColor(const char *, const char *); __declspec(dllexport) LegoBackgroundColor(const char *, const char *);
void SetColorString(const char *colorString); void SetColorString(const char *colorString);
protected:
float h;
float s;
float v;
}; };
#endif // LEGOBACKGROUNDCOLOR_H #endif // LEGOBACKGROUNDCOLOR_H

View file

@ -10,7 +10,7 @@ void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, floa
double v12; double v12;
double v13; double v13;
if (s > 0.5f) if (s > 0.5f)
calc = ((1.0f - v) * s + v); // calc = (1.0f - v) * s + v;
else else
calc = (v + 1.0) * s; calc = (v + 1.0) * s;
if (calc <= 0.0) if (calc <= 0.0)

View file

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

View file

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

View file

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

20
LEGO1/mxstringvariable.h Normal file
View file

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

View file

@ -62,7 +62,7 @@ CLEAN :
-@erase "$(INTDIR)\legovideomanager.obj" -@erase "$(INTDIR)\legovideomanager.obj"
-@erase "$(INTDIR)\mxatomid.obj" -@erase "$(INTDIR)\mxatomid.obj"
-@erase "$(INTDIR)\mxautolocker.obj" -@erase "$(INTDIR)\mxautolocker.obj"
-@erase "$(INTDIR)\mxbackgroundcolor.obj" -@erase "$(INTDIR)\MxStringVariable.obj"
-@erase "$(INTDIR)\mxcore.obj" -@erase "$(INTDIR)\mxcore.obj"
-@erase "$(INTDIR)\mxcriticalsection.obj" -@erase "$(INTDIR)\mxcriticalsection.obj"
-@erase "$(INTDIR)\mxdsfile.obj" -@erase "$(INTDIR)\mxdsfile.obj"
@ -146,7 +146,7 @@ LINK32_OBJS= \
"$(INTDIR)\legovideomanager.obj" \ "$(INTDIR)\legovideomanager.obj" \
"$(INTDIR)\mxatomid.obj" \ "$(INTDIR)\mxatomid.obj" \
"$(INTDIR)\mxautolocker.obj" \ "$(INTDIR)\mxautolocker.obj" \
"$(INTDIR)\mxbackgroundcolor.obj" \ "$(INTDIR)\MxStringVariable.obj" \
"$(INTDIR)\mxcore.obj" \ "$(INTDIR)\mxcore.obj" \
"$(INTDIR)\mxcriticalsection.obj" \ "$(INTDIR)\mxcriticalsection.obj" \
"$(INTDIR)\mxdsfile.obj" \ "$(INTDIR)\mxdsfile.obj" \
@ -196,7 +196,7 @@ CLEAN :
-@erase "$(INTDIR)\legovideomanager.obj" -@erase "$(INTDIR)\legovideomanager.obj"
-@erase "$(INTDIR)\mxatomid.obj" -@erase "$(INTDIR)\mxatomid.obj"
-@erase "$(INTDIR)\mxautolocker.obj" -@erase "$(INTDIR)\mxautolocker.obj"
-@erase "$(INTDIR)\mxbackgroundcolor.obj" -@erase "$(INTDIR)\MxStringVariable.obj"
-@erase "$(INTDIR)\mxcore.obj" -@erase "$(INTDIR)\mxcore.obj"
-@erase "$(INTDIR)\mxcriticalsection.obj" -@erase "$(INTDIR)\mxcriticalsection.obj"
-@erase "$(INTDIR)\mxdsfile.obj" -@erase "$(INTDIR)\mxdsfile.obj"
@ -282,7 +282,7 @@ LINK32_OBJS= \
"$(INTDIR)\legovideomanager.obj" \ "$(INTDIR)\legovideomanager.obj" \
"$(INTDIR)\mxatomid.obj" \ "$(INTDIR)\mxatomid.obj" \
"$(INTDIR)\mxautolocker.obj" \ "$(INTDIR)\mxautolocker.obj" \
"$(INTDIR)\mxbackgroundcolor.obj" \ "$(INTDIR)\MxStringVariable.obj" \
"$(INTDIR)\mxcore.obj" \ "$(INTDIR)\mxcore.obj" \
"$(INTDIR)\mxcriticalsection.obj" \ "$(INTDIR)\mxcriticalsection.obj" \
"$(INTDIR)\mxdsfile.obj" \ "$(INTDIR)\mxdsfile.obj" \
@ -971,7 +971,7 @@ DEP_CPP_LEGOB=\
".\LEGO1\legovideomanager.h"\ ".\LEGO1\legovideomanager.h"\
".\LEGO1\mxatomid.h"\ ".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\ ".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbackgroundcolor.h"\ ".\LEGO1\MxStringVariable.h"\
".\LEGO1\mxcore.h"\ ".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\ ".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdsaction.h"\ ".\LEGO1\mxdsaction.h"\
@ -1014,15 +1014,15 @@ DEP_CPP_LEGOB=\
################################################################################ ################################################################################
# Begin Source File # Begin Source File
SOURCE=.\LEGO1\mxbackgroundcolor.cpp SOURCE=.\LEGO1\MxStringVariable.cpp
DEP_CPP_MXBAC=\ DEP_CPP_MXBAC=\
".\LEGO1\mxbackgroundcolor.h"\ ".\LEGO1\MxStringVariable.h"\
".\LEGO1\mxcore.h"\ ".\LEGO1\mxcore.h"\
".\LEGO1\mxstring.h"\ ".\LEGO1\mxstring.h"\
".\LEGO1\mxtypes.h"\ ".\LEGO1\mxtypes.h"\
"$(INTDIR)\mxbackgroundcolor.obj" : $(SOURCE) $(DEP_CPP_MXBAC) "$(INTDIR)" "$(INTDIR)\MxStringVariable.obj" : $(SOURCE) $(DEP_CPP_MXBAC) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)