Split out unrelated changes to CleanupRoundup branch

This commit is contained in:
jadebenn 2024-02-03 02:07:57 -06:00
parent b3dd1d3d4c
commit 74d8a5b167
6 changed files with 104 additions and 91 deletions

View File

@ -10,6 +10,7 @@
#include "Database.h"
#include "eConnectionType.h"
#include "eChatInternalMessageType.h"
#include "eGameMasterLevel.h"
#include "ChatPackets.h"
#include "dConfig.h"
@ -20,6 +21,14 @@ void PlayerContainer::Initialize() {
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_friends")).value_or(m_MaxNumberOfFriends);
}
PlayerContainer::~PlayerContainer() {
m_Players.clear();
}
PlayerData::PlayerData() {
gmLevel = eGameMasterLevel::CIVILIAN;
}
TeamData::TeamData() {
lootFlag = Game::config->GetValue("default_team_loot") == "0" ? 0 : 1;
}

View File

@ -1,13 +1,14 @@
#pragma once
#include <map>
#include "dCommonVars.h"
#include "eGameMasterLevel.h"
#include "RakString.h"
#include <vector>
#include "Game.h"
#include "dServer.h"
#include <unordered_map>
enum class eGameMasterLevel : uint8_t;
struct IgnoreData {
IgnoreData(const std::string& name, const LWOOBJID& id) : playerName(name), playerId(id) {}
inline bool operator==(const std::string& other) const noexcept {
@ -23,6 +24,7 @@ struct IgnoreData {
};
struct PlayerData {
PlayerData();
operator bool() const noexcept {
return playerID != LWOOBJID_EMPTY;
}
@ -43,7 +45,7 @@ struct PlayerData {
std::string playerName;
std::vector<FriendData> friends;
std::vector<IgnoreData> ignoredPlayers;
eGameMasterLevel gmLevel = eGameMasterLevel::CIVILIAN;
eGameMasterLevel gmLevel;
bool isFTP = false;
};
@ -59,6 +61,8 @@ struct TeamData {
class PlayerContainer {
public:
~PlayerContainer();
void Initialize();
void InsertPlayer(Packet* packet);
void RemovePlayer(Packet* packet);

View File

@ -162,7 +162,7 @@ public:
return new LDFData<T>(key, value);
}
inline static const T Default = {};
inline static T Default = {};
};
// LDF Types

View File

@ -39,49 +39,49 @@ constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate);
//=========== TYPEDEFS ==========
using LOT = int32_t; //!< A LOT
using LWOOBJID = int64_t; //!< An object ID (should be unsigned actually but ok)
using TSkillID = int32_t; //!< A skill ID
using LWOCLONEID = uint32_t; //!< Used for Clone IDs
using LWOMAPID = uint16_t; //!< Used for Map IDs
using LWOINSTANCEID = uint16_t; //!< Used for Instance IDs
using PROPERTYCLONELIST = uint32_t; //!< Used for Property Clone IDs
using StripId = uint32_t;
typedef int32_t LOT; //!< A LOT
typedef int64_t LWOOBJID; //!< An object ID (should be unsigned actually but ok)
typedef int32_t TSkillID; //!< A skill ID
typedef uint32_t LWOCLONEID; //!< Used for Clone IDs
typedef uint16_t LWOMAPID; //!< Used for Map IDs
typedef uint16_t LWOINSTANCEID; //!< Used for Instance IDs
typedef uint32_t PROPERTYCLONELIST; //!< Used for Property Clone IDs
typedef uint32_t StripId;
constexpr LWOOBJID LWOOBJID_EMPTY = 0; //!< An empty object ID
constexpr LOT LOT_NULL = -1; //!< A null LOT
constexpr int32_t LOOTTYPE_NONE = 0; //!< No loot type available
constexpr float SECONDARY_PRIORITY = 1.0f; //!< Secondary Priority
constexpr uint32_t INVENTORY_MAX = 9999999; //!< The Maximum Inventory Size
constexpr LWOCLONEID LWOCLONEID_INVALID = -1; //!< Invalid LWOCLONEID
constexpr LWOINSTANCEID LWOINSTANCEID_INVALID = -1; //!< Invalid LWOINSTANCEID
constexpr LWOMAPID LWOMAPID_INVALID = -1; //!< Invalid LWOMAPID
constexpr uint64_t LWOZONEID_INVALID = 0; //!< Invalid LWOZONEID
const LWOOBJID LWOOBJID_EMPTY = 0; //!< An empty object ID
const LOT LOT_NULL = -1; //!< A null LOT
const int32_t LOOTTYPE_NONE = 0; //!< No loot type available
const float SECONDARY_PRIORITY = 1.0f; //!< Secondary Priority
const uint32_t INVENTORY_MAX = 9999999; //!< The Maximum Inventory Size
const uint32_t LWOCLONEID_INVALID = -1; //!< Invalid LWOCLONEID
const uint16_t LWOINSTANCEID_INVALID = -1; //!< Invalid LWOINSTANCEID
const uint16_t LWOMAPID_INVALID = -1; //!< Invalid LWOMAPID
const uint64_t LWOZONEID_INVALID = 0; //!< Invalid LWOZONEID
constexpr float PI = 3.14159f;
const float PI = 3.14159f;
//============ STRUCTS ==============
struct LWOSCENEID {
public:
constexpr LWOSCENEID() noexcept { m_sceneID = -1; m_layerID = 0; }
constexpr LWOSCENEID(int sceneID) noexcept { m_sceneID = sceneID; m_layerID = 0; }
constexpr LWOSCENEID(int sceneID, unsigned int layerID) noexcept { m_sceneID = sceneID; m_layerID = layerID; }
LWOSCENEID() { m_sceneID = -1; m_layerID = 0; }
LWOSCENEID(int sceneID) { m_sceneID = sceneID; m_layerID = 0; }
LWOSCENEID(int sceneID, unsigned int layerID) { m_sceneID = sceneID; m_layerID = layerID; }
constexpr LWOSCENEID& operator=(const LWOSCENEID& rhs) noexcept { m_sceneID = rhs.m_sceneID; m_layerID = rhs.m_layerID; return *this; }
constexpr LWOSCENEID& operator=(const int rhs) noexcept { m_sceneID = rhs; m_layerID = 0; return *this; }
LWOSCENEID& operator=(const LWOSCENEID& rhs) { m_sceneID = rhs.m_sceneID; m_layerID = rhs.m_layerID; return *this; }
LWOSCENEID& operator=(const int rhs) { m_sceneID = rhs; m_layerID = 0; return *this; }
constexpr bool operator<(const LWOSCENEID& rhs) const noexcept { return (m_sceneID < rhs.m_sceneID || (m_sceneID == rhs.m_sceneID && m_layerID < rhs.m_layerID)); }
constexpr bool operator<(const int rhs) const noexcept { return m_sceneID < rhs; }
bool operator<(const LWOSCENEID& rhs) const { return (m_sceneID < rhs.m_sceneID || (m_sceneID == rhs.m_sceneID && m_layerID < rhs.m_layerID)); }
bool operator<(const int rhs) const { return m_sceneID < rhs; }
constexpr bool operator==(const LWOSCENEID& rhs) const noexcept { return (m_sceneID == rhs.m_sceneID && m_layerID == rhs.m_layerID); }
constexpr bool operator==(const int rhs) const noexcept { return m_sceneID == rhs; }
bool operator==(const LWOSCENEID& rhs) const { return (m_sceneID == rhs.m_sceneID && m_layerID == rhs.m_layerID); }
bool operator==(const int rhs) const { return m_sceneID == rhs; }
constexpr int GetSceneID() const noexcept { return m_sceneID; }
constexpr unsigned int GetLayerID() const noexcept { return m_layerID; }
const int GetSceneID() const { return m_sceneID; }
const unsigned int GetLayerID() const { return m_layerID; }
constexpr void SetSceneID(const int sceneID) noexcept { m_sceneID = sceneID; }
constexpr void SetLayerID(const unsigned int layerID) noexcept { m_layerID = layerID; }
void SetSceneID(const int sceneID) { m_sceneID = sceneID; }
void SetLayerID(const unsigned int layerID) { m_layerID = layerID; }
private:
int m_sceneID;
@ -90,14 +90,14 @@ private:
struct LWOZONEID {
public:
constexpr const LWOMAPID& GetMapID() const noexcept { return m_MapID; }
constexpr const LWOINSTANCEID& GetInstanceID() const noexcept { return m_InstanceID; }
constexpr const LWOCLONEID& GetCloneID() const noexcept { return m_CloneID; }
const LWOMAPID& GetMapID() const { return m_MapID; }
const LWOINSTANCEID& GetInstanceID() const { return m_InstanceID; }
const LWOCLONEID& GetCloneID() const { return m_CloneID; }
//In order: def constr, constr, assign op
constexpr LWOZONEID() noexcept { m_MapID = LWOMAPID_INVALID; m_InstanceID = LWOINSTANCEID_INVALID; m_CloneID = LWOCLONEID_INVALID; }
constexpr LWOZONEID(const LWOMAPID& mapID, const LWOINSTANCEID& instanceID, const LWOCLONEID& cloneID) noexcept { m_MapID = mapID; m_InstanceID = instanceID; m_CloneID = cloneID; }
constexpr LWOZONEID(const LWOZONEID& replacement) noexcept { *this = replacement; }
LWOZONEID() { m_MapID = LWOMAPID_INVALID; m_InstanceID = LWOINSTANCEID_INVALID; m_CloneID = LWOCLONEID_INVALID; }
LWOZONEID(const LWOMAPID& mapID, const LWOINSTANCEID& instanceID, const LWOCLONEID& cloneID) { m_MapID = mapID; m_InstanceID = instanceID; m_CloneID = cloneID; }
LWOZONEID(const LWOZONEID& replacement) { *this = replacement; }
private:
LWOMAPID m_MapID; //1000 for VE, 1100 for AG, etc...
@ -105,20 +105,20 @@ private:
LWOCLONEID m_CloneID; //To differentiate between "your property" and "my property". Always 0 for non-prop worlds.
};
constexpr LWOSCENEID LWOSCENEID_INVALID = -1;
const LWOSCENEID LWOSCENEID_INVALID = -1;
struct LWONameValue {
uint32_t length = 0; //!< The length of the name
std::u16string name; //!< The name
LWONameValue() = default;
LWONameValue(void) {}
LWONameValue(const std::u16string& name) {
this->name = name;
this->length = static_cast<uint32_t>(name.length());
}
~LWONameValue() = default;
~LWONameValue(void) {}
};
struct FriendData {

View File

@ -23,7 +23,7 @@
#include "CppScripts.h"
QuickBuildComponent::QuickBuildComponent(Entity* entity) : Component{ entity } {
QuickBuildComponent::QuickBuildComponent(Entity* entity) : Component(entity) {
std::u16string checkPreconditions = entity->GetVar<std::u16string>(u"CheckPrecondition");
if (!checkPreconditions.empty()) {
@ -283,47 +283,47 @@ void QuickBuildComponent::DespawnActivator() {
}
}
Entity* QuickBuildComponent::GetActivator() const {
Entity* QuickBuildComponent::GetActivator() {
return Game::entityManager->GetEntity(m_ActivatorId);
}
NiPoint3 QuickBuildComponent::GetActivatorPosition() const noexcept {
NiPoint3 QuickBuildComponent::GetActivatorPosition() {
return m_ActivatorPosition;
}
float QuickBuildComponent::GetResetTime() const noexcept {
float QuickBuildComponent::GetResetTime() {
return m_ResetTime;
}
float QuickBuildComponent::GetCompleteTime() const noexcept {
float QuickBuildComponent::GetCompleteTime() {
return m_CompleteTime;
}
int QuickBuildComponent::GetTakeImagination() const noexcept {
int QuickBuildComponent::GetTakeImagination() {
return m_TakeImagination;
}
bool QuickBuildComponent::GetInterruptible() const noexcept {
bool QuickBuildComponent::GetInterruptible() {
return m_Interruptible;
}
bool QuickBuildComponent::GetSelfActivator() const noexcept {
bool QuickBuildComponent::GetSelfActivator() {
return m_SelfActivator;
}
std::vector<int> QuickBuildComponent::GetCustomModules() const noexcept {
std::vector<int> QuickBuildComponent::GetCustomModules() {
return m_CustomModules;
}
int QuickBuildComponent::GetActivityId() const noexcept {
int QuickBuildComponent::GetActivityId() {
return m_ActivityId;
}
int QuickBuildComponent::GetPostImaginationCost() const noexcept {
int QuickBuildComponent::GetPostImaginationCost() {
return m_PostImaginationCost;
}
float QuickBuildComponent::GetTimeBeforeSmash() const noexcept {
float QuickBuildComponent::GetTimeBeforeSmash() {
return m_TimeBeforeSmash;
}
@ -337,19 +337,19 @@ Entity* QuickBuildComponent::GetBuilder() const {
return builder;
}
bool QuickBuildComponent::GetRepositionPlayer() const noexcept {
bool QuickBuildComponent::GetRepositionPlayer() const {
return m_RepositionPlayer;
}
void QuickBuildComponent::SetActivatorPosition(NiPoint3 value) noexcept {
void QuickBuildComponent::SetActivatorPosition(NiPoint3 value) {
m_ActivatorPosition = value;
}
void QuickBuildComponent::SetResetTime(float value) noexcept {
void QuickBuildComponent::SetResetTime(float value) {
m_ResetTime = value;
}
void QuickBuildComponent::SetCompleteTime(float value) noexcept {
void QuickBuildComponent::SetCompleteTime(float value) {
if (value < 0) {
m_CompleteTime = 4.5f;
} else {
@ -357,31 +357,31 @@ void QuickBuildComponent::SetCompleteTime(float value) noexcept {
}
}
void QuickBuildComponent::SetTakeImagination(int value) noexcept {
void QuickBuildComponent::SetTakeImagination(int value) {
m_TakeImagination = value;
}
void QuickBuildComponent::SetInterruptible(bool value) noexcept {
void QuickBuildComponent::SetInterruptible(bool value) {
m_Interruptible = value;
}
void QuickBuildComponent::SetSelfActivator(bool value) noexcept {
void QuickBuildComponent::SetSelfActivator(bool value) {
m_SelfActivator = value;
}
void QuickBuildComponent::SetCustomModules(std::vector<int> value) noexcept {
void QuickBuildComponent::SetCustomModules(std::vector<int> value) {
m_CustomModules = value;
}
void QuickBuildComponent::SetActivityId(int value) noexcept {
void QuickBuildComponent::SetActivityId(int value) {
m_ActivityId = value;
}
void QuickBuildComponent::SetPostImaginationCost(int value) noexcept {
void QuickBuildComponent::SetPostImaginationCost(int value) {
m_PostImaginationCost = value;
}
void QuickBuildComponent::SetTimeBeforeSmash(float value) noexcept {
void QuickBuildComponent::SetTimeBeforeSmash(float value) {
if (value < 0) {
m_TimeBeforeSmash = 10.0f;
} else {
@ -389,7 +389,7 @@ void QuickBuildComponent::SetTimeBeforeSmash(float value) noexcept {
}
}
void QuickBuildComponent::SetRepositionPlayer(bool value) noexcept {
void QuickBuildComponent::SetRepositionPlayer(bool value) {
m_RepositionPlayer = value;
}

View File

@ -50,124 +50,124 @@ public:
* Returns the entity that acts as the activator for this quickbuild
* @return the entity that acts as the activator for this quickbuild
*/
[[nodiscard]] Entity* GetActivator() const;
Entity* GetActivator();
/**
* Returns the spawn position of the activator for this quickbuild, if any
* @return the spawn position of the activator for this quickbuild, if any
*/
[[nodiscard]] NiPoint3 GetActivatorPosition() const noexcept;
NiPoint3 GetActivatorPosition();
/**
* Sets the spawn position for the activator of this quickbuild
* @param value the spawn position to set for the activator
*/
void SetActivatorPosition(NiPoint3 value) noexcept;
void SetActivatorPosition(NiPoint3 value);
/**
* Returns the time it takes for the quickbuild to reset after being built
* @return the time it takes for the quickbuild to reset after being built
*/
[[nodiscard]] float GetResetTime() const noexcept;
float GetResetTime();
/**
* Sets the time it takes for the quickbuild to reset after being built
* @param value the reset time to set
*/
void SetResetTime(float value) noexcept;
void SetResetTime(float value);
/**
* Returns the time it takes to complete the quickbuild
* @return the time it takes to complete the quickbuild
*/
[[nodiscard]] float GetCompleteTime() const noexcept;
float GetCompleteTime();
/**
* Sets the time it takes to complete the quickbuild
* @param value the completion time to set
*/
void SetCompleteTime(float value) noexcept;
void SetCompleteTime(float value);
/**
* Returns the imagination that's taken when completing the quickbuild
* @return the imagination that's taken when completing the quickbuild
*/
[[nodiscard]] int GetTakeImagination() const noexcept;
int GetTakeImagination();
/**
* Sets the imagination that's taken when completing the quickbuild
* @param value the imagination deduction to set
*/
void SetTakeImagination(int value) noexcept;
void SetTakeImagination(int value);
/**
* Returns if the quickbuild can be interrupted, currently unused
* @return if the quickbuild can be interrupted
*/
[[nodiscard]] bool GetInterruptible() const noexcept;
bool GetInterruptible();
/**
* Sets whether or not the quickbuild can be interrupted, currently unused
* @param value true if the quickbuild may be interrupted, false otherwise
*/
void SetInterruptible(bool value) noexcept;
void SetInterruptible(bool value);
/**
* Returns whether or not this entity contains a built-in activator
* @return whether or not this entity contains a built-in activator
*/
[[nodiscard]] bool GetSelfActivator() const noexcept;
bool GetSelfActivator();
/**
* Sets whether or not this entity contains a built-in activator. If set to false this will spawn activators on
* each new quickbuild.
* @param value whether or not this entity contains a built-in activator
*/
void SetSelfActivator(bool value) noexcept;
void SetSelfActivator(bool value);
/**
* Currently unused
*/
[[nodiscard]] std::vector<int> GetCustomModules() const noexcept;
std::vector<int> GetCustomModules();
/**
* Currently unused
*/
void SetCustomModules(std::vector<int> value) noexcept;
void SetCustomModules(std::vector<int> value);
/**
* Returns the activity ID for participating in this quickbuild
* @return the activity ID for participating in this quickbuild
*/
[[nodiscard]] int GetActivityId() const noexcept;
int GetActivityId();
/**
* Sets the activity ID for participating in this quickbuild
* @param value the activity ID to set
*/
void SetActivityId(int value) noexcept;
void SetActivityId(int value);
/**
* Currently unused
*/
[[nodiscard]] int GetPostImaginationCost() const noexcept;
int GetPostImaginationCost();
/**
* Currently unused
*/
void SetPostImaginationCost(int value) noexcept;
void SetPostImaginationCost(int value);
/**
* Returns the time it takes for an incomplete quickbuild to be smashed automatically
* @return the time it takes for an incomplete quickbuild to be smashed automatically
*/
[[nodiscard]] float GetTimeBeforeSmash() const noexcept;
float GetTimeBeforeSmash();
/**
* Sets the time it takes for an incomplete quickbuild to be smashed automatically
* @param value the time to set
*/
void SetTimeBeforeSmash(float value) noexcept;
void SetTimeBeforeSmash(float value);
/**
* Returns the current quickbuild state
@ -179,19 +179,19 @@ public:
* Returns the player that is currently building this quickbuild
* @return the player that is currently building this quickbuild
*/
[[nodiscard]] Entity* GetBuilder() const;
Entity* GetBuilder() const;
/**
* Returns whether or not the player is repositioned when initiating the quickbuild
* @return whether or not the player is repositioned when initiating the quickbuild
*/
[[nodiscard]] bool GetRepositionPlayer() const noexcept;
bool GetRepositionPlayer() const;
/**
* Sets whether or not the player is repositioned when initiating the quickbuild
* @param value whether or not the player is repositioned when initiating the quickbuild
*/
void SetRepositionPlayer(bool value) noexcept;
void SetRepositionPlayer(bool value);
/**
* Adds a callback that is called when the quickbuild is completed