mirror of https://github.com/OpenRCT2/OpenRCT2.git
force a object repo reload if language changes
This commit is contained in:
parent
82d90fe350
commit
13e9a76732
|
@ -60,6 +60,7 @@ void editor_load()
|
|||
audio_pause_sounds();
|
||||
audio_unpause_sounds();
|
||||
object_unload_all();
|
||||
object_list_load();
|
||||
map_init(150);
|
||||
banner_init();
|
||||
reset_park_entrances();
|
||||
|
@ -146,6 +147,7 @@ void trackdesigner_load()
|
|||
gScreenAge = 0;
|
||||
|
||||
object_unload_all();
|
||||
object_list_load();
|
||||
map_init(150);
|
||||
set_all_land_owned();
|
||||
banner_init();
|
||||
|
@ -184,6 +186,7 @@ void trackmanager_load()
|
|||
gScreenAge = 0;
|
||||
|
||||
object_unload_all();
|
||||
object_list_load();
|
||||
map_init(150);
|
||||
set_all_land_owned();
|
||||
banner_init();
|
||||
|
|
|
@ -46,11 +46,12 @@ extern "C"
|
|||
#include "../util/sawyercoding.h"
|
||||
}
|
||||
|
||||
constexpr uint16 OBJECT_REPOSITORY_VERSION = 8;
|
||||
constexpr uint16 OBJECT_REPOSITORY_VERSION = 9;
|
||||
|
||||
struct ObjectRepositoryHeader
|
||||
{
|
||||
uint16 Version;
|
||||
uint16 LanguageId;
|
||||
uint32 TotalFiles;
|
||||
uint64 TotalFileSize;
|
||||
uint32 FileDateModifiedChecksum;
|
||||
|
@ -96,6 +97,7 @@ class ObjectRepository : public IObjectRepository
|
|||
std::vector<ObjectRepositoryItem> _items;
|
||||
QueryDirectoryResult _queryDirectoryResult;
|
||||
ObjectEntryMap _itemMap;
|
||||
uint16 _languageId;
|
||||
|
||||
public:
|
||||
~ObjectRepository()
|
||||
|
@ -103,7 +105,7 @@ public:
|
|||
ClearItems();
|
||||
}
|
||||
|
||||
void LoadOrConstruct()
|
||||
void LoadOrConstruct() override
|
||||
{
|
||||
ClearItems();
|
||||
|
||||
|
@ -117,6 +119,8 @@ public:
|
|||
|
||||
if (!Load())
|
||||
{
|
||||
_languageId = gCurrentLanguage;
|
||||
|
||||
Construct();
|
||||
Save();
|
||||
}
|
||||
|
@ -310,6 +314,7 @@ private:
|
|||
auto header = fs.ReadValue<ObjectRepositoryHeader>();
|
||||
|
||||
if (header.Version == OBJECT_REPOSITORY_VERSION &&
|
||||
header.LanguageId == gCurrentLanguage &&
|
||||
header.TotalFiles == _queryDirectoryResult.TotalFiles &&
|
||||
header.TotalFileSize == _queryDirectoryResult.TotalFileSize &&
|
||||
header.FileDateModifiedChecksum == _queryDirectoryResult.FileDateModifiedChecksum &&
|
||||
|
@ -344,6 +349,7 @@ private:
|
|||
// Write header
|
||||
ObjectRepositoryHeader header;
|
||||
header.Version = OBJECT_REPOSITORY_VERSION;
|
||||
header.LanguageId = _languageId;
|
||||
header.TotalFiles = _queryDirectoryResult.TotalFiles;
|
||||
header.TotalFileSize = _queryDirectoryResult.TotalFileSize;
|
||||
header.FileDateModifiedChecksum = _queryDirectoryResult.FileDateModifiedChecksum;
|
||||
|
@ -571,7 +577,6 @@ IObjectRepository * GetObjectRepository()
|
|||
if (_objectRepository == nullptr)
|
||||
{
|
||||
_objectRepository = new ObjectRepository();
|
||||
_objectRepository->LoadOrConstruct();
|
||||
}
|
||||
return _objectRepository;
|
||||
}
|
||||
|
@ -605,7 +610,8 @@ extern "C"
|
|||
|
||||
void object_list_load()
|
||||
{
|
||||
IObjectRepository * objRepo = GetObjectRepository();
|
||||
IObjectRepository * objectRepository = GetObjectRepository();
|
||||
objectRepository->LoadOrConstruct();
|
||||
}
|
||||
|
||||
bool object_load_chunk(int groupIndex, const rct_object_entry * entry, int * outGroupIndex)
|
||||
|
|
|
@ -62,6 +62,7 @@ interface IObjectRepository
|
|||
{
|
||||
virtual ~IObjectRepository() { }
|
||||
|
||||
virtual void LoadOrConstruct() abstract;
|
||||
virtual const size_t GetNumObjects() const abstract;
|
||||
virtual const ObjectRepositoryItem * GetObjects() const abstract;
|
||||
virtual const ObjectRepositoryItem * FindObject(const utf8 * name) const abstract;
|
||||
|
|
Loading…
Reference in New Issue