RigsofRods
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
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  CacheQueryResult(CacheEntryPtr entry, size_t score);
150 
151  bool operator<(CacheQueryResult const& other) const;
152 
154  size_t cqr_score;
155 };
156 
157 enum class CacheSearchMethod // Always case-insensitive
158 {
159  NONE,
160  FULLTEXT,
161  GUID,
162  AUTHORS,
163  WHEELS,
164  FILENAME
165 };
166 
168 {
171  std::string cqy_filter_guid;
174  std::string cqy_search_string;
175 
176  std::vector<CacheQueryResult> cqy_results;
177  std::map<int, size_t> cqy_res_category_usage;
178  std::time_t cqy_res_last_update = std::time_t();
179 
181  {
182  cqy_results.clear();
183  cqy_res_category_usage.clear();
184  cqy_res_last_update = std::time_t();
185  }
186 };
187 
188 enum class CacheValidity
189 {
190  UNKNOWN,
191  VALID,
192  NEEDS_UPDATE,
194 };
195 
197 {
198  NONE,
199  DEFAULT,
200  SAVE_TUNEUP,
201  ACTOR_PROJECT,
202 };
203 
206 {
209 
210  std::string cpr_name;
211  std::string cpr_description;
215  bool cpr_overwrite = false;
216 };
217 
219 {
220  NONE,
252 };
253 
255 {
258 
259  // Subject (either name or ID applies depending on type)
260  std::string mpr_subject; // addonpart
261  int mpr_subject_id = -1; // wheel, prop, flexbody, node
262  int mpr_value_int; // forced wheel side
263 };
264 
278 {
279  friend class ContentManager;
280 public:
281  typedef std::map<int, Ogre::String> CategoryIdNameMap;
282 
283  CacheSystem();
284 
287  void LoadModCache(CacheValidity validity);
288  bool IsModCacheLoaded() { return m_loaded; }
290 
293  CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string& _filename_maybe_bundlequalified);
294  CacheEntryPtr GetEntryByNumber(int modid);
295  CacheEntryPtr FetchSkinByName(std::string const & skin_name);
296  size_t Query(CacheQuery& query);
298 
301  void LoadResource(CacheEntryPtr& t);
302  void ReLoadResource(CacheEntryPtr& t);
303  void UnLoadResource(CacheEntryPtr& t);
305  void LoadAssetPack(CacheEntryPtr& t_dest, Ogre::String const & assetpack_filename);
306 
311  void ModifyProject(ModifyProjectRequest* request);
312  void DeleteProject(CacheEntryPtr& entry);
314 
315  const std::vector<CacheEntryPtr> &GetEntries() const { return m_entries; }
316  const CategoryIdNameMap &GetCategories() const { return m_categories; }
317 
318  Ogre::String GetPrettyName(Ogre::String fname);
319  std::string ActorTypeToName(ActorType driveable);
320 
321  const std::vector<std::string>& GetContentDirs() const { return m_content_dirs; }
322 
323 private:
324 
325  CacheValidity EvaluateCacheValidity(); // Called by `ContentManager` on startup only.
326 
327  void WriteCacheFileJson();
328  void ExportEntryToJson(rapidjson::Value& j_entries, rapidjson::Document& j_doc, CacheEntryPtr const & entry);
330  void ImportEntryFromJson(rapidjson::Value& j_entry, CacheEntryPtr & out_entry);
331 
332  static Ogre::String StripUIDfromString(Ogre::String uidstr);
333  static Ogre::String StripSHA1fromString(Ogre::String sha1str);
334  static std::string ComposeResourceGroupName(const CacheEntryPtr& entry);
335 
336  void ParseZipArchives(Ogre::String group);
337  bool ParseKnownFiles(Ogre::String group); // returns true if no known files are found
338  void ParseSingleZip(Ogre::String path);
339 
340  void ClearCache(); // removes all files from the cache
341  void PruneCache(); // removes modified (or deleted) files from the cache
342  void ClearResourceGroups();
343 
344  void AddFile(Ogre::String group, Ogre::FileInfo f, Ogre::String ext);
345 
346  void DetectDuplicates();
347 
350  void LoadAssociatedSkinDef(CacheEntryPtr& cache_entry);
351  void LoadAssociatedTuneupDef(CacheEntryPtr& cache_entry);
352 
356  void FillTerrainDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname);
357  void FillTruckDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname, Ogre::String group);
358  void FillSkinDetailInfo(CacheEntryPtr &entry, std::shared_ptr<SkinDocument>& skin_def);
359  void FillAddonPartDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds);
360  void FillTuneupDetailInfo(CacheEntryPtr &entry, TuneupDefPtr& tuneup_def);
361  void FillAssetPackDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds);
362  void FillDashboardDetailInfo(CacheEntryPtr& entry, Ogre::DataStreamPtr ds);
363  void FillGadgetDetailInfo(CacheEntryPtr& entry, Ogre::DataStreamPtr ds);
365 
367 
368  void GenerateFileCache(CacheEntryPtr &entry, Ogre::String group);
369  void RemoveFileCache(CacheEntryPtr &entry);
370 
371  bool Match(size_t& out_score, std::string data, std::string const& query, size_t );
372 
373  bool IsPathContentDirRoot(const std::string& path) const;
374 
375  bool m_loaded = false;
376  std::time_t m_update_time;
379  std::vector<CacheEntryPtr> m_entries;
380  std::vector<Ogre::String> m_known_extensions;
381  std::vector<std::string> m_content_dirs;
382  std::set<Ogre::String> m_resource_paths;
383  std::map<int, Ogre::String> m_categories = {
384  // these are the category numbers from the repository. do not modify them!
385 
386  // vehicles
387  {108, _LC("ModCategory", "Other Land Vehicles")},
388 
389  {146, _LC("ModCategory", "Street Cars")},
390  {147, _LC("ModCategory", "Light Racing Cars")},
391  {148, _LC("ModCategory", "Offroad Cars")},
392  {149, _LC("ModCategory", "Fantasy Cars")},
393  {150, _LC("ModCategory", "Bikes")},
394  {155, _LC("ModCategory", "Crawlers")},
395 
396  {152, _LC("ModCategory", "Towercranes")},
397  {153, _LC("ModCategory", "Mobile Cranes")},
398  {154, _LC("ModCategory", "Other cranes")},
399 
400  {107, _LC("ModCategory", "Buses")},
401  {151, _LC("ModCategory", "Tractors")},
402  {156, _LC("ModCategory", "Forklifts")},
403  {159, _LC("ModCategory", "Fantasy Trucks")},
404  {160, _LC("ModCategory", "Transport Trucks")},
405  {161, _LC("ModCategory", "Racing Trucks")},
406  {162, _LC("ModCategory", "Offroad Trucks")},
407 
408  {110, _LC("ModCategory", "Boats")},
409 
410  {113, _LC("ModCategory", "Helicopters")},
411  {114, _LC("ModCategory", "Aircraft")},
412 
413  {117, _LC("ModCategory", "Trailers")},
414  {118, _LC("ModCategory", "Other Loads")},
415 
416  // terrains
417  {129, _LC("ModCategory", "Addon Terrains")},
418 
419  {859, _LC("ModCategory", "Container")},
420 
421  {875, _LC("ModCategory", "Submarine")},
422 
423  // dashboards
424  {200, _LC("ModCategory", "Dashboards - Generic")},
425  {201, _LC("ModCategory", "Dashboards - Truck")},
426  {202, _LC("ModCategory", "Dashboards - Boat")},
427 
428  // gadgets
429  {CID_GadgetsGeneric, _LC("ModCategory", "Gadgets - Generic")},
430  {CID_GadgetsActor, _LC("ModCategory", "Gadgets - Actor")},
431  {CID_GadgetsTerrain, _LC("ModCategory", "Gadgets - Terrain")},
432 
433  // note: these categories are NOT in the repository:
434  {5000, _LC("ModCategory", "Official Terrains")},
435  {5001, _LC("ModCategory", "Night Terrains")},
436 
437  {CID_Projects, _LC("ModCategory", "Projects")},
438  {CID_Tuneups, _LC("ModCategory", "Tuneups")},
439 
440  // do not use category numbers above 9000!
441  {CID_Unsorted, _LC("ModCategory", "Unsorted")},
442  {CID_All, _LC("ModCategory", "All")},
443  {CID_Fresh, _LC("ModCategory", "Fresh")},
444  {CID_Hidden, _LC("ModCategory", "Hidden")},
445  };
446 };
447 
448 } // namespace RoR
RoR::CacheEntryID_t
int CacheEntryID_t
index to CacheSystem::m_cache_entries, use RoR::CACHEENTRYNUM_INVALID as empty value.
Definition: ForwardDeclarations.h:51
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:154
RoR::CacheSystem::m_known_extensions
std::vector< Ogre::String > m_known_extensions
the extensions we track in the cache system
Definition: CacheSystem.h:380
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:1407
RoR::CacheSystem::GetEntries
const std::vector< CacheEntryPtr > & GetEntries() const
Definition: CacheSystem.h:315
RoR::CacheSystem::UnLoadResource
void UnLoadResource(CacheEntryPtr &t)
Unloads associated bundle, destroying all spawned actors.
Definition: CacheSystem.cpp:1647
RoR::CacheSystem::CategoryIdNameMap
std::map< int, Ogre::String > CategoryIdNameMap
Definition: CacheSystem.h:281
RoR::CacheSystem::FillTerrainDetailInfo
void FillTerrainDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds, Ogre::String fname)
Definition: CacheSystem.cpp:1192
RoR::ModifyProjectRequest::mpr_subject
std::string mpr_subject
Definition: CacheSystem.h:260
RoR::CID_Unsorted
@ CID_Unsorted
Definition: Application.h:493
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:261
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:211
RoR::CacheEntry::deleted
bool deleted
is this mod deleted?
Definition: CacheSystem.h:84
RoR::CacheSystem::IsModCacheLoaded
bool IsModCacheLoaded()
Definition: CacheSystem.h:288
RoR::CacheSystem::DeleteProject
void DeleteProject(CacheEntryPtr &entry)
Definition: CacheSystem.cpp:2256
RoR::CacheSystem::FillDashboardDetailInfo
void FillDashboardDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
Definition: CacheSystem.cpp:1303
RoR::CacheQuery::cqy_filter_category_id
int cqy_filter_category_id
Definition: CacheSystem.h:170
RoR::CacheEntry::tuneup_def
TuneupDefPtr tuneup_def
Cached tuning info, added on first use or during cache rebuild.
Definition: CacheSystem.h:93
RoR::CacheSystem::FillGadgetDetailInfo
void FillGadgetDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
Definition: CacheSystem.cpp:1340
RoR::ModifyProjectRequestType::TUNEUP_FORCED_VCAM_ROLE_RESET
@ TUNEUP_FORCED_VCAM_ROLE_RESET
'subject_id' is video camera ID.
RoR::ModifyProjectRequestType::TUNEUP_PROTECTED_FLEXBODY_SET
@ TUNEUP_PROTECTED_FLEXBODY_SET
'subject_id' is flexbody ID.
RoR::CacheEntryPtr
RefCountingObjectPtr< CacheEntry > CacheEntryPtr
Definition: ForwardDeclarations.h:229
RoR::ModifyProjectRequestType
ModifyProjectRequestType
Definition: CacheSystem.h:218
RoR::CacheSearchMethod
CacheSearchMethod
Definition: CacheSystem.h:157
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_PROP_RESET
@ TUNEUP_FORCEREMOVE_PROP_RESET
'subject_id' is prop ID.
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:464
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:1066
RoR::CacheQuery::cqy_search_method
CacheSearchMethod cqy_search_method
Definition: CacheSystem.h:173
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:376
RoR::CreateProjectRequest::~CreateProjectRequest
~CreateProjectRequest()
Definition: CacheSystem.cpp:115
RoR::CacheSystem::LoadModCache
void LoadModCache(CacheValidity validity)
Definition: CacheSystem.cpp:153
RoR::CacheSystem::AddFile
void AddFile(Ogre::String group, Ogre::FileInfo f, Ogre::String ext)
Definition: CacheSystem.cpp:744
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:214
RoR::CacheSystem::m_entries
std::vector< CacheEntryPtr > m_entries
Definition: CacheSystem.h:379
RoR::CacheSearchMethod::FILENAME
@ FILENAME
Partial match in file name.
RoR::ModifyProjectRequestType::TUNEUP_USE_ADDONPART_RESET
@ TUNEUP_USE_ADDONPART_RESET
'subject' is addonpart filename.
RoR::CacheQuery
Definition: CacheSystem.h:167
RoR::ModifyProjectRequestType::ACTOR_UPDATE_DEF_DOCUMENT
@ ACTOR_UPDATE_DEF_DOCUMENT
'subject' is empty; 'target_actor' is the actual subject. Propagates modifications from the live acto...
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:549
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: Application.h:489
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:1237
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:2015
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_GadgetsActor
@ CID_GadgetsActor
Definition: Application.h:486
RoR::CacheEntry::addonpart_data_only
TuneupDefPtr addonpart_data_only
Cached addonpart data (dummy tuneup), only used for evaluating conflicts, see AddonPartUtility::Recor...
Definition: CacheSystem.h:94
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:583
RoR::CacheSystem::StripSHA1fromString
static Ogre::String StripSHA1fromString(Ogre::String sha1str)
Definition: CacheSystem.cpp:736
RoR::CacheSystem::ImportEntryFromJson
void ImportEntryFromJson(rapidjson::Value &j_entry, CacheEntryPtr &out_entry)
Definition: CacheSystem.cpp:297
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::Terrn2DocumentPtr
std::shared_ptr< Terrn2Document > Terrn2DocumentPtr
Definition: ForwardDeclarations.h:226
RoR::CacheEntry::description
Ogre::String description
Definition: CacheSystem.h:105
RoR::CacheQueryResult::cqr_entry
CacheEntryPtr cqr_entry
Definition: CacheSystem.h:153
RefCountingObjectPtr< TuneupDef >
RoR::CacheSystem::PruneCache
void PruneCache()
Definition: CacheSystem.cpp:431
RoR::CacheSystem
A content database MOTIVATION: RoR users usually have A LOT of content installed.
Definition: CacheSystem.h:277
RoR::CreateProjectRequest::cpr_source_entry
CacheEntryPtr cpr_source_entry
The original mod to copy files from.
Definition: CacheSystem.h:212
RoR::CreateProjectRequest::cpr_name
std::string cpr_name
Directory and also the mod file (without extension).
Definition: CacheSystem.h:210
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:1523
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:2451
RoR::CacheSystem::LoadCacheFileJson
CacheValidity LoadCacheFileJson()
Definition: CacheSystem.cpp:399
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:177
RoR::CacheSystem::LoadAssociatedSkinDef
void LoadAssociatedSkinDef(CacheEntryPtr &cache_entry)
Loads+parses the .skin file and updates all related CacheEntries.
Definition: CacheSystem.cpp:1685
RoR::SkinDocumentPtr
std::shared_ptr< SkinDocument > SkinDocumentPtr
Definition: ForwardDeclarations.h:224
RoR::CreateProjectRequestType::ACTOR_PROJECT
@ ACTOR_PROJECT
Like DEFAULT but fixes up name + category in the truckfile.
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:848
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:186
RoR::CacheSystem::ClearCache
void ClearCache()
Definition: CacheSystem.cpp:712
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:2436
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:1125
RoR::CacheEntry::propscount
int propscount
Definition: CacheSystem.h:119
RoR::CacheSystem::DetectDuplicates
void DetectDuplicates()
Definition: CacheSystem.cpp:477
RoR::CacheValidity
CacheValidity
Definition: CacheSystem.h:188
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:316
RoR::CID_GadgetsTerrain
@ CID_GadgetsTerrain
Definition: Application.h:487
RoR::CacheQueryResult
Definition: CacheSystem.h:147
RoR::CacheSystem::GetContentDirs
const std::vector< std::string > & GetContentDirs() const
Definition: CacheSystem.h:321
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:196
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:1148
RoR::CID_Hidden
@ CID_Hidden
Definition: Application.h:496
RoR::CacheSystem::FillTuneupDetailInfo
void FillTuneupDetailInfo(CacheEntryPtr &entry, TuneupDefPtr &tuneup_def)
Definition: CacheSystem.cpp:1386
RoR::CacheSystem::LoadAssociatedTuneupDef
void LoadAssociatedTuneupDef(CacheEntryPtr &cache_entry)
Loads+parses the .tuneup file and updates all related CacheEntries.
Definition: CacheSystem.cpp:1734
RoR::CacheSystem::GetPrettyName
Ogre::String GetPrettyName(Ogre::String fname)
Definition: CacheSystem.cpp:559
RoR::CacheSystem::ParseKnownFiles
bool ParseKnownFiles(Ogre::String group)
Definition: CacheSystem.cpp:1171
RoR::CacheEntry::skin_def
SkinDocumentPtr skin_def
Cached skin info, added on first use or during cache rebuild.
Definition: CacheSystem.h:92
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::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::LoaderType
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
Definition: Application.h:455
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:256
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:377
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:174
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:381
RoR::CacheSystem::m_categories
std::map< int, Ogre::String > m_categories
Definition: CacheSystem.h:383
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:378
RoR::CacheQuery::cqy_res_last_update
std::time_t cqy_res_last_update
Definition: CacheSystem.h:178
RoR::CacheSystem::GenerateFileCache
void GenerateFileCache(CacheEntryPtr &entry, Ogre::String group)
Definition: CacheSystem.cpp:1074
RoR::CacheEntry::uniqueid
Ogre::String uniqueid
file's unique id
Definition: CacheSystem.h:76
RoR::CacheSystem::EvaluateCacheValidity
CacheValidity EvaluateCacheValidity()
Definition: CacheSystem.cpp:259
RoR::AuthorInfo
Definition: CacheSystem.h:47
RoR::ModifyProjectRequest::mpr_value_int
int mpr_value_int
Definition: CacheSystem.h:262
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:38
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:1783
RoR::CacheSystem::LoadSupplementaryDocuments
void LoadSupplementaryDocuments(CacheEntryPtr &t)
Loads the associated .truck*, .skin and .tuneup files.
Definition: CacheSystem.cpp:1502
RoR::CacheSystem::FillSkinDetailInfo
void FillSkinDetailInfo(CacheEntryPtr &entry, std::shared_ptr< SkinDocument > &skin_def)
Definition: CacheSystem.cpp:1218
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_FLARE_SET
@ TUNEUP_FORCEREMOVE_FLARE_SET
'subject_id' is flare ID.
RoR::CacheQuery::resetResults
void resetResults()
Definition: CacheSystem.h:180
RoR::ModifyProjectRequest
Definition: CacheSystem.h:254
RoR::CID_Fresh
@ CID_Fresh
Definition: Application.h:495
RoR::CreateProjectRequest
Creates subdirectory in 'My Games\Rigs of Rods\projects', pre-populates it with files and adds modcac...
Definition: CacheSystem.h:205
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:569
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:1481
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:213
RoR::ModifyProjectRequestType::NONE
@ NONE
RoR::CacheValidity::VALID
@ VALID
RoR::CacheSystem::FetchSkinByName
CacheEntryPtr FetchSkinByName(std::string const &skin_name)
Definition: CacheSystem.cpp:1673
RoR::CacheValidity::NEEDS_REBUILD
@ NEEDS_REBUILD
RoR::CID_Tuneups
@ CID_Tuneups
For unsorted tuneup files.
Definition: Application.h:490
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:169
RoR::CacheSystem::LoadResource
void LoadResource(CacheEntryPtr &t)
Loads the associated resource bundle if not already done.
Definition: CacheSystem.cpp:1538
RoR::CacheSystem::WriteCacheFileJson
void WriteCacheFileJson()
Definition: CacheSystem.cpp:686
RoR::CacheEntry::wheelcount
int wheelcount
Definition: CacheSystem.h:115
RoR::LT_None
@ LT_None
Definition: Application.h:457
RoR::ModifyProjectRequestType::TUNEUP_FORCEREMOVE_FLEXBODY_RESET
@ TUNEUP_FORCEREMOVE_FLEXBODY_RESET
'subject_id' is flexbody ID.
RoR::CacheEntry::terrn2_def
Terrn2DocumentPtr terrn2_def
Cached terrain definition document.
Definition: CacheSystem.h:95
RoR::CacheEntry::nodecount
int nodecount
Definition: CacheSystem.h:110
RoR::CreateProjectRequest::cpr_overwrite
bool cpr_overwrite
Definition: CacheSystem.h:215
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:1634
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:171
RoR::ModifyProjectRequestType::TUNEUP_FORCED_VCAM_ROLE_SET
@ TUNEUP_FORCED_VCAM_ROLE_SET
'subject_id' is video camera ID, 'value_int' is RoR::VideoCamRole
RoR::CacheEntry::turbojetcount
int turbojetcount
Definition: CacheSystem.h:122
RigDef::DocumentPtr
std::shared_ptr< Document > DocumentPtr
Definition: ForwardDeclarations.h:281
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:257
RoR::ActorType
ActorType
< Aka 'Driveable'
Definition: SimData.h:80
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::CID_GadgetsGeneric
@ CID_GadgetsGeneric
Definition: Application.h:485
RoR::CacheSystem::FillAssetPackDetailInfo
void FillAssetPackDetailInfo(CacheEntryPtr &entry, Ogre::DataStreamPtr ds)
Definition: CacheSystem.cpp:1271
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: Application.h:494
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:172
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:2294
RoR::CacheQuery::cqy_results
std::vector< CacheQueryResult > cqy_results
Definition: CacheSystem.h:176
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:1186
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:382
RoR::CacheEntry::flarescount
int flarescount
Definition: CacheSystem.h:118
RoR::CacheSystem::m_loaded
bool m_loaded
Definition: CacheSystem.h:375
RoR::CacheSystem::StripUIDfromString
static Ogre::String StripUIDfromString(Ogre::String uidstr)
Definition: CacheSystem.cpp:728
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