mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +00:00
breakout object bits into scoped enum (#997)
* breakout object bits into enum class tested that things still work as expected use the inplace set bits where appropiate * add inline
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "dLogger.h"
|
||||
|
||||
enum eInventoryType : uint32_t;
|
||||
enum class eObjectBits : size_t;
|
||||
enum class eReplicaComponentType : uint32_t;
|
||||
|
||||
/*!
|
||||
@@ -66,9 +67,9 @@ namespace GeneralUtils {
|
||||
|
||||
//! Sets a bit on a numerical value
|
||||
template <typename T>
|
||||
void SetBit(T& value, size_t index) {
|
||||
inline void SetBit(T& value, eObjectBits bits) {
|
||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
||||
|
||||
auto index = static_cast<size_t>(bits);
|
||||
if (index > (sizeof(T) * 8) - 1) {
|
||||
return;
|
||||
}
|
||||
@@ -78,9 +79,9 @@ namespace GeneralUtils {
|
||||
|
||||
//! Clears a bit on a numerical value
|
||||
template <typename T>
|
||||
void ClearBit(T& value, size_t index) {
|
||||
inline void ClearBit(T& value, eObjectBits bits) {
|
||||
static_assert(std::is_arithmetic<T>::value, "Not an arithmetic type");
|
||||
|
||||
auto index = static_cast<size_t>(bits);
|
||||
if (index > (sizeof(T) * 8 - 1)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -177,14 +177,6 @@ union suchar {
|
||||
|
||||
//=========== LU ENUMS ============
|
||||
|
||||
//! An enum for object ID bits
|
||||
enum eObjectBits : int32_t {
|
||||
OBJECT_BIT_PERSISTENT = 32, //!< The 32 bit index
|
||||
OBJECT_BIT_CLIENT = 46, //!< The 46 bit index
|
||||
OBJECT_BIT_SPAWNED = 58, //!< The 58 bit index
|
||||
OBJECT_BIT_CHARACTER = 60 //!< The 60 bit index
|
||||
};
|
||||
|
||||
//! An enum for MatchUpdate types
|
||||
enum eMatchUpdate : int {
|
||||
MATCH_UPDATE_PLAYER_JOINED = 0,
|
||||
|
13
dCommon/dEnums/eObjectBits.h
Normal file
13
dCommon/dEnums/eObjectBits.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef __EOBJECTBITS__H__
|
||||
#define __EOBJECTBITS__H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class eObjectBits : size_t {
|
||||
PERSISTENT = 32,
|
||||
CLIENT = 46,
|
||||
SPAWNED = 58,
|
||||
CHARACTER = 60
|
||||
};
|
||||
|
||||
#endif //!__EOBJECTBITS__H__
|
Reference in New Issue
Block a user