37#include <rapidjson/document.h>
41#define CACHE_FILE "mods.cache"
42#define CACHE_FILE_FORMAT 14
43#define CACHE_FILE_FRESHNESS 86400
354 void AddFile(Ogre::String group, Ogre::FileInfo f, Ogre::String ext);
381 bool Match(
size_t& out_score, std::string data, std::string
const& query,
size_t );
397 {108,
_LC(
"ModCategory",
"Other Land Vehicles")},
399 {146,
_LC(
"ModCategory",
"Street Cars")},
400 {147,
_LC(
"ModCategory",
"Light Racing Cars")},
401 {148,
_LC(
"ModCategory",
"Offroad Cars")},
402 {149,
_LC(
"ModCategory",
"Fantasy Cars")},
403 {150,
_LC(
"ModCategory",
"Bikes")},
404 {155,
_LC(
"ModCategory",
"Crawlers")},
406 {152,
_LC(
"ModCategory",
"Towercranes")},
407 {153,
_LC(
"ModCategory",
"Mobile Cranes")},
408 {154,
_LC(
"ModCategory",
"Other cranes")},
410 {107,
_LC(
"ModCategory",
"Buses")},
411 {151,
_LC(
"ModCategory",
"Tractors")},
412 {156,
_LC(
"ModCategory",
"Forklifts")},
413 {159,
_LC(
"ModCategory",
"Fantasy Trucks")},
414 {160,
_LC(
"ModCategory",
"Transport Trucks")},
415 {161,
_LC(
"ModCategory",
"Racing Trucks")},
416 {162,
_LC(
"ModCategory",
"Offroad Trucks")},
418 {110,
_LC(
"ModCategory",
"Boats")},
420 {113,
_LC(
"ModCategory",
"Helicopters")},
421 {114,
_LC(
"ModCategory",
"Aircraft")},
423 {117,
_LC(
"ModCategory",
"Trailers")},
424 {118,
_LC(
"ModCategory",
"Other Loads")},
427 {129,
_LC(
"ModCategory",
"Addon Terrains")},
429 {859,
_LC(
"ModCategory",
"Container")},
431 {875,
_LC(
"ModCategory",
"Submarine")},
434 {200,
_LC(
"ModCategory",
"Dashboards - Generic")},
435 {201,
_LC(
"ModCategory",
"Dashboards - Truck")},
436 {202,
_LC(
"ModCategory",
"Dashboards - Boat")},
444 {5000,
_LC(
"ModCategory",
"Official Terrains")},
445 {5001,
_LC(
"ModCategory",
"Night Terrains")},
Central state/object manager and communications hub.
Data structures representing 'truck' file format, see https://docs.rigsofrods.org/vehicle-creation/fi...
Core data structures for simulation; Everything affected by by either physics, network or user intera...
Self reference-counting objects, as requred by AngelScript garbage collector.
Terrn2DocumentPtr terrn2_def
Cached terrain definition document.
CacheEntryID_t number
Sequential number, assigned internally, used by Selector-GUI.
std::vector< Ogre::String > sectionconfigs
Ogre::String fname
filename
int version
file's version
Ogre::String fext
file's extension
std::set< std::string > addonpart_guids
GUIDs of all vehicles this addonpart is used with.
Ogre::String fpath
filepath relative to the .zip file
std::string tuneup_associated_filename
Value of 'filename' field in the tuneup file; always lowercase.
int categoryid
category id
TuneupDefPtr addonpart_data_only
Cached addonpart data (dummy tuneup), only used for evaluating conflicts, see AddonPartUtility::Recor...
Ogre::String dname
name parsed from the file
std::vector< AuthorInfo > authors
authors
SkinDocumentPtr skin_def
Cached skin info, added on first use or during cache rebuild.
std::time_t addtimestamp
timestamp when this file was added to the cache
CacheEntry()
default constructor resets the data.
Ogre::String resource_group
Resource group of the loaded bundle. Empty if not loaded yet.
TuneupDefPtr tuneup_def
Cached tuning info, added on first use or during cache rebuild.
std::set< std::string > addonpart_filenames
File names of all vehicles this addonpart is used with. If empty, any filename goes.
int usagecounter
how much it was used already
Ogre::String fname_without_uid
filename
std::string resource_bundle_type
Archive type recognized by OGRE resource system: 'FileSystem' or 'Zip'.
std::string resource_bundle_path
Path of ZIP or directory which contains the media. Shared between CacheEntries, loaded only once.
bool deleted
is this mod deleted?
Ogre::String categoryname
category name
Ogre::String filecachename
preview image filename
RigDef::DocumentPtr actor_def
Cached actor definition (aka truckfile) after first spawn.
std::time_t filetime
filetime
Ogre::String uniqueid
file's unique id
Ogre::String guid
global unique id; Type "addonpart" leaves this empty and uses addonpart_guids; Always lowercase.
A content database MOTIVATION: RoR users usually have A LOT of content installed.
void ReLoadResource(CacheEntryPtr &t)
Forces reloading the associated bundle.
void GenerateFileCache(CacheEntryPtr &entry, Ogre::String group)
void LoadSupplementaryDocuments(CacheEntryPtr &t)
Loads the associated .truck*, .skin and .tuneup files.
std::vector< std::string > m_content_dirs
the various mod directories we track in the cache system
std::vector< Ogre::String > m_known_extensions
the extensions we track in the cache system
void FillTerrainDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname)
void UnLoadResource(CacheEntryPtr &t)
Unloads associated bundle, destroying all spawned actors.
void ParseZipArchives(Ogre::String group)
bool Match(size_t &out_score, std::string data, std::string const &query, size_t)
void RemoveFileCache(CacheEntryPtr &entry)
std::set< Ogre::String > m_resource_paths
A temporary list of existing resource paths.
void ModifyProject(ModifyProjectRequest *request)
std::time_t m_update_time
Ensures that all inserted files share the same timestamp.
const std::vector< CacheEntryPtr > & GetEntries() const
void LoadAssetPack(CacheEntryPtr &t_dest, Ogre::String const &assetpack_filename)
Adds asset pack to the requesting cache entry's resource group.
static Ogre::String StripSHA1fromString(Ogre::String sha1str)
void FillTuneupDetailInfo(CacheEntryPtr &entry, TuneupDefPtr &tuneup_def)
void FillTruckDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname, Ogre::String group)
void FillSkinDetailInfo(CacheEntryPtr &entry, std::shared_ptr< SkinDocument > &skin_def)
void ClearResourceGroups()
std::string m_filenames_hash_loaded
hash from cachefile, for quick update detection
std::vector< CacheEntryPtr > m_entries
bool ParseKnownFiles(Ogre::String group)
void FillGadgetDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
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,...
const CategoryIdNameMap & GetCategories() const
Ogre::String GetPrettyName(Ogre::String fname)
void GenerateHashFromFilenames()
For quick detection of added/removed content.
void ImportEntryFromJson(rapidjson::Value &j_entry, CacheEntryPtr &out_entry)
void DeleteProject(CacheEntryPtr &entry)
void ParseSingleZip(Ogre::String path)
std::string ActorTypeToName(ActorType driveable)
CacheEntryPtr FetchSkinByName(std::string const &skin_name)
static Ogre::String StripUIDfromString(Ogre::String uidstr)
size_t Query(CacheQuery &query)
void LoadAssociatedTuneupDef(CacheEntryPtr &cache_entry)
Loads+parses the .tuneup file and updates all related CacheEntries.
std::map< int, Ogre::String > m_categories
void LoadAssociatedSkinDef(CacheEntryPtr &cache_entry)
Loads+parses the .skin file and updates all related CacheEntries.
void AddFile(Ogre::String group, Ogre::FileInfo f, Ogre::String ext)
void WriteCacheFileJson()
CacheEntryPtr CreateProject(CreateProjectRequest *request)
Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcac...
bool IsPathContentDirRoot(const std::string &path) const
bool IsRepoFileInstalled(const std::string &repo_filename, std::string &out_filepath)
Checks whether a ZIP archive from the online repository is installed in the local modcache.
CacheEntryPtr GetEntryByNumber(int modid)
void FillAddonPartDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
CacheValidity EvaluateCacheValidity()
std::map< int, Ogre::String > CategoryIdNameMap
const std::vector< std::string > & GetContentDirs() const
void ExportEntryToJson(rapidjson::Value &j_entries, rapidjson::Document &j_doc, CacheEntryPtr const &entry)
void FillDashboardDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
std::string m_filenames_hash_generated
stores hash over the content, for quick update detection
void LoadResource(CacheEntryPtr &t)
Loads the associated resource bundle if not already done.
static std::string ComposeResourceGroupName(const CacheEntryPtr &entry)
void FillAssetPackDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
void LoadModCache(CacheValidity validity)
CacheValidity LoadCacheFileJson()
void DeleteResourceBundleByFilename(const std::string &bundle_filename)
Deletes all CacheEntries which share the given resource bundle (ZIP or directory).
ActorType
< Aka 'Driveable'
std::shared_ptr< Document > DocumentPtr
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
@ SAVE_TUNEUP
Dumps .tuneup file with CID_Tuneup from source actor, will not overwrite existing unless explicitly i...
@ DEFAULT
Copy files from source mod. Source mod Determines mod file extension.
@ ACTOR_PROJECT
Like DEFAULT but fixes up name + category in the truckfile.
@ TUNEUP_PROTECTED_WHEEL_RESET
'subject_id' is wheel ID.
@ TUNEUP_FORCED_VCAM_ROLE_RESET
'subject_id' is video camera ID.
@ TUNEUP_FORCEREMOVE_MANAGEDMAT_RESET
'subject' is managed material name.
@ TUNEUP_FORCEREMOVE_FLEXBODY_SET
'subject_id' is flexbody ID.
@ TUNEUP_PROTECTED_WHEEL_SET
'subject_id' is wheel ID.
@ TUNEUP_PROTECTED_MANAGEDMAT_SET
'subject' is managed material name.
@ TUNEUP_FORCEREMOVE_EXHAUST_SET
'subject_id' is exhaust ID.
@ TUNEUP_USE_ADDONPART_RESET
'subject' is addonpart filename.
@ TUNEUP_PROTECTED_PROP_SET
'subject_id' is prop ID.
@ TUNEUP_USE_ADDONPART_SET
'subject' is addonpart filename.
@ TUNEUP_FORCEREMOVE_PROP_SET
'subject_id' is prop ID.
@ TUNEUP_PROTECTED_EXHAUST_SET
'subject_id' is exhaust ID.
@ TUNEUP_PROTECTED_FLARE_SET
'subject_id' is flare ID.
@ TUNEUP_FORCED_WHEEL_SIDE_RESET
'subject_id' is wheel ID.
@ TUNEUP_FORCEREMOVE_MANAGEDMAT_SET
'subject' is managed material name.
@ TUNEUP_PROTECTED_FLEXBODY_RESET
'subject_id' is flexbody ID.
@ TUNEUP_PROTECTED_FLEXBODY_SET
'subject_id' is flexbody ID.
@ TUNEUP_FORCED_WHEEL_SIDE_SET
'subject_id' is wheel ID, 'value_int' is RoR::WheelSide
@ ACTOR_UPDATE_DEF_DOCUMENT
'subject' is empty; 'target_actor' is the actual subject. Propagates modifications from the live acto...
@ TUNEUP_PROTECTED_EXHAUST_RESET
'subject_id' is exhaust ID.
@ TUNEUP_PROTECTED_MANAGEDMAT_RESET
'subject' is managed material name.
@ TUNEUP_FORCED_VCAM_ROLE_SET
'subject_id' is video camera ID, 'value_int' is RoR::VideoCamRole
@ PROJECT_RESET_TUNEUP
'subject' is empty. This resets the auto-generated tuneup to orig. values.
@ TUNEUP_FORCEREMOVE_FLARE_RESET
'subject_id' is flare ID.
@ TUNEUP_PROTECTED_PROP_RESET
'subject_id' is prop ID.
@ TUNEUP_FORCEREMOVE_FLEXBODY_RESET
'subject_id' is flexbody ID.
@ TUNEUP_FORCEREMOVE_PROP_RESET
'subject_id' is prop ID.
@ TUNEUP_PROTECTED_FLARE_RESET
'subject_id' is flare ID.
@ TUNEUP_FORCEREMOVE_EXHAUST_RESET
'subject_id' is exhaust ID.
@ PROJECT_LOAD_TUNEUP
'subject' is tuneup filename. This overwrites the auto-generated tuneup with the save.
@ TUNEUP_FORCEREMOVE_FLARE_SET
'subject_id' is flare ID.
@ AUTHORS
Partial match in: author name/email.
@ FILENAME
Partial match in file name.
@ WHEELS
Wheel configuration, i.e. 4x4.
@ GUID
Partial match in: guid.
@ NONE
Ignore the search string and find all.
@ FULLTEXT
Partial match in: name, filename, description, author name/mail.
std::shared_ptr< Terrn2Document > Terrn2DocumentPtr
int CacheEntryID_t
index to CacheSystem::m_cache_entries, use RoR::CACHEENTRYNUM_INVALID as empty value.
@ CID_Projects
For truck files under 'projects/' directory, to allow listing from editors.
@ CID_Tuneups
For unsorted tuneup files.
RefCountingObjectPtr< CacheEntry > CacheEntryPtr
std::shared_ptr< SkinDocument > SkinDocumentPtr
int cqy_filter_category_id
std::string cqy_filter_target_filename
Exact match (case-insensitive); leave empty to disable (currently only used with addonparts)
std::string cqy_filter_guid
Exact match (case-insensitive); leave empty to disable.
std::map< int, size_t > cqy_res_category_usage
Total usage (ignores search params + category filter)
std::time_t cqy_res_last_update
std::string cqy_search_string
CacheSearchMethod cqy_search_method
std::vector< CacheQueryResult > cqy_results
RoR::LoaderType cqy_filter_type
bool operator<(CacheQueryResult const &other) const
Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcac...
std::string cpr_description
Optional, implemented for tuneups.
CreateProjectRequestType cpr_type
CacheEntryPtr cpr_source_entry
The original mod to copy files from.
std::string cpr_name
Directory and also the mod file (without extension).
ActorPtr cpr_source_actor
Only for type SAVE_TUNEUP
ModifyProjectRequestType mpr_type
ActorPtr mpr_target_actor