diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index fecf624177..2ae21166af 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -2710,8 +2710,6 @@ STR_5503 :Enter hostname or IP address: STR_5504 :Show multiplayer status STR_5505 :Unable to connect to server. STR_5506 :Guests ignore intensities -STR_5508 :Allow loading files with incorrect checksums -STR_5509 :Allows loading scenarios and saves{NEWLINE}that have an incorrect checksum,{NEWLINE}like the scenarios from the demo{NEWLINE}or damaged saves. STR_5510 :Default sound device STR_5511 :(UNKNOWN) STR_5512 :Save Game As diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 255fdbbe5c..fd4e8e7a46 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -196,7 +196,6 @@ enum WindowOptionsWidgetIdx { // Advanced WIDX_DEBUGGING_TOOLS = WIDX_PAGE_START, - WIDX_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM, WIDX_SAVE_PLUGIN_DATA_CHECKBOX, WIDX_STAY_CONNECTED_AFTER_DESYNC, WIDX_ALWAYS_NATIVE_LOADSAVE, @@ -384,7 +383,6 @@ static rct_widget window_options_misc_widgets[] = { static rct_widget window_options_advanced_widgets[] = { MAIN_OPTIONS_WIDGETS, MakeWidget ({ 10, 54}, {290, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ENABLE_DEBUGGING_TOOLS, STR_ENABLE_DEBUGGING_TOOLS_TIP ), // Enable debugging tools - MakeWidget ({ 10, 69}, {290, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM, STR_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM_TIP), // Allow loading with incorrect checksum MakeWidget ({ 10, 84}, {290, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_SAVE_PLUGIN_DATA, STR_SAVE_PLUGIN_DATA_TIP ), // Export plug-in objects with saved games MakeWidget ({ 10, 99}, {290, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_STAY_CONNECTED_AFTER_DESYNC, STR_STAY_CONNECTED_AFTER_DESYNC_TIP ), // Do not disconnect after the client desynchronises with the server MakeWidget ({ 10, 114}, {290, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_ALWAYS_NATIVE_LOADSAVE, STR_ALWAYS_NATIVE_LOADSAVE_TIP ), // Use native load/save window @@ -1878,11 +1876,6 @@ private: config_save_default(); gfx_invalidate_screen(); break; - case WIDX_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM: - gConfigGeneral.allow_loading_with_incorrect_checksum = !gConfigGeneral.allow_loading_with_incorrect_checksum; - config_save_default(); - Invalidate(); - break; case WIDX_SAVE_PLUGIN_DATA_CHECKBOX: gConfigGeneral.save_plugin_data ^= 1; config_save_default(); @@ -2001,8 +1994,6 @@ private: void AdvancedPrepareDraw() { SetCheckboxValue(WIDX_DEBUGGING_TOOLS, gConfigGeneral.debugging_tools); - WidgetSetCheckboxValue( - *this, WIDX_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM, gConfigGeneral.allow_loading_with_incorrect_checksum); SetCheckboxValue(WIDX_SAVE_PLUGIN_DATA_CHECKBOX, gConfigGeneral.save_plugin_data); SetCheckboxValue(WIDX_STAY_CONNECTED_AFTER_DESYNC, gConfigNetwork.stay_connected); SetCheckboxValue(WIDX_ALWAYS_NATIVE_LOADSAVE, gConfigGeneral.use_native_browse_dialog); diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 6e90ace5e2..f6b195509e 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -192,7 +192,6 @@ namespace Config model->enable_light_fx_for_vehicles = isHardware && reader->GetBoolean("enable_light_fx_for_vehicles", false); model->upper_case_banners = reader->GetBoolean("upper_case_banners", false); model->disable_lightning_effect = reader->GetBoolean("disable_lightning_effect", false); - model->allow_loading_with_incorrect_checksum = reader->GetBoolean("allow_loading_with_incorrect_checksum", true); model->steam_overlay_pause = reader->GetBoolean("steam_overlay_pause", true); model->window_scale = reader->GetFloat("window_scale", Platform::GetDefaultScale()); model->show_fps = reader->GetBoolean("show_fps", false); @@ -278,7 +277,6 @@ namespace Config writer->WriteBoolean("enable_light_fx_for_vehicles", model->enable_light_fx_for_vehicles); writer->WriteBoolean("upper_case_banners", model->upper_case_banners); writer->WriteBoolean("disable_lightning_effect", model->disable_lightning_effect); - writer->WriteBoolean("allow_loading_with_incorrect_checksum", model->allow_loading_with_incorrect_checksum); writer->WriteBoolean("steam_overlay_pause", model->steam_overlay_pause); writer->WriteFloat("window_scale", model->window_scale); writer->WriteBoolean("show_fps", model->show_fps); diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index f1cfdfd7ac..f4c65f3ef8 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -89,7 +89,6 @@ struct GeneralConfiguration // Miscellaneous bool play_intro; int32_t window_snap_proximity; - bool allow_loading_with_incorrect_checksum; bool save_plugin_data; bool debugging_tools; int32_t autosave_frequency; 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/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 98f80f5ade..769bd8f0f4 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -2841,8 +2841,6 @@ enum : uint16_t STR_SHOW_MULTIPLAYER_STATUS_TIP = 5504, STR_UNABLE_TO_CONNECT_TO_SERVER = 5505, STR_CHEAT_IGNORE_INTENSITY = 5506, - STR_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM = 5508, - STR_ALLOW_LOADING_WITH_INCORRECT_CHECKSUM_TIP = 5509, STR_OPTIONS_SOUND_VALUE_DEFAULT = 5510, STR_OPTIONS_SOUND_VALUE_UNKNOWN = 5511, STR_SAVE_GAME_AS = 5512, diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index 0e1a026bd5..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" @@ -53,12 +52,6 @@ namespace RCT1 bool LoadFromStream(OpenRCT2::IStream* stream) override { - auto checksumType = SawyerEncoding::ValidateTrackChecksum(stream); - if (!gConfigGeneral.allow_loading_with_incorrect_checksum && checksumType == RCT12TrackDesignVersion::unknown) - { - throw IOException("Invalid checksum."); - } - auto chunkReader = SawyerChunkReader(stream); auto data = chunkReader.ReadChunkTrack(); _stream.WriteArray(reinterpret_cast(data->GetData()), data->GetLength()); 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 d4faa848a9..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" @@ -141,12 +140,6 @@ namespace RCT2 OpenRCT2::IStream* stream, bool isScenario, [[maybe_unused]] bool skipObjectCheck = false, const utf8* path = String::Empty) override { - if (isScenario && !gConfigGeneral.allow_loading_with_incorrect_checksum - && !SawyerEncoding::ValidateChecksum(stream)) - { - throw IOException("Invalid checksum."); - } - auto chunkReader = SawyerChunkReader(stream); chunkReader.ReadChunk(&_s6.header, sizeof(_s6.header)); diff --git a/src/openrct2/rct2/T6Importer.cpp b/src/openrct2/rct2/T6Importer.cpp index 20a40d6120..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" @@ -57,12 +56,6 @@ namespace RCT2 bool LoadFromStream(OpenRCT2::IStream* stream) override { - if (!gConfigGeneral.allow_loading_with_incorrect_checksum - && SawyerEncoding::ValidateTrackChecksum(stream) != RCT12TrackDesignVersion::TD6) - { - throw IOException("Invalid checksum."); - } - auto chunkReader = SawyerChunkReader(stream); auto data = chunkReader.ReadChunkTrack(); _stream.WriteArray(reinterpret_cast(data->GetData()), data->GetLength());