2014-05-25 14:13:07 +02:00
|
|
|
#ifndef OPENMW_MWWORLD_CELLREF_H
|
|
|
|
#define OPENMW_MWWORLD_CELLREF_H
|
|
|
|
|
2022-08-27 13:07:59 +02:00
|
|
|
#include <string_view>
|
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/cellref.hpp>
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
2014-05-27 13:27:18 +02:00
|
|
|
struct ObjectState;
|
2014-05-25 14:13:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
|
|
|
|
/// \brief Encapsulated variant of ESM::CellRef with change tracking
|
|
|
|
class CellRef
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CellRef(const ESM::CellRef& ref)
|
|
|
|
: mCellRef(ref)
|
|
|
|
{
|
|
|
|
mChanged = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note: Currently unused for items in containers
|
2021-10-11 21:33:35 +02:00
|
|
|
const ESM::RefNum& getRefNum() const { return mCellRef.mRefNum; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
2021-01-22 15:48:37 +01:00
|
|
|
// Returns RefNum.
|
|
|
|
// If RefNum is not set, assigns a generated one and changes the "lastAssignedRefNum" counter.
|
|
|
|
const ESM::RefNum& getOrAssignRefNum(ESM::RefNum& lastAssignedRefNum);
|
|
|
|
|
2014-07-29 15:55:58 +02:00
|
|
|
// Set RefNum to its default state.
|
|
|
|
void unsetRefNum();
|
|
|
|
|
2015-01-11 12:20:22 +13:00
|
|
|
/// Does the RefNum have a content file?
|
2021-10-11 21:33:35 +02:00
|
|
|
bool hasContentFile() const { return mCellRef.mRefNum.hasContentFile(); }
|
2015-01-11 12:20:22 +13:00
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
// Id of object being referenced
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& getRefId() const { return mCellRef.mRefID; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// For doors - true if this door teleports to somewhere else, false
|
|
|
|
// if it should open through animation.
|
2021-10-11 21:33:35 +02:00
|
|
|
bool getTeleport() const { return mCellRef.mTeleport; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// Teleport location for the door, if this is a teleporting door.
|
2021-10-11 21:33:35 +02:00
|
|
|
const ESM::Position& getDoorDest() const { return mCellRef.mDoorDest; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// Destination cell for doors (optional)
|
2023-01-19 17:31:45 +01:00
|
|
|
const std::string& getDestCell() const { return mCellRef.mDestCell; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// Scale applied to mesh
|
2021-10-11 21:33:35 +02:00
|
|
|
float getScale() const { return mCellRef.mScale; }
|
2014-05-25 14:13:07 +02:00
|
|
|
void setScale(float scale);
|
|
|
|
|
2014-06-14 17:56:41 +02:00
|
|
|
// The *original* position and rotation as it was given in the Construction Set.
|
|
|
|
// Current position and rotation of the object is stored in RefData.
|
2021-10-11 21:33:35 +02:00
|
|
|
const ESM::Position& getPosition() const { return mCellRef.mPos; }
|
2014-05-25 14:13:07 +02:00
|
|
|
void setPosition(const ESM::Position& position);
|
|
|
|
|
|
|
|
// Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
|
2021-10-11 21:33:35 +02:00
|
|
|
float getEnchantmentCharge() const { return mCellRef.mEnchantmentCharge; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
2018-10-25 16:09:07 +03:00
|
|
|
// Remaining enchantment charge rescaled to the supplied maximum charge (such as one of the enchantment).
|
|
|
|
float getNormalizedEnchantmentCharge(int maxCharge) const;
|
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
void setEnchantmentCharge(float charge);
|
|
|
|
|
|
|
|
// For weapon or armor, this is the remaining item health.
|
|
|
|
// For tools (lockpicks, probes, repair hammer) it is the remaining uses.
|
2015-01-23 15:33:39 +01:00
|
|
|
// If this returns int(-1) it means full health.
|
2021-10-11 21:33:35 +02:00
|
|
|
int getCharge() const { return mCellRef.mChargeInt; }
|
|
|
|
float getChargeFloat() const { return mCellRef.mChargeFloat; } // Implemented as union with int charge
|
2014-05-25 14:13:07 +02:00
|
|
|
void setCharge(int charge);
|
2015-01-23 15:33:39 +01:00
|
|
|
void setChargeFloat(float charge);
|
2016-12-09 19:55:26 -07:00
|
|
|
void applyChargeRemainderToBeSubtracted(float chargeRemainder); // Stores remainders and applies if > 1
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// The NPC that owns this object (and will get angry if you steal it)
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& getOwner() const { return mCellRef.mOwner; }
|
2022-10-18 09:26:55 +02:00
|
|
|
void setOwner(const ESM::RefId& owner);
|
2014-05-25 14:13:07 +02:00
|
|
|
|
2014-07-22 17:05:05 +02:00
|
|
|
// Name of a global variable. If the global variable is set to '1', using the object is temporarily allowed
|
|
|
|
// even if it has an Owner field.
|
|
|
|
// Used by bed rent scripts to allow the player to use the bed for the duration of the rent.
|
2021-10-11 21:33:35 +02:00
|
|
|
const std::string& getGlobalVariable() const { return mCellRef.mGlobalVariable; }
|
2014-07-22 17:05:05 +02:00
|
|
|
|
2015-02-04 21:18:43 +01:00
|
|
|
void resetGlobalVariable();
|
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
// ID of creature trapped in this soul gem
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& getSoul() const { return mCellRef.mSoul; }
|
|
|
|
void setSoul(const ESM::RefId& soul);
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// The faction that owns this object (and will get angry if
|
|
|
|
// you take it and are not a faction member)
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& getFaction() const { return mCellRef.mFaction; }
|
|
|
|
void setFaction(const ESM::RefId& faction);
|
2014-05-25 14:13:07 +02:00
|
|
|
|
2014-07-22 20:03:35 +02:00
|
|
|
// PC faction rank required to use the item. Sometimes is -1, which means "any rank".
|
2014-12-20 22:00:45 +01:00
|
|
|
void setFactionRank(int factionRank);
|
2021-10-11 21:33:35 +02:00
|
|
|
int getFactionRank() const { return mCellRef.mFactionRank; }
|
2014-07-22 20:03:35 +02:00
|
|
|
|
2014-05-25 14:13:07 +02:00
|
|
|
// Lock level for doors and containers
|
|
|
|
// Positive for a locked door. 0 for a door that was never locked.
|
|
|
|
// For an unlocked door, it is set to -(previous locklevel)
|
2021-10-11 21:33:35 +02:00
|
|
|
int getLockLevel() const { return mCellRef.mLockLevel; }
|
2014-05-25 14:13:07 +02:00
|
|
|
void setLockLevel(int lockLevel);
|
2019-09-17 20:30:37 +02:00
|
|
|
void lock(int lockLevel);
|
|
|
|
void unlock();
|
2014-05-25 14:13:07 +02:00
|
|
|
// Key and trap ID names, if any
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& getKey() const { return mCellRef.mKey; }
|
|
|
|
const ESM::RefId& getTrap() const { return mCellRef.mTrap; }
|
|
|
|
void setTrap(const ESM::RefId& trap);
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
// This is 5 for Gold_005 references, 100 for Gold_100 and so on.
|
2021-10-11 21:33:35 +02:00
|
|
|
int getGoldValue() const { return mCellRef.mGoldValue; }
|
2014-05-25 14:13:07 +02:00
|
|
|
void setGoldValue(int value);
|
|
|
|
|
|
|
|
// Write the content of this CellRef into the given ObjectState
|
|
|
|
void writeState(ESM::ObjectState& state) const;
|
|
|
|
|
|
|
|
// Has this CellRef changed since it was originally loaded?
|
2021-10-11 21:33:35 +02:00
|
|
|
bool hasChanged() const { return mChanged; }
|
2014-05-25 14:13:07 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool mChanged;
|
|
|
|
ESM::CellRef mCellRef;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|