Skip to content

Commit 1493e66

Browse files
committed
Reset vpaths after CreateProject has been called
Added premake project lua files to solutions Fixed a couple instances where vpath was not setup correctly Refactored MetaGen to now run within our Premake Build System Removed TypeParser, TypeGenerator
1 parent db1cf18 commit 1493e66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+14428
-6455
lines changed

Premake/ProjectUtil.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ Solution.Util.CreateProject = function(name, projectType, binDir, dependencies,
289289
if callback then
290290
callback()
291291
end
292+
293+
vpaths {}
292294
end
293295

294296
Solution.Util.CreateStaticLib = function(name, binDir, dependencies, callback)

Source/Base/Base.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@ Solution.Util.CreateStaticLib(mod.Name, Solution.Projects.Current.BinDir, mod.De
66
Solution.Util.SetLanguage("C++")
77
Solution.Util.SetCppDialect(20)
88

9+
local projFile = mod.Path .. "/" .. mod.Name .. ".lua"
910
local files = Solution.Util.GetFilesForCpp(mod.Path)
11+
table.insert(files, projFile)
12+
1013
Solution.Util.SetFiles(files)
1114
Solution.Util.SetIncludes(mod.Path)
1215
Solution.Util.SetDefines(defines)
1316

1417
Solution.Util.SetFilter("platforms:Win64", function()
1518
Solution.Util.SetDefines({"WIN32_LEAN_AND_MEAN", "NOMINMAX"})
1619
end)
20+
21+
vpaths {
22+
["/*"] = { "*.lua", mod.Name .. "/**" }
23+
}
1724
end)
1825

1926
Solution.Util.CreateDep(mod.NameLow, mod.Dependencies, function()

Source/Engine-Tests/Engine-Tests.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@ Solution.Util.CreateConsoleApp(mod.Name, Solution.Projects.Current.BinDir, mod.D
88
Solution.Util.SetLanguage("C++")
99
Solution.Util.SetCppDialect(20)
1010

11+
local projFile = mod.Path .. "/" .. mod.Name .. ".lua"
1112
local files = Solution.Util.GetFilesForCpp(mod.Path)
13+
table.insert(files, projFile)
14+
1215
Solution.Util.SetFiles(files)
1316
Solution.Util.SetIncludes(mod.Path)
1417
Solution.Util.SetDefines(defines)
1518

16-
vpaths { ["Tests"] = "**" }
19+
vpaths {
20+
["/*"] = { "*.lua" },
21+
["Catch2/*"] = { "../../Dependencies/catch2/catch2/**" },
22+
["Tests/*"] = { mod.Name .. "/**" }
23+
}
1724
end)

Source/FileFormat/FileFormat.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ Solution.Util.CreateStaticLib(mod.Name, Solution.Projects.Current.BinDir, mod.De
66
Solution.Util.SetLanguage("C++")
77
Solution.Util.SetCppDialect(20)
88

9+
local projFile = mod.Path .. "/" .. mod.Name .. ".lua"
910
local files = Solution.Util.GetFilesForCpp(mod.Path)
11+
table.insert(files, projFile)
12+
1013
Solution.Util.SetFiles(files)
1114
Solution.Util.SetIncludes(mod.Path)
1215
Solution.Util.SetDefines(defines)
16+
17+
vpaths {
18+
["/*"] = { "*.lua", mod.Name .. "/**" }
19+
}
1320
end)
1421

1522
Solution.Util.CreateDep(mod.NameLow, mod.Dependencies, function()

Source/FileFormat/FileFormat/Novus/ClientDB/ClientDB.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ namespace ClientDB
7979
};
8080

8181
template <typename T>
82-
concept ValidName = std::is_class_v<T> && requires { T::Name; } && std::same_as<std::decay_t<decltype(T::Name)>, std::string>;
82+
concept ValidName = std::is_class_v<T> && requires { T::NAME; } && std::same_as<std::decay_t<decltype(T::NAME)>, std::string>;
8383

8484
template <typename T>
85-
concept ValidNameHash = std::is_class_v<T> && requires { T::NameHash; } && std::same_as<std::decay_t<decltype(T::NameHash)>, u32>;
85+
concept ValidNameHash = std::is_class_v<T> && requires { T::NAME_HASH; } && std::same_as<std::decay_t<decltype(T::NAME_HASH)>, u32>;
8686

8787
template <typename T>
88-
concept ValidFieldInfo = std::is_class_v<T> && requires { T::FieldInfo; } && std::same_as<std::decay_t<decltype(T::FieldInfo)>, std::vector<FieldInfo>>;
88+
concept ValidFieldList = std::is_class_v<T> && requires { T::FIELD_LIST; } && std::same_as<std::decay_t<decltype(T::FIELD_LIST)>, std::vector<FieldInfo>>;
8989

9090
template <typename T>
91-
concept ValidClientDB = ValidName<T> && ValidNameHash<T> && ValidFieldInfo<T>;
91+
concept ValidClientDB = ValidName<T> && ValidNameHash<T> && ValidFieldList<T>;
9292

9393
struct Data
9494
{
@@ -100,17 +100,17 @@ namespace ClientDB
100100
bool Initialize(const std::vector<FieldInfo>& fieldInfos);
101101

102102
// Preferred overload if T meets the requirements.
103-
template <typename T> requires ValidFieldInfo<T>
103+
template <typename T> requires ValidFieldList<T>
104104
bool Initialize()
105105
{
106-
return Initialize(T::FieldInfo);
106+
return Initialize(T::FIELD_LIST);
107107
}
108108

109109
// Fallback overload to produce a custom error message when T is invalid.
110-
template <typename T, typename = std::enable_if_t<!ValidFieldInfo<T>>>
110+
template <typename T, typename = std::enable_if_t<!ValidFieldList<T>>>
111111
bool Initialize()
112112
{
113-
static_assert(ValidFieldInfo<T>, "T must be a struct or class with a static member FieldInfo of type std::vector<FieldInfo>");
113+
static_assert(ValidFieldList<T>, "T must be a struct or class with a static member FIELD_LIST of type std::vector<FieldInfo>");
114114
return false;
115115
}
116116

Source/Gameplay/Gameplay.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
local mod = Solution.Util.CreateModuleTable("Gameplay", { "base", "network", "meta" })
2-
dependson { "Gen-Meta" }
32

43
Solution.Util.CreateStaticLib(mod.Name, Solution.Projects.Current.BinDir, mod.Dependencies, function()
54
local defines = { "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS", "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS" }
65

76
Solution.Util.SetLanguage("C++")
87
Solution.Util.SetCppDialect(20)
98

9+
local projFile = mod.Path .. "/" .. mod.Name .. ".lua"
1010
local files = Solution.Util.GetFilesForCpp(mod.Path)
11+
table.insert(files, projFile)
12+
1113
Solution.Util.SetFiles(files)
1214
Solution.Util.SetIncludes(mod.Path)
1315
Solution.Util.SetDefines(defines)
16+
17+
vpaths {
18+
["/*"] = { "*.lua", mod.Name .. "/**" }
19+
}
1420
end)
1521

1622
Solution.Util.CreateDep(mod.NameLow, mod.Dependencies, function()

Source/Gameplay/Gameplay/Network/Define.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
#include <Base/Types.h>
55

6-
#include <Meta/Generated/Shared/NetFieldsEnum.h>
6+
#include <MetaGen/EnumTraits.h>
7+
#include <MetaGen/Shared/NetField/NetField.h>
78

89
namespace Network
910
{
@@ -20,9 +21,9 @@ namespace Network
2021
Connected
2122
};
2223

23-
using ObjectNetFields = NetFields<Generated::ObjectNetFieldsEnum>;
24-
using ObjectNetFieldsListener = NetFieldListener<Generated::ObjectNetFieldsEnum>;
24+
using ObjectNetFields = NetFields<MetaGen::Shared::NetField::ObjectNetFieldEnum>;
25+
using ObjectNetFieldsListener = NetFieldListener<MetaGen::Shared::NetField::ObjectNetFieldEnum>;
2526

26-
using UnitNetFields = NetFields<Generated::UnitNetFieldsEnum>;
27-
using UnitNetFieldsListener = NetFieldListener<Generated::UnitNetFieldsEnum>;
27+
using UnitNetFields = NetFields<MetaGen::Shared::NetField::UnitNetFieldEnum>;
28+
using UnitNetFieldsListener = NetFieldListener<MetaGen::Shared::NetField::UnitNetFieldEnum>;
2829
}

Source/Gameplay/Gameplay/Network/GameMessageRouter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <Base/Memory/Bytebuffer.h>
44

5-
#include <Meta/Generated/Shared/NetworkPacket.h>
5+
#include <MetaGen/Shared/Packet/Packet.h>
66

77
namespace Network
88
{
@@ -18,7 +18,7 @@ namespace Network
1818
if (!message.buffer->Get(header))
1919
return false;
2020

21-
if (header.opcode == Generated::InvalidPacket::PACKET_ID || header.opcode >= (u16)Generated::PacketListEnum::Count)
21+
if (header.opcode == (u16)MetaGen::PacketListEnum::Invalid || header.opcode >= (u16)MetaGen::PacketListEnum::Count)
2222
return false;
2323

2424
return true;

Source/Gameplay/Gameplay/Network/GameMessageRouter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <Base/FunctionTraits.h>
66
#include <Base/Memory/Bytebuffer.h>
77

8-
#include <Meta/Generated/Shared/PacketList.h>
8+
#include <MetaGen/PacketList.h>
99

1010
#include <Network/Define.h>
1111

@@ -76,6 +76,6 @@ namespace Network
7676
bool CallHandler(SocketID socketID, Network::MessageHeader& header, Message& message);
7777

7878
private:
79-
GameMessageHandler _handlers[(u16)Generated::PacketListEnum::Count];
79+
GameMessageHandler _handlers[(u16)MetaGen::PacketListEnum::Count];
8080
};
8181
}

Source/Gameplay/Gameplay/Network/NetFields.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ namespace Network
2525
struct NetFields
2626
{
2727
using Meta = typename EnumTraits<TEnum>::Meta;
28-
static constexpr u16 NumFields = static_cast<u16>(Meta::EnumList.size());
28+
static constexpr u16 NUM_FIELDS = static_cast<u16>(Meta::ENUM_FIELD_LIST.size());
2929

3030
public:
31-
static_assert(NumFields > 0, "NumFields must be greater than zero.");
31+
static_assert(NUM_FIELDS > 0, "NUM_FIELDS must be greater than zero.");
3232

3333
template <typename T> requires std::is_trivially_copyable_v<std::decay_t<T>>
3434
void SetField(TEnum startField, T&& value, u8 fieldByteOffset = 0, u8 fieldBitOffset = 0, u8 bitCount = sizeof(std::decay_t<T>) * 8)
@@ -53,7 +53,7 @@ namespace Network
5353

5454
u16 startFieldIndex = static_cast<u16>(startField);
5555
constexpr u16 numFieldsTouched = (sizeof(DecayedT) + fieldSize - 1) / fieldSize;
56-
NC_ASSERT(startFieldIndex + numFieldsTouched <= NumFields, "Attempting to Set NetField out of bounds");
56+
NC_ASSERT(startFieldIndex + numFieldsTouched <= NUM_FIELDS, "Attempting to Set NetField out of bounds");
5757

5858
std::byte* base = reinterpret_cast<std::byte*>(fields);
5959
std::byte* dest = base + (startFieldIndex * fieldSize) + fieldByteOffset;
@@ -99,7 +99,7 @@ namespace Network
9999
constexpr u16 fieldBits = fieldSize * 8;
100100

101101
const u16 startFieldIndex = static_cast<u16>(startField);
102-
NC_ASSERT(startFieldIndex < NumFields, "Start field index out of bounds.");
102+
NC_ASSERT(startFieldIndex < NUM_FIELDS, "Start field index out of bounds.");
103103

104104
const std::byte* base = reinterpret_cast<const std::byte*>(fields);
105105
const std::byte* src = base + (startFieldIndex * fieldSize) + fieldByteOffset;
@@ -109,7 +109,7 @@ namespace Network
109109
{
110110
// Multi-field or full-field read
111111
NC_ASSERT(fieldByteOffset == 0 && fieldBitOffset == 0, "Byte/Bit offsets only allowed for partial reads.");
112-
NC_ASSERT(startFieldIndex + ((typeSize + fieldSize - 1) / fieldSize) <= NumFields, "Read exceeds field range.");
112+
NC_ASSERT(startFieldIndex + ((typeSize + fieldSize - 1) / fieldSize) <= NUM_FIELDS, "Read exceeds field range.");
113113

114114
T result;
115115
std::memcpy(&result, src, sizeof(T));
@@ -146,15 +146,15 @@ namespace Network
146146
T* GetFieldPtr(TEnum startField)
147147
{
148148
u16 startFieldIndex = static_cast<u16>(startField);
149-
NC_ASSERT(startFieldIndex < NumFields, "Start field index out of bounds.");
149+
NC_ASSERT(startFieldIndex < NUM_FIELDS, "Start field index out of bounds.");
150150

151151
T* ptr = reinterpret_cast<T*>(&fields[startFieldIndex]);
152152
return ptr;
153153
}
154154

155155
bool SerializeSetFields(Bytebuffer* buffer)
156156
{
157-
constexpr u16 NumMaskQwords = (FieldMaskSize + 7) / 8;
157+
constexpr u16 NumMaskQwords = (FIELD_MASK_SIZE + 7) / 8;
158158

159159
const u64* mask64 = reinterpret_cast<const u64*>(setFieldMask);
160160
const u16 lastQwordIndex = NumMaskQwords - 1;
@@ -180,7 +180,7 @@ namespace Network
180180

181181
const u16 startByte = firstQword * 8;
182182
const u16 endByte = (lastQword + 1) * 8;
183-
const u16 maskCount = (endByte > FieldMaskSize ? FieldMaskSize : endByte) - startByte;
183+
const u16 maskCount = (endByte > FIELD_MASK_SIZE ? FIELD_MASK_SIZE : endByte) - startByte;
184184

185185
// Header: start byte | number of mask bytes written
186186
buffer->PutU8(static_cast<u8>(startByte));
@@ -192,7 +192,7 @@ namespace Network
192192
// Process 64-bit chunks for set bits
193193
const u16 startBlock = startByte * 8;
194194
const u16 endBlock = endByte * 8;
195-
const u16 limit = (endBlock > NumFields) ? NumFields : endBlock;
195+
const u16 limit = (endBlock > NUM_FIELDS) ? NUM_FIELDS : endBlock;
196196

197197
for (u16 q = firstQword; q <= lastQword; ++q)
198198
{
@@ -224,7 +224,7 @@ namespace Network
224224
if (!isDirty)
225225
return false;
226226

227-
constexpr u16 NumMaskQwords = (FieldMaskSize + 7) / 8;
227+
constexpr u16 NumMaskQwords = (FIELD_MASK_SIZE + 7) / 8;
228228

229229
const u64* mask64 = reinterpret_cast<const u64*>(dirtyFieldMask);
230230
const u16 lastQwordIndex = NumMaskQwords - 1;
@@ -251,7 +251,7 @@ namespace Network
251251

252252
const u16 startByte = firstQword * 8;
253253
const u16 endByte = (lastQword + 1) * 8;
254-
const u16 maskCount = (endByte > FieldMaskSize ? FieldMaskSize : endByte) - startByte;
254+
const u16 maskCount = (endByte > FIELD_MASK_SIZE ? FIELD_MASK_SIZE : endByte) - startByte;
255255

256256
// Header: start byte | number of mask bytes written
257257
buffer->PutU8(static_cast<u8>(startByte));
@@ -263,7 +263,7 @@ namespace Network
263263
// Process 64-bit chunks for dirty bits
264264
const u16 startBlock = startByte * 8;
265265
const u16 endBlock = endByte * 8;
266-
const u16 limit = (endBlock > NumFields) ? NumFields : endBlock;
266+
const u16 limit = (endBlock > NUM_FIELDS) ? NUM_FIELDS : endBlock;
267267

268268
for (u16 q = firstQword; q <= lastQword; ++q)
269269
{
@@ -294,7 +294,7 @@ namespace Network
294294
void SetFieldsDirty(TEnum startField, u16 numFields = 1)
295295
{
296296
u16 startFieldIndex = static_cast<u16>(startField);
297-
if (startFieldIndex + numFields > NumFields)
297+
if (startFieldIndex + numFields > NUM_FIELDS)
298298
return;
299299

300300
const u16 startByte = startFieldIndex / 8;
@@ -339,12 +339,12 @@ namespace Network
339339
}
340340

341341
public:
342-
static constexpr u16 FieldMaskSize = (NumFields + 7) / 8;
342+
static constexpr u16 FIELD_MASK_SIZE = (NUM_FIELDS + 7) / 8;
343343

344344
// Fields are stored as a 4 byte integer array, however dirtymask is stored as a byte array where one bit refers to 1 field
345-
u32 fields[NumFields];
346-
u8 setFieldMask[FieldMaskSize];
347-
u8 dirtyFieldMask[FieldMaskSize];
345+
u32 fields[NUM_FIELDS];
346+
u8 setFieldMask[FIELD_MASK_SIZE];
347+
u8 dirtyFieldMask[FIELD_MASK_SIZE];
348348
bool isDirty = false;
349349
};
350350

0 commit comments

Comments
 (0)