Skip to content

Commit c6bdf98

Browse files
authored
Add script action count warning and allow loading all script actions
1 parent cf6cc91 commit c6bdf98

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/TSMapEditor/Config/Translations/en/Translation_en.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Map.CheckForIssues.ImpassableTile=Cell at {0} has Tiberium on an otherwise impas
112112
Map.CheckForIssues.DuplicateHouseININame=The map has multiple houses named "{0}"! This will result in a corrupted house list in-game!
113113
Map.CheckForIssues.TeamTypeWithoutTaskForce=TeamType "{0}" has no TaskForce set!
114114
Map.CheckForIssues.TeamTypeWithoutScript=TeamType "{0}" has no Script set!
115+
Map.CheckForIssues.ScriptTooManyActions="Script '{0}' has more than {1} actions, which is not supported by the game. Consider organizing your script actions or splitting it to multiple scripts."
115116
CheckForIssues.TriggerDisabled=Trigger "{0}" ({1}) is disabled and never enabled by another trigger.@Did you forget to enable it? If the trigger exists for debugging purposes, add DEBUG or OBSOLETE to its name to skip this warning.
116117
CheckForIssues.TriggerEnabledByOtherTriggers=Trigger "{0}" ({1}) is enabled by another trigger, but it is never in a disabled state@(it is neither disabled by default nor disabled by other triggers). Did you forget to disable it?
117118
CheckForIssues.TriggerEnableSelf=Trigger "{0}" ({1}) has an action for enabling itself. Is it supposed to enable something else instead?

src/TSMapEditor/Models/Map.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,18 @@ public List<string> CheckForIssues()
20922092
Constants.TS_WAYPT_SPECIAL));
20932093
}
20942094

2095+
// Check for scripts that have more than 50 Script Actions. This is unsupported by the game.
2096+
const int maxScriptActionCount = 50;
2097+
foreach (var script in Scripts)
2098+
{
2099+
if (script.Actions.Count > maxScriptActionCount)
2100+
{
2101+
issueList.Add(string.Format(Translate(this, "CheckForIssues.ScriptTooManyActions",
2102+
"Script '{0}' has more than {1} actions, which is not supported by the game. Consider organizing your script actions or splitting it to multiple scripts."),
2103+
script.Name, maxScriptActionCount));
2104+
}
2105+
}
2106+
20952107
return issueList;
20962108
}
20972109

src/TSMapEditor/Models/Script.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public ScriptActionEntry Clone()
4242

4343
public class Script : IIDContainer
4444
{
45-
public const int MaxActionCount = 50;
46-
4745
public Script(string iniName)
4846
{
4947
ININame = iniName;
@@ -139,14 +137,17 @@ public static Script ParseScript(string id, IniSection scriptSection)
139137
var script = new Script(id);
140138
script.Name = scriptSection.GetStringValue("Name", string.Empty);
141139

142-
for (int i = 0; i < MaxActionCount; i++)
140+
int i = 0;
141+
while (true)
143142
{
144143
if (!scriptSection.KeyExists(i.ToString()))
145-
continue;
144+
break;
146145

147146
var scriptActionEntry = ScriptActionEntry.ParseScriptActionEntry(scriptSection.GetStringValue(i.ToString(), "-1,-1"));
148147
if (scriptActionEntry != null)
149148
script.Actions.Add(scriptActionEntry);
149+
150+
i++;
150151
}
151152

152153
return script;

0 commit comments

Comments
 (0)