Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): stop a replay checkpoint from changing the playback
Olcay Seygand4c1f1560e5f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 673e6fc5e..ba18fc50e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -331,6 +331,7 @@ found and fixed — EA's own, not port damage.**## Every replay, not just the last one- A replay is watched the way an observer watches a match. The empty command grid and portrait plate are gone from the bottom of the screen, and in their place is a timeline with the time reached and the whole length. Click anywhere on it to jump there: forward, the replay races ahead to that moment; back, the picture stops for about a second and the replay carries on from the moment you clicked. There is no loading screen and no start over from the beginning: the replay keeps its place every half minute as it plays, and a jump back picks up from the last of those. Beside it are pause and five speeds, from half to eight times the speed the game was played at.+- A replay you watch past its first half minute stays the match that was recorded. Each time the replay kept its place for a jump back, every unit's facing was nudged by a hair, and a soldier who later turned on the spot turned from the wrong angle. From there the replay played a different battle from the one you fought: one match between two GLA computers split four minutes in and ended with a different army on the field.- Replays stopped crashing when an order took every unit out of the selection it was given to. The game throws an empty selection away at once, and with the recorded camera switched on the replay went on to read the one it had just thrown away.- Replay archiving saves each match under its own date-and-time name.- Long lists scroll the whole way, past two thousand rows.diff --git a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cppindex 207b11bc5..b0a9a8da4 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/StateMachine.cpp@@ -899,13 +899,17 @@ void StateMachine::xfer( Xfer *xfer )}} else {- if( m_currentState == NULL )- {- DEBUG_ASSERTCRASH(m_currentState != NULL, ("currentState was NULL on xfer, trying to heal..."));- // Hmm... too late to find out why we are getting NULL in our state, but if we let it go, we will Throw in xferSnapshot.- m_currentState = internalGetState(m_defaultStateID);- }- xfer->xferSnapshot(m_currentState);+ //+ // A machine can stand with no current state (halt and clear both leave it so), and the file+ // needs some state's block here, so the default one is written in its place. It used to be+ // assigned as well. A replay checkpoint is a save taken mid-playback: a unit with no state in+ // the recording got an idle one in the playback and went on thinking. A load has already+ // taken the default for an id it cannot find, a few lines up.+ //+ State *state = m_currentState;+ if( state == NULL )+ state = internalGetState(m_defaultStateID);+ xfer->xferSnapshot(state);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 92cb83339..05cf6e2f1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -5669,7 +5669,11 @@ void Drawable::xfer( Xfer *xfer ){Matrix3D mtx = *getTransformMatrix();xfer->xferMatrix3D(&mtx);- setTransformMatrix(&mtx);++ // as in Object::xfer: a save has nothing to set, and a replay checkpoint is a save taken+ // mid-playback, which must leave the cached angle as it found it+ if( xfer->getXferMode() == XFER_LOAD )+ setTransformMatrix(&mtx);}else{diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 65579eec4..806696c9a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -4099,8 +4099,14 @@ void Object::onDisabledEdge(Bool becomingDisabled)for( BehaviorModule **module = m_behaviors; *module; ++module )(*module)->onDisabledEdge( becomingDisabled );+ //+ // Going into any container holds the object, and held is a disabled type, so this is also what a+ // builder hears on the step into a tunnel mouth - before it is recorded as inside anything. One+ // that took the tunnel as the shorter way to its job (DozerActionPickActionPosState::update) is+ // not giving the job up: it keeps it and carries on from the far mouth.+ //DozerAIInterface *dozerAI = getAI() ? getAI()->getDozerAIInterface() : NULL;- if( becomingDisabled && dozerAI )+ if( becomingDisabled && dozerAI && !( isDisabledByType( DISABLED_HELD ) && getAI()->hasTunnelTrip() ) ){// Have to say goodbye to the thing we might be building or repairing so someone else can do it.if( dozerAI->getCurrentTask() != DOZER_TASK_INVALID )@@ -4336,7 +4342,15 @@ void Object::xfer( Xfer *xfer ){Matrix3D mtx = *getTransformMatrix();xfer->xferMatrix3D(&mtx);- setTransformMatrix(&mtx);++ //+ // Only a load has a matrix to take in. Setting it again on the way out re-derives the cached+ // angle from the matrix, a few bits off the angle setOrientation stored, and a replay checkpoint+ // is a save taken mid-playback: the playback then turned its idle units from a different angle+ // than the recording had.+ //+ if( xfer->getXferMode() == XFER_LOAD )+ setTransformMatrix(&mtx);}else{