RigsofRods
Soft-body Physics Simulation
CacheSystem.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2023 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
26 
27 #pragma once
28 
29 #include "Application.h"
30 #include "Language.h"
31 #include "RefCountingObject.h"
32 #include "RefCountingObjectPtr.h"
33 #include "RigDef_File.h"
34 #include "SimData.h"
35 
36 #include <Ogre.h>
37 #include <rapidjson/document.h>
38 #include <string>
39 #include <set>
40 
41 #define CACHE_FILE "mods.cache"
42 #define CACHE_FILE_FORMAT 14
43 #define CACHE_FILE_FRESHNESS 86400 // 60*60*24 = one day
44 
45 namespace RoR {
46 
47 struct AuthorInfo
48 {
49  int id = -1;
50  Ogre::String type;
51  Ogre::String name;
52  Ogre::String email;
53 };
54 
55 class CacheEntry: public RefCountingObject<CacheEntry>
56 {
57 
58 public:
59 
61  CacheEntry();
62  ~CacheEntry();
63 
65 
66  Ogre::String fpath;
67  Ogre::String fname;
68  Ogre::String fname_without_uid;
69  Ogre::String fext;
70  Ogre::String dname;
71 
72  int categoryid;
73  Ogre::String categoryname;
74 
75  std::time_t addtimestamp;
76  Ogre::String uniqueid;
77  Ogre::String guid;
78  int version;
79 
80  std::string resource_bundle_type;
81  std::string resource_bundle_path;
82 
83  std::time_t filetime;
84  bool deleted;
86  std::vector<AuthorInfo> authors;
87  Ogre::String filecachename;
88 
89  Ogre::String resource_group;
90 
92  std::shared_ptr<RoR::SkinDef> skin_def;
95  // TBD: Make Terrn2Def a RefcountingObjectPtr<> and cache it here too.
96 
97  // following all ADDONPART detail information:
98  std::set<std::string> addonpart_guids;
99  std::set<std::string> addonpart_filenames;
100 
101  // following all TUNEUP detail information:
103 
104  // following all TRUCK detail information:
105  Ogre::String description;
106  Ogre::String tags;
107  std::string default_skin;
127 
128  float truckmass;
129  float loadmass;
130  float minrpm;
131  float maxrpm;
132  float torque;
137  bool rescuer;
138 
140  int numgears;
142  std::vector<Ogre::String> sectionconfigs;
143 };
144 
146 
148 {
149  CID_None = 0,
150 
151  CID_Projects = 8000,
152  CID_Tuneups = 8001,
153 
154  CID_Max = 9000,
155  CID_Unsorted = 9990,
156  CID_All = 9991,
157  CID_Fresh = 9992,
158  CID_Hidden = 9993,
160 };
161 
163 {
164  CacheQueryResult(CacheEntryPtr entry, size_t score);
165 
166  bool operator<(CacheQueryResult const& other) const;
167 
169  size_t cqr_score;
170 };
171 
172 enum class CacheSearchMethod // Always case-insensitive
173 {
174  NONE,
175  FULLTEXT,
176  GUID,
177  AUTHORS,
178  WHEELS,
179  FILENAME
180 };
181 
183 {
186  std::string cqy_filter_guid;
189  std::string cqy_search_string;
190 
191  std::vector<CacheQueryResult> cqy_results;
192  std::map<int, size_t> cqy_res_category_usage;
193  std::time_t cqy_res_last_update = std::time_t();
194 
196  {
197  cqy_results.clear();
198  cqy_res_category_usage.clear();
199  cqy_res_last_update = std::time_t();
200  }
201 };
202 
203 enum class CacheValidity
204 {
205  UNKNOWN,
206  VALID,
207  NEEDS_UPDATE,
209 };
210 
212 {
213  NONE,
214  DEFAULT,
215  SAVE_TUNEUP,
216 };
217 
220 {
223 
224  std::string cpr_name;
225  std::string cpr_description;
230 };
231 
233 {
234  NONE,
263 };
264 
266 {
269 
270  // Subject (either name or ID applies depending on type)
271  std::string mpr_subject; // addonpart
272  int mpr_subject_id = -1; // wheel, prop, flexbody, node
273  int mpr_value_int; // forced wheel side
274 };
275 
289 {
290  friend class ContentManager;
291 public:
292  typedef std::map<int, Ogre::String> CategoryIdNameMap;
293 
294  CacheSystem();
295 
298  void LoadModCache(CacheValidity validity);
299  bool IsModCacheLoaded() { return m_loaded; }
301 
304  CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string& _filename_maybe_bundlequalified);
305  CacheEntryPtr GetEntryByNumber(int modid);
306  CacheEntryPtr FetchSkinByName(std::string const & skin_name);
307  size_t Query(CacheQuery& query);
309 
312  void LoadResource(CacheEntryPtr& t);
313  void ReLoadResource(CacheEntryPtr& t);
314  void UnLoadResource(CacheEntryPtr& t);
316  void LoadAssetPack(CacheEntryPtr& t_dest, Ogre::String const & assetpack_filename);
317 
322  void ModifyProject(ModifyProjectRequest* request);
323  void DeleteProject(CacheEntryPtr& entry);
325 
326  const std::vector<CacheEntryPtr> &GetEntries() const { return m_entries; }
327  const CategoryIdNameMap &GetCategories() const { return m_categories; }
328 
329  Ogre::String GetPrettyName(Ogre::String fname);
330  std::string ActorTypeToName(ActorType driveable);
331 
332  const std::vector<std::string>& GetContentDirs() const { return m_content_dirs; }
333 
334 private:
335 
336  CacheValidity EvaluateCacheValidity(); // Called by `ContentManager` on startup only.
337 
338  void WriteCacheFileJson();
339  void ExportEntryToJson(rapidjson::Value& j_entries, rapidjson::Document& j_doc, CacheEntryPtr const & entry);
341  void ImportEntryFromJson(rapidjson::Value& j_entry, CacheEntryPtr & out_entry);
342 
343  static Ogre::String StripUIDfromString(Ogre::String uidstr);
344  static Ogre::String StripSHA1fromString(Ogre::String sha1str);
345  static std::string ComposeResourceGroupName(const CacheEntryPtr& entry);
346 
347  void ParseZipArchives(Ogre::String group);
348  bool ParseKnownFiles(Ogre::String group); // returns true if no known files are found
349  void ParseSingleZip(Ogre::String path);
350 
351  void ClearCache(); // removes all files from the cache
352  void PruneCache(); // removes modified (or deleted) files from the cache
353  void ClearResourceGroups();
354 
355  void AddFile(Ogre::String group, Ogre::FileInfo f, Ogre::String ext);
356 
357  void DetectDuplicates();
358 
361  void LoadAssociatedSkinDef(CacheEntryPtr& cache_entry);
362  void LoadAssociatedTuneupDef(CacheEntryPtr& cache_entry);
363 
367  void FillTerrainDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname);
368  void FillTruckDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname, Ogre::String group);
369  void FillSkinDetailInfo(CacheEntryPtr &entry, std::shared_ptr<SkinDef>& skin_def);
370  void FillAddonPartDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds);
371  void FillTuneupDetailInfo(CacheEntryPtr &entry, TuneupDefPtr& tuneup_def);
372  void FillAssetPackDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds);
374 
376 
377  void GenerateFileCache(CacheEntryPtr &entry, Ogre::String group);
378  void RemoveFileCache(CacheEntryPtr &entry);
379 
380  bool Match(size_t& out_score, std::string data, std::string const& query, size_t );
381 
382  bool IsPathContentDirRoot(const std::string& path) const;
383 
384  bool m_loaded = false;
385  std::time_t m_update_time;
388  std::vector<CacheEntryPtr> m_entries;
389  std::vector<Ogre::String> m_known_extensions;
390  std::vector<std::string> m_content_dirs;
391  std::set<Ogre::String> m_resource_paths;
392  std::map<int, Ogre::String> m_categories = {
393  // these are the category numbers from the repository. do not modify them!
394 
395  // vehicles
396  {108, _LC("ModCategory", "Other Land Vehicles")},
397 
398  {146, _LC("ModCategory", "Street Cars")},
399  {147, _LC("ModCategory", "Light Racing Cars")},
400  {148, _LC("ModCategory", "Offroad Cars")},
401  {149, _LC("ModCategory", "Fantasy Cars")},
402  {150, _LC("ModCategory", "Bikes")},
403  {155, _LC("ModCategory", "Crawlers")},
404 
405  {152, _LC("ModCategory", "Towercranes")},
406  {153, _LC("ModCategory", "Mobile Cranes")},
407  {154, _LC("ModCategory", "Other cranes")},
408 
409  {107, _LC("ModCategory", "Buses")},
410  {151, _LC("ModCategory", "Tractors")},
411  {156, _LC("ModCategory", "Forklifts")},
412  {159, _LC("ModCategory", "Fantasy Trucks")},
413  {160, _LC("ModCategory", "Transport Trucks")},
414  {161, _LC("ModCategory", "Racing Trucks")},
415  {162, _LC("ModCategory", "Offroad Trucks")},
416 
417  {110, _LC("ModCategory", "Boats")},
418 
419  {113, _LC("ModCategory", "Helicopters")},
420  {114, _LC("ModCategory", "Aircraft")},
421 
422  {117, _LC("ModCategory", "Trailers")},
423  {118, _LC("ModCategory", "Other Loads")},
424 
425  // terrains
426  {129, _LC("ModCategory", "Addon Terrains")},
427 
428  {859, _LC("ModCategory", "Container")},
429 
430  {875, _LC("ModCategory", "Submarine")},
431 
432  // note: these categories are NOT in the repository:
433  {5000, _LC("ModCategory", "Official Terrains")},
434  {5001, _LC("ModCategory", "Night Terrains")},
435 
436  {CID_Projects, _LC("ModCategory", "Projects")},
437  {CID_Tuneups, _LC("ModCategory", "Tuneups")},
438 
439  // do not use category numbers above 9000!
440  {CID_Unsorted, _LC("ModCategory", "Unsorted")},
441  {CID_All, _LC("ModCategory", "All")},
442  {CID_Fresh, _LC("ModCategory", "Fresh")},
443  {CID_Hidden, _LC("ModCategory", "Hidden")},
444  };
445 };
446 
447 } // namespace RoR
RoR::CacheEntryID_t
int CacheEntryID_t
index to CacheSystem::m_cache_entries, use RoR::CACHEENTRYNUM_INVALID as empty value.
Definition: ForwardDeclarations.h:49
RoR::CacheEntry::resource_bundle_type
std::string resource_bundle_type
Archive type recognized by OGRE resource system: 'FileSystem' or 'Zip'.
Definition: CacheSystem.h:80
RoR::CacheEntry::addonpart_guids
std::set< std::string > addonpart_guids
GUIDs of all vehicles this addonpart is used with.
Definition: CacheSystem.h:98
RoR::CacheQueryResult::cqr_score
size_t cqr_score
Definition: CacheSystem.h:169
RoR::CacheSystem::m_known_extensions
std::vector< Ogre::String > m_known_extensions
the extensions we track in the cache system
Definition: CacheSystem.h:389
RoR::CacheSystem::LoadAssetPack
void LoadAssetPack(CacheEntryPtr &t_dest, Ogre::String const &assetpack_filename)
Adds asset pack to the requesting cache entry's resource group.
Definition: CacheSystem.cpp:1304
RoR::CacheSystem::GetEntries
const std::vector< CacheEntryPtr > & GetEntries() const
Definition: CacheSystem.h:326
RoR::CacheSystem::UnLoadResource
void UnLoadResource(CacheEntryPtr &t)
Unloads associated bundle, destroying all spawned actors.
Definition: CacheSystem.cpp:1534
RoR::CacheSystem::CategoryIdNameMap
std::map< int, Ogre::String > CategoryIdNameMap
Definition: CacheSystem.h:292
RoR::CacheSystem::FillTerrainDetailInfo
void FillTerrainDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname)
Definition: CacheSystem.cpp:1177
RoR::ModifyProjectRequest::mpr_subject
std::string mpr_subject
Definition: CacheSystem.h:271
RoR::CID_Unsorted
@ CID_Unsorted
Definition: CacheSystem.h:155
RoR::CacheEntry::categoryid
int categoryid
category id
Definition: CacheSystem.h:72
RoR::CacheEntry::dname
Ogre::String dname
name parsed from the file
Definition: CacheSystem.h:70
RoR::CacheSearchMethod::GUID
@ GUID
Partial match in: guid.
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_PROP_SET
@ TUNEUP_FORCEREMOVE_PROP_SET
'subject_id' is prop ID.
RoR::ModifyProjectRequest::mpr_subject_id
int mpr_subject_id
Definition: CacheSystem.h:272
RoR::CacheEntry::tags
Ogre::String tags
Definition: CacheSystem.h:106
RoR::CreateProjectRequest::cpr_description
std::string cpr_description
Optional, implemented for tuneups.
Definition: CacheSystem.h:225
RoR::CacheEntry::deleted
bool deleted
is this mod deleted?
Definition: CacheSystem.h:84
RoR::CacheSystem::IsModCacheLoaded
bool IsModCacheLoaded()
Definition: CacheSystem.h:299
RoR::CacheSystem::DeleteProject
void DeleteProject(CacheEntryPtr &entry)
Definition: CacheSystem.cpp:2052
RoR::CacheQuery::cqy_filter_category_id
int cqy_filter_category_id
Definition: CacheSystem.h:185
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_FLEXBODY_SET
@ TUNEUP_PROTECTED_FLEXBODY_SET
'subject_id' is flexbody ID.
RoR::CacheEntryPtr
RefCountingObjectPtr< CacheEntry > CacheEntryPtr
Definition: ForwardDeclarations.h:197
RoR::ModifyProjectRequestType
ModifyProjectRequestType
Definition: CacheSystem.h:232
RoR::CacheSearchMethod
CacheSearchMethod
Definition: CacheSystem.h:172
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_PROP_RESET
@ TUNEUP_FORCEREMOVE_PROP_RESET
'subject_id' is prop ID.
RoR::CacheEntry::skin_def
std::shared_ptr< RoR::SkinDef > skin_def
Cached skin info, added on first use or during cache rebuild.
Definition: CacheSystem.h:92
RoR::AuthorInfo::type
Ogre::String type
Definition: CacheSystem.h:50
RoR::CacheEntry::version
int version
file's version
Definition: CacheSystem.h:78
RoR::CacheSystem::ClearResourceGroups
void ClearResourceGroups()
Definition: CacheSystem.cpp:461
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_FLEXBODY_SET
@ TUNEUP_FORCEREMOVE_FLEXBODY_SET
'subject_id' is flexbody ID.
RoR::CacheSystem::RemoveFileCache
void RemoveFileCache(CacheEntryPtr &entry)
Definition: CacheSystem.cpp:1051
RoR::CacheQuery::cqy_search_method
CacheSearchMethod cqy_search_method
Definition: CacheSystem.h:188
RoR::CreateProjectRequestType::NONE
@ NONE
RoR::CreateProjectRequestType::SAVE_TUNEUP
@ SAVE_TUNEUP
Dumps .tuneup file with CID_Tuneup from source actor, will not overwrite existing unless explicitly i...
RoR::CacheSystem::m_update_time
std::time_t m_update_time
Ensures that all inserted files share the same timestamp.
Definition: CacheSystem.h:385
RoR::CreateProjectRequest::~CreateProjectRequest
~CreateProjectRequest()
Definition: CacheSystem.cpp:115
RoR::CacheSystem::LoadModCache
void LoadModCache(CacheValidity validity)
Definition: CacheSystem.cpp:151
RoR::CacheSystem::AddFile
void AddFile(Ogre::String group, Ogre::FileInfo f, Ogre::String ext)
Definition: CacheSystem.cpp:741
RoR::CacheEntry::driveable
ActorType driveable
Definition: CacheSystem.h:139
RoR::CacheEntry::importcommands
bool importcommands
Definition: CacheSystem.h:136
RoR::CacheEntry::number
CacheEntryID_t number
Sequential number, assigned internally, used by Selector-GUI.
Definition: CacheSystem.h:64
RoR::CreateProjectRequest::cpr_type
CreateProjectRequestType cpr_type
Definition: CacheSystem.h:228
RoR::CacheSystem::m_entries
std::vector< CacheEntryPtr > m_entries
Definition: CacheSystem.h:388
RoR::CacheSearchMethod::FILENAME
@ FILENAME
Partial match in file name.
RoR::ModifyProjectRequestType::TUNEUP_USE_ADDONPART_RESET
@ TUNEUP_USE_ADDONPART_RESET
'subject' is addonpart filename.
RoR::CacheEntry::tuneup_def
RoR::TuneupDefPtr tuneup_def
Cached tuning info, added on first use or during cache rebuild.
Definition: CacheSystem.h:93
RoR::CacheQuery
Definition: CacheSystem.h:182
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_WHEEL_RESET
@ TUNEUP_PROTECTED_WHEEL_RESET
'subject_id' is wheel ID.
RoR::CacheSystem::GetEntryByNumber
CacheEntryPtr GetEntryByNumber(int modid)
Definition: CacheSystem.cpp:546
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_FLEXBODY_RESET
@ TUNEUP_PROTECTED_FLEXBODY_RESET
'subject_id' is flexbody ID.
RoR::CID_Projects
@ CID_Projects
For truck files under 'projects/' directory, to allow listing from editors.
Definition: CacheSystem.h:151
RoR::CacheEntry::propwheelcount
int propwheelcount
Definition: CacheSystem.h:116
RoR::CacheEntry::tuneup_associated_filename
std::string tuneup_associated_filename
Value of 'filename' field in the tuneup file; always lowercase.
Definition: CacheSystem.h:102
RoR::CacheSystem::FillAddonPartDetailInfo
void FillAddonPartDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
Definition: CacheSystem.cpp:1217
RoR::CacheEntry::hasSubmeshs
bool hasSubmeshs
Definition: CacheSystem.h:109
RoR::CacheEntry::resource_group
Ogre::String resource_group
Resource group of the loaded bundle. Empty if not loaded yet.
Definition: CacheSystem.h:89
RoR::CacheSystem::ModifyProject
void ModifyProject(ModifyProjectRequest *request)
Definition: CacheSystem.cpp:1843
RoR::ModifyProjectRequestType::TUNEUP_USE_ADDONPART_SET
@ TUNEUP_USE_ADDONPART_SET
'subject' is addonpart filename.
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_EXHAUST_RESET
@ TUNEUP_PROTECTED_EXHAUST_RESET
'subject_id' is exhaust ID.
RoR::CID_None
@ CID_None
Definition: CacheSystem.h:149
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_MANAGEDMAT_SET
@ TUNEUP_PROTECTED_MANAGEDMAT_SET
'subject' is managed material name.
RoR::CreateProjectRequest::CreateProjectRequest
CreateProjectRequest()
Definition: CacheSystem.cpp:110
RoR::CacheEntry::customtach
bool customtach
Definition: CacheSystem.h:133
RoR::CacheEntry::sectionconfigs
std::vector< Ogre::String > sectionconfigs
Definition: CacheSystem.h:142
RoR::CacheSystem::ExportEntryToJson
void ExportEntryToJson(rapidjson::Value &j_entries, rapidjson::Document &j_doc, CacheEntryPtr const &entry)
Definition: CacheSystem.cpp:580
RoR::CacheSystem::StripSHA1fromString
static Ogre::String StripSHA1fromString(Ogre::String sha1str)
Definition: CacheSystem.cpp:733
RoR::CacheSystem::ImportEntryFromJson
void ImportEntryFromJson(rapidjson::Value &j_entry, CacheEntryPtr &out_entry)
Definition: CacheSystem.cpp:294
RoR::CacheEntry::enginetype
char enginetype
Definition: CacheSystem.h:141
RoR::ContentManager
Definition: ContentManager.h:35
Language.h
RoR::CacheEntry::minrpm
float minrpm
Definition: CacheSystem.h:130
RoR::CacheEntry::description
Ogre::String description
Definition: CacheSystem.h:105
RoR::CacheQueryResult::cqr_entry
CacheEntryPtr cqr_entry
Definition: CacheSystem.h:168
RefCountingObjectPtr< TuneupDef >
RoR::CacheSystem::FillSkinDetailInfo
void FillSkinDetailInfo(CacheEntryPtr &entry, std::shared_ptr< SkinDef > &skin_def)
Definition: CacheSystem.cpp:1198
RoR::CacheSystem::PruneCache
void PruneCache()
Definition: CacheSystem.cpp:428
RoR::CacheSystem
A content database MOTIVATION: RoR users usually have A LOT of content installed.
Definition: CacheSystem.h:288
RoR::CreateProjectRequest::cpr_source_entry
CacheEntryPtr cpr_source_entry
The original mod to copy files from.
Definition: CacheSystem.h:226
RoR::CreateProjectRequest::cpr_name
std::string cpr_name
Directory and also the mod file (without extension).
Definition: CacheSystem.h:224
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_MANAGEDMAT_SET
@ TUNEUP_FORCEREMOVE_MANAGEDMAT_SET
'subject' is managed material name.
RoR::CacheSystem::IsPathContentDirRoot
bool IsPathContentDirRoot(const std::string &path) const
Definition: CacheSystem.cpp:1420
RoR::CacheEntry::forwardcommands
bool forwardcommands
Definition: CacheSystem.h:135
RoR::CacheSearchMethod::NONE
@ NONE
Ignore the search string and find all.
RoR::CacheEntry::beamcount
int beamcount
Definition: CacheSystem.h:111
RoR::CacheEntry::addonpart_filenames
std::set< std::string > addonpart_filenames
File names of all vehicles this addonpart is used with. If empty, any filename goes.
Definition: CacheSystem.h:99
RoR::CacheQueryResult::operator<
bool operator<(CacheQueryResult const &other) const
Definition: CacheSystem.cpp:2243
RoR::CacheSystem::LoadCacheFileJson
CacheValidity LoadCacheFileJson()
Definition: CacheSystem.cpp:396
RoR::CacheEntry::shockcount
int shockcount
Definition: CacheSystem.h:112
RoR::ModifyProjectRequestType::TUNEUP_FORCED_WHEEL_SIDE_SET
@ TUNEUP_FORCED_WHEEL_SIDE_SET
'subject_id' is wheel ID, 'value_int' is RoR::WheelSide
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_FLARE_RESET
@ TUNEUP_PROTECTED_FLARE_RESET
'subject_id' is flare ID.
RoR::CacheQuery::cqy_res_category_usage
std::map< int, size_t > cqy_res_category_usage
Total usage (ignores search params + category filter)
Definition: CacheSystem.h:192
RoR::CacheSystem::LoadAssociatedSkinDef
void LoadAssociatedSkinDef(CacheEntryPtr &cache_entry)
Loads+parses the .skin file and updates all related CacheEntries.
Definition: CacheSystem.cpp:1572
RoR::CacheSearchMethod::AUTHORS
@ AUTHORS
Partial match in: author name/email.
RoR::CacheEntry::rotatorscount
int rotatorscount
Definition: CacheSystem.h:123
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_FLARE_RESET
@ TUNEUP_FORCEREMOVE_FLARE_RESET
'subject_id' is flare ID.
RoR::CacheEntry::soundsourcescount
int soundsourcescount
Definition: CacheSystem.h:126
RoR::CacheSystem::FillTruckDetailInfo
void FillTruckDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname, Ogre::String group)
Definition: CacheSystem.cpp:833
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_FLARE_SET
@ TUNEUP_PROTECTED_FLARE_SET
'subject_id' is flare ID.
RoR::CacheEntry::torque
float torque
Definition: CacheSystem.h:132
RoR::CacheSystem::FindEntryByFilename
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,...
Definition: CacheSystem.cpp:184
RoR::CacheSystem::ClearCache
void ClearCache()
Definition: CacheSystem.cpp:709
SimData.h
Core data structures for simulation; Everything affected by by either physics, network or user intera...
RoR::CacheEntry::CacheEntry
CacheEntry()
default constructor resets the data.
Definition: CacheSystem.cpp:62
RoR::CacheSystem::Match
bool Match(size_t &out_score, std::string data, std::string const &query, size_t)
Definition: CacheSystem.cpp:2228
RoR::CacheEntry::authors
std::vector< AuthorInfo > authors
authors
Definition: CacheSystem.h:86
RoR::CacheEntry::filecachename
Ogre::String filecachename
preview image filename
Definition: CacheSystem.h:87
RoR::CacheSystem::ParseZipArchives
void ParseZipArchives(Ogre::String group)
Definition: CacheSystem.cpp:1110
RoR::CacheEntry::propscount
int propscount
Definition: CacheSystem.h:119
RoR::CacheSystem::DetectDuplicates
void DetectDuplicates()
Definition: CacheSystem.cpp:474
RoR::CacheValidity
CacheValidity
Definition: CacheSystem.h:203
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_EXHAUST_SET
@ TUNEUP_PROTECTED_EXHAUST_SET
'subject_id' is exhaust ID.
RoR::CacheSystem::GetCategories
const CategoryIdNameMap & GetCategories() const
Definition: CacheSystem.h:327
RoR::CacheQueryResult
Definition: CacheSystem.h:162
RoR::CacheSystem::GetContentDirs
const std::vector< std::string > & GetContentDirs() const
Definition: CacheSystem.h:332
RoR::CacheEntry::addtimestamp
std::time_t addtimestamp
timestamp when this file was added to the cache
Definition: CacheSystem.h:75
RoR::CreateProjectRequestType
CreateProjectRequestType
Definition: CacheSystem.h:211
RoR::CacheEntry::~CacheEntry
~CacheEntry()
Definition: CacheSystem.cpp:105
RoR::AuthorInfo::email
Ogre::String email
Definition: CacheSystem.h:52
RoR::CacheSystem::ParseSingleZip
void ParseSingleZip(Ogre::String path)
Definition: CacheSystem.cpp:1133
RoR::CID_Hidden
@ CID_Hidden
Definition: CacheSystem.h:158
RoR::CacheSystem::FillTuneupDetailInfo
void FillTuneupDetailInfo(CacheEntryPtr &entry, TuneupDefPtr &tuneup_def)
Definition: CacheSystem.cpp:1283
RoR::CacheSystem::LoadAssociatedTuneupDef
void LoadAssociatedTuneupDef(CacheEntryPtr &cache_entry)
Loads+parses the .tuneup file and updates all related CacheEntries.
Definition: CacheSystem.cpp:1621
RoR::CacheSystem::GetPrettyName
Ogre::String GetPrettyName(Ogre::String fname)
Definition: CacheSystem.cpp:556
RoR::CacheSystem::ParseKnownFiles
bool ParseKnownFiles(Ogre::String group)
Definition: CacheSystem.cpp:1156
RoR::CacheEntry::actor_def
RigDef::DocumentPtr actor_def
Cached actor definition (aka truckfile) after first spawn.
Definition: CacheSystem.h:91
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_MANAGEDMAT_RESET
@ TUNEUP_FORCEREMOVE_MANAGEDMAT_RESET
'subject' is managed material name.
RoR::CID_SearchResults
@ CID_SearchResults
Definition: CacheSystem.h:159
RoR::CacheEntry::fpath
Ogre::String fpath
filepath relative to the .zip file
Definition: CacheSystem.h:66
RoR::CacheSearchMethod::FULLTEXT
@ FULLTEXT
Partial match in: name, filename, description, author name/mail.
RoR::CacheSearchMethod::WHEELS
@ WHEELS
Wheel configuration, i.e. 4x4.
RoR::CacheValidity::UNKNOWN
@ UNKNOWN
RefCountingObject.h
RoR::CacheCategoryId
CacheCategoryId
Definition: CacheSystem.h:147
RoR::LoaderType
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
Definition: Application.h:289
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_EXHAUST_RESET
@ TUNEUP_FORCEREMOVE_EXHAUST_RESET
'subject_id' is exhaust ID.
RoR::CacheEntry::rescuer
bool rescuer
Definition: CacheSystem.h:137
RoR::ModifyProjectRequest::mpr_target_actor
ActorPtr mpr_target_actor
Definition: CacheSystem.h:267
Application.h
Central state/object manager and communications hub.
RoR::CacheSystem::m_filenames_hash_loaded
std::string m_filenames_hash_loaded
hash from cachefile, for quick update detection
Definition: CacheSystem.h:386
RoR::CacheQueryResult::CacheQueryResult
CacheQueryResult(CacheEntryPtr entry, size_t score)
Definition: CacheSystem.cpp:120
RoR::CacheQuery::cqy_search_string
std::string cqy_search_string
Definition: CacheSystem.h:189
RoR::CacheSystem::m_content_dirs
std::vector< std::string > m_content_dirs
the various mod directories we track in the cache system
Definition: CacheSystem.h:390
RoR::CacheSystem::m_categories
std::map< int, Ogre::String > m_categories
Definition: CacheSystem.h:392
RoR::CacheEntry
Definition: CacheSystem.h:55
RoR::CacheSystem::m_filenames_hash_generated
std::string m_filenames_hash_generated
stores hash over the content, for quick update detection
Definition: CacheSystem.h:387
RoR::CacheQuery::cqy_res_last_update
std::time_t cqy_res_last_update
Definition: CacheSystem.h:193
RoR::CacheSystem::GenerateFileCache
void GenerateFileCache(CacheEntryPtr &entry, Ogre::String group)
Definition: CacheSystem.cpp:1059
RoR::CacheEntry::uniqueid
Ogre::String uniqueid
file's unique id
Definition: CacheSystem.h:76
RoR::CacheSystem::EvaluateCacheValidity
CacheValidity EvaluateCacheValidity()
Definition: CacheSystem.cpp:256
RoR::AuthorInfo
Definition: CacheSystem.h:47
RoR::ModifyProjectRequest::mpr_value_int
int mpr_value_int
Definition: CacheSystem.h:273
RoR::CacheEntry::loadmass
float loadmass
Definition: CacheSystem.h:129
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_EXHAUST_SET
@ TUNEUP_FORCEREMOVE_EXHAUST_SET
'subject_id' is exhaust ID.
RoR::CacheEntry::fixescount
int fixescount
Definition: CacheSystem.h:113
_LC
#define _LC(ctx, str)
Definition: Language.h:42
RoR::CacheSystem::CreateProject
CacheEntryPtr CreateProject(CreateProjectRequest *request)
Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcac...
Definition: CacheSystem.cpp:1670
RoR::CacheSystem::LoadSupplementaryDocuments
void LoadSupplementaryDocuments(CacheEntryPtr &t)
Loads the associated .truck*, .skin and .tuneup files.
Definition: CacheSystem.cpp:1399
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_FLARE_SET
@ TUNEUP_FORCEREMOVE_FLARE_SET
'subject_id' is flare ID.
RoR::CacheQuery::resetResults
void resetResults()
Definition: CacheSystem.h:195
RoR::ModifyProjectRequest
Definition: CacheSystem.h:265
RoR::CID_Fresh
@ CID_Fresh
Definition: CacheSystem.h:157
RoR::CreateProjectRequest
Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcac...
Definition: CacheSystem.h:219
RoR::ModifyProjectRequestType::PROJECT_LOAD_TUNEUP
@ PROJECT_LOAD_TUNEUP
'subject' is tuneup filename. This overwrites the auto-generated tuneup with the save.
RoR::CacheSystem::ActorTypeToName
std::string ActorTypeToName(ActorType driveable)
Definition: CacheSystem.cpp:566
RoR::CacheEntry::fileformatversion
int fileformatversion
Definition: CacheSystem.h:108
RoR::CacheEntry::numgears
int numgears
Definition: CacheSystem.h:140
RoR::CacheSystem::ComposeResourceGroupName
static std::string ComposeResourceGroupName(const CacheEntryPtr &entry)
Definition: CacheSystem.cpp:1378
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_PROP_SET
@ TUNEUP_PROTECTED_PROP_SET
'subject_id' is prop ID.
RoR::CreateProjectRequest::cpr_source_actor
ActorPtr cpr_source_actor
Only for type SAVE_TUNEUP
Definition: CacheSystem.h:227
RoR::ModifyProjectRequestType::NONE
@ NONE
RoR::CacheValidity::VALID
@ VALID
RoR::CacheSystem::FetchSkinByName
CacheEntryPtr FetchSkinByName(std::string const &skin_name)
Definition: CacheSystem.cpp:1560
RoR::CacheValidity::NEEDS_REBUILD
@ NEEDS_REBUILD
RoR::CID_Tuneups
@ CID_Tuneups
For unsorted tuneup files.
Definition: CacheSystem.h:152
RoR::CacheEntry::usagecounter
int usagecounter
how much it was used already
Definition: CacheSystem.h:85
RoR::CacheValidity::NEEDS_UPDATE
@ NEEDS_UPDATE
RoR::CacheEntry::fext
Ogre::String fext
file's extension
Definition: CacheSystem.h:69
RoR::CacheQuery::cqy_filter_type
RoR::LoaderType cqy_filter_type
Definition: CacheSystem.h:184
RoR::CacheSystem::LoadResource
void LoadResource(CacheEntryPtr &t)
Loads the associated resource bundle if not already done.
Definition: CacheSystem.cpp:1435
RoR::CacheSystem::WriteCacheFileJson
void WriteCacheFileJson()
Definition: CacheSystem.cpp:683
RoR::CacheEntry::wheelcount
int wheelcount
Definition: CacheSystem.h:115
RoR::CID_Max
@ CID_Max
SPECIAL VALUE - Maximum allowed to be present in any mod files.
Definition: CacheSystem.h:154
RoR::LT_None
@ LT_None
Definition: Application.h:291
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_FLEXBODY_RESET
@ TUNEUP_FORCEREMOVE_FLEXBODY_RESET
'subject_id' is flexbody ID.
RoR::CacheEntry::nodecount
int nodecount
Definition: CacheSystem.h:110
RoR::CreateProjectRequest::cpr_overwrite
bool cpr_overwrite
Definition: CacheSystem.h:229
RoR::CacheEntry::resource_bundle_path
std::string resource_bundle_path
Path of ZIP or directory which contains the media. Shared between CacheEntries, loaded only once.
Definition: CacheSystem.h:81
RoR::CacheEntry::flexbodiescount
int flexbodiescount
Definition: CacheSystem.h:125
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_PROP_RESET
@ TUNEUP_PROTECTED_PROP_RESET
'subject_id' is prop ID.
RoR::CacheEntry::wingscount
int wingscount
Definition: CacheSystem.h:120
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_MANAGEDMAT_RESET
@ TUNEUP_PROTECTED_MANAGEDMAT_RESET
'subject' is managed material name.
RoR::CacheSystem::ReLoadResource
void ReLoadResource(CacheEntryPtr &t)
Forces reloading the associated bundle.
Definition: CacheSystem.cpp:1521
RoR::CacheEntry::categoryname
Ogre::String categoryname
category name
Definition: CacheSystem.h:73
RefCountingObjectPtr.h
RoR::CacheEntry::exhaustscount
int exhaustscount
Definition: CacheSystem.h:124
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_WHEEL_SET
@ TUNEUP_PROTECTED_WHEEL_SET
'subject_id' is wheel ID.
RoR::CacheEntry::truckmass
float truckmass
Definition: CacheSystem.h:128
RoR::CacheEntry::maxrpm
float maxrpm
Definition: CacheSystem.h:131
RoR::ModifyProjectRequestType::PROJECT_RESET_TUNEUP
@ PROJECT_RESET_TUNEUP
'subject' is empty. This resets the auto-generated tuneup to orig. values.
RoR::CacheSystem::CacheSystem
CacheSystem()
Definition: CacheSystem.cpp:125
RoR::CacheEntry::turbopropscount
int turbopropscount
Definition: CacheSystem.h:121
RoR::CacheQuery::cqy_filter_guid
std::string cqy_filter_guid
Exact match (case-insensitive); leave empty to disable.
Definition: CacheSystem.h:186
RoR::CacheEntry::turbojetcount
int turbojetcount
Definition: CacheSystem.h:122
RigDef::DocumentPtr
std::shared_ptr< Document > DocumentPtr
Definition: RigDef_Prerequisites.h:38
RoR::CacheEntry::hydroscount
int hydroscount
Definition: CacheSystem.h:114
RefCountingObject
Self reference-counting objects, as requred by AngelScript garbage collector.
Definition: RefCountingObject.h:26
RoR::ModifyProjectRequest::mpr_type
ModifyProjectRequestType mpr_type
Definition: CacheSystem.h:268
RoR::ActorType
ActorType
< Aka 'Driveable'
Definition: SimData.h:88
RoR::ModifyProjectRequestType::TUNEUP_FORCED_WHEEL_SIDE_RESET
@ TUNEUP_FORCED_WHEEL_SIDE_RESET
'subject_id' is wheel ID.
RoR::CacheEntry::filetime
std::time_t filetime
filetime
Definition: CacheSystem.h:83
RoR::CacheSystem::FillAssetPackDetailInfo
void FillAssetPackDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
Definition: CacheSystem.cpp:1251
RoR::CacheEntry::custom_particles
bool custom_particles
Definition: CacheSystem.h:134
RoR::CreateProjectRequestType::DEFAULT
@ DEFAULT
Copy files from source mod. Source mod Determines mod file extension.
RoR::CID_All
@ CID_All
Definition: CacheSystem.h:156
RoR::AuthorInfo::name
Ogre::String name
Definition: CacheSystem.h:51
RoR::CacheQuery::cqy_filter_target_filename
std::string cqy_filter_target_filename
Exact match (case-insensitive); leave empty to disable (currently only used with addonparts)
Definition: CacheSystem.h:187
RoR::CacheEntry::commandscount
int commandscount
Definition: CacheSystem.h:117
RigDef_File.h
Data structures representing 'truck' file format, see https://docs.rigsofrods.org/vehicle-creation/fi...
RoR
Definition: AppContext.h:36
RoR::CacheSystem::Query
size_t Query(CacheQuery &query)
Definition: CacheSystem.cpp:2090
RoR::CacheEntry::addonpart_data_only
RoR::TuneupDefPtr addonpart_data_only
Cached addonpart data (dummy tuneup), only used for evaluating conflicts, see AddonPartUtility::Recor...
Definition: CacheSystem.h:94
RoR::CacheQuery::cqy_results
std::vector< CacheQueryResult > cqy_results
Definition: CacheSystem.h:191
RoR::CacheEntry::default_skin
std::string default_skin
Definition: CacheSystem.h:107
RoR::CacheSystem::GenerateHashFromFilenames
void GenerateHashFromFilenames()
For quick detection of added/removed content.
Definition: CacheSystem.cpp:1171
RoR::CacheEntry::guid
Ogre::String guid
global unique id; Type "addonpart" leaves this empty and uses addonpart_guids; Always lowercase.
Definition: CacheSystem.h:77
RoR::CacheSystem::m_resource_paths
std::set< Ogre::String > m_resource_paths
A temporary list of existing resource paths.
Definition: CacheSystem.h:391
RoR::CacheEntry::flarescount
int flarescount
Definition: CacheSystem.h:118
RoR::CacheSystem::m_loaded
bool m_loaded
Definition: CacheSystem.h:384
RoR::CacheSystem::StripUIDfromString
static Ogre::String StripUIDfromString(Ogre::String uidstr)
Definition: CacheSystem.cpp:725
RoR::CacheEntry::fname
Ogre::String fname
filename
Definition: CacheSystem.h:67
RoR::CacheEntry::fname_without_uid
Ogre::String fname_without_uid
filename
Definition: CacheSystem.h:68