mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 12:26:39 +00:00 
			
		
		
		
	Fixed some types removed useless header applied clang format fixed compile tests fixed clang tidy, and closer to logic before this MR Removed hardcoded refids unless there is a returned value we don't use static RefIds can use == between RefId and hardcoded string Fix clang format Fixed a few instances where std::string was used, when only const std::string& was needed removed unused variable
		
			
				
	
	
		
			98 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
	
		
			3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef OPENMW_ESM_LEVLISTS_H
 | 
						|
#define OPENMW_ESM_LEVLISTS_H
 | 
						|
 | 
						|
#include <string>
 | 
						|
#include <vector>
 | 
						|
 | 
						|
#include "components/esm/refid.hpp"
 | 
						|
#include <components/esm/defs.hpp>
 | 
						|
#include <components/esm/esmcommon.hpp>
 | 
						|
 | 
						|
namespace ESM
 | 
						|
{
 | 
						|
 | 
						|
    class ESMReader;
 | 
						|
    class ESMWriter;
 | 
						|
 | 
						|
    /*
 | 
						|
     * Levelled lists. Since these have identical layout, I only bothered
 | 
						|
     * to implement it once.
 | 
						|
     *
 | 
						|
     * We should later implement the ability to merge levelled lists from
 | 
						|
     * several files.
 | 
						|
     */
 | 
						|
 | 
						|
    struct LevelledListBase
 | 
						|
    {
 | 
						|
        int mFlags;
 | 
						|
        unsigned char mChanceNone; // Chance that none are selected (0-100)
 | 
						|
        unsigned int mRecordFlags;
 | 
						|
        RefId mId;
 | 
						|
 | 
						|
        struct LevelItem
 | 
						|
        {
 | 
						|
            RefId mId;
 | 
						|
            short mLevel;
 | 
						|
        };
 | 
						|
 | 
						|
        std::vector<LevelItem> mList;
 | 
						|
 | 
						|
        void load(ESMReader& esm, NAME recName, bool& isDeleted);
 | 
						|
        void save(ESMWriter& esm, NAME recName, bool isDeleted) const;
 | 
						|
 | 
						|
        void blank();
 | 
						|
        ///< Set record to default state (does not touch the ID).
 | 
						|
    };
 | 
						|
 | 
						|
    template <class Base>
 | 
						|
    struct CustomLevelledListBase : LevelledListBase
 | 
						|
    {
 | 
						|
        void load(ESMReader& esm, bool& isDeleted) { LevelledListBase::load(esm, Base::sRecName, isDeleted); }
 | 
						|
        void save(ESMWriter& esm, bool isDeleted = false) const
 | 
						|
        {
 | 
						|
            LevelledListBase::save(esm, Base::sRecName, isDeleted);
 | 
						|
        }
 | 
						|
    };
 | 
						|
 | 
						|
    struct CreatureLevList : CustomLevelledListBase<CreatureLevList>
 | 
						|
    {
 | 
						|
        /// Record name used to read references.
 | 
						|
        static constexpr NAME sRecName{ "CNAM" };
 | 
						|
        static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVC;
 | 
						|
        /// Return a string descriptor for this record type. Currently used for debugging / error logs only.
 | 
						|
        static std::string_view getRecordType() { return "CreatureLevList"; }
 | 
						|
 | 
						|
        enum Flags
 | 
						|
        {
 | 
						|
 | 
						|
            AllLevels = 0x01 // Calculate from all levels <= player
 | 
						|
                             // level, not just the closest below
 | 
						|
                             // player.
 | 
						|
        };
 | 
						|
    };
 | 
						|
 | 
						|
    struct ItemLevList : CustomLevelledListBase<ItemLevList>
 | 
						|
    {
 | 
						|
        /// Record name used to read references.
 | 
						|
        static constexpr NAME sRecName{ "INAM" };
 | 
						|
        static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVI;
 | 
						|
        /// Return a string descriptor for this record type. Currently used for debugging / error logs only.
 | 
						|
        static std::string_view getRecordType() { return "ItemLevList"; }
 | 
						|
 | 
						|
        enum Flags
 | 
						|
        {
 | 
						|
 | 
						|
            Each = 0x01, // Select a new item each time this
 | 
						|
                         // list is instantiated, instead of
 | 
						|
                         // giving several identical items
 | 
						|
                         // (used when a container has more
 | 
						|
                         // than one instance of one levelled
 | 
						|
                         // list.)
 | 
						|
            AllLevels = 0x02 // Calculate from all levels <= player
 | 
						|
                             // level, not just the closest below
 | 
						|
                             // player.
 | 
						|
        };
 | 
						|
    };
 | 
						|
 | 
						|
}
 | 
						|
#endif
 |