File: attr.cpp

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 (56 lines) | stat: -rw-r--r-- 1,631 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
#include "attr.hpp"

#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>

#include <stdexcept>

namespace ESM
{
    const Attribute::AttributeID Attribute::Strength("Strength");
    const Attribute::AttributeID Attribute::Intelligence("Intelligence");
    const Attribute::AttributeID Attribute::Willpower("Willpower");
    const Attribute::AttributeID Attribute::Agility("Agility");
    const Attribute::AttributeID Attribute::Speed("Speed");
    const Attribute::AttributeID Attribute::Endurance("Endurance");
    const Attribute::AttributeID Attribute::Personality("Personality");
    const Attribute::AttributeID Attribute::Luck("Luck");

    static const RefId sAttributes[Attribute::Length] = {
        Attribute::Strength,
        Attribute::Intelligence,
        Attribute::Willpower,
        Attribute::Agility,
        Attribute::Speed,
        Attribute::Endurance,
        Attribute::Personality,
        Attribute::Luck,
    };

    RefId Attribute::indexToRefId(int index)
    {
        if (index < 0 || index >= Length)
            return RefId();
        return sAttributes[index];
    }

    int Attribute::refIdToIndex(RefId id)
    {
        for (int i = 0; i < Length; ++i)
        {
            if (sAttributes[i] == id)
                return i;
        }
        return -1;
    }

    void Attribute::load(ESMReader& esm, bool& isDeleted)
    {
        throw std::runtime_error("Attribute loading not yet implemented");
    }

    void Attribute::save(ESMWriter& esm, bool isDeleted) const
    {
        throw std::runtime_error("Attribute saving not yet implemented");
    }
}