From 079253e168ee6b1791dd50bdd424345703c6dbbd Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 8 Oct 2022 23:09:07 +0200 Subject: [PATCH] Remove now-unused SawyerEncoding.{cpp,h} --- src/openrct2/libopenrct2.vcxproj | 4 +- src/openrct2/rct1/T4Importer.cpp | 1 - src/openrct2/rct12/SawyerEncoding.cpp | 107 -------------------------- src/openrct2/rct12/SawyerEncoding.h | 25 ------ src/openrct2/rct2/S6Importer.cpp | 1 - src/openrct2/rct2/T6Importer.cpp | 1 - 6 files changed, 1 insertion(+), 138 deletions(-) delete mode 100644 src/openrct2/rct12/SawyerEncoding.cpp delete mode 100644 src/openrct2/rct12/SawyerEncoding.h diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 585de5ad8c..55e497161f 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -345,7 +345,6 @@ - @@ -841,7 +840,6 @@ - @@ -1011,4 +1009,4 @@ - \ No newline at end of file + diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index 88fa795a9b..581449a5e6 100644 --- a/src/openrct2/rct1/T4Importer.cpp +++ b/src/openrct2/rct1/T4Importer.cpp @@ -16,7 +16,6 @@ #include "../rct1/RCT1.h" #include "../rct1/Tables.h" #include "../rct12/SawyerChunkReader.h" -#include "../rct12/SawyerEncoding.h" #include "../ride/Ride.h" #include "../ride/RideData.h" #include "../ride/TrackDesign.h" diff --git a/src/openrct2/rct12/SawyerEncoding.cpp b/src/openrct2/rct12/SawyerEncoding.cpp deleted file mode 100644 index 428aab1a45..0000000000 --- a/src/openrct2/rct12/SawyerEncoding.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2022 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#include "SawyerEncoding.h" - -#include "../core/IStream.hpp" -#include "../core/Numerics.hpp" -#include "RCT12.h" - -#include - -namespace SawyerEncoding -{ - bool ValidateChecksum(OpenRCT2::IStream* stream) - { - uint64_t initialPosition = stream->GetPosition(); - uint64_t dataSize = stream->GetLength() - initialPosition; - if (dataSize < 8) - { - return false; - } - dataSize -= 4; - - try - { - // Calculate checksum - uint32_t checksum = 0; - do - { - uint8_t buffer[4096]; - uint64_t bufferSize = std::min(dataSize, sizeof(buffer)); - stream->Read(buffer, bufferSize); - - for (uint64_t i = 0; i < bufferSize; i++) - { - checksum += buffer[i]; - } - - dataSize -= bufferSize; - } while (dataSize != 0); - - // Read file checksum - uint32_t fileChecksum = stream->ReadValue(); - - // Rewind back to original position - stream->SetPosition(initialPosition); - return checksum == fileChecksum; - } - catch (const std::exception&) - { - // Rewind back to original position - stream->SetPosition(initialPosition); - return false; - } - } - - // Returns version number - RCT12TrackDesignVersion ValidateTrackChecksum(OpenRCT2::IStream* stream) - { - uint64_t initialPosition = stream->GetPosition(); - uint64_t dataSize = stream->GetLength() - initialPosition; - - if (dataSize < 4) - { - return RCT12TrackDesignVersion::unknown; - } - dataSize -= 4; - - try - { - const auto buffer = stream->ReadArray(dataSize); - const auto* data = buffer.get(); - uint32_t checksum = 0; - for (size_t i = 0; i < dataSize; i++, ++data) - { - uint8_t newByte = ((checksum & 0xFF) + *data) & 0xFF; - checksum = (checksum & 0xFFFFFF00) + newByte; - checksum = Numerics::rol32(checksum, 3); - } - - uint32_t fileChecksum = stream->ReadValue(); - // Rewind back to original position - stream->SetPosition(initialPosition); - - if (checksum - 0x1D4C1 == fileChecksum) - return RCT12TrackDesignVersion::TD6; - if (checksum - 0x1A67C == fileChecksum) - return RCT12TrackDesignVersion::TD4; - if (checksum - 0x1A650 == fileChecksum) - return RCT12TrackDesignVersion::TD4; - - return RCT12TrackDesignVersion::unknown; - } - catch (const std::exception&) - { - // Rewind back to original position - stream->SetPosition(initialPosition); - return RCT12TrackDesignVersion::unknown; - } - } -} // namespace SawyerEncoding diff --git a/src/openrct2/rct12/SawyerEncoding.h b/src/openrct2/rct12/SawyerEncoding.h deleted file mode 100644 index 4f31962318..0000000000 --- a/src/openrct2/rct12/SawyerEncoding.h +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014-2022 OpenRCT2 developers - * - * For a complete list of all authors, please refer to contributors.md - * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is licensed under the GNU General Public License version 3. - *****************************************************************************/ - -#pragma once - -#include "../common.h" - -namespace OpenRCT2 -{ - struct IStream; -} - -enum class RCT12TrackDesignVersion : uint8_t; - -namespace SawyerEncoding -{ - bool ValidateChecksum(OpenRCT2::IStream* stream); - RCT12TrackDesignVersion ValidateTrackChecksum(OpenRCT2::IStream* stream); -} // namespace SawyerEncoding diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index d0e79b4918..5cf7117d0e 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -52,7 +52,6 @@ #include "../rct12/EntryList.h" #include "../rct12/RCT12.h" #include "../rct12/SawyerChunkReader.h" -#include "../rct12/SawyerEncoding.h" #include "../rct2/RCT2.h" #include "../ride/Ride.h" #include "../ride/RideData.h" diff --git a/src/openrct2/rct2/T6Importer.cpp b/src/openrct2/rct2/T6Importer.cpp index 914ccea0cc..33a64fdace 100644 --- a/src/openrct2/rct2/T6Importer.cpp +++ b/src/openrct2/rct2/T6Importer.cpp @@ -16,7 +16,6 @@ #include "../object/ObjectRepository.h" #include "../object/RideObject.h" #include "../rct12/SawyerChunkReader.h" -#include "../rct12/SawyerEncoding.h" #include "../ride/Ride.h" #include "../ride/RideData.h" #include "../ride/TrackDesign.h"