@@ -356,9 +356,6 @@ private void ProcessMissionFiles()
356356
357357 newContent = ConvertHardcodedSubsystemNamesToVariables ( newContent ) ;
358358
359- // the following method is too specific so not used anymore
360- //newContent = ConvertAltArgumentsToVariables(newContent);
361-
362359 file . SaveContent ( newContent ) ;
363360
364361 Parent . IncreaseProgress ( Sender , CurrentProgress ++ ) ;
@@ -1064,15 +1061,19 @@ private string ConvertSpecialMessageSendersToVariables(string content)
10641061 {
10651062 MatchCollection specialSenderMatches = Regex . Matches ( message . Value , "\" (#.*?)\" " ) ;
10661063
1064+ string currentMessage = message . Value ;
1065+
10671066 // in case of send-message-list, there can be several special senders
10681067 foreach ( Match specialSender in specialSenderMatches )
10691068 {
10701069 if ( variableList . Any ( v => v . DefaultValue == specialSender . Groups [ 1 ] . Value ) )
10711070 {
10721071 MissionVariable variable = variableList . FirstOrDefault ( v => v . DefaultValue == specialSender . Groups [ 1 ] . Value ) ;
10731072
1074- string newMessage = message . Value . Replace ( specialSender . Value , variable . NewSexp ) ;
1075- content = content . Replace ( message . Value , newMessage ) ;
1073+ string newMessage = currentMessage . Replace ( specialSender . Value , variable . NewSexp ) ;
1074+ content = content . Replace ( currentMessage , newMessage ) ;
1075+ // once the currentMessage has been replaced in the original content, the newMessage becomes the currentMessage
1076+ currentMessage = newMessage ;
10761077 }
10771078 }
10781079 }
@@ -1197,45 +1198,5 @@ private string ConvertHardcodedSubsystemNamesToVariables(string content)
11971198
11981199 return content ;
11991200 }
1200-
1201- private string ConvertAltArgumentsToVariables ( string content )
1202- {
1203- MatchCollection randomArguments = Regex . Matches ( content , "when-argument[ \\ t\\ r\\ n]*\\ ([ \\ t]*random-multiple-of([^\\ (]*?)\\ )[ \\ t\\ r\\ n]*\\ ([^\\ (]*?\\ )[ \\ t\\ r\\ n]*\\ ([ \\ t]*ship-change-alt-name[ \\ t\\ r\\ n]*\" <argument>\" " , RegexOptions . Singleline ) ;
1204- List < MissionVariable > variableList = new ( ) ;
1205-
1206- foreach ( Match match in randomArguments )
1207- {
1208- MatchCollection arguments = Regex . Matches ( match . Groups [ 1 ] . Value , "\" ([^\\ r]*)\" " , RegexOptions . Multiline ) ;
1209-
1210- foreach ( Match argument in arguments )
1211- {
1212- if ( ! argument . Groups [ 1 ] . Value . StartsWith ( "@" , StringComparison . InvariantCulture ) )
1213- {
1214- variableList . Add ( new MissionVariable ( argument . Groups [ 1 ] . Value ) ) ;
1215- }
1216- }
1217- }
1218-
1219- if ( variableList . Count > 0 )
1220- {
1221- content = AddVariablesToSexpVariablesSection ( content , variableList ) ;
1222- string newSexp = PrepareNewSexpForVariables ( variableList ) ;
1223- content = AddEventToManageTranslations ( content , newSexp ) ;
1224-
1225- foreach ( Match match in randomArguments )
1226- {
1227- string arguments = match . Value ;
1228-
1229- foreach ( MissionVariable variable in variableList )
1230- {
1231- arguments = arguments . Replace ( $ "\" { variable . DefaultValue } \" ", variable . NewSexp ) ;
1232- }
1233-
1234- content = content . Replace ( match . Value , arguments ) ;
1235- }
1236- }
1237-
1238- return content ;
1239- }
12401201 }
12411202}
0 commit comments