mirror of https://github.com/OpenRCT2/OpenRCT2.git
Make -force-scan command run without starting game
reformat object_list_load to use parameter instead of external flag boolean remove object_list_load_force_scan, call directly from RootCommands
This commit is contained in:
parent
5cd6c864a5
commit
6ba51e36da
|
@ -190,7 +190,7 @@ extern "C"
|
|||
// TODO Ideally we want to delay this until we show the title so that we can
|
||||
// still open the game window and draw a progress screen for the creation
|
||||
// of the object cache.
|
||||
objRepo->LoadOrConstruct();
|
||||
objRepo->LoadOrConstruct(false);
|
||||
|
||||
// TODO Like objects, this can take a while if there are a lot of track designs
|
||||
// its also really something really we might want to do in the background
|
||||
|
|
|
@ -23,7 +23,6 @@ extern "C"
|
|||
#include "../config.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../platform/crash.h"
|
||||
#include "../object/ObjectRepository.h"
|
||||
}
|
||||
|
||||
#include "../core/Console.hpp"
|
||||
|
@ -31,6 +30,7 @@ extern "C"
|
|||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../network/network.h"
|
||||
#include "../object/ObjectRepository.h"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
#ifdef USE_BREAKPAD
|
||||
|
@ -196,7 +196,14 @@ exitcode_t CommandLine::HandleCommandDefault()
|
|||
|
||||
gOpenRCT2Headless = _headless;
|
||||
gOpenRCT2SilentBreakpad = _silentBreakpad || _headless;
|
||||
object_repository_force_scan_flag = _forceScan;
|
||||
|
||||
if (_forceScan)
|
||||
{
|
||||
IObjectRepository * objectRepository = GetObjectRepository();
|
||||
objectRepository->LoadOrConstruct(true);
|
||||
|
||||
result = EXITCODE_OK;
|
||||
}
|
||||
|
||||
if (_userDataPath != nullptr)
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
ClearItems();
|
||||
}
|
||||
|
||||
void LoadOrConstruct() override
|
||||
void LoadOrConstruct(bool forceScan) override
|
||||
{
|
||||
ClearItems();
|
||||
|
||||
|
@ -123,8 +123,12 @@ public:
|
|||
QueryDirectory(&_queryDirectoryResult, rct2Path);
|
||||
QueryDirectory(&_queryDirectoryResult, openrct2Path);
|
||||
|
||||
if (!Load())
|
||||
if (forceScan || !Load())
|
||||
{
|
||||
if (forceScan)
|
||||
{
|
||||
Console::WriteLine("Forcing object repository scan.");
|
||||
}
|
||||
_languageId = gCurrentLanguage;
|
||||
|
||||
Construct();
|
||||
|
@ -300,16 +304,6 @@ 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);
|
||||
|
@ -659,8 +653,6 @@ 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();
|
||||
|
@ -678,7 +670,7 @@ extern "C"
|
|||
void object_list_load()
|
||||
{
|
||||
IObjectRepository * objectRepository = GetObjectRepository();
|
||||
objectRepository->LoadOrConstruct();
|
||||
objectRepository->LoadOrConstruct(false);
|
||||
|
||||
IObjectManager * objectManager = GetObjectManager();
|
||||
objectManager->UnloadAll();
|
||||
|
|
|
@ -63,7 +63,7 @@ interface IObjectRepository
|
|||
{
|
||||
virtual ~IObjectRepository() { }
|
||||
|
||||
virtual void LoadOrConstruct() abstract;
|
||||
virtual void LoadOrConstruct(bool forceScan) abstract;
|
||||
virtual size_t GetNumObjects() const abstract;
|
||||
virtual const ObjectRepositoryItem * GetObjects() const abstract;
|
||||
virtual const ObjectRepositoryItem * FindObject(const utf8 * name) const abstract;
|
||||
|
@ -88,8 +88,6 @@ 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);
|
||||
|
|
Loading…
Reference in New Issue