![]() |
RigsofRods
2023.09
Soft-body Physics Simulation
|
A content database MOTIVATION: RoR users usually have A LOT of content installed. More...
#include <CacheSystem.h>
Public Types | |
| typedef std::map< int, Ogre::String > | CategoryIdNameMap |
Public Member Functions | |
| CacheSystem () | |
| const std::vector< CacheEntryPtr > & | GetEntries () const |
| const CategoryIdNameMap & | GetCategories () const |
| Ogre::String | GetPrettyName (Ogre::String fname) |
| std::string | ActorTypeToName (ActorType driveable) |
| const std::vector< std::string > & | GetContentDirs () const |
Startup | |
| void | LoadModCache (CacheValidity validity) |
| bool | IsModCacheLoaded () |
Lookups | |
| CacheEntryPtr | FindEntryByFilename (RoR::LoaderType type, bool partial, const std::string &_filename_maybe_bundlequalified) |
| Returns NULL if none found; "Bundle-qualified" format also specifies the ZIP/directory in modcache, i.e. "mybundle.zip:myactor.truck". More... | |
| CacheEntryPtr | GetEntryByNumber (int modid) |
| CacheEntryPtr | FetchSkinByName (std::string const &skin_name) |
| size_t | Query (CacheQuery &query) |
Loading | |
| void | LoadResource (CacheEntryPtr &t) |
| Loads the associated resource bundle if not already done. More... | |
| void | ReLoadResource (CacheEntryPtr &t) |
| Forces reloading the associated bundle. More... | |
| void | UnLoadResource (CacheEntryPtr &t) |
| Unloads associated bundle, destroying all spawned actors. More... | |
| void | LoadSupplementaryDocuments (CacheEntryPtr &t) |
| Loads the associated .truck*, .skin and .tuneup files. More... | |
| void | LoadAssetPack (CacheEntryPtr &t_dest, Ogre::String const &assetpack_filename) |
| Adds asset pack to the requesting cache entry's resource group. More... | |
Projects | |
| CacheEntryPtr | CreateProject (CreateProjectRequest *request) |
| Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcache entry. More... | |
| void | ModifyProject (ModifyProjectRequest *request) |
| void | DeleteProject (CacheEntryPtr &entry) |
Private Member Functions | |
| CacheValidity | EvaluateCacheValidity () |
| void | WriteCacheFileJson () |
| void | ExportEntryToJson (rapidjson::Value &j_entries, rapidjson::Document &j_doc, CacheEntryPtr const &entry) |
| CacheValidity | LoadCacheFileJson () |
| void | ImportEntryFromJson (rapidjson::Value &j_entry, CacheEntryPtr &out_entry) |
| void | ParseZipArchives (Ogre::String group) |
| bool | ParseKnownFiles (Ogre::String group) |
| void | ParseSingleZip (Ogre::String path) |
| void | ClearCache () |
| void | PruneCache () |
| void | ClearResourceGroups () |
| void | AddFile (Ogre::String group, Ogre::FileInfo f, Ogre::String ext) |
| void | DetectDuplicates () |
| void | GenerateHashFromFilenames () |
| For quick detection of added/removed content. More... | |
| void | GenerateFileCache (CacheEntryPtr &entry, Ogre::String group) |
| void | RemoveFileCache (CacheEntryPtr &entry) |
| bool | Match (size_t &out_score, std::string data, std::string const &query, size_t) |
| bool | IsPathContentDirRoot (const std::string &path) const |
Document loading helpers | |
| void | LoadAssociatedSkinDef (CacheEntryPtr &cache_entry) |
| Loads+parses the .skin file and updates all related CacheEntries. More... | |
| void | LoadAssociatedTuneupDef (CacheEntryPtr &cache_entry) |
| Loads+parses the .tuneup file and updates all related CacheEntries. More... | |
Cache update helpers | |
| void | FillTerrainDetailInfo (CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname) |
| void | FillTruckDetailInfo (CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname, Ogre::String group) |
| void | FillSkinDetailInfo (CacheEntryPtr &entry, std::shared_ptr< SkinDocument > &skin_def) |
| void | FillAddonPartDetailInfo (CacheEntryPtr &entry, Ogre::DataStreamPtr ds) |
| void | FillTuneupDetailInfo (CacheEntryPtr &entry, TuneupDefPtr &tuneup_def) |
| void | FillAssetPackDetailInfo (CacheEntryPtr &entry, Ogre::DataStreamPtr ds) |
| void | FillDashboardDetailInfo (CacheEntryPtr &entry, Ogre::DataStreamPtr ds) |
| void | FillGadgetDetailInfo (CacheEntryPtr &entry, Ogre::DataStreamPtr ds) |
Static Private Member Functions | |
| static Ogre::String | StripUIDfromString (Ogre::String uidstr) |
| static Ogre::String | StripSHA1fromString (Ogre::String sha1str) |
| static std::string | ComposeResourceGroupName (const CacheEntryPtr &entry) |
Private Attributes | |
| bool | m_loaded = false |
| std::time_t | m_update_time |
| Ensures that all inserted files share the same timestamp. More... | |
| std::string | m_filenames_hash_loaded |
| hash from cachefile, for quick update detection More... | |
| std::string | m_filenames_hash_generated |
| stores hash over the content, for quick update detection More... | |
| std::vector< CacheEntryPtr > | m_entries |
| std::vector< Ogre::String > | m_known_extensions |
| the extensions we track in the cache system More... | |
| std::vector< std::string > | m_content_dirs |
| the various mod directories we track in the cache system More... | |
| std::set< Ogre::String > | m_resource_paths |
| A temporary list of existing resource paths. More... | |
| std::map< int, Ogre::String > | m_categories |
Friends | |
| class | ContentManager |
A content database MOTIVATION: RoR users usually have A LOT of content installed.
Traversing it all on every game startup would be a pain. HOW IT WORKS: For each recognized resource type (vehicle, terrain, skin...) an instance of 'CacheEntry' is created. These entries are persisted in file CACHE_FILE (see above) Associated media live in a "resource bundle" (ZIP archive or subdirectory) in content directory (ROR_HOME/mods) and subdirectories. If multiple CacheEntries share a bundle, the bundle is loaded only once. Each bundle has dedicated OGRE resource group. UPDATING THE CACHE: Historically it was a synchronous process which could only happen at main menu, in bulk. In October 2023 it became an ad-hoc process but all synchronous logic was kept, to be slowly phased out later. See https://github.com/RigsOfRods/rigs-of-rods/pull/3096
Definition at line 283 of file CacheSystem.h.
| typedef std::map<int, Ogre::String> RoR::CacheSystem::CategoryIdNameMap |
Definition at line 287 of file CacheSystem.h.
| CacheSystem::CacheSystem | ( | ) |
Definition at line 125 of file CacheSystem.cpp.
| std::string CacheSystem::ActorTypeToName | ( | ActorType | driveable | ) |
Definition at line 569 of file CacheSystem.cpp.
|
private |
Definition at line 744 of file CacheSystem.cpp.
|
private |
Definition at line 712 of file CacheSystem.cpp.
|
private |
Definition at line 464 of file CacheSystem.cpp.
|
staticprivate |
Definition at line 1481 of file CacheSystem.cpp.
| CacheEntryPtr CacheSystem::CreateProject | ( | CreateProjectRequest * | request | ) |
Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcache entry.
Definition at line 1783 of file CacheSystem.cpp.
| void CacheSystem::DeleteProject | ( | CacheEntryPtr & | entry | ) |
Definition at line 2256 of file CacheSystem.cpp.
|
private |
Definition at line 477 of file CacheSystem.cpp.
|
private |
Definition at line 259 of file CacheSystem.cpp.
|
private |
Definition at line 583 of file CacheSystem.cpp.
| CacheEntryPtr CacheSystem::FetchSkinByName | ( | std::string const & | skin_name | ) |
Definition at line 1673 of file CacheSystem.cpp.
|
private |
Definition at line 1237 of file CacheSystem.cpp.
|
private |
Definition at line 1271 of file CacheSystem.cpp.
|
private |
Definition at line 1303 of file CacheSystem.cpp.
|
private |
Definition at line 1340 of file CacheSystem.cpp.
|
private |
Definition at line 1218 of file CacheSystem.cpp.
|
private |
Definition at line 1192 of file CacheSystem.cpp.
|
private |
Definition at line 848 of file CacheSystem.cpp.
|
private |
Definition at line 1386 of file CacheSystem.cpp.
| CacheEntryPtr CacheSystem::FindEntryByFilename | ( | RoR::LoaderType | type, |
| bool | partial, | ||
| const std::string & | _filename_maybe_bundlequalified | ||
| ) |
Returns NULL if none found; "Bundle-qualified" format also specifies the ZIP/directory in modcache, i.e. "mybundle.zip:myactor.truck".
Definition at line 186 of file CacheSystem.cpp.
|
private |
Definition at line 1074 of file CacheSystem.cpp.
|
private |
For quick detection of added/removed content.
Definition at line 1186 of file CacheSystem.cpp.
|
inline |
Definition at line 322 of file CacheSystem.h.
|
inline |
Definition at line 327 of file CacheSystem.h.
|
inline |
Definition at line 321 of file CacheSystem.h.
| CacheEntryPtr CacheSystem::GetEntryByNumber | ( | int | modid | ) |
Definition at line 549 of file CacheSystem.cpp.
| String CacheSystem::GetPrettyName | ( | Ogre::String | fname | ) |
Definition at line 559 of file CacheSystem.cpp.
|
private |
Definition at line 297 of file CacheSystem.cpp.
|
inline |
Definition at line 294 of file CacheSystem.h.
|
private |
Definition at line 1523 of file CacheSystem.cpp.
| void CacheSystem::LoadAssetPack | ( | CacheEntryPtr & | t_dest, |
| Ogre::String const & | assetpack_filename | ||
| ) |
Adds asset pack to the requesting cache entry's resource group.
Definition at line 1407 of file CacheSystem.cpp.
|
private |
Loads+parses the .skin file and updates all related CacheEntries.
Definition at line 1685 of file CacheSystem.cpp.
|
private |
Loads+parses the .tuneup file and updates all related CacheEntries.
Definition at line 1734 of file CacheSystem.cpp.
|
private |
Definition at line 399 of file CacheSystem.cpp.
| void CacheSystem::LoadModCache | ( | CacheValidity | validity | ) |
Definition at line 153 of file CacheSystem.cpp.
| void CacheSystem::LoadResource | ( | CacheEntryPtr & | t | ) |
Loads the associated resource bundle if not already done.
Definition at line 1538 of file CacheSystem.cpp.
| void CacheSystem::LoadSupplementaryDocuments | ( | CacheEntryPtr & | t | ) |
Loads the associated .truck*, .skin and .tuneup files.
Definition at line 1502 of file CacheSystem.cpp.
|
private |
Definition at line 2436 of file CacheSystem.cpp.
| void CacheSystem::ModifyProject | ( | ModifyProjectRequest * | request | ) |
Definition at line 2015 of file CacheSystem.cpp.
|
private |
Definition at line 1171 of file CacheSystem.cpp.
|
private |
Definition at line 1148 of file CacheSystem.cpp.
|
private |
Definition at line 1125 of file CacheSystem.cpp.
|
private |
Definition at line 431 of file CacheSystem.cpp.
| size_t CacheSystem::Query | ( | CacheQuery & | query | ) |
Definition at line 2294 of file CacheSystem.cpp.
| void CacheSystem::ReLoadResource | ( | CacheEntryPtr & | t | ) |
Forces reloading the associated bundle.
Definition at line 1634 of file CacheSystem.cpp.
|
private |
Definition at line 1066 of file CacheSystem.cpp.
|
staticprivate |
Definition at line 736 of file CacheSystem.cpp.
|
staticprivate |
Definition at line 728 of file CacheSystem.cpp.
| void CacheSystem::UnLoadResource | ( | CacheEntryPtr & | t | ) |
Unloads associated bundle, destroying all spawned actors.
Definition at line 1647 of file CacheSystem.cpp.
|
private |
Definition at line 686 of file CacheSystem.cpp.
|
friend |
Definition at line 285 of file CacheSystem.h.
|
private |
Definition at line 389 of file CacheSystem.h.
|
private |
the various mod directories we track in the cache system
Definition at line 387 of file CacheSystem.h.
|
private |
Definition at line 385 of file CacheSystem.h.
|
private |
stores hash over the content, for quick update detection
Definition at line 384 of file CacheSystem.h.
|
private |
hash from cachefile, for quick update detection
Definition at line 383 of file CacheSystem.h.
|
private |
the extensions we track in the cache system
Definition at line 386 of file CacheSystem.h.
|
private |
Definition at line 381 of file CacheSystem.h.
|
private |
A temporary list of existing resource paths.
Definition at line 388 of file CacheSystem.h.
|
private |
Ensures that all inserted files share the same timestamp.
Definition at line 382 of file CacheSystem.h.
1.8.17