Skip to content

Commit fcc193a

Browse files
authored
bugfix(script): Restore retail compatibility for sequential scripts in ScriptEngine (#2129)
1 parent b398d5c commit fcc193a

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7155,12 +7155,13 @@ void ScriptEngine::setSequentialTimer(Team *team, Int frameCount)
71557155
void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
71567156
{
71577157
VecSequentialScriptPtrIt it;
7158-
SequentialScript* lastScript = nullptr;
7158+
size_t currIndex = 0;
7159+
size_t prevIndex = ~0u;
71597160
Bool itAdvanced = false;
71607161

71617162
Int spinCount = 0;
71627163
for (it = m_sequentialScripts.begin(); it != m_sequentialScripts.end(); /* empty */) {
7163-
if ((*it) == lastScript) {
7164+
if (currIndex == prevIndex) {
71647165
++spinCount;
71657166
} else {
71667167
spinCount = 0;
@@ -7173,11 +7174,11 @@ void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
71737174
seqScript->m_scriptToExecuteSequentially->getName().str()));
71747175
}
71757176
++it;
7177+
++currIndex;
71767178
continue;
71777179
}
71787180

7179-
lastScript = (*it);
7180-
7181+
prevIndex = currIndex;
71817182
itAdvanced = false;
71827183

71837184
SequentialScript *seqScript = (*it);
@@ -7285,6 +7286,7 @@ void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
72857286
// Check to see if executing our action told us to wait. If so, skip to the next Sequential script
72867287
if (seqScript->m_dontAdvanceInstruction) {
72877288
++it;
7289+
++currIndex;
72887290
itAdvanced = true;
72897291
continue;
72907292
}
@@ -7338,6 +7340,7 @@ void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
73387340

73397341
if (!itAdvanced) {
73407342
++it;
7343+
++currIndex;
73417344
}
73427345
}
73437346
m_currentPlayer = nullptr;

GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7878,12 +7878,13 @@ void ScriptEngine::setSequentialTimer(Team *team, Int frameCount)
78787878
void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
78797879
{
78807880
VecSequentialScriptPtrIt it;
7881-
SequentialScript* lastScript = nullptr;
7881+
size_t currIndex = 0;
7882+
size_t prevIndex = ~0u;
78827883
Bool itAdvanced = false;
78837884

78847885
Int spinCount = 0;
78857886
for (it = m_sequentialScripts.begin(); it != m_sequentialScripts.end(); /* empty */) {
7886-
if ((*it) == lastScript) {
7887+
if (currIndex == prevIndex) {
78877888
++spinCount;
78887889
} else {
78897890
spinCount = 0;
@@ -7896,11 +7897,11 @@ void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
78967897
seqScript->m_scriptToExecuteSequentially->getName().str()));
78977898
}
78987899
++it;
7900+
++currIndex;
78997901
continue;
79007902
}
79017903

7902-
lastScript = (*it);
7903-
7904+
prevIndex = currIndex;
79047905
itAdvanced = false;
79057906

79067907
SequentialScript *seqScript = (*it);
@@ -8008,6 +8009,7 @@ void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
80088009
// Check to see if executing our action told us to wait. If so, skip to the next Sequential script
80098010
if (seqScript->m_dontAdvanceInstruction) {
80108011
++it;
8012+
++currIndex;
80118013
itAdvanced = true;
80128014
continue;
80138015
}
@@ -8061,6 +8063,7 @@ void ScriptEngine::evaluateAndProgressAllSequentialScripts( void )
80618063

80628064
if (!itAdvanced) {
80638065
++it;
8066+
++currIndex;
80648067
}
80658068
}
80668069
m_currentPlayer = nullptr;

0 commit comments

Comments
 (0)