This repository was archived by the owner on Jan 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -70,10 +70,12 @@ namespace RTE {
70
70
std::string soundOverlapModeString = reader.ReadPropValue ();
71
71
if (c_SoundOverlapModeMap.find (soundOverlapModeString) != c_SoundOverlapModeMap.end ()) {
72
72
m_SoundOverlapMode = c_SoundOverlapModeMap.find (soundOverlapModeString)->second ;
73
- } else if (std::stoi (soundOverlapModeString)) {
74
- m_SoundOverlapMode = static_cast <SoundOverlapMode>(std::stoi (soundOverlapModeString));
75
73
} else {
76
- reader.ReportError (" Cycle mode " + soundOverlapModeString + " is invalid." );
74
+ try {
75
+ m_SoundOverlapMode = static_cast <SoundOverlapMode>(std::stoi (soundOverlapModeString));
76
+ } catch (const std::exception &) {
77
+ reader.ReportError (" Cycle mode " + soundOverlapModeString + " is invalid." );
78
+ }
77
79
}
78
80
} else if (propName == " Immobile" ) {
79
81
reader >> m_Immobile;
Original file line number Diff line number Diff line change @@ -101,17 +101,21 @@ namespace RTE {
101
101
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
102
102
103
103
SoundSet::SoundSelectionCycleMode SoundSet::ReadSoundSelectionCycleMode (Reader &reader) {
104
+ SoundSelectionCycleMode soundSelectionCycleModeToReturn;
104
105
std::string soundSelectionCycleModeString = reader.ReadPropValue ();
105
106
106
107
std::unordered_map<std::string, SoundSelectionCycleMode>::const_iterator soundSelectionCycleMode = c_SoundSelectionCycleModeMap.find (soundSelectionCycleModeString);
107
108
if (soundSelectionCycleMode != c_SoundSelectionCycleModeMap.end ()) {
108
- return soundSelectionCycleMode->second ;
109
- } else if (std::stoi (soundSelectionCycleModeString)) {
110
- return static_cast <SoundSelectionCycleMode>(std::stoi (soundSelectionCycleModeString));
109
+ soundSelectionCycleModeToReturn = soundSelectionCycleMode->second ;
110
+ } else {
111
+ try {
112
+ soundSelectionCycleModeToReturn = static_cast <SoundSelectionCycleMode>(std::stoi (soundSelectionCycleModeString));
113
+ } catch (const std::exception &) {
114
+ reader.ReportError (" Sound selection cycle mode " + soundSelectionCycleModeString + " is invalid." );
115
+ }
111
116
}
112
-
113
- reader.ReportError (" Sound selection cycle mode " + soundSelectionCycleModeString + " is invalid." );
114
- return SoundSelectionCycleMode::RANDOM;
117
+
118
+ return soundSelectionCycleModeToReturn;
115
119
}
116
120
117
121
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments