Skip to content

Commit 84e7402

Browse files
authored
bugfix(saveload): Serialize base state machine in TurretStateMachine and DozerActionStateMachine (TheSuperHackers#2896)
1 parent 6aab954 commit 84e7402

4 files changed

Lines changed: 70 additions & 10 deletions

File tree

Generals/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,36 @@ void TurretStateMachine::crc( Xfer *xfer )
146146
}
147147

148148
// ------------------------------------------------------------------------------------------------
149-
/** Xfer Method */
149+
/** Xfer Method
150+
* Version Info:
151+
* 1: Initial version
152+
* 2: TheSuperHackers @bugfix bobtista 19/07/2026 Serialize the base StateMachine state.
153+
* Without this the turret reverts to its default state on load.
154+
*/
150155
// ------------------------------------------------------------------------------------------------
151156
void TurretStateMachine::xfer( Xfer *xfer )
152157
{
153-
XferVersion cv = 1;
154-
XferVersion v = cv;
155-
xfer->xferVersion( &v, cv );
158+
// version
159+
#if RETAIL_COMPATIBLE_XFER_SAVE
160+
XferVersion currentVersion = 1;
161+
#else
162+
XferVersion currentVersion = 2;
163+
#endif
164+
XferVersion version = currentVersion;
165+
xfer->xferVersion( &version, currentVersion );
156166

167+
if (version >= 2)
168+
{
169+
StateMachine::xfer(xfer);
170+
}
157171
}
158172

159173
// ------------------------------------------------------------------------------------------------
160174
/** Load post process */
161175
// ------------------------------------------------------------------------------------------------
162176
void TurretStateMachine::loadPostProcess()
163177
{
178+
StateMachine::loadPostProcess();
164179
}
165180

166181
//----------------------------------------------------------------------------------------------------------

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,23 +827,38 @@ void DozerActionStateMachine::crc( Xfer *xfer )
827827
}
828828

829829
// ------------------------------------------------------------------------------------------------
830-
/** Xfer Method */
830+
/** Xfer Method
831+
* Version Info:
832+
* 1: Initial version
833+
* 2: TheSuperHackers @bugfix bobtista 19/07/2026 Serialize the base StateMachine state.
834+
* Without this the dozer reverts to its default state on load.
835+
*/
831836
// ------------------------------------------------------------------------------------------------
832837
void DozerActionStateMachine::xfer( Xfer *xfer )
833838
{
834839
// version
840+
#if RETAIL_COMPATIBLE_XFER_SAVE
835841
XferVersion currentVersion = 1;
842+
#else
843+
XferVersion currentVersion = 2;
844+
#endif
836845
XferVersion version = currentVersion;
837846
xfer->xferVersion( &version, currentVersion );
838847

839848
xfer->xferUser(&m_task, sizeof(m_task));
849+
850+
if (version >= 2)
851+
{
852+
StateMachine::xfer(xfer);
853+
}
840854
}
841855

842856
// ------------------------------------------------------------------------------------------------
843857
/** Load post process */
844858
// ------------------------------------------------------------------------------------------------
845859
void DozerActionStateMachine::loadPostProcess()
846860
{
861+
StateMachine::loadPostProcess();
847862
}
848863

849864

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,21 +146,36 @@ void TurretStateMachine::crc( Xfer *xfer )
146146
}
147147

148148
// ------------------------------------------------------------------------------------------------
149-
/** Xfer Method */
149+
/** Xfer Method
150+
* Version Info:
151+
* 1: Initial version
152+
* 2: TheSuperHackers @bugfix bobtista 19/07/2026 Serialize the base StateMachine state.
153+
* Without this the turret reverts to its default state on load.
154+
*/
150155
// ------------------------------------------------------------------------------------------------
151156
void TurretStateMachine::xfer( Xfer *xfer )
152157
{
153-
XferVersion cv = 1;
154-
XferVersion v = cv;
155-
xfer->xferVersion( &v, cv );
158+
// version
159+
#if RETAIL_COMPATIBLE_XFER_SAVE
160+
XferVersion currentVersion = 1;
161+
#else
162+
XferVersion currentVersion = 2;
163+
#endif
164+
XferVersion version = currentVersion;
165+
xfer->xferVersion( &version, currentVersion );
156166

167+
if (version >= 2)
168+
{
169+
StateMachine::xfer(xfer);
170+
}
157171
}
158172

159173
// ------------------------------------------------------------------------------------------------
160174
/** Load post process */
161175
// ------------------------------------------------------------------------------------------------
162176
void TurretStateMachine::loadPostProcess()
163177
{
178+
StateMachine::loadPostProcess();
164179
}
165180

166181
//----------------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,23 +832,38 @@ void DozerActionStateMachine::crc( Xfer *xfer )
832832
}
833833

834834
// ------------------------------------------------------------------------------------------------
835-
/** Xfer Method */
835+
/** Xfer Method
836+
* Version Info:
837+
* 1: Initial version
838+
* 2: TheSuperHackers @bugfix bobtista 19/07/2026 Serialize the base StateMachine state.
839+
* Without this the dozer reverts to its default state on load.
840+
*/
836841
// ------------------------------------------------------------------------------------------------
837842
void DozerActionStateMachine::xfer( Xfer *xfer )
838843
{
839844
// version
845+
#if RETAIL_COMPATIBLE_XFER_SAVE
840846
XferVersion currentVersion = 1;
847+
#else
848+
XferVersion currentVersion = 2;
849+
#endif
841850
XferVersion version = currentVersion;
842851
xfer->xferVersion( &version, currentVersion );
843852

844853
xfer->xferUser(&m_task, sizeof(m_task));
854+
855+
if (version >= 2)
856+
{
857+
StateMachine::xfer(xfer);
858+
}
845859
}
846860

847861
// ------------------------------------------------------------------------------------------------
848862
/** Load post process */
849863
// ------------------------------------------------------------------------------------------------
850864
void DozerActionStateMachine::loadPostProcess()
851865
{
866+
StateMachine::loadPostProcess();
852867
}
853868

854869

0 commit comments

Comments
 (0)