mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 22:34:33 +01:00
implement "force-scan" command
Formatting improvements
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user