File: loadfact.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (86 lines) | stat: -rw-r--r-- 2,403 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef OPENMW_ESM_FACT_H
#define OPENMW_ESM_FACT_H

#include <array>
#include <map>
#include <string>

#include "components/esm/defs.hpp"
#include "components/esm/refid.hpp"

namespace ESM
{

    class ESMReader;
    class ESMWriter;

    /*
     * Faction definitions
     */

    // Requirements for each rank
    struct RankData
    {
        int32_t mAttribute1, mAttribute2; // Attribute level

        // Skill level (faction skills given in
        // skillID below.) You need one skill at
        // level 'mPrimarySkill' and two skills at level
        // 'mFavouredSkill' to advance to this rank.
        int32_t mPrimarySkill, mFavouredSkill;

        int32_t mFactReaction; // Reaction from faction members

        void load(ESMReader& esm);
        void save(ESMWriter& esm) const;
    };

    struct Faction
    {
        constexpr static RecNameInts sRecordId = REC_FACT;

        /// Return a string descriptor for this record type. Currently used for debugging / error logs only.
        static std::string_view getRecordType() { return "Faction"; }

        uint32_t mRecordFlags;
        std::string mName;
        RefId mId;

        struct FADTstruct
        {
            // Which attributes we like
            std::array<int32_t, 2> mAttribute;

            std::array<RankData, 10> mRankData;

            std::array<int32_t, 7> mSkills; // IDs of skills this faction require
                                            // Each element will either contain an Skill index, or -1.

            int32_t mIsHidden; // 1 - hidden from player

            int32_t& getSkill(size_t index, bool ignored = false);
            ///< Throws an exception for invalid values of \a index.

            int32_t getSkill(size_t index, bool ignored = false) const;
            ///< Throws an exception for invalid values of \a index.

            void load(ESMReader& esm);
            void save(ESMWriter& esm) const;
        }; // 240 bytes

        FADTstruct mData;

        // <Faction ID, Reaction>
        std::map<ESM::RefId, int32_t> mReactions;

        // Name of faction ranks (may be empty for NPC factions)
        std::array<std::string, 10> mRanks;

        void load(ESMReader& esm, bool& isDeleted);
        void save(ESMWriter& esm, bool isDeleted = false) const;

        void blank();
        ///< Set record to default state (does not touch the ID/index).
    };
}
#endif