File: importercontext.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 (87 lines) | stat: -rw-r--r-- 2,577 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
87
#ifndef OPENMW_ESSIMPORT_CONTEXT_H
#define OPENMW_ESSIMPORT_CONTEXT_H

#include <map>

#include <components/esm3/controlsstate.hpp>
#include <components/esm3/dialoguestate.hpp>
#include <components/esm3/globalmap.hpp>
#include <components/esm3/loadcell.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadnpc.hpp>
#include <components/esm3/player.hpp>

#include "importcntc.hpp"
#include "importcrec.hpp"
#include "importnpcc.hpp"
#include "importsplm.h"

namespace ESSImport
{

    struct Context
    {
        // set from the TES3 header
        std::string mPlayerCellName;

        ESM::Player mPlayer;
        ESM::NPC mPlayerBase;
        std::string mCustomPlayerClassName;

        ESM::DialogueState mDialogueState;

        ESM::ControlsState mControlsState;

        // cells which should show an explored overlay on the global map
        std::set<std::pair<int, int>> mExploredCells;

        ESM::GlobalMap mGlobalMapState;

        int mDay, mMonth, mYear;
        float mHour;

        // key <refIndex, refId>
        std::map<std::pair<int, ESM::RefId>, CREC> mCreatureChanges;
        std::map<std::pair<int, ESM::RefId>, NPCC> mNpcChanges;
        std::map<std::pair<int, ESM::RefId>, CNTC> mContainerChanges;

        std::map<std::pair<int, ESM::RefId>, int> mActorIdMap;
        int mNextActorId;

        std::map<ESM::RefId, ESM::Creature> mCreatures;
        std::map<ESM::RefId, ESM::NPC> mNpcs;

        std::vector<SPLM::ActiveSpell> mActiveSpells;

        Context()
            : mDay(0)
            , mMonth(0)
            , mYear(0)
            , mHour(0.f)
            , mNextActorId(0)
        {
            mPlayer.mCellId = ESM::RefId::esm3ExteriorCell(0, 0);
            mPlayer.mLastKnownExteriorPosition[0] = mPlayer.mLastKnownExteriorPosition[1]
                = mPlayer.mLastKnownExteriorPosition[2] = 0.0f;
            mPlayer.mHasMark = 0;
            mPlayer.mCurrentCrimeId = -1; // TODO
            mPlayer.mPaidCrimeId = -1;
            mPlayer.mObject.blank();
            mPlayer.mObject.mEnabled = true;
            mPlayer.mObject.mRef.mRefID = ESM::RefId::stringRefId("player"); // REFR.mRefID would be PlayerSaveGame
            mPlayer.mObject.mCreatureStats.mActorId = generateActorId();

            mGlobalMapState.mBounds.mMinX = 0;
            mGlobalMapState.mBounds.mMaxX = 0;
            mGlobalMapState.mBounds.mMinY = 0;
            mGlobalMapState.mBounds.mMaxY = 0;

            mPlayerBase.blank();
        }

        int generateActorId() { return mNextActorId++; }
    };

}

#endif