diff --git a/src/textures/buildtexture.cpp b/src/textures/buildtexture.cpp index dd9545553..722328667 100644 --- a/src/textures/buildtexture.cpp +++ b/src/textures/buildtexture.cpp @@ -48,18 +48,14 @@ // //========================================================================== -class FBuildTexture : public FTexture +class FBuildTexture : public FWorldTexture { public: FBuildTexture (int tilenum, const uint8_t *pixels, int width, int height, int left, int top); - ~FBuildTexture (); - - const uint8_t *GetColumn (unsigned int column, const Span **spans_out); - const uint8_t *GetPixels (); + uint8_t *MakeTexture(FRenderStyle style) override { return const_cast(Pixels); } // This is only to make it compile for now and will be changed later. protected: const uint8_t *Pixels; - Span **Spans; }; @@ -70,8 +66,9 @@ protected: //========================================================================== FBuildTexture::FBuildTexture (int tilenum, const uint8_t *pixels, int width, int height, int left, int top) -: Pixels (pixels), Spans (NULL) +: Pixels (pixels) { + PixelsAreStatic = 3; Width = width; Height = height; LeftOffset = left; @@ -81,62 +78,6 @@ FBuildTexture::FBuildTexture (int tilenum, const uint8_t *pixels, int width, int UseType = TEX_Build; } -//========================================================================== -// -// -// -//========================================================================== - -FBuildTexture::~FBuildTexture () -{ - if (Spans != NULL) - { - FreeSpans (Spans); - Spans = NULL; - } -} - -//========================================================================== -// -// -// -//========================================================================== - -const uint8_t *FBuildTexture::GetPixels () -{ - return Pixels; -} - -//========================================================================== -// -// -// -//========================================================================== - -const uint8_t *FBuildTexture::GetColumn (unsigned int column, const Span **spans_out) -{ - if (column >= Width) - { - if (WidthMask + 1 == Width) - { - column &= WidthMask; - } - else - { - column %= Width; - } - } - if (spans_out != NULL) - { - if (Spans == NULL) - { - Spans = CreateSpans (Pixels); - } - *spans_out = Spans[column]; - } - return Pixels + column*Height; -} - //=========================================================================== // // AddTiles diff --git a/src/textures/worldtexture.cpp b/src/textures/worldtexture.cpp index 0370bf3e8..896890236 100644 --- a/src/textures/worldtexture.cpp +++ b/src/textures/worldtexture.cpp @@ -91,7 +91,7 @@ void FWorldTexture::Unload () // //========================================================================== -const uint8_t *FWorldTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FWorldTexture::GetColumn(unsigned int column, const Span **spans_out) { GetPixels(); if ((unsigned)column >= (unsigned)Width) @@ -124,6 +124,10 @@ const uint8_t *FWorldTexture::GetColumn (unsigned int column, const Span **spans const uint8_t *FWorldTexture::GetPixels () { + if (CheckModified()) + { + Unload(); + } if (Pixeldata[0] == nullptr) { Pixeldata[0] = MakeTexture (LegacyRenderStyles[STYLE_Normal]);