Session Events (#32)

This commit is contained in:
Ryan 2024-07-27 22:24:50 -04:00 committed by GitHub
parent 8358e73c43
commit ec19493aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 157 additions and 25 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.11)
project(RDR-Classes)
project(RDR-Classes LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "Reversed structures for Red Dead Redemption 2 PC")
include(CheckIncludeFileCXX)
@ -15,8 +15,8 @@ set(OK TRUE)
file(GLOB_RECURSE HEADERS "**.hpp")
file(GLOB_RECURSE SRC_MAIN "**.cpp")
source_group(FILES "${SRC_MAIN}")
add_library(RDR-Classes MODULE "${SRC_MAIN}")
add_library(RDR-Classes STATIC "${SRC_MAIN}" "${HEADERS}")
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
message(STATUS "")

View File

@ -27,6 +27,7 @@
#include "network/rlGamerInfoBase.hpp"
#include "network/rlScPeerConnection.hpp"
#include "network/rlScSession.hpp"
#include "network/rlScSessionEvent.hpp"
#include "network/rlScSessionManagerImpl.hpp"
#include "network/rlScSessionMultiplayer.hpp"
#include "network/rlScSessionPeer.hpp"

View File

@ -16,6 +16,7 @@ namespace rage
}
};
static_assert(sizeof(rlScSessionId) == 0x10);
using rlScSessionRequestId = rlScSessionId; // for now
class rlScSessionPeerPoolEntry
{

View File

@ -0,0 +1,126 @@
#pragma once
#include "rlGamerHandle.hpp"
#include "rlGamerInfoBase.hpp"
#include "rlScSession.hpp"
#include "rage/atUri.hpp"
#pragma pack(push, 8)
namespace rage
{
enum class SessionEvent : std::uint32_t
{
LEAVE_SESSION = 6,
ADD_PLAYER = 7,
REMOVE_PLAYER = 8,
HOST_CHANGED = 9,
QUEUE_ERROR = 17,
LOCALIZED_MESSAGE = 19,
CONFIG_PARAM = 20,
COMPLAINT_RECEIVED = 31,
QUEUE_ENTERED = 32,
ADMIN_SECURITY_INVITE = 38
};
class rlScSessionEvent
{
public:
virtual ~rlScSessionEvent() = default;
SessionEvent m_EventType;
template<typename T>
inline T* As()
{
return T*(this);
}
};
static_assert(sizeof(rage::rlScSessionEvent) == 0x10);
class rlScLeaveSessionEvent : public rlScSessionEvent
{
public:
rage::rlScSessionId m_SessionId;
int m_Reason;
int m_Reason2;
int m_PlayerCount;
};
static_assert(sizeof(rage::rlScLeaveSessionEvent) == 0x30);
class rlScAddPlayerEvent : public rlScSessionEvent
{
public:
rage::rlScSessionId m_SessionId;
rage::rlScSessionPeerIdentifier m_Identifier;
rage::rlGamerInfoBase m_PeerAddress;
};
static_assert(sizeof(rage::rlScAddPlayerEvent) == 0xD0);
class rlScRemovePlayerEvent : public rlScSessionEvent
{
public:
rage::rlScSessionId m_SessionId;
rage::rlScSessionPeerIdentifier m_Identifier;
};
static_assert(sizeof(rage::rlScRemovePlayerEvent) == 0x38);
class rlScHostChangedEvent : public rlScSessionEvent
{
public:
rage::rlScSessionId m_SessionId;
int m_OldIndex;
int m_NewIndex;
};
static_assert(sizeof(rage::rlScHostChangedEvent) == 0x28);
class rlScComplaintReceivedEvent : public rlScSessionEvent
{
public:
rage::rlGamerHandle m_Complainer;
};
static_assert(sizeof(rage::rlScComplaintReceivedEvent) == 0x20);
class rlScQueueEnteredEvent : public rlScSessionEvent
{
public:
rage::rlScSessionRequestId m_RequestId;
int m_QueueGroup;
int m_OptionFlags;
};
static_assert(sizeof(rage::rlScQueueEnteredEvent) == 0x28);
class rlScQueueErrorEvent : public rlScSessionEvent
{
public:
rage::rlScSessionRequestId m_RequestId;
int m_Reason;
};
static_assert(sizeof(rage::rlScQueueErrorEvent) == 0x28);
// not rlScLocalizedMessageEvent
class rlScLocalizedMessage : public rlScSessionEvent
{
public:
char m_Key[128];
};
static_assert(sizeof(rage::rlScLocalizedMessage) == 0x90);
class rlScConfigParamEvent : public rlScSessionEvent
{
public:
int m_NameHash; // TODO: reverse this
char m_Value[32];
};
static_assert(sizeof(rage::rlScConfigParamEvent) == 0x38);
class rlScAdminSecurityInviteEvent : public rlScSessionEvent
{
public:
rage::rlGamerHandle m_Handle;
int m_InviteId;
int m_Flags;
rage::atUri m_ServerUri;
int m_SessionType;
};
static_assert(sizeof(rage::rlScAdminSecurityInviteEvent) == 0x4B8);
}
#pragma pack(pop)

View File

@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#pragma pack(push, 8)
namespace rage
{
class atUri
@ -22,3 +23,4 @@ namespace rage
};
static_assert(sizeof(atUri) == 0x488);
}
#pragma pack(pop)

