@@ -479,30 +479,34 @@ int MOSRotating::ReadProperty(std::string propName, Reader &reader)
479
479
reader >> m_DamageMultiplier;
480
480
m_DamageMultiplierRedefined = true ;
481
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 ();
482
+ ReadCustomValueProperty (reader);
499
483
} else
500
484
// See if the base class(es) can find a match instead
501
485
return MOSprite::ReadProperty (propName, reader);
502
486
503
487
return 0 ;
504
488
}
505
489
490
+ void MOSRotating::ReadCustomValueProperty (Reader &reader) {
491
+ std::string customValueType;
492
+ reader >> customValueType;
493
+ std::string customKey = reader.ReadPropName ();
494
+ std::string customValue = reader.ReadPropValue ();
495
+ if (customValueType == " NumberValue" ) {
496
+ try {
497
+ SetNumberValue (customKey, std::stod (customValue));
498
+ } catch (const std::invalid_argument) {
499
+ reader.ReportError (" Tried to read a non-number value for SetNumberValue." );
500
+ }
501
+ } else if (customValueType == " StringValue" ) {
502
+ SetStringValue (customKey, customValue);
503
+ } else {
504
+ reader.ReportError (" Invalid CustomValue type " + customValueType);
505
+ }
506
+ // Artificially end reading this property since we got all we needed
507
+ reader.NextProperty ();
508
+ }
509
+
506
510
507
511
// ////////////////////////////////////////////////////////////////////////////////////////
508
512
// Virtual method: Save
0 commit comments