1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-09 18:40:14 +00:00
OpenMW/apps/openmw/mwworld/player.hpp
fteppe 125b21de20 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-12-27 19:15:54 +01:00

141 lines
4.0 KiB
C++

#ifndef GAME_MWWORLD_PLAYER_H
#define GAME_MWWORLD_PLAYER_H
#include <map>
#include "../mwworld/livecellref.hpp"
#include "../mwmechanics/drawstate.hpp"
#include <components/esm/attr.hpp>
#include <components/esm/refid.hpp>
#include <components/esm3/loadnpc.hpp>
#include <components/esm3/loadskil.hpp>
namespace ESM
{
class ESMWriter;
class ESMReader;
}
namespace Loading
{
class Listener;
}
namespace MWWorld
{
class CellStore;
class ConstPtr;
/// \brief NPC object representing the player and additional player data
class Player
{
LiveCellRef<ESM::NPC> mPlayer;
MWWorld::CellStore* mCellStore;
ESM::RefId mSign;
osg::Vec3f mLastKnownExteriorPosition;
ESM::Position mMarkedPosition;
// If no position was marked, this is nullptr
CellStore* mMarkedCell;
bool mAutoMove;
float mForwardBackward;
bool mTeleported;
int mCurrentCrimeId; // the id assigned witnesses
int mPaidCrimeId; // the last id paid off (0 bounty)
typedef std::map<ESM::RefId, ESM::RefId> PreviousItems; // previous equipped items, needed for bound spells
PreviousItems mPreviousItems;
// Saved stats prior to becoming a werewolf
float mSaveSkills[ESM::Skill::Length];
float mSaveAttributes[ESM::Attribute::Length];
bool mJumping;
public:
Player(const ESM::NPC* player);
void saveStats();
void restoreStats();
void setWerewolfStats();
// For mark/recall magic effects
void markPosition(CellStore* markedCell, const ESM::Position& markedPosition);
void getMarkedPosition(CellStore*& markedCell, ESM::Position& markedPosition) const;
/// Interiors can not always be mapped to a world position. However
/// world position is still required for divine / almsivi magic effects
/// and the player arrow on the global map.
void setLastKnownExteriorPosition(const osg::Vec3f& position) { mLastKnownExteriorPosition = position; }
osg::Vec3f getLastKnownExteriorPosition() const { return mLastKnownExteriorPosition; }
void set(const ESM::NPC* player);
void setCell(MWWorld::CellStore* cellStore);
MWWorld::Ptr getPlayer();
MWWorld::ConstPtr getConstPlayer() const;
void setBirthSign(const ESM::RefId& sign);
const ESM::RefId& getBirthSign() const;
void setDrawState(MWMechanics::DrawState state);
MWMechanics::DrawState getDrawState(); /// \todo constness
/// Activate the object under the crosshair, if any
void activate();
bool getAutoMove() const;
void setAutoMove(bool enable);
void setLeftRight(float value);
void setForwardBackward(float value);
void setUpDown(int value);
void setRunState(bool run);
void setSneak(bool sneak);
void yaw(float yaw);
void pitch(float pitch);
void roll(float roll);
bool wasTeleported() const;
void setTeleported(bool teleported);
void setAttackingOrSpell(bool attackingOrSpell);
void setJumping(bool jumping);
bool getJumping() const;
/// Checks all nearby actors to see if anyone has an aipackage against you
bool isInCombat();
bool enemiesNearby();
void clear();
void write(ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord(ESM::ESMReader& reader, uint32_t type);
int getNewCrimeId(); // get new id for witnesses
void recordCrimeId(); // record the paid crime id when bounty is 0
int getCrimeId() const; // get the last paid crime id
void setPreviousItem(const ESM::RefId& boundItemId, const ESM::RefId& previousItemId);
ESM::RefId getPreviousItem(const ESM::RefId& boundItemId);
void erasePreviousItem(const ESM::RefId& boundItemId);
void setSelectedSpell(const ESM::RefId& spellId);
void update();
};
}
#endif