From 5cd6c864a5bca3ddf346a6c63bbbc6b622547266 Mon Sep 17 00:00:00 2001 From: wolfreak99 Date: Wed, 19 Oct 2016 17:49:25 -0400 Subject: [PATCH] implement "force-scan" command Formatting improvements --- src/cmdline/RootCommands.cpp | 4 ++++ src/object/ObjectRepository.cpp | 12 ++++++++++++ src/object/ObjectRepository.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/cmdline/RootCommands.cpp b/src/cmdline/RootCommands.cpp index 2586279392..798b3a5ca5 100644 --- a/src/cmdline/RootCommands.cpp +++ b/src/cmdline/RootCommands.cpp @@ -23,6 +23,7 @@ extern "C" #include "../config.h" #include "../OpenRCT2.h" #include "../platform/crash.h" + #include "../object/ObjectRepository.h" } #include "../core/Console.hpp" @@ -66,6 +67,7 @@ static utf8 * _userDataPath = nullptr; static utf8 * _openrctDataPath = nullptr; static utf8 * _rct2DataPath = nullptr; static bool _silentBreakpad = false; +static bool _forceScan = false; static const CommandLineOptionDefinition StandardOptions[] { @@ -89,6 +91,7 @@ static const CommandLineOptionDefinition StandardOptions[] #ifdef USE_BREAKPAD { CMDLINE_TYPE_SWITCH, &_silentBreakpad, NAC, "silent-breakpad", "make breakpad crash reporting silent" }, #endif // USE_BREAKPAD + { CMDLINE_TYPE_SWITCH, &_forceScan, 'f', "force-scan", "forces scanning of object repository" }, OptionTableEnd }; @@ -193,6 +196,7 @@ exitcode_t CommandLine::HandleCommandDefault() gOpenRCT2Headless = _headless; gOpenRCT2SilentBreakpad = _silentBreakpad || _headless; + object_repository_force_scan_flag = _forceScan; if (_userDataPath != nullptr) { diff --git a/src/object/ObjectRepository.cpp b/src/object/ObjectRepository.cpp index da913cb4ba..80fcda6d2c 100644 --- a/src/object/ObjectRepository.cpp +++ b/src/object/ObjectRepository.cpp @@ -300,6 +300,16 @@ private: bool Load() { const std::string &path = _env->GetFilePath(PATHID::CACHE_OBJECTS); + + // Override if force-flag is set. + if (object_repository_force_scan_flag) + { + Console::WriteLine("Forcing object repository scan."); + // This should only be called once, so set back to false. + object_repository_force_scan_flag = false; + return false; + } + try { auto fs = FileStream(path, FILE_MODE_OPEN); @@ -649,6 +659,8 @@ static int GetObjectEntryIndex(uint8 objectType, uint8 entryIndex) extern "C" { + bool object_repository_force_scan_flag = false; + rct_object_entry * object_list_find(rct_object_entry * entry) { IObjectRepository * objRepo = GetObjectRepository(); diff --git a/src/object/ObjectRepository.h b/src/object/ObjectRepository.h index 11ef872873..c417faf003 100644 --- a/src/object/ObjectRepository.h +++ b/src/object/ObjectRepository.h @@ -88,6 +88,8 @@ extern "C" { #endif +extern bool object_repository_force_scan_flag; + size_t object_repository_get_items_count(); const ObjectRepositoryItem * object_repository_get_items(); const ObjectRepositoryItem * object_repository_find_object_by_entry(const rct_object_entry * entry);