Skip to content

Commit

Permalink
Add Dumper namespace exceptionality (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mozz3d authored Jan 28, 2025
1 parent 78c3e9d commit 588936e
Show file tree
Hide file tree
Showing 23 changed files with 170 additions and 100 deletions.
16 changes: 13 additions & 3 deletions include/RED4ext/Dump/Reflection-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,20 @@ RED4EXT_INLINE void Dump(std::filesystem::path aOutPath, std::filesystem::path a
{
size_t i = 0;

// Special case for AI
if (aInput.size() >= 2 && aInput[0] == 'A' && aInput[1] == 'I')
static constexpr std::pair<std::string_view, bool> uniqueNamespaces[] = {
{"AI", false}, {"GpuApi", true}, {"GpuWrapApiVertexPacking", true}, {"GpuWrapApi", true}};

for (const auto& [name, isSpecialCase] : uniqueNamespaces)
{
i = 2;
if (aInput.size() >= name.size() && aInput.starts_with(name))
{
i = name.size();

if (isSpecialCase)
{
return aInput.substr(0, i);
}
}
}

// Special case of "in", this will break directory layout for "ink", "interop", etc..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/NativeTypes.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApiVertexPackingPackingElement.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/VertexPacking/PackingElement.hpp>

namespace RED4ext
{
struct GpuWrapApiVertexLayoutDesc
namespace GpuWrapApi
{
struct VertexLayoutDesc
{
static constexpr const char* NAME = "GpuWrapApiVertexLayoutDesc";
static constexpr const char* ALIAS = NAME;

StaticArray<GpuWrapApiVertexPackingPackingElement, 32> elements; // 00
StaticArray<GpuWrapApi::VertexPacking::PackingElement, 32> elements; // 00
StaticArray<uint8_t, 8> slotStrides; // A4
uint32_t slotMask; // B0
uint32_t hash; // B4
};
RED4EXT_ASSERT_SIZE(GpuWrapApiVertexLayoutDesc, 0xB8);
RED4EXT_ASSERT_SIZE(VertexLayoutDesc, 0xB8);
} // namespace GpuWrapApi
using GpuWrapApiVertexLayoutDesc = GpuWrapApi::VertexLayoutDesc;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApiVertexPackingEStreamType : uint8_t
namespace GpuWrapApi::VertexPacking {
enum class EStreamType : uint8_t
{
ST_PerVertex = 0,
ST_PerInstance = 1,
ST_Max = 2,
ST_Invalid = 255,
};
} // namespace GpuWrapApi::VertexPacking
using GpuWrapApiVertexPackingEStreamType = GpuWrapApi::VertexPacking::EStreamType;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

// clang-format off

// This file is generated from the Game's Reflection data

#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/VertexPacking/EStreamType.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/VertexPacking/ePackingType.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/VertexPacking/ePackingUsage.hpp>

namespace RED4ext
{
namespace GpuWrapApi::VertexPacking
{
struct PackingElement
{
static constexpr const char* NAME = "GpuWrapApiVertexPackingPackingElement";
static constexpr const char* ALIAS = NAME;

GpuWrapApi::VertexPacking::ePackingType type; // 00
GpuWrapApi::VertexPacking::ePackingUsage usage; // 01
uint8_t usageIndex; // 02
uint8_t streamIndex; // 03
GpuWrapApi::VertexPacking::EStreamType streamType; // 04
};
RED4EXT_ASSERT_SIZE(PackingElement, 0x5);
} // namespace GpuWrapApi::VertexPacking
using GpuWrapApiVertexPackingPackingElement = GpuWrapApi::VertexPacking::PackingElement;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApiVertexPackingePackingType : uint8_t
namespace GpuWrapApi::VertexPacking {
enum class ePackingType : uint8_t
{
PT_Float1 = 0,
PT_Float2 = 1,
Expand Down Expand Up @@ -43,6 +44,8 @@ enum class GpuWrapApiVertexPackingePackingType : uint8_t
PT_Max = 31,
PT_Invalid = 255,
};
} // namespace GpuWrapApi::VertexPacking
using GpuWrapApiVertexPackingePackingType = GpuWrapApi::VertexPacking::ePackingType;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApiVertexPackingePackingUsage : uint8_t
namespace GpuWrapApi::VertexPacking {
enum class ePackingUsage : uint8_t
{
PS_SysPosition = 0,
PS_Position = 1,
Expand Down Expand Up @@ -36,6 +37,8 @@ enum class GpuWrapApiVertexPackingePackingUsage : uint8_t
PS_Max = 24,
PS_Invalid = 255,
};
} // namespace GpuWrapApi::VertexPacking
using GpuWrapApiVertexPackingePackingUsage = GpuWrapApi::VertexPacking::ePackingUsage;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApieIndexBufferChunkType : uint8_t
namespace GpuWrapApi {
enum class eIndexBufferChunkType : uint8_t
{
IBCT_IndexUInt = 0,
IBCT_IndexUShort = 1,
IBCT_Max = 2,
};
} // namespace GpuWrapApi
using GpuWrapApieIndexBufferChunkType = GpuWrapApi::eIndexBufferChunkType;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApieTextureFormat : uint8_t
namespace GpuWrapApi {
enum class eTextureFormat : uint8_t
{
TEXFMT_A8_Unorm = 0,
TEXFMT_R8_Unorm = 1,
Expand Down Expand Up @@ -77,6 +78,8 @@ enum class GpuWrapApieTextureFormat : uint8_t
TEXFMT_Uint_32 = TEXFMT_R32_Uint,
TEXFMT_Uint_R32G32B32A32 = TEXFMT_R16G16B16A16_Uint,
};
} // namespace GpuWrapApi
using GpuWrapApieTextureFormat = GpuWrapApi::eTextureFormat;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApieTextureGroup : uint8_t
namespace GpuWrapApi {
enum class eTextureGroup : uint8_t
{
TEXG_Generic_Color = 1,
TEXG_Generic_Grayscale = 2,
Expand All @@ -22,6 +23,8 @@ enum class GpuWrapApieTextureGroup : uint8_t
TEXG_Multilayer_Grayscale = 11,
TEXG_Multilayer_Microblend = 12,
};
} // namespace GpuWrapApi
using GpuWrapApieTextureGroup = GpuWrapApi::eTextureGroup;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
#include <cstdint>
namespace RED4ext
{
enum class GpuWrapApieTextureType : uint8_t
namespace GpuWrapApi {
enum class eTextureType : uint8_t
{
TEXTYPE_2D = 0,
TEXTYPE_CUBE = 1,
TEXTYPE_ARRAY = 2,
TEXTYPE_3D = 3,
};
} // namespace GpuWrapApi
using GpuWrapApieTextureType = GpuWrapApi::eTextureType;
} // namespace RED4ext

// clang-format on

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/NativeTypes.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApieTextureFormat.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/eTextureFormat.hpp>

namespace RED4ext
{
Expand All @@ -16,8 +16,8 @@ struct PSODescRenderTargetSetup
static constexpr const char* NAME = "PSODescRenderTargetSetup";
static constexpr const char* ALIAS = NAME;

StaticArray<GpuWrapApieTextureFormat, 8> rtFormats; // 00
GpuWrapApieTextureFormat dsFormat; // 0C
StaticArray<GpuWrapApi::eTextureFormat, 8> rtFormats; // 00
GpuWrapApi::eTextureFormat dsFormat; // 0C
uint8_t unk0D[0x10 - 0xD]; // D
};
RED4EXT_ASSERT_SIZE(PSODescRenderTargetSetup, 0x10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/ETextureCompression.hpp>
#include <RED4ext/Scripting/Natives/Generated/ETextureRawFormat.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApieTextureGroup.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/eTextureGroup.hpp>

namespace RED4ext
{
Expand All @@ -19,7 +19,7 @@ struct STextureGroupSetup

ETextureCompression compression; // 00
ETextureRawFormat rawFormat; // 04
GpuWrapApieTextureGroup group; // 08
GpuWrapApi::eTextureGroup group; // 08
uint8_t platformMipBiasPC; // 09
uint8_t platformMipBiasConsole; // 0A
bool isStreamable; // 0B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct __declspec(align(0x10)) PhotoModeSystem : game::IPhotoModeSystem
static constexpr const char* NAME = "gamePhotoModeSystem";
static constexpr const char* ALIAS = "PhotoModeSystem";

uint8_t unk48[0xA40 - 0x48]; // 48
uint8_t unk48[0xA60 - 0x48]; // 48
};
RED4EXT_ASSERT_SIZE(PhotoModeSystem, 0xA40);
RED4EXT_ASSERT_SIZE(PhotoModeSystem, 0xA60);
} // namespace game
using gamePhotoModeSystem = game::PhotoModeSystem;
using PhotoModeSystem = game::PhotoModeSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ struct Vehicle_Record : game::data::SpawnableObject_Record
static constexpr const char* NAME = "gamedataVehicle_Record";
static constexpr const char* ALIAS = "Vehicle_Record";

uint8_t unkF8[0x590 - 0xF8]; // F8
uint8_t unkF8[0x5A0 - 0xF8]; // F8
};
RED4EXT_ASSERT_SIZE(Vehicle_Record, 0x590);
RED4EXT_ASSERT_SIZE(Vehicle_Record, 0x5A0);
} // namespace game::data
using gamedataVehicle_Record = game::data::Vehicle_Record;
using Vehicle_Record = game::data::Vehicle_Record;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ struct ChangeCameraControlHintVisibilityEvent : red::Event
static constexpr const char* NAME = "gameuiChangeCameraControlHintVisibilityEvent";
static constexpr const char* ALIAS = "ChangeCameraControlHintVisibilityEvent";

bool visible; // 40
uint8_t unk41[0x48 - 0x41]; // 41
bool movementVisible; // 40
bool rotationVisible; // 41
uint8_t unk42[0x48 - 0x42]; // 42
};
RED4EXT_ASSERT_SIZE(ChangeCameraControlHintVisibilityEvent, 0x48);
} // namespace game::ui
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

// clang-format off

// This file is generated from the Game's Reflection data

#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/ink/CallbackBase.hpp>

namespace RED4ext
{
namespace ink
{
struct GameScreenshotCallback : ink::CallbackBase
{
static constexpr const char* NAME = "inkGameScreenshotCallback";
static constexpr const char* ALIAS = NAME;

uint8_t unk28[0x38 - 0x28]; // 28
};
RED4EXT_ASSERT_SIZE(GameScreenshotCallback, 0x38);
} // namespace ink
using inkGameScreenshotCallback = ink::GameScreenshotCallback;
} // namespace RED4ext

// clang-format on
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApieIndexBufferChunkType.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/eIndexBufferChunkType.hpp>

namespace RED4ext
{
Expand All @@ -17,7 +17,7 @@ struct IndexBufferChunk
static constexpr const char* NAME = "rendIndexBufferChunk";
static constexpr const char* ALIAS = NAME;

GpuWrapApieIndexBufferChunkType pe; // 00
GpuWrapApi::eIndexBufferChunkType pe; // 00
uint8_t unk01[0x4 - 0x1]; // 1
uint32_t teOffset; // 04
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApieTextureType.hpp>
#include <RED4ext/Scripting/Natives/Generated/GpuWrapApi/eTextureType.hpp>

namespace RED4ext
{
Expand All @@ -17,7 +17,7 @@ struct RenderTextureBlobTextureInfo
static constexpr const char* NAME = "rendRenderTextureBlobTextureInfo";
static constexpr const char* ALIAS = NAME;

GpuWrapApieTextureType type; // 00
GpuWrapApi::eTextureType type; // 00
uint8_t unk01[0x4 - 0x1]; // 1
uint32_t textureDataSize; // 04
uint32_t sliceSize; // 08
Expand Down
Loading

0 comments on commit 588936e

Please sign in to comment.