Skip to content

Commit 429a448

Browse files
committed
Add game version to json, format, remove CS2_ONLY
1 parent f431071 commit 429a448

File tree

11 files changed

+215
-124
lines changed

11 files changed

+215
-124
lines changed

.clang-format

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Language: Cpp
2+
ColumnLimit: 0
3+
UseTab: AlignWithSpaces
4+
TabWidth: 4
5+
IndentWidth: 4
6+
ContinuationIndentWidth: 4
7+
AccessModifierOffset: -4
8+
NamespaceIndentation: None
9+
BreakBeforeBraces: Custom
10+
SpaceBeforeParens: ControlStatements
11+
PointerAlignment: Left
12+
ReferenceAlignment: Left
13+
AlignAfterOpenBracket: DontAlign
14+
AllowShortBlocksOnASingleLine: Empty
15+
AllowShortFunctionsOnASingleLine: Empty
16+
AllowShortIfStatementsOnASingleLine: Never
17+
AllowShortLoopsOnASingleLine: false
18+
AllowShortCaseLabelsOnASingleLine: false
19+
IndentCaseLabels: true
20+
BraceWrapping:
21+
AfterCaseLabel: true
22+
AfterClass: true
23+
AfterControlStatement: Always
24+
AfterEnum: true
25+
AfterFunction: true
26+
AfterNamespace: true
27+
AfterStruct: true
28+
AfterUnion: true
29+
BeforeCatch: true
30+
BeforeElse: true
31+
IndentBraces: false
32+
SplitEmptyFunction: false
33+
SplitEmptyRecord: false
34+
SortIncludes: false
35+
InsertBraces: false
36+
FixNamespaceComments: true
37+
SpaceBeforeCaseColon: false
38+
SpacesInParens: Never
39+
Cpp11BracedListStyle: false

src/main/appframework.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@
3030

3131
static DumperApplication g_Application;
3232

33-
#define CS2_ONLY (1<<0)
34-
3533
struct AppSystemInfo
3634
{
3735
bool gameBin;
3836
const char* moduleName;
3937
std::string interfaceVersion;
4038
bool connect = true;
41-
uint64_t flags = 0;
4239
};
4340

