From fc5c3470003b588f56ee988bb5abc7087d7245d1 Mon Sep 17 00:00:00 2001 From: wutno Date: Tue, 9 Jan 2024 19:37:49 -0500 Subject: [PATCH] printing multiple times broken because SDL_FreeSurface doesnt make the ptr nullptr --- Includes/Printer.cpp | 2 +- Includes/Printer.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Includes/Printer.cpp b/Includes/Printer.cpp index cfa3a1a..295d430 100644 --- a/Includes/Printer.cpp +++ b/Includes/Printer.cpp @@ -93,7 +93,7 @@ bool Printer::QueuePrintLine(std::vector& data) // Microsoft in their infinite wisdom defines min in windows.h, so we can't use std::min constexpr auto maxOffset = 0x14; - uint8_t offset = (data[2] < maxOffset) ? data[2] : maxOffset; + uint8_t offset = data[2]; if (static_cast(data[1]) == BufferControl::Clear) m_printQueue.clear(); diff --git a/Includes/Printer.h b/Includes/Printer.h index 0012ae8..6e9c7df 100644 --- a/Includes/Printer.h +++ b/Includes/Printer.h @@ -63,14 +63,17 @@ class Printer if (m_cardImage != nullptr) { SaveCardImage(m_localName); SDL_FreeSurface(m_cardImage); + m_cardImage = nullptr; } m_localName = ""; } void Erase() { - if (m_cardImage != nullptr) + if (m_cardImage != nullptr) { SDL_FreeSurface(m_cardImage); + m_cardImage = nullptr; + } } bool RegisterFont(std::vector& data);