View File

@ -1,6 +1,7 @@
#pragma once
#include "script/types.hpp"
#include "rage/joaat.hpp"
#include <unordered_map> // TODO: remove!
enum class CampState
{
@ -10,7 +11,7 @@ enum class CampState
CLEANUP
};
inline std::map<CampState, std::string> g_CampStateMap = {
inline std::unordered_map<CampState, std::string> g_CampStateMap = {
{CampState::INVALID, "Invalid"},
{CampState::WAITING, "Waiting"},
{CampState::RUNNING, "Running"},
@ -19,22 +20,22 @@ inline std::map<CampState, std::string> g_CampStateMap = {
enum class CampLocationIndex : std::uint32_t
{
GRIZZLIES_CAMP = rage::joaat("GRIZZLIES_CAMP"),
BAYOU_NAWAS_CAMP = rage::joaat("BAYOU_NAWAS_CAMP"),
BIG_VALLEY_CAMP = rage::joaat("BIG_VALLEY_CAMP"),
CHOLLA_SPRINGS_CAMP = rage::joaat("CHOLLA_SPRINGS_CAMP"),
CUMBERLAND_FOREST_CAMP = rage::joaat("CUMBERLAND_FOREST_CAMP"),
GAPTOOTH_RIDGE_CAMP = rage::joaat("GAPTOOTH_RIDGE_CAMP"),
GREAT_PLAINS_CAMP = rage::joaat("GREAT_PLAINS_CAMP"),
HEARTLAND_CAMP = rage::joaat("HEARTLAND_CAMP"),
HENNIGANS_STEAD_CAMP = rage::joaat("HENNIGANS_STEAD_CAMP"),
RIO_BRAVO_CAMP = rage::joaat("RIO_BRAVO_CAMP"),
ROANOKE_RIDGE_CAMP = rage::joaat("ROANOKE_RIDGE_CAMP"),
SCARLETT_MEADOWS_CAMP = rage::joaat("SCARLETT_MEADOWS_CAMP"),
TALL_TREES_CAMP = rage::joaat("TALL_TREES_CAMP"),
GRIZZLIES_CAMP = rage::Joaat("GRIZZLIES_CAMP"),
BAYOU_NAWAS_CAMP = rage::Joaat("BAYOU_NAWAS_CAMP"),
BIG_VALLEY_CAMP = rage::Joaat("BIG_VALLEY_CAMP"),
CHOLLA_SPRINGS_CAMP = rage::Joaat("CHOLLA_SPRINGS_CAMP"),
CUMBERLAND_FOREST_CAMP = rage::Joaat("CUMBERLAND_FOREST_CAMP"),
GAPTOOTH_RIDGE_CAMP = rage::Joaat("GAPTOOTH_RIDGE_CAMP"),
GREAT_PLAINS_CAMP = rage::Joaat("GREAT_PLAINS_CAMP"),
HEARTLAND_CAMP = rage::Joaat("HEARTLAND_CAMP"),
HENNIGANS_STEAD_CAMP = rage::Joaat("HENNIGANS_STEAD_CAMP"),
RIO_BRAVO_CAMP = rage::Joaat("RIO_BRAVO_CAMP"),
ROANOKE_RIDGE_CAMP = rage::Joaat("ROANOKE_RIDGE_CAMP"),
SCARLETT_MEADOWS_CAMP = rage::Joaat("SCARLETT_MEADOWS_CAMP"),
TALL_TREES_CAMP = rage::Joaat("TALL_TREES_CAMP"),
};
inline std::map<CampLocationIndex, std::string> g_CampLocationMap = {
inline std::unordered_map<CampLocationIndex, std::string> g_CampLocationMap = {
{CampLocationIndex::GRIZZLIES_CAMP, "Grizzlies"},
{CampLocationIndex::BAYOU_NAWAS_CAMP, "Bayou Nawas"},
{CampLocationIndex::BIG_VALLEY_CAMP, "Big Valley"},
@ -67,7 +68,7 @@ enum class CampBit
WHITE_FLAG_LOCKED_FOR_CONTENT
};
inline std::map<CampBit, std::string> g_CampBitMap = {
inline std::unordered_map<CampBit, std::string> g_CampBitMap = {
{CampBit::IS_LAUNCHED, "Is Launched"},
{CampBit::IS_ATTACKING, "Is Attacking"},
{CampBit::IS_ACTIVE, "Is Active"},
@ -92,7 +93,7 @@ enum class CampContentType
CAMP_RAID
};
inline std::map<CampContentType, std::string> g_CampContentTypeMap = {
inline std::unordered_map<CampContentType, std::string> g_CampContentTypeMap = {
{CampContentType::NONE, "None"},
{CampContentType::NET_BEAT, "Net Beat"},
{CampContentType::DYNAMIC_MISSION, "Dynamic Mission"},

View File

@ -1,5 +1,6 @@
#pragma once
#include "script/types.hpp"
#include "unordered_map"
enum class PlayerStatus
{
@ -355,7 +356,7 @@ enum class Region
MAX
};
inline std::map<Region, std::string> g_RegionMap = {
inline std::unordered_map<Region, std::string> g_RegionMap = {
{ Region::INVALID, "Invalid" },
{ Region::BAY_CRAWDADWILLIES, "Crawdad Willies" },
{ Region::BAY_MACOMBS_END, "Macomb's End" },
@ -522,7 +523,7 @@ enum class District
HENNIGANS_STEAD
};
inline std::map<District, std::string> g_DistrictMap = {
inline std::unordered_map<District, std::string> g_DistrictMap = {
{ District::INVALID, "Invalid" },
{ District::BAYOU_NWA, "Bayou Nwa" },
{ District::BIG_VALLEY, "Big Valley" },
@ -562,7 +563,7 @@ enum class Language
CHINESE_SIMP
};
inline std::map<Language, std::string> g_LanguageMap = {
inline std::unordered_map<Language, std::string> g_LanguageMap = {
{ Language::UNDEFINED, "Undefined" },
{ Language::ENGLISH, "English" },
{ Language::FRENCH, "French" },
@ -588,7 +589,7 @@ enum class PassiveState
FORCED_FROM_PASSIVE
};
inline std::map<PassiveState, std::string> g_PassiveStateMap = {
inline std::unordered_map<PassiveState, std::string> g_PassiveStateMap = {
{PassiveState::NOT_PASSIVE, "Not Passive"},
{PassiveState::WAITING_FOR_PASSIVE, "Waiting for Passive"},
{PassiveState::PASSIVE, "Passive"},