Skip to content

bugfix(damage): Fix kill flag version check in DamageInfoInput::xfer - #3299

Draft
bobtista wants to merge 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/damage-info-xfer-version
Draft

bobtista wants to merge 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/damage-info-xfer-version

Conversation

@bobtista

Copy link
Copy Markdown

DamageInfoInput::xfer checks currentVersion before reading m_kill:

// kill no matter what (old versions default to FALSE).
if( currentVersion >= 2 )
{
    xfer->xferBool( &m_kill );
}

currentVersion is 1 in a retail compatible Generals build and 3 otherwise. A Generals build with retail compatibility off reads a byte that a version 1 record does not have, and every field after it is off by one. ActiveBody::xfer transfers a DamageInfo for every object, so the load dies on the first one.

Now it checks version. The m_damageFXOverride read above it and the version 3 block below it already do. Save output does not change, version and currentVersion are equal when saving.

Measured on USA01. Saved at frame 1903 with a retail compatible build, then loaded that save with a build configured RTS_BUILD_OPTION_RETAIL_COMPATIBLE_GAME=OFF, once before and once after this change. The retail compatible build writes version 1 damage records, same as retail 1.08.

Before the change the load hits an access violation on Xfer Object GLATankScorpion id=2363, the first object in the file. After it, all 3781 objects load and the game runs on to frame 2100 and saves again. Same tree, same build directory, this line is the only difference between the two exes.

Zero Hour saves are always version 3, so nothing changes there.

Todo:

  • A version 1 save loads in a build with retail compatibility disabled
  • Save output is unchanged
  • Replicate to Generals — N/A, shared Core code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generals crashes loading a retail compatible save when retail compatibility is disabled

1 participant