4441
std::vector<AppSystemInfo> g_appSystems{
@@ -47,12 +44,14 @@ std::vector<AppSystemInfo> g_appSystems{
4744
{ true, "client", "Source2ClientConfig001" },
4845
{ false, "engine2", SOURCE2ENGINETOSERVER_INTERFACE_VERSION },
4946
{ true, "host", "GameSystem2HostHook" },
50-
{ true, "matchmaking", MATCHFRAMEWORK_INTERFACE_VERSION, true, CS2_ONLY },
47+
#ifdef GAME_CS2
48+
{ true, "matchmaking", MATCHFRAMEWORK_INTERFACE_VERSION },
49+
#endif
5150
{ true, "server", SOURCE2SERVERCONFIG_INTERFACE_VERSION },
5251
{ false, "animationsystem", ANIMATIONSYSTEM_INTERFACE_VERSION },
5352
{ false, "materialsystem2", TEXTLAYOUT_INTERFACE_VERSION },
5453
{ false, "meshsystem", MESHSYSTEM_INTERFACE_VERSION, false },
55-
{ false, "networksystem", NETWORKSYSTEM_INTERFACE_VERSION, false}, // can't connect on linux cuz of missing gameinfo in IApplication
54+
{ false, "networksystem", NETWORKSYSTEM_INTERFACE_VERSION, false }, // can't connect on linux cuz of missing gameinfo in IApplication
5655
{ false, "panorama", PANORAMAUIENGINE_INTERFACE_VERSION },
5756
{ false, "particles", PARTICLESYSTEMMGR_INTERFACE_VERSION, false }, // needs renderdevice interface
5857
{ false, "pulse_system", PULSESYSTEM_INTERFACE_VERSION },
@@ -148,16 +147,12 @@ void InitializeAppSystems()
148147
spdlog::info("Initializing app systems");
149148
for (const auto& appSystem : g_appSystems)
150149
{
151-
#ifndef GAME_CS2
152-
if ((appSystem.flags & CS2_ONLY) != 0)
153-
continue;
154-
#endif // !GAME_CS2
155-
156150
std::string path = appSystem.gameBin ? fmt::format("../../{}/bin/{}", GAME_PATH, PLATFORM_FOLDER) : "";
157151

158152
auto targetPath = (std::filesystem::current_path() / path / (MODULE_PREFIX + std::string(appSystem.moduleName) + MODULE_EXT)).lexically_normal().generic_string();
159153

160-
if (!std::filesystem::exists(targetPath)) {
154+
if (!std::filesystem::exists(targetPath))
155+
{
161156
spdlog::info("Skipping module as it does not exist: {}", targetPath);
162157
continue;
163158
}

src/main/dumpers/schemas/filesystem_exporter.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ namespace Dumpers::Schemas::FilesystemExporter
3434
std::string CommentBlock(std::string str)
3535
{
3636
size_t pos = 0;
37-
while ((pos = str.find('\n', pos)) != std::string::npos) {
37+
while ((pos = str.find('\n', pos)) != std::string::npos)
38+
{
3839
str.replace(pos, 1, "\n//");
3940
pos += 3;
4041
}
4142

4243
return str;
4344
}
4445

45-
4646
void OutputMetadataEntry(const IntermediateMetadata& entry, std::ofstream& output, bool tabulate)
4747
{
4848
output << (tabulate ? "\t" : "") << "// " << entry.name;
4949

50-
if (entry.hasValue) {
51-
if (entry.stringValue) {
50+
if (entry.hasValue)
51+
{
52+
if (entry.stringValue)
53+
{
5254
output << " = " << CommentBlock(*entry.stringValue);
5355
}
5456
else
@@ -135,7 +137,7 @@ void DumpEnums(const std::vector<IntermediateSchemaEnum>& enums, std::filesystem
135137

136138
std::ofstream output((schemaPath / intermediateEnum.module / sanitizedFileName).replace_extension(".h"));
137139

138-
for(const auto& metadata : intermediateEnum.metadata)
140+
for (const auto& metadata : intermediateEnum.metadata)
139141
{
140142
OutputMetadataEntry(metadata, output, false);
141143
}
@@ -146,7 +148,7 @@ void DumpEnums(const std::vector<IntermediateSchemaEnum>& enums, std::filesystem
146148
for (const auto& member : intermediateEnum.members)
147149
{
148150
// Output metadata entires as comments before the field definition
149-
for(const auto& metadata: member.metadata)
151+
for (const auto& metadata : member.metadata)
150152
{
151153
OutputMetadataEntry(metadata, output, true);
152154
}

src/main/dumpers/schemas/json_exporter.cpp

Lines changed: 87 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -56,89 +56,89 @@ json SerializeType(CSchemaType* type)
5656

5757
switch (type->m_eTypeCategory)
5858
{
59-
case SCHEMA_TYPE_BUILTIN:
60-
j["category"] = "builtin";
61-
j["name"] = type->m_sTypeName.String();
62-
break;
63-
case SCHEMA_TYPE_POINTER:
64-
j["category"] = "ptr";
65-
j["inner"] = SerializeType(static_cast<CSchemaType_Ptr*>(type)->m_pObjectType);
66-
break;
67-
case SCHEMA_TYPE_FIXED_ARRAY:
68-
{
69-
auto* arr = static_cast<CSchemaType_FixedArray*>(type);
70-
j["category"] = "fixed_array";
71-
j["count"] = arr->m_nElementCount;
72-
j["inner"] = SerializeType(arr->m_pElementType);
73-
break;
74-
}
75-
case SCHEMA_TYPE_ATOMIC:
76-
{
77-
j["category"] = "atomic";
78-
79-
// Extract outer name from m_sTypeName before '<'
80-
std::string typeName = type->m_sTypeName.String();
81-
auto pos = typeName.find('<');
82-
if (pos != std::string::npos)
83-
{
84-
auto name = typeName.substr(0, pos);
85-
// Trim trailing whitespace
86-
while (!name.empty() && name.back() == ' ')
87-
name.pop_back();
88-
j["name"] = name;
89-
}
90-
else
91-
{
92-
j["name"] = typeName;
93-
}
94-
95-
if (type->m_eAtomicCategory == SCHEMA_ATOMIC_T ||
96-
type->m_eAtomicCategory == SCHEMA_ATOMIC_COLLECTION_OF_T)
59+
case SCHEMA_TYPE_BUILTIN:
60+
j["category"] = "builtin";
61+
j["name"] = type->m_sTypeName.String();
62+
break;
63+
case SCHEMA_TYPE_POINTER:
64+
j["category"] = "ptr";
65+
j["inner"] = SerializeType(static_cast<CSchemaType_Ptr*>(type)->m_pObjectType);
66+
break;
67+
case SCHEMA_TYPE_FIXED_ARRAY:
9768
{
98-
j["inner"] = SerializeType(static_cast<CSchemaType_Atomic_T*>(type)->m_pTemplateType);
69+
auto* arr = static_cast<CSchemaType_FixedArray*>(type);
70+
j["category"] = "fixed_array";
71+
j["count"] = arr->m_nElementCount;
72+
j["inner"] = SerializeType(arr->m_pElementType);
73+
break;
9974
}
100-
else if (type->m_eAtomicCategory == SCHEMA_ATOMIC_TT)
75+
case SCHEMA_TYPE_ATOMIC:
10176
{
102-
auto* tt = static_cast<CSchemaType_Atomic_TT*>(type);
103-
j["inner"] = SerializeType(tt->m_pTemplateType);
104-
j["inner2"] = SerializeType(tt->m_pTemplateType2);
77+
j["category"] = "atomic";
78+
79+
// Extract outer name from m_sTypeName before '<'
80+
std::string typeName = type->m_sTypeName.String();
81+
auto pos = typeName.find('<');
82+
if (pos != std::string::npos)
83+
{
84+
auto name = typeName.substr(0, pos);
85+
// Trim trailing whitespace
86+
while (!name.empty() && name.back() == ' ')
87+
name.pop_back();
88+
j["name"] = name;
89+
}
90+
else
91+
{
92+
j["name"] = typeName;
93+
}
94+
95+
if (type->m_eAtomicCategory == SCHEMA_ATOMIC_T ||
96+
type->m_eAtomicCategory == SCHEMA_ATOMIC_COLLECTION_OF_T)
97+
{
98+
j["inner"] = SerializeType(static_cast<CSchemaType_Atomic_T*>(type)->m_pTemplateType);
99+
}
100+
else if (type->m_eAtomicCategory == SCHEMA_ATOMIC_TT)
101+
{
102+
auto* tt = static_cast<CSchemaType_Atomic_TT*>(type);
103+
j["inner"] = SerializeType(tt->m_pTemplateType);
104+
j["inner2"] = SerializeType(tt->m_pTemplateType2);
105+
}
106+
break;
105107
}
106-
break;
107-
}
108-
case SCHEMA_TYPE_DECLARED_CLASS:
109-
{
110-
j["category"] = "declared_class";
111-
auto* classType = static_cast<CSchemaType_DeclaredClass*>(type);
112-
if (classType->m_pClassInfo && classType->m_pClassInfo->m_pszName)
108+
case SCHEMA_TYPE_DECLARED_CLASS:
113109
{
114-
j["name"] = classType->m_pClassInfo->m_pszName;
115-
j["module"] = classType->m_pClassInfo->m_pszProjectName;
110+
j["category"] = "declared_class";
111+
auto* classType = static_cast<CSchemaType_DeclaredClass*>(type);
112+
if (classType->m_pClassInfo && classType->m_pClassInfo->m_pszName)
113+
{
114+
j["name"] = classType->m_pClassInfo->m_pszName;
115+
j["module"] = classType->m_pClassInfo->m_pszProjectName;
116+
}
117+
else
118+
j["name"] = type->m_sTypeName.String();
119+
break;
116120
}
117-
else
118-
j["name"] = type->m_sTypeName.String();
119-
break;
120-
}
121-
case SCHEMA_TYPE_DECLARED_ENUM:
122-
{
123-
j["category"] = "declared_enum";
124-
auto* enumType = static_cast<CSchemaType_DeclaredEnum*>(type);
125-
if (enumType->m_pEnumInfo && enumType->m_pEnumInfo->m_pszName)
121+
case SCHEMA_TYPE_DECLARED_ENUM:
126122
{
127-
j["name"] = enumType->m_pEnumInfo->m_pszName;
128-
j["module"] = enumType->m_pEnumInfo->m_pszProjectName;
123+
j["category"] = "declared_enum";
124+
auto* enumType = static_cast<CSchemaType_DeclaredEnum*>(type);
125+
if (enumType->m_pEnumInfo && enumType->m_pEnumInfo->m_pszName)
126+
{
127+
j["name"] = enumType->m_pEnumInfo->m_pszName;
128+
j["module"] = enumType->m_pEnumInfo->m_pszProjectName;
129+
}
130+
else
131+
j["name"] = type->m_sTypeName.String();
132+
break;
129133
}
130-
else
134+
case SCHEMA_TYPE_BITFIELD:
135+
j["category"] = "bitfield";
136+
j["count"] = static_cast<CSchemaType_Bitfield*>(type)->m_nBitfieldCount;
137+
break;
138+
default:
139+
j["category"] = "builtin";
131140
j["name"] = type->m_sTypeName.String();
132-
break;
133-
}
134-
case SCHEMA_TYPE_BITFIELD:
135-
j["category"] = "bitfield";
136-
j["count"] = static_cast<CSchemaType_Bitfield*>(type)->m_nBitfieldCount;
137-
break;
138-
default:
139-
j["category"] = "builtin";
140-
j["name"] = type->m_sTypeName.String();
141-
break;
141+
break;
142142
}
143143

144144
return j;
@@ -167,7 +167,7 @@ void DumpClasses(const std::vector<IntermediateSchemaClass>& classes, json& clas
167167
parents.push_back(std::move(parentObj));
168168
}
169169

170-
if(parents.size())
170+
if (parents.size())
171171
classObj["parents"] = std::move(parents);
172172

173173
json fields = json::array();
@@ -180,7 +180,7 @@ void DumpClasses(const std::vector<IntermediateSchemaClass>& classes, json& clas
180180
fieldObj["type"] = SerializeType(field.type);
181181

182182
auto fieldMetadataArr = SerializeMetadataArray(field.metadata);
183-
if(fieldMetadataArr.size())
183+
if (fieldMetadataArr.size())
184184
fieldObj["metadata"] = std::move(fieldMetadataArr);
185185

186186
fields.push_back(fieldObj);
@@ -192,7 +192,7 @@ void DumpClasses(const std::vector<IntermediateSchemaClass>& classes, json& clas
192192
classesArray.push_back(std::move(classObj));
193193
}
194194
}
195-
195+
196196
void DumpEnums(const std::vector<IntermediateSchemaEnum>& enums, json& enumsArray)
197197
{
198198
for (const auto& intermediateEnum : enums)
@@ -220,7 +220,7 @@ void DumpEnums(const std::vector<IntermediateSchemaEnum>& enums, json& enumsArra
220220
members.push_back(std::move(memberObj));
221221
}
222222

223-
if(members.size())
223+
if (members.size())
224224
enumObj["members"] = std::move(members);
225225

226226
enumsArray.push_back(std::move(enumObj));
@@ -238,6 +238,15 @@ void Dump(const std::vector<IntermediateSchemaEnum>& enums, const std::vector<In
238238
DumpClasses(classes, classesArray);
239239
DumpEnums(enums, enumsArray);
240240

241+
if (!Globals::sourceRevision.empty())
242+
root["revision"] = std::stoi(Globals::sourceRevision);
243+
244+
if (!Globals::versionDate.empty())
245+
root["version_date"] = Globals::versionDate;
246+
247+
if (!Globals::versionTime.empty())
248+
root["version_time"] = Globals::versionTime;
249+
241250
root["classes"] = classesArray;
242251
root["enums"] = enumsArray;
243252

0 commit comments

Comments
 (0)