![]() |
RigsofRods
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 () | |
void | LoadModCache (CacheValidity validity) |
CacheEntry * | FindEntryByFilename (RoR::LoaderType type, bool partial, std::string filename) |
Returns NULL if none found. More... | |
CacheEntry * | FetchSkinByName (std::string const &skin_name) |
CacheValidity | EvaluateCacheValidity () |
size_t | Query (CacheQuery &query) |
void | LoadResource (CacheEntry &t) |
Loads the associated resource bundle if not already done. More... | |
bool | CheckResourceLoaded (Ogre::String &in_out_filename) |
Finds + loads the associated resource bundle if not already done. More... | |
bool | CheckResourceLoaded (Ogre::String &in_out_filename, Ogre::String &out_group) |
Finds given resource, outputs group name. Also loads the associated resource bundle if not already done. More... | |
void | ReLoadResource (CacheEntry &t) |
Forces reloading the associated bundle. More... | |
void | UnLoadResource (CacheEntry &t) |
Unloads associated bundle, destroying all spawned actors. More... | |
const std::vector< CacheEntry > & | GetEntries () const |
const CategoryIdNameMap & | GetCategories () const |
std::shared_ptr< RoR::SkinDef > | FetchSkinDef (CacheEntry *cache_entry) |
Loads+parses the .skin file once. More... | |
CacheEntry * | GetEntry (int modid) |
Ogre::String | GetPrettyName (Ogre::String fname) |
std::string | ActorTypeToName (ActorType driveable) |
Private Member Functions | |
void | WriteCacheFileJson () |
void | ExportEntryToJson (rapidjson::Value &j_entries, rapidjson::Document &j_doc, CacheEntry const &entry) |
CacheValidity | LoadCacheFileJson () |
void | ImportEntryFromJson (rapidjson::Value &j_entry, CacheEntry &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 | FillTerrainDetailInfo (CacheEntry &entry, Ogre::DataStreamPtr ds, Ogre::String fname) |
void | FillTruckDetailInfo (CacheEntry &entry, Ogre::DataStreamPtr ds, Ogre::String fname, Ogre::String group) |
void | GenerateHashFromFilenames () |
For quick detection of added/removed content. More... | |
void | GenerateFileCache (CacheEntry &entry, Ogre::String group) |
void | RemoveFileCache (CacheEntry &entry) |
bool | Match (size_t &out_score, std::string data, std::string const &query, size_t) |
Static Private Member Functions | |
static Ogre::String | StripUIDfromString (Ogre::String uidstr) |
static Ogre::String | StripSHA1fromString (Ogre::String sha1str) |
Private Attributes | |
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< CacheEntry > | m_entries |
std::vector< Ogre::String > | m_known_extensions |
the extensions 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 |
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.
Definition at line 190 of file CacheSystem.h.
typedef std::map<int, Ogre::String> RoR::CacheSystem::CategoryIdNameMap |
Definition at line 193 of file CacheSystem.h.
CacheSystem::CacheSystem | ( | ) |
Definition at line 100 of file CacheSystem.cpp.
std::string CacheSystem::ActorTypeToName | ( | ActorType | driveable | ) |
|
private |
Definition at line 626 of file CacheSystem.cpp.
bool CacheSystem::CheckResourceLoaded | ( | Ogre::String & | in_out_filename | ) |
Finds + loads the associated resource bundle if not already done.
Definition at line 1071 of file CacheSystem.cpp.
bool CacheSystem::CheckResourceLoaded | ( | Ogre::String & | in_out_filename, |
Ogre::String & | out_group | ||
) |
Finds given resource, outputs group name. Also loads the associated resource bundle if not already done.
Definition at line 1077 of file CacheSystem.cpp.
|
private |
Definition at line 594 of file CacheSystem.cpp.
|
private |
|
private |
Definition at line 381 of file CacheSystem.cpp.
CacheValidity CacheSystem::EvaluateCacheValidity | ( | ) |
|
private |
CacheEntry * CacheSystem::FetchSkinByName | ( | std::string const & | skin_name | ) |
std::shared_ptr< SkinDef > CacheSystem::FetchSkinDef | ( | CacheEntry * | cache_entry | ) |
Loads+parses the .skin file once.
Definition at line 1222 of file CacheSystem.cpp.
|
private |
Definition at line 1050 of file CacheSystem.cpp.
|
private |
Definition at line 707 of file CacheSystem.cpp.
CacheEntry * CacheSystem::FindEntryByFilename | ( | RoR::LoaderType | type, |
bool | partial, | ||
std::string | filename | ||
) |
Returns NULL if none found.
Definition at line 148 of file CacheSystem.cpp.
|
private |
Definition at line 932 of file CacheSystem.cpp.
|
private |
For quick detection of added/removed content.
Definition at line 1044 of file CacheSystem.cpp.
|
inline |
|
inline |
Definition at line 209 of file CacheSystem.h.
CacheEntry * CacheSystem::GetEntry | ( | int | modid | ) |
Definition at line 449 of file CacheSystem.cpp.
String CacheSystem::GetPrettyName | ( | Ogre::String | fname | ) |
|
private |
|
private |
Definition at line 303 of file CacheSystem.cpp.
void CacheSystem::LoadModCache | ( | CacheValidity | validity | ) |
void CacheSystem::LoadResource | ( | CacheEntry & | t | ) |
Loads the associated resource bundle if not already done.
Definition at line 1111 of file CacheSystem.cpp.
|
private |
|
private |
Definition at line 1029 of file CacheSystem.cpp.
|
private |
Definition at line 1006 of file CacheSystem.cpp.
|
private |
Definition at line 983 of file CacheSystem.cpp.
|
private |
Definition at line 335 of file CacheSystem.cpp.
size_t CacheSystem::Query | ( | CacheQuery & | query | ) |
Definition at line 1266 of file CacheSystem.cpp.
void CacheSystem::ReLoadResource | ( | CacheEntry & | t | ) |
Forces reloading the associated bundle.
Definition at line 1175 of file CacheSystem.cpp.
|
private |
Definition at line 924 of file CacheSystem.cpp.
|
staticprivate |
|
staticprivate |
void CacheSystem::UnLoadResource | ( | CacheEntry & | t | ) |
Unloads associated bundle, destroying all spawned actors.
Definition at line 1188 of file CacheSystem.cpp.
|
private |
Definition at line 568 of file CacheSystem.cpp.
|
private |
Definition at line 256 of file CacheSystem.h.
|
private |
Definition at line 253 of file CacheSystem.h.
|
private |
stores hash over the content, for quick update detection
Definition at line 252 of file CacheSystem.h.
|
private |
hash from cachefile, for quick update detection
Definition at line 251 of file CacheSystem.h.
|
private |
the extensions we track in the cache system
Definition at line 254 of file CacheSystem.h.
|
private |
A temporary list of existing resource paths.
Definition at line 255 of file CacheSystem.h.
|
private |
Ensures that all inserted files share the same timestamp.
Definition at line 250 of file CacheSystem.h.