diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 77a9da40b..5ed0fcab2 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -76,19 +76,19 @@ public: /* Variable: width Contains the width of the image */ - int m_Width; + int m_Width = 0; /* Variable: height Contains the height of the image */ - int m_Height; + int m_Height = 0; /* Variable: format Contains the format of the image. See for more information. */ - int m_Format; + int m_Format = FORMAT_RGB; /* Variable: data Pointer to the image data. */ - void *m_pData; + void *m_pData = nullptr; }; /* diff --git a/src/game/editor/mapitems/image.cpp b/src/game/editor/mapitems/image.cpp index 365c6687d..514a1cadf 100644 --- a/src/game/editor/mapitems/image.cpp +++ b/src/game/editor/mapitems/image.cpp @@ -1,14 +1,28 @@ #include "image.h" -#include +#include + +CEditorImage::CEditorImage(CEditor *pEditor) : + m_AutoMapper(pEditor) +{ + Init(pEditor); + m_Texture.Invalidate(); +} CEditorImage::~CEditorImage() { - m_pEditor->Graphics()->UnloadTexture(&m_Texture); + Graphics()->UnloadTexture(&m_Texture); free(m_pData); m_pData = nullptr; } +void CEditorImage::Init(CEditor *pEditor) +{ + CEditorComponent::Init(pEditor); + RegisterSubComponent(m_AutoMapper); + InitSubComponents(); +} + void CEditorImage::AnalyseTileFlags() { mem_zero(m_aTileFlags, sizeof(m_aTileFlags)); diff --git a/src/game/editor/mapitems/image.h b/src/game/editor/mapitems/image.h index b34edba79..cffbd6c7e 100644 --- a/src/game/editor/mapitems/image.h +++ b/src/game/editor/mapitems/image.h @@ -4,35 +4,22 @@ #include #include +#include -class CEditor; - -class CEditorImage : public CImageInfo +class CEditorImage : public CImageInfo, public CEditorComponent { public: - CEditor *m_pEditor; - - CEditorImage(CEditor *pEditor): m_AutoMapper(pEditor) - { - m_pEditor = pEditor; - m_aName[0] = 0; - m_Texture.Invalidate(); - m_External = 0; - m_Width = 0; - m_Height = 0; - m_pData = nullptr; - m_Format = 0; - } - + explicit CEditorImage(CEditor *pEditor); ~CEditorImage(); + void Init(CEditor *pEditor) override; void AnalyseTileFlags(); IGraphics::CTextureHandle m_Texture; - int m_External; - char m_aName[IO_MAX_PATH_LENGTH]; + int m_External = 0; + char m_aName[IO_MAX_PATH_LENGTH] = ""; unsigned char m_aTileFlags[256]; - class CAutoMapper m_AutoMapper; + CAutoMapper m_AutoMapper; }; #endif