#ifndef MODINFOWITHCONFLICTINFO_H #define MODINFOWITHCONFLICTINFO_H #include #include "thread_utils.h" #include "modinfo.h" #include #include class ModInfoWithConflictInfo : public ModInfo { public: std::vector getConflictFlags() const override; virtual std::vector getFlags() const override; /** * @return true if this mod is considered "valid", that is: it contains data used by the game **/ virtual bool isValid() const override; /** * @return a list of content types contained in a mod */ virtual const std::set& getContents() const override; /** * @brief Test if the mod contains the specified content. * * @param content ID of the content to test. * * @return true if the content is there, false otherwise. */ virtual bool hasContent(int content) const override; /** * @brief clear all caches held for this mod */ virtual void clearCaches() override; virtual std::set getModOverwrite() const override { return m_OverwriteList; } virtual std::set getModOverwritten() const override { return m_OverwrittenList; } virtual std::set getModArchiveOverwrite() const override { return m_ArchiveOverwriteList; } virtual std::set getModArchiveOverwritten() const override { return m_ArchiveOverwrittenList; } virtual std::set getModArchiveLooseOverwrite() const override { return m_ArchiveLooseOverwriteList; } virtual std::set getModArchiveLooseOverwritten() const override { return m_ArchiveLooseOverwrittenList; } virtual void doConflictCheck() const override; public slots: /** * @brief Notify this mod that the content of the disk may have changed. */ virtual void diskContentModified(); protected: /** * @brief Check if the content of this mod is valid. * * @return true if the content is valid, false otherwise. **/ virtual bool doIsValid() const; /** * @brief Compute the contents for this mod. * * @return the contents for this mod. **/ virtual std::set doGetContents() const { return {}; } /** * @brief Retrieve a file tree corresponding to the underlying disk content * of this mod. * * The file tree should not be cached since it is already cached and updated when * required. * * @return a file tree representing the content of this mod. */ std::shared_ptr contentFileTree() const; ModInfoWithConflictInfo( PluginContainer* pluginContainer, const MOBase::IPluginGame* gamePlugin, MOShared::DirectoryEntry** directoryStructure); private: enum EConflictType { CONFLICT_NONE, CONFLICT_OVERWRITE, CONFLICT_OVERWRITTEN, CONFLICT_MIXED, CONFLICT_REDUNDANT, CONFLICT_CROSS }; private: /** * @return true if there is a conflict for files in this mod */ EConflictType isConflicted() const; /** * @return true if there are archive conflicts for files in this mod */ EConflictType isArchiveConflicted() const; /** * @return true if there are archive conflicts with loose files in this mod */ EConflictType isLooseArchiveConflicted() const; /** * @return true if this mod is completely replaced by others */ bool isRedundant() const; bool hasHiddenFiles() const; protected: /** * @brief Prefetch content for this mod. * * This method can be used to prefetch content from the mod, e.g., for isValid() * or getContents(). This method will only be called when first creating the mod * using multiple threads for all the mods. */ virtual void prefetch() override; // Current game plugin running in MO2: MOBase::IPluginGame const * const m_GamePlugin; private: MOShared::MemoizedLocked> m_FileTree; MOShared::MemoizedLocked m_Valid; MOShared::MemoizedLocked> m_Contents; MOShared::DirectoryEntry **m_DirectoryStructure; mutable EConflictType m_CurrentConflictState; mutable EConflictType m_ArchiveConflictState; mutable EConflictType m_ArchiveConflictLooseState; mutable bool m_HasLooseOverwrite; mutable bool m_HasHiddenFiles; mutable QTime m_LastConflictCheck; mutable std::set m_OverwriteList; // indices of mods overritten by this mod mutable std::set m_OverwrittenList; // indices of mods overwriting this mod mutable std::set m_ArchiveOverwriteList; // indices of mods with archive files overritten by this mod mutable std::set m_ArchiveOverwrittenList; // indices of mods with archive files overwriting this mod mutable std::set m_ArchiveLooseOverwriteList; // indices of mods with archives being overwritten by this mod's loose files mutable std::set m_ArchiveLooseOverwrittenList; // indices of mods with loose files overwriting this mod's archive files }; #endif // MODINFOWITHCONFLICTINFO_H