Skip to content

Commit c89d22e

Browse files
committed
feat: hide volatile default values
1 parent 9f24fd8 commit c89d22e

1 file changed

Lines changed: 180 additions & 1 deletion

File tree

src/main/dumpers/schemas/metadata_stringifier.cpp

Lines changed: 180 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <fmt/format.h>
3636
#include "metadata_stringifier.h"
3737
#include <modules.h>
38+
#include <regex>
3839

3940
class SimpleCUtlString {
4041
public:
@@ -48,6 +49,174 @@ class SimpleCUtlString {
4849
namespace Dumpers::Schemas
4950
{
5051

52+
std::map<std::string, std::vector<std::regex>> g_replaceMap{
53+
{
54+
"CTestBlendContainer",
55+
{
56+
std::regex(R"#(("m_nStreamingSize":) .*,)#"),
57+
std::regex(R"#(("m_nRate":) .*,)#"),
58+
std::regex(R"#(("m_nFormat":) .*,)#"),
59+
std::regex(R"#(("m_nSampleCount":) .*,)#"),
60+
std::regex(R"#(("m_nLoopStart":) .*,)#"),
61+
std::regex(R"#(("m_nLoopEnd":) .*,)#"),
62+
std::regex(R"#(("m_nChannels":) .*,)#"),
63+
}
64+
},
65+
{
66+
"CVoiceContainerBlender",
67+
{
68+
std::regex(R"#(("m_nStreamingSize":) .*,)#"),
69+
std::regex(R"#(("m_nRate":) .*,)#"),
70+
std::regex(R"#(("m_nFormat":) .*,)#"),
71+
std::regex(R"#(("m_nSampleCount":) .*,)#"),
72+
std::regex(R"#(("m_nLoopStart":) .*,)#"),
73+
std::regex(R"#(("m_nLoopEnd":) .*,)#"),
74+
std::regex(R"#(("m_nChannels":) .*,)#"),
75+
}
76+
},
77+
{
78+
"CVoiceContainerEnvelope",
79+
{
80+
std::regex(R"#(("m_nStreamingSize":) .*,)#"),
81+
std::regex(R"#(("m_nRate":) .*,)#"),
82+
std::regex(R"#(("m_nFormat":) .*,)#"),
83+
std::regex(R"#(("m_nSampleCount":) .*,)#"),
84+
std::regex(R"#(("m_nLoopStart":) .*,)#"),
85+
std::regex(R"#(("m_nLoopEnd":) .*,)#"),
86+
std::regex(R"#(("m_nChannels":) .*,)#"),
87+
}
88+
},
89+
{
90+
"CVoiceContainerSet",
91+
{
92+
std::regex(R"#(("m_nStreamingSize":) .*,)#"),
93+
std::regex(R"#(("m_nRate":) .*,)#"),
94+
std::regex(R"#(("m_nFormat":) .*,)#"),
95+
std::regex(R"#(("m_nSampleCount":) .*,)#"),
96+
std::regex(R"#(("m_nLoopStart":) .*,)#"),
97+
std::regex(R"#(("m_nLoopEnd":) .*,)#"),
98+
std::regex(R"#(("m_nChannels":) .*,)#"),
99+
}
100+
},
101+
{
102+
"CVoiceContainerStaticAdditiveSynth",
103+
{
104+
std::regex(R"#(("m_nStreamingSize":) .*,)#"),
105+
std::regex(R"#(("m_nRate":) .*,)#"),
106+
std::regex(R"#(("m_nFormat":) .*,)#"),
107+
std::regex(R"#(("m_nSampleCount":) .*,)#"),
108+
std::regex(R"#(("m_nLoopStart":) .*,)#"),
109+
std::regex(R"#(("m_nLoopEnd":) .*,)#"),
110+
std::regex(R"#(("m_nChannels":) .*,)#"),
111+
}
112+
},
113+
{
114+
"CVoiceContainerSwitch",
115+
{
116+
std::regex(R"#(("m_nStreamingSize":) .*,)#"),
117+
std::regex(R"#(("m_nRate":) .*,)#"),
118+
std::regex(R"#(("m_nFormat":) .*,)#"),
119+
std::regex(R"#(("m_nSampleCount":) .*,)#"),
120+
std::regex(R"#(("m_nLoopStart":) .*,)#"),
121+
std::regex(R"#(("m_nLoopEnd":) .*,)#"),
122+
std::regex(R"#(("m_nChannels":) .*,)#"),
123+
}
124+
},
125+
{
126+
"VMixDynamics3BandDesc_t",
127+
{
128+
std::regex(R"#(("m_fldbKneeWidth":) .*,)#"),
129+
std::regex(R"#(("m_flLowCutoffFreq":) .*,)#"),
130+
}
131+
},
132+
{
133+
"VMixVocoderDesc_t",
134+
{
135+
std::regex(R"#(("m_fldBModGain":) .*,)#"),
136+
}
137+
},
138+
{
139+
"CLookAtUpdateNode",
140+
{
141+
std::regex(R"#(("m_target":) .*,)#"),
142+
}
143+
},
144+
{
145+
"CFootLockUpdateNode",
146+
{
147+
std::regex(R"#(("m_flTiltPlanePitchSpringStrength":) .*,)#"),
148+
std::regex(R"#(("m_flTiltPlaneRollSpringStrength":) .*,)#"),
149+
}
150+
},
151+
{
152+
"CBlockSelectionMetricEvaluator",
153+
{
154+
std::regex(R"#(("m_means":)[\s\S]*?\],)#"),
155+
std::regex(R"#(("m_standardDeviations":)[\s\S]*?\],)#"),
156+
}
157+
},
158+
{
159+
"CFeNamedJiggleBone",
160+
{
161+
std::regex(R"#(("m_transform":)[\s\S]*?\],)#"),
162+
std::regex(R"#(("m_nJiggleParent":) .*,)#"),
163+
}
164+
},
165+
{
166+
"Dop26_t",
167+
{
168+
std::regex(R"#(("m_flSupport":)[\s\S]*?\])#"),
169+
}
170+
},
171+
{
172+
"FourCovMatrices3",
173+
{
174+
std::regex(R"#(("m_vDiag":)[\s\S]*?\],)#"),
175+
}
176+
},
177+
{
178+
"CVoxelVisibility",
179+
{
180+
std::regex(R"#(("m_nOffset":) .*,)#"),
181+
std::regex(R"#(("m_nElementCount":) .*,)#"),
182+
}
183+
},
184+
{
185+
"CDOTAFightingGameActionDefinition",
186+
{
187+
std::regex(R"#(("m_nActionID":) .*,)#"),
188+
}
189+
},
190+
{
191+
"CDOTAMinesweeperGameDefinition",
192+
{
193+
std::regex(R"#(("m_flTimeLimit":) .*,)#"),
194+
std::regex(R"#(("m_nStageProgressionTimerIncrease":) .*,)#"),
195+
std::regex(R"#(("m_nTimerIncreaseExpireClicks":) .*,)#"),
196+
std::regex(R"#(("m_nTimerIncreaseChance":) .*,)#"),
197+
}
198+
},
199+
{
200+
"CDOTAOverworldDefinition",
201+
{
202+
std::regex(R"#(("m_eAssociatedEvent":) .*,)#"),
203+
}
204+
},
205+
{
206+
"CSurvivorsGameModeDefinition",
207+
{
208+
std::regex(R"#(("m_vCollisionIndicatorColorPlayer":)[\s\S]*?\],)#"),
209+
std::regex(R"#(("m_vCollisionIndicatorColorEnemy":)[\s\S]*?\],)#"),
210+
}
211+
},
212+
{
213+
"CSurvivorsPowerUpDefinition",
214+
{
215+
std::regex(R"#(("m_vWarmupEffectColor":)[\s\S]*?\],)#"),
216+
}
217+
},
218+
};
219+
51220
// Determine how and if to output metadata entry value based on it's type.
52221
std::optional<std::string> GetMetadataValue(const SchemaMetadataEntryData_t& entry, const char* metadataTargetName)
53222
{
@@ -133,7 +302,17 @@ std::optional<std::string> GetMetadataValue(const SchemaMetadataEntryData_t& ent
133302
int res = SaveKV3AsJson(*(void**)value, err, buf);
134303

135304
if (res) {
136-
return buf.Get();
305+
std::string out = buf.Get();
306+
if (g_replaceMap.find(metadataTargetName) != g_replaceMap.end())
307+
{
308+
const auto& regexVector = g_replaceMap.at(metadataTargetName);
309+
310+
for (const auto& regex : regexVector) {
311+
out = std::regex_replace(out, regex, "$1 <HIDDEN FOR DIFF>,");
312+
}
313+
}
314+
315+
return out;
137316
}
138317

139318
return "Could not parse KV3 Defaults";

0 commit comments

Comments
 (0)