Skip to content

Commit d0048c9

Browse files
committed
ChaosMod: Fix compile on MSVC
1 parent 377f244 commit d0048c9

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

ChaosMod/Effects/EffectConfig.h

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,30 @@ namespace EffectConfig
4343

4444
for (auto &[effectId, effectInfo] : g_EffectsMap)
4545
{
46-
struct
46+
struct ConfigValues
4747
{
48+
// Declared as named struct outside the union because MSVC doesn't like default initialization in
49+
// unnamed structs inside unions
50+
struct DetailedValues
51+
{
52+
bool Enabled = true;
53+
EffectTimedType TimedType = EffectTimedType::NotTimed;
54+
int CustomTime = 0;
55+
int WeightMult = 0;
56+
bool Permanent = false;
57+
bool ExcludedFromVoting = false;
58+
char Placeholder;
59+
int ShortcutKeycode = 0;
60+
};
4861
union
4962
{
50-
std::array<int, 8> Values;
51-
struct
52-
{
53-
bool Enabled = true;
54-
EffectTimedType TimedType = EffectTimedType::NotTimed;
55-
int CustomTime = 0;
56-
int WeightMult = 0;
57-
bool Permanent = false;
58-
bool ExcludedFromVoting = false;
59-
char Placeholder;
60-
int ShortcutKeycode = 0;
61-
};
63+
std::array<int, 8> ValuesRaw;
64+
DetailedValues Values;
6265
};
66+
67+
ConfigValues()
68+
{
69+
}
6370
} configValues;
6471
// HACK: Store EffectCustomName seperately
6572
std::string valueEffectName;
@@ -89,7 +96,7 @@ namespace EffectConfig
8996
{
9097
const auto &split = value.substr(0, splitIndex);
9198

92-
Util::TryParse<int>(split, configValues.Values[j]);
99+
Util::TryParse<int>(split, configValues.ValuesRaw[j]);
93100
}
94101

95102
if (splitIndex == value.npos)
@@ -102,7 +109,7 @@ namespace EffectConfig
102109
}
103110
}
104111

105-
if (!configValues.Enabled)
112+
if (!configValues.Values.Enabled)
106113
{
107114
continue;
108115
}
@@ -112,37 +119,37 @@ namespace EffectConfig
112119
{
113120
effectData.TimedType = EffectTimedType::NotTimed;
114121
}
115-
else if (configValues.Permanent)
122+
else if (configValues.Values.Permanent)
116123
{
117124
effectData.TimedType = EffectTimedType::Permanent;
118125
}
119-
else if (configValues.CustomTime > 0)
126+
else if (configValues.Values.CustomTime > 0)
120127
{
121128
effectData.TimedType = EffectTimedType::Custom;
122-
effectData.CustomTime = configValues.CustomTime;
129+
effectData.CustomTime = configValues.Values.CustomTime;
123130
}
124131
else
125132
{
126133
effectData.TimedType =
127-
configValues.TimedType == EffectTimedType::NotTimed
134+
configValues.Values.TimedType == EffectTimedType::NotTimed
128135
? (effectInfo.IsShortDuration ? EffectTimedType::Short : EffectTimedType::Normal)
129-
: configValues.TimedType;
136+
: configValues.Values.TimedType;
130137
}
131138

132-
if (configValues.WeightMult > 0)
139+
if (configValues.Values.WeightMult > 0)
133140
{
134-
effectData.WeightMult = configValues.WeightMult;
141+
effectData.WeightMult = configValues.Values.WeightMult;
135142
}
136143
effectData.Weight = effectData.WeightMult; // Set initial effect weight to WeightMult
137-
effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, configValues.ExcludedFromVoting);
144+
effectData.SetAttribute(EffectAttributes::ExcludedFromVoting, configValues.Values.ExcludedFromVoting);
138145
effectData.SetAttribute(EffectAttributes::IsMeta, effectInfo.ExecutionType == EffectExecutionType::Meta);
139146
effectData.Name = effectInfo.Name;
140147
effectData.SetAttribute(EffectAttributes::HideRealNameOnStart, effectInfo.HideRealNameOnStart);
141148
#ifdef _DEBUG
142149
effectData.ShortcutKeycode =
143-
effectInfo.DebugShortcutKeycode ? effectInfo.DebugShortcutKeycode : configValues.ShortcutKeycode;
150+
effectInfo.DebugShortcutKeycode ? effectInfo.DebugShortcutKeycode : configValues.SValues.hortcutKeycode;
144151
#else
145-
effectData.ShortcutKeycode = configValues.ShortcutKeycode;
152+
effectData.ShortcutKeycode = configValues.Values.ShortcutKeycode;
146153
#endif
147154
if (!valueEffectName.empty())
148155
{

0 commit comments

Comments
 (0)