From 824e0793faa616c59d9e870c64747cf7ea935a94 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Thu, 10 Apr 2025 19:14:03 -0700 Subject: [PATCH] change arguments and add eof check Revert "fix: buff station cycling and dying too soon" This reverts commit 1c6cb2921e10eb2000ac40007d0c2636ba2ac151. fix: buff station cycling and dying too soon Tested that the buff station now only cycles after it has been built and has been alive for 25 seconds. --- dCommon/Sd0.cpp | 4 ++-- dCommon/Sd0.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dCommon/Sd0.cpp b/dCommon/Sd0.cpp index 39908d14..5b97cb75 100644 --- a/dCommon/Sd0.cpp +++ b/dCommon/Sd0.cpp @@ -54,10 +54,10 @@ Sd0::Sd0(std::istream& buffer) { return; } - while (buffer) { + while (buffer && buffer.peek() != std::istream::traits_type::eof()) { uint32_t chunkSize{}; if (!BinaryIO::BinaryRead(buffer, chunkSize)) { - LOG("Failed to read chunk size from stream %li %li", buffer.tellg(), m_Chunks.size()); + LOG("Failed to read chunk size from stream %lld %zu", buffer.tellg(), m_Chunks.size()); break; } auto& chunk = m_Chunks.emplace_back(); diff --git a/dCommon/Sd0.h b/dCommon/Sd0.h index 6340c78c..40bf9930 100644 --- a/dCommon/Sd0.h +++ b/dCommon/Sd0.h @@ -8,6 +8,8 @@ #include // Sd0 is comprised of multiple zlib compressed buffers stored in a row. +// The format starts with a SD0 header (see SD0_HEADER) followed by the size of a zlib buffer, and then the zlib buffer itself. +// This repeats until end of file class Sd0 { public: using BinaryBuffer = std::vector;