refactor(Enums): Changed to enum class

This commit is contained in:
Yimura 2021-05-20 15:48:36 +02:00
parent 091dd429d5
commit 1317bc09cd
2 changed files with 24 additions and 22 deletions

View File

@ -1,14 +1,14 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
enum eGameState : std::uint32_t enum class eGameState : std::uint32_t
{ {
Playing = 0 Playing = 0
}; };
constexpr auto MAX_PLAYERS = 32; constexpr auto MAX_PLAYERS = 32;
enum ControllerInputs : std::uint32_t enum class ControllerInputs : std::uint32_t
{ {
INPUT_NEXT_CAMERA, INPUT_NEXT_CAMERA,
INPUT_LOOK_LR, INPUT_LOOK_LR,
@ -377,7 +377,7 @@ enum ControllerInputs : std::uint32_t
SCRIPTED_INPUT_LAST SCRIPTED_INPUT_LAST
}; };
enum ExplosionTypes : std::uint32_t enum class ExplosionTypes : std::uint32_t
{ {
EXPLOSION_GRENADE, EXPLOSION_GRENADE,
EXPLOSION_GRENADELAUNCHER, EXPLOSION_GRENADELAUNCHER,
@ -418,7 +418,7 @@ enum ExplosionTypes : std::uint32_t
EXPLOSION_SNOWBALL = 39 EXPLOSION_SNOWBALL = 39
}; };
enum HudColor : std::uint32_t enum class HudColor : std::uint32_t
{ {
HUD_COLOUR_PURE_WHITE, HUD_COLOUR_PURE_WHITE,
HUD_COLOUR_WHITE, HUD_COLOUR_WHITE,
@ -638,7 +638,7 @@ enum HudColor : std::uint32_t
HUD_COLOUR_STUNT_2 HUD_COLOUR_STUNT_2
}; };
enum RadioStationIndexes : std::uint32_t enum class RadioStationIndexes : std::uint32_t
{ {
RADIO_LSROCKRADIO, RADIO_LSROCKRADIO,
RADIO_NONSTOPPOPFM, RADIO_NONSTOPPOPFM,
@ -664,7 +664,7 @@ enum RadioStationIndexes : std::uint32_t
RADIO_OFF RADIO_OFF
}; };
enum NetObjEntityType : uint16_t enum class NetObjEntityType : uint16_t
{ {
NetObjEntityType_Automobile, NetObjEntityType_Automobile,
NetObjEntityType_Bike, NetObjEntityType_Bike,
@ -683,7 +683,7 @@ enum NetObjEntityType : uint16_t
NetObjEntityType_Max NetObjEntityType_Max
}; };
enum RockstarEvent : uint16_t enum class RockstarEvent : uint16_t
{ {
OBJECT_ID_FREED_EVENT, OBJECT_ID_FREED_EVENT,
OBJECT_ID_REQUEST_EVENT, OBJECT_ID_REQUEST_EVENT,
@ -775,7 +775,7 @@ enum RockstarEvent : uint16_t
NETWORK_CHECK_CATALOG_CRC NETWORK_CHECK_CATALOG_CRC
}; };
enum BlipIcons enum class BlipIcons
{ {
Null, Null,
Circle, Circle,
@ -1235,7 +1235,7 @@ enum BlipIcons
ZR380 ZR380
}; };
enum BlipColors enum class BlipColors
{ {
None, None,
Red, Red,
@ -1255,7 +1255,7 @@ enum BlipColors
WaypointColor = 0x54 WaypointColor = 0x54
}; };
enum BlipDisplayBits enum class BlipDisplayBits
{ {
BlipIsBright = (1 << 1), BlipIsBright = (1 << 1),
BlipEngageFlashing = (1 << 3), BlipEngageFlashing = (1 << 3),
@ -1275,12 +1275,12 @@ enum BlipDisplayBits
BlipIsSelected = (1 << 22), BlipIsSelected = (1 << 22),
}; };
enum BlipRenderBits enum class BlipRenderBits
{ {
BlipIsOnScreen = (1 << 6) BlipIsOnScreen = (1 << 6)
}; };
enum eFrameFlags : std::uint32_t enum class eFrameFlags : std::uint32_t
{ {
eFrameFlagExplosiveAmmo = 1 << 11, eFrameFlagExplosiveAmmo = 1 << 11,
eFrameFlagFireAmmo = 1 << 12, eFrameFlagFireAmmo = 1 << 12,
@ -1288,7 +1288,7 @@ enum eFrameFlags : std::uint32_t
eFrameFlagSuperJump = 1 << 14, eFrameFlagSuperJump = 1 << 14,
}; };
enum eNetObjType enum class eNetObjType
{ {
NET_OBJ_TYPE_AUTOMOBILE, NET_OBJ_TYPE_AUTOMOBILE,
NET_OBJ_TYPE_BIKE, NET_OBJ_TYPE_BIKE,
@ -1306,13 +1306,13 @@ enum eNetObjType
NET_OBJ_TYPE_TRAIN NET_OBJ_TYPE_TRAIN
}; };
enum eNetObjectFlags : std::uint16_t enum class eNetObjectFlags : std::uint16_t
{ {
NET_OBJ_FLAGS_FROM_SCRIPT = 1 << 2, NET_OBJ_FLAGS_FROM_SCRIPT = 1 << 2,
NET_OBJ_FLAGS_SCRIPTED = 1 << 6, NET_OBJ_FLAGS_SCRIPTED = 1 << 6,
}; };
enum eAckCode : std::uint32_t enum class eAckCode : std::uint32_t
{ {
ACKCODE_SUCCESS, ACKCODE_SUCCESS,
ACKCODE_FAIL, ACKCODE_FAIL,
@ -1325,7 +1325,7 @@ enum eAckCode : std::uint32_t
ACKCODE_NONE ACKCODE_NONE
}; };
enum PedBones : std::uint32_t enum class PedBones : std::uint32_t
{ {
SKEL_ROOT = 0x0, SKEL_ROOT = 0x0,
SKEL_Pelvis = 0x2E28, SKEL_Pelvis = 0x2E28,

View File

@ -11,17 +11,19 @@ namespace big::gta_util
{ {
inline void defuse_event(RockstarEvent e, bool toggle) inline void defuse_event(RockstarEvent e, bool toggle)
{ {
if (g_pointers->m_event_ptr[e] == nullptr) return; int event_index = (int)e;
char* p = (char*)g_pointers->m_event_ptr[e]; if (g_pointers->m_event_ptr[event_index] == nullptr) return;
char* p = (char*)g_pointers->m_event_ptr[event_index];
if (toggle) if (toggle)
{ {
if (g_pointers->m_event_restore[e] == 0) if (g_pointers->m_event_restore[event_index] == 0)
g_pointers->m_event_restore[e] = p[0]; g_pointers->m_event_restore[event_index] = p[0];
*p = (unsigned char)0xC3; *p = (unsigned char)0xC3;
} }
else if (g_pointers->m_event_restore[e] != 0) else if (g_pointers->m_event_restore[event_index] != 0)
*p = g_pointers->m_event_restore[e]; *p = g_pointers->m_event_restore[event_index];
} }
inline CPed *get_local_ped() inline CPed *get_local_ped()