diff --git a/src/openrct2-ui/audio/AudioMixer.cpp b/src/openrct2-ui/audio/AudioMixer.cpp index de345e584f..22265e8f0a 100644 --- a/src/openrct2-ui/audio/AudioMixer.cpp +++ b/src/openrct2-ui/audio/AudioMixer.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/audio/MemoryAudioSource.cpp b/src/openrct2-ui/audio/MemoryAudioSource.cpp index a2f3b0bb30..ab50144759 100644 --- a/src/openrct2-ui/audio/MemoryAudioSource.cpp +++ b/src/openrct2-ui/audio/MemoryAudioSource.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include "AudioContext.h" diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 6cddc0cf8a..c8ee5f2938 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -16,33 +16,29 @@ #ifndef DISABLE_OPENGL +#include #include #include #include - #include #include -#include -#include +#include #include #include +#include #include #include -#include - -#include #include -#include -#include - +#include +#include #include "../DrawingEngines.h" -#include "GLSLTypes.h" -#include "OpenGLAPI.h" -#include "OpenGLFramebuffer.h" #include "ApplyPaletteShader.h" #include "DrawCommands.h" #include "DrawLineShader.h" #include "DrawRectShader.h" +#include "GLSLTypes.h" +#include "OpenGLAPI.h" +#include "OpenGLFramebuffer.h" #include "SwapFramebuffer.h" #include "TextureCache.h" #include "TransparencyDepth.h" @@ -346,27 +342,27 @@ private: uint8 * newBits = new uint8[newBitsSize]; if (_bits == nullptr) { - Memory::Set(newBits, 0, newBitsSize); + std::fill_n(newBits, newBitsSize, 0); } else { if (_pitch == pitch) { - Memory::Copy(newBits, _bits, Math::Min(_bitsSize, newBitsSize)); + std::copy_n(_bits, std::min(_bitsSize, newBitsSize), newBits); } else { uint8 * src = _bits; uint8 * dst = newBits; - uint32 minWidth = Math::Min(_width, width); - uint32 minHeight = Math::Min(_height, height); + uint32 minWidth = std::min(_width, width); + uint32 minHeight = std::min(_height, height); for (uint32 y = 0; y < minHeight; y++) { - Memory::Copy(dst, src, minWidth); + std::copy_n(src, minWidth, dst); if (pitch - minWidth > 0) { - Memory::Set(dst + minWidth, 0, pitch - minWidth); + std::fill_n(dst + minWidth, pitch - minWidth, 0); } src += _pitch; dst += pitch; @@ -716,8 +712,8 @@ void OpenGLDrawingContext::DrawSpriteRawMasked(sint32 x, sint32 y, uint32 maskIm sint32 drawOffsetX = g1ElementMask->x_offset; sint32 drawOffsetY = g1ElementMask->y_offset; - sint32 drawWidth = Math::Min(g1ElementMask->width, g1ElementColour->width); - sint32 drawHeight = Math::Min(g1ElementMask->height, g1ElementColour->height); + sint32 drawWidth = std::min(g1ElementMask->width, g1ElementColour->width); + sint32 drawHeight = std::min(g1ElementMask->height, g1ElementColour->height); sint32 left = x + drawOffsetX; sint32 top = y + drawOffsetY; diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp index f75731a462..e7a4fe1853 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp @@ -16,9 +16,10 @@ #ifndef DISABLE_OPENGL +#include +#include #include #include -#include #include "OpenGLFramebuffer.h" constexpr GLuint BACKBUFFER_ID = 0; @@ -94,21 +95,20 @@ void OpenGLFramebuffer::GetPixels(rct_drawpixelinfo &dpi) const { assert(dpi.width == _width && dpi.height == _height); - uint8 * pixels = Memory::Allocate(_width * _height); + auto pixels = std::make_unique(_width * _height); glBindTexture(GL_TEXTURE_2D, _texture); glPixelStorei(GL_PACK_ALIGNMENT, 1); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, pixels); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, pixels.get()); // Flip pixels vertically on copy - uint8 * src = pixels + ((_height - 1) * _width); + uint8 * src = pixels.get() + ((_height - 1) * _width); uint8 * dst = dpi.bits; for (sint32 y = 0; y < _height; y++) { - Memory::Copy(dst, src, _width); + std::copy_n(src, _width, dst); src -= _width; dst += dpi.width + dpi.pitch; } - Memory::Free(pixels); } void OpenGLFramebuffer::SwapColourBuffer(OpenGLFramebuffer &other) diff --git a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp index df7119cfeb..18dda9014e 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp @@ -16,12 +16,11 @@ #ifndef DISABLE_OPENGL -#include +#include #include -#include -#include "TextureCache.h" - +#include #include +#include "TextureCache.h" constexpr uint32 UNUSED_INDEX = 0xFFFFFFFF; @@ -95,7 +94,7 @@ BasicTextureInfo TextureCache::GetOrLoadGlyphTexture(uint32 image, uint8 * palet { GlyphId glyphId; glyphId.Image = image; - Memory::Copy(&glyphId.Palette, palette, sizeof(glyphId.Palette)); + std::copy_n((uint8 *)&glyphId.Palette, sizeof(glyphId.Palette), palette); auto kvp = _glyphTextureMap.find(glyphId); if (kvp != _glyphTextureMap.end()) @@ -290,8 +289,8 @@ void TextureCache::FreeTextures() rct_drawpixelinfo TextureCache::CreateDPI(sint32 width, sint32 height) { size_t numPixels = width * height; - uint8 * pixels8 = Memory::Allocate(numPixels); - Memory::Set(pixels8, 0, numPixels); + auto pixels8 = new uint8[numPixels]; + std::fill_n(pixels8, numPixels, 0); rct_drawpixelinfo dpi; dpi.bits = pixels8; @@ -306,7 +305,7 @@ rct_drawpixelinfo TextureCache::CreateDPI(sint32 width, sint32 height) void TextureCache::DeleteDPI(rct_drawpixelinfo dpi) { - Memory::Free(dpi.bits); + delete dpi.bits; } GLuint TextureCache::GetAtlasesTexture() diff --git a/src/openrct2-ui/input/KeyboardShortcuts.cpp b/src/openrct2-ui/input/KeyboardShortcuts.cpp index 4891a6106a..96464fa957 100644 --- a/src/openrct2-ui/input/KeyboardShortcuts.cpp +++ b/src/openrct2-ui/input/KeyboardShortcuts.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index 0cad3e4dbd..9dde814a1f 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index dbd2b0a7f1..7eb0bde28f 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 415c584fe4..72db5f7c06 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/TitleScenarioSelect.cpp b/src/openrct2-ui/windows/TitleScenarioSelect.cpp index 99ff4f4098..5cc2f9d392 100644 --- a/src/openrct2-ui/windows/TitleScenarioSelect.cpp +++ b/src/openrct2-ui/windows/TitleScenarioSelect.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index cffd2a6ed3..b99b6ffbb5 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include