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