Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 5072edb

Browse files
committed
Added handling for custom number and string values in INI
1 parent 8cf5f09 commit 5072edb

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Entities/MOSRotating.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,28 @@ int MOSRotating::ReadProperty(std::string propName, Reader &reader)
475475
reader >> m_EffectOnGib;
476476
else if (propName == "LoudnessOnGib")
477477
reader >> m_LoudnessOnGib;
478-
else if (propName == "DamageMultiplier")
479-
{
478+
else if (propName == "DamageMultiplier") {
480479
reader >> m_DamageMultiplier;
481480
m_DamageMultiplierRedefined = true;
482-
}
483-
else
481+
} else if (propName == "AddCustomValue") {
482+
std::string customValueType, customKey, customValue;
483+
reader >> customValueType;
484+
customKey = reader.ReadPropName();
485+
customValue = reader.ReadPropValue();
486+
if (customValueType == "NumberValue") {
487+
try {
488+
SetNumberValue(customKey, std::stod(customValue));
489+
} catch (const std::invalid_argument) {
490+
reader.ReportError("Tried to read a non-number value for SetNumberValue.");
491+
}
492+
} else if (customValueType == "StringValue") {
493+
SetStringValue(customKey, customValue);
494+
} else {
495+
reader.ReportError("Invalid CustomValue type " + customValueType);
496+
}
497+
// Artificially end reading this property since we got all we needed
498+
reader.NextProperty();
499+
} else
484500
// See if the base class(es) can find a match instead
485501
return MOSprite::ReadProperty(propName, reader);
486502

0 commit comments

Comments
 (0)