Define all remaining defaults in player structs; remove unused enum

This commit is contained in:
Sezz 2023-04-09 19:39:39 +10:00
parent 05e2d17814
commit 73ce16b092

View file

@ -4,14 +4,10 @@
using namespace TEN::Math; using namespace TEN::Math;
namespace TEN::Renderer
{
struct RendererMesh;
}
struct CreatureInfo; struct CreatureInfo;
struct FX_INFO; struct FX_INFO;
struct ItemInfo; struct ItemInfo;
namespace TEN::Renderer { struct RendererMesh; };
// Inventory object constants // Inventory object constants
constexpr int NUM_PUZZLES = ID_PUZZLE_ITEM16 - ID_PUZZLE_ITEM1 + 1; constexpr int NUM_PUZZLES = ID_PUZZLE_ITEM16 - ID_PUZZLE_ITEM1 + 1;
@ -865,6 +861,18 @@ enum LARA_MESHES
NUM_LARA_MESHES NUM_LARA_MESHES
}; };
enum LaraWeaponTypeCarried
{
WTYPE_MISSING = 0,
WTYPE_PRESENT = (1 << 0),
WTYPE_SILENCER = (1 << 1),
WTYPE_LASERSIGHT = (1 << 2),
WTYPE_AMMO_1 = (1 << 3),
WTYPE_AMMO_2 = (1 << 4),
WTYPE_AMMO_3 = (1 << 5),
WTYPE_MASK_AMMO = WTYPE_AMMO_1 | WTYPE_AMMO_2 | WTYPE_AMMO_3,
};
enum class WeaponAmmoType enum class WeaponAmmoType
{ {
Ammo1, Ammo1,
@ -893,18 +901,6 @@ enum class LaraWeaponType
NumWeapons NumWeapons
}; };
enum LaraWeaponTypeCarried
{
WTYPE_MISSING = 0,
WTYPE_PRESENT = (1 << 0),
WTYPE_SILENCER = (1 << 1),
WTYPE_LASERSIGHT = (1 << 2),
WTYPE_AMMO_1 = (1 << 3),
WTYPE_AMMO_2 = (1 << 4),
WTYPE_AMMO_3 = (1 << 5),
WTYPE_MASK_AMMO = WTYPE_AMMO_1 | WTYPE_AMMO_2 | WTYPE_AMMO_3,
};
enum class HolsterSlot enum class HolsterSlot
{ {
Empty = ID_LARA_HOLSTERS, Empty = ID_LARA_HOLSTERS,
@ -919,14 +915,6 @@ enum class HolsterSlot
RocketLauncher = ID_ROCKET_ANIM RocketLauncher = ID_ROCKET_ANIM
}; };
// TODO: Unused.
enum class ClothType
{
None,
Dry,
Wet
};
enum class WaterStatus enum class WaterStatus
{ {
Dry, Dry,
@ -966,16 +954,16 @@ enum class JumpDirection
struct Ammo struct Ammo
{ {
using CountType = uint16_t; using CountType = unsigned short;
private: private:
CountType Count; CountType Count = 0;
bool IsInfinite; bool IsInfinite = false;
public: public:
static CountType Clamp(int value) static CountType Clamp(int value)
{ {
return std::clamp(value, 0, static_cast<int>(std::numeric_limits<CountType>::max())); return std::clamp(value, 0, (int)std::numeric_limits<CountType>::max());
} }
bool HasInfinite() const bool HasInfinite() const
@ -988,15 +976,15 @@ public:
return Count; return Count;
} }
void SetInfinite(bool infinite) void SetInfinite(bool isInfinite)
{ {
this->IsInfinite = infinite; IsInfinite = isInfinite;
} }
Ammo& operator --() Ammo& operator --()
{ {
assertion(this->Count > 0, "Ammo count is already 0!"); assertion(Count > 0, "Ammo count is already 0.");
--this->Count; --Count;
return *this; return *this;
} }
@ -1009,7 +997,7 @@ public:
Ammo& operator ++() Ammo& operator ++()
{ {
++this->Count; ++Count;
return *this; return *this;
} }
@ -1022,7 +1010,7 @@ public:
Ammo& operator =(size_t value) Ammo& operator =(size_t value)
{ {
this->Count = Clamp(value); Count = Clamp(value);
return *this; return *this;
} }
@ -1031,10 +1019,10 @@ public:
return (Count == Clamp(value)); return (Count == Clamp(value));
} }
Ammo& operator =(Ammo& rhs) Ammo& operator =(Ammo& ammo)
{ {
this->Count = rhs.Count; Count = ammo.Count;
this->IsInfinite = rhs.Count; IsInfinite = ammo.Count;
return *this; return *this;
} }
@ -1055,20 +1043,20 @@ public:
Ammo& operator +=(size_t value) Ammo& operator +=(size_t value)
{ {
int temp = Count + value; int temp = Count + value;
this->Count = Clamp(temp); Count = Clamp(temp);
return *this; return *this;
} }
Ammo& operator -=(size_t value) Ammo& operator -=(size_t value)
{ {
int temp = Count - value; int temp = Count - value;
this->Count = Clamp(temp); Count = Clamp(temp);
return *this; return *this;
} }
operator bool() operator bool()
{ {
return (IsInfinite || Count > 0); return (IsInfinite || (Count > 0));
} }
}; };
@ -1092,15 +1080,15 @@ struct CarriedWeaponInfo
struct ArmInfo struct ArmInfo
{ {
int AnimNumber; int AnimNumber = 0;
int FrameNumber; int FrameNumber = 0;
int FrameBase; int FrameBase = 0;
EulerAngles Orientation; EulerAngles Orientation = EulerAngles::Zero;
bool Locked = false;
bool Locked; int GunFlash = 0;
int GunFlash; int GunSmoke = 0;
int GunSmoke;
}; };
struct FlareData struct FlareData
@ -1122,29 +1110,29 @@ constexpr int MAX_DIARY_STRINGS_PER_PAGE = 8;
struct DiaryString struct DiaryString
{ {
Vector2i Position; Vector2i Position = Vector2i::Zero;
int StringID; int StringID = 0;
}; };
struct DiaryPage struct DiaryPage
{ {
DiaryString Strings[MAX_DIARY_STRINGS_PER_PAGE]; DiaryString Strings[MAX_DIARY_STRINGS_PER_PAGE] = {};
}; };
struct DiaryInfo struct DiaryInfo
{ {
bool Present; bool Present = false;
DiaryPage Pages[MAX_DIARY_PAGES]; DiaryPage Pages[MAX_DIARY_PAGES] = {};
unsigned int NumPages; unsigned int NumPages = 0;
unsigned int CurrentPage; unsigned int CurrentPage = 0;
}; };
struct LaraInventoryData struct LaraInventoryData
{ {
bool IsBusy; bool IsBusy = false;
bool OldBusy; bool OldBusy = false;
DiaryInfo Diary; DiaryInfo Diary = {};
byte BeetleLife; byte BeetleLife;
int BeetleComponents; // BeetleComponentFlags enum int BeetleComponents; // BeetleComponentFlags enum
@ -1157,29 +1145,29 @@ struct LaraInventoryData
int TotalFlares; int TotalFlares;
unsigned int TotalSecrets; unsigned int TotalSecrets;
bool HasBinoculars; bool HasBinoculars = false;
bool HasCrowbar; bool HasCrowbar = false;
bool HasTorch; bool HasTorch = false;
bool HasLasersight; bool HasLasersight = false;
bool HasSilencer; // TODO: Unused. bool HasSilencer = false; // TODO: Unused.
// TODO: Convert to bools. // TODO: Convert to bools.
int Puzzles[NUM_PUZZLES]; int Puzzles[NUM_PUZZLES] = {};
int Keys[NUM_KEYS]; int Keys[NUM_KEYS] = {};
int Pickups[NUM_PICKUPS]; int Pickups[NUM_PICKUPS] = {};
int Examines[NUM_EXAMINES]; int Examines[NUM_EXAMINES] = {};
int PuzzlesCombo[NUM_PUZZLES * 2]; int PuzzlesCombo[NUM_PUZZLES * 2] = {};
int KeysCombo[NUM_KEYS * 2]; int KeysCombo[NUM_KEYS * 2] = {};
int PickupsCombo[NUM_PICKUPS * 2]; int PickupsCombo[NUM_PICKUPS * 2] = {};
int ExaminesCombo[NUM_EXAMINES * 2]; int ExaminesCombo[NUM_EXAMINES * 2] = {};
}; };
struct LaraCountData struct LaraCountData
{ {
unsigned int Pose; unsigned int Pose = 0;
unsigned int PositionAdjust; unsigned int PositionAdjust = 0;
unsigned int Run; unsigned int Run = 0;
unsigned int Death; unsigned int Death = 0;
}; };
struct WeaponControlData struct WeaponControlData
@ -1204,31 +1192,37 @@ struct WeaponControlData
struct RopeControlData struct RopeControlData
{ {
byte Segment; byte Segment = 0;
byte Direction; byte Direction = 0;
short ArcFront;
short ArcBack; short ArcFront = 0;
short LastX; short ArcBack = 0;
short MaxXForward;
short MaxXBackward; short LastX = 0;
int DFrame; short MaxXForward = 0;
int Frame; short MaxXBackward = 0;
unsigned short FrameRate;
unsigned short Y; int DFrame = 0;
int Ptr; int Frame = 0;
int Offset; unsigned short FrameRate = 0;
int DownVel;
byte Flag; unsigned short Y = 0;
int Count; int Ptr = 0;
int Offset = 0;
int DownVel = 0;
byte Flag = 0;
int Count = 0;
}; };
// TODO: Give tightrope a property for difficulty?
// TODO: Remove old tightrope functionality.
struct TightropeControlData struct TightropeControlData
{ {
#if NEW_TIGHTROPE #if NEW_TIGHTROPE
float Balance; short TightropeItem = 0;
unsigned int TimeOnTightrope; bool CanDismount = false;
bool CanDismount; float Balance = 0.0f;
short TightropeItem; // TODO: Give tightrope a property for difficulty? unsigned int TimeOnTightrope = 0;
#else // !NEW_TIGHTROPE #else // !NEW_TIGHTROPE
unsigned int OnCount; unsigned int OnCount;
byte Off; byte Off;
@ -1238,14 +1232,14 @@ struct TightropeControlData
struct SubsuitControlData struct SubsuitControlData
{ {
short XRot; short XRot = 0;
short DXRot; short DXRot = 0;
int Velocity[2]; int Velocity[2] = {};
int VerticalVelocity; int VerticalVelocity = 0;
// TODO: These appear to be unused. // TODO: These appear to be unused.
short XRotVel; short XRotVel = 0;
unsigned short HitCount; unsigned short HitCount = 0;
}; };
struct LaraControlData struct LaraControlData
@ -1254,9 +1248,9 @@ struct LaraControlData
short TurnRate = 0; short TurnRate = 0;
int CalculatedJumpVelocity = 0; int CalculatedJumpVelocity = 0;
JumpDirection JumpDirection = {};
HandStatus HandStatus = {}; HandStatus HandStatus = {};
WaterStatus WaterStatus = {}; WaterStatus WaterStatus = {};
JumpDirection JumpDirection = {};
LaraCountData Count = {}; LaraCountData Count = {};
RopeControlData Rope = {}; RopeControlData Rope = {};
@ -1265,12 +1259,12 @@ struct LaraControlData
WeaponControlData Weapon = {}; WeaponControlData Weapon = {};
bool IsClimbingLadder = false; bool IsClimbingLadder = false;
bool Locked = false; bool Locked = false; // IsLocked
bool IsLow = false; bool IsLow = false;
bool IsMonkeySwinging = false; bool IsMonkeySwinging = false;
bool IsMoving = false; bool IsMoving = false;
bool RunJumpQueued = false; bool RunJumpQueued = false; // IsRunJumpQueued
bool KeepLow = false; bool KeepLow = false; // IsInLowSpace
bool CanClimbLadder = false; bool CanClimbLadder = false;
bool CanLook = false; bool CanLook = false;
@ -1283,7 +1277,7 @@ struct PlayerEffectData
std::array<float, NUM_LARA_MESHES> BubbleNodes = {}; std::array<float, NUM_LARA_MESHES> BubbleNodes = {};
}; };
// TODO: Make these floats. // TODO: Refactor status handling to use floats.
struct PlayerStatusData struct PlayerStatusData
{ {
int Air = 0; int Air = 0;
@ -1294,39 +1288,42 @@ struct PlayerStatusData
struct LaraInfo struct LaraInfo
{ {
int ItemNumber = 0; // TODO: Remove. No longer necessary since ItemInfo already has this. int ItemNumber = 0; // TODO: Remove. No longer necessary since ItemInfo already has it. -- Sezz 2023.04.09
PlayerStatusData Status = {};
LaraControlData Control = {}; LaraControlData Control = {};
LaraInventoryData Inventory; PlayerStatusData Status = {};
CarriedWeaponInfo Weapons[(int)LaraWeaponType::NumWeapons]; LaraInventoryData Inventory = {};
FlareData Flare = {}; FlareData Flare = {};
TorchData Torch = {}; TorchData Torch = {};
CarriedWeaponInfo Weapons[(int)LaraWeaponType::NumWeapons] = {};
EulerAngles ExtraHeadRot = {}; EulerAngles ExtraHeadRot = {};
EulerAngles ExtraTorsoRot = {}; EulerAngles ExtraTorsoRot = {};
short WaterCurrentActive = 0;
Vector3i WaterCurrentPull = Vector3i::Zero;
ArmInfo LeftArm = {}; ArmInfo LeftArm = {};
ArmInfo RightArm = {}; ArmInfo RightArm = {};
EulerAngles TargetArmOrient = EulerAngles::Zero; EulerAngles TargetArmOrient = EulerAngles::Zero;
ItemInfo* TargetEntity = nullptr; ItemInfo* TargetEntity = nullptr; // TargetEntityPtr. Should use item number instead?
int Vehicle; EulerAngles TargetOrientation = EulerAngles::Zero;
int ExtraAnim; Pose NextCornerPos = Pose::Zero;
int HitFrame;
int HitDirection;
FX_INFO* SpasmEffect; // Not saved. TODO: Restore this effect.
short InteractedItem; int ProjectedFloorHeight = 0;
int ProjectedFloorHeight; int WaterSurfaceDist = 0;
EulerAngles TargetOrientation; short WaterCurrentActive = 0; // Sink number? Often used as bool.
int WaterSurfaceDist; Vector3i WaterCurrentPull = Vector3i::Zero;
Pose NextCornerPos;
int InteractedItem = 0; // Item number.
int Vehicle = 0; // Item number.
int ExtraAnim = 0; // Item number? Only ever set to NO_ITEM or 1.
PlayerEffectData Effect = {}; PlayerEffectData Effect = {};
// TODO: Rewrite and restore spasm effect.
int HitFrame = 0; // Frame index.
int HitDirection = 0; // Cardinal direction.
FX_INFO* SpasmEffect = nullptr; // Not saved.
signed char Location = 0; signed char Location = 0;
signed char HighestLocation = 0; signed char HighestLocation = 0;
signed char LocationPad = 0; signed char LocationPad = 0;