OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cellref.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_ESM_CELLREF_H
2 #define OPENMW_ESM_CELLREF_H
3 
4 #include <limits>
5 #include <string>
6 
7 #include "defs.hpp"
8 
9 namespace ESM
10 {
11  class ESMWriter;
12  class ESMReader;
13 
14  const int UnbreakableLock = std::numeric_limits<int>::max();
15 
16  struct RefNum
17  {
18  unsigned int mIndex;
20 
21  void load (ESMReader& esm, bool wide = false, const std::string& tag = "FRMR");
22 
23  void save (ESMWriter &esm, bool wide = false, const std::string& tag = "FRMR") const;
24 
25  enum { RefNum_NoContentFile = -1 };
26  inline bool hasContentFile() const { return mContentFile != RefNum_NoContentFile; }
27  inline void unset() { mIndex = 0; mContentFile = RefNum_NoContentFile; }
28  };
29 
30  /* Cell reference. This represents ONE object (of many) inside the
31  cell. The cell references are not loaded as part of the normal
32  loading process, but are rather loaded later on demand when we are
33  setting up a specific cell.
34  */
35 
36  class CellRef
37  {
38  public:
39  // Reference number
40  // Note: Currently unused for items in containers
42 
43  std::string mRefID; // ID of object being referenced
44 
45  float mScale; // Scale applied to mesh
46 
47  // The NPC that owns this object (and will get angry if you steal it)
48  std::string mOwner;
49 
50  // Name of a global variable. If the global variable is set to '1', using the object is temporarily allowed
51  // even if it has an Owner field.
52  // Used by bed rent scripts to allow the player to use the bed for the duration of the rent.
53  std::string mGlobalVariable;
54 
55  // ID of creature trapped in this soul gem
56  std::string mSoul;
57 
58  // The faction that owns this object (and will get angry if
59  // you take it and are not a faction member)
60  std::string mFaction;
61 
62  // PC faction rank required to use the item. Sometimes is -1, which means "any rank".
64 
65  // For weapon or armor, this is the remaining item health.
66  // For tools (lockpicks, probes, repair hammer) it is the remaining uses.
67  // For lights it is remaining time.
68  // This could be -1 if the charge was not touched yet (i.e. full).
69  union
70  {
71  int mChargeInt; // Used by everything except lights
72  float mChargeFloat; // Used only by lights
73  };
74  float mChargeIntRemainder; // Stores amount of charge not subtracted from mChargeInt
75 
76  // Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
78 
79  // This is 5 for Gold_005 references, 100 for Gold_100 and so on.
81 
82  // For doors - true if this door teleports to somewhere else, false
83  // if it should open through animation.
84  bool mTeleport;
85 
86  // Teleport location for the door, if this is a teleporting door.
88 
89  // Destination cell for doors (optional)
90  std::string mDestCell;
91 
92  // Lock level for doors and containers
94  std::string mKey, mTrap; // Key and trap ID names, if any
95 
96  // This corresponds to the "Reference Blocked" checkbox in the construction set,
97  // which prevents editing that reference.
98  // -1 is not blocked, otherwise it is blocked.
99  signed char mReferenceBlocked;
100 
101  // Position and rotation of this object within the cell
103 
105  void load (ESMReader& esm, bool &isDeleted, bool wideRefNum = false);
106 
107  void loadId (ESMReader& esm, bool wideRefNum = false);
108 
110  void loadData (ESMReader& esm, bool &isDeleted);
111 
112  void save (ESMWriter &esm, bool wideRefNum = false, bool inInventory = false, bool isDeleted = false) const;
113 
114  void blank();
115  };
116 
117  bool operator== (const RefNum& left, const RefNum& right);
118  bool operator< (const RefNum& left, const RefNum& right);
119 }
120 
121 #endif
float mChargeFloat
Definition: cellref.hpp:72
std::string mSoul
Definition: cellref.hpp:56
void load(ESMReader &esm, bool wide=false, const std::string &tag="FRMR")
Definition: cellref.cpp:8
bool operator==(const CellId &left, const CellId &right)
Definition: cellid.cpp:29
void blank()
Definition: cellref.cpp:189
Definition: esmreader.hpp:21
const int UnbreakableLock
Definition: cellref.hpp:14
int mChargeInt
Definition: cellref.hpp:71
bool operator<(const CellId &left, const CellId &right)
Definition: cellid.cpp:40
float mEnchantmentCharge
Definition: cellref.hpp:77
std::string mOwner
Definition: cellref.hpp:48
RefNum mRefNum
Definition: cellref.hpp:41
signed char mReferenceBlocked
Definition: cellref.hpp:99
Definition: esmwriter.hpp:17
Definition: cellref.hpp:16
unsigned int mIndex
Definition: cellref.hpp:18
float mChargeIntRemainder
Definition: cellref.hpp:74
int mGoldValue
Definition: cellref.hpp:80
void loadData(ESMReader &esm, bool &isDeleted)
Implicitly called by load.
Definition: cellref.cpp:55
void loadId(ESMReader &esm, bool wideRefNum=false)
Definition: cellref.cpp:35
Position mDoorDest
Definition: cellref.hpp:87
void load(ESMReader &esm, bool &isDeleted, bool wideRefNum=false)
Calls loadId and loadData.
Definition: cellref.cpp:29
int mContentFile
Definition: cellref.hpp:19
Definition: cellref.hpp:36
int mLockLevel
Definition: cellref.hpp:93
Position mPos
Definition: cellref.hpp:102
Definition: defs.hpp:38
std::string mFaction
Definition: cellref.hpp:60
bool mTeleport
Definition: cellref.hpp:84
std::string mDestCell
Definition: cellref.hpp:90
bool hasContentFile() const
Definition: cellref.hpp:26
void save(ESMWriter &esm, bool wideRefNum=false, bool inInventory=false, bool isDeleted=false) const
Definition: cellref.cpp:132
std::string mTrap
Definition: cellref.hpp:94
void unset()
Definition: cellref.hpp:27
float mScale
Definition: cellref.hpp:45
int mFactionRank
Definition: cellref.hpp:63
Definition: cellref.hpp:25
void save(ESMWriter &esm, bool wide=false, const std::string &tag="FRMR") const
Definition: cellref.cpp:16
std::string mGlobalVariable
Definition: cellref.hpp:53
std::string mRefID
Definition: cellref.hpp:43
std::string mKey
Definition: cellref.hpp:94