Skip to content

bugfix(saveload): Transfer the weapon set pitch limit flag - #3145

Draft
bobtista wants to merge 2 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/weaponset-pitch-limit-xfer
Draft

bugfix(saveload): Transfer the weapon set pitch limit flag#3145
bobtista wants to merge 2 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/weaponset-pitch-limit-xfer

Conversation

@bobtista

@bobtista bobtista commented Aug 14, 2026

Copy link
Copy Markdown

WeaponSet::xfer writes two bools and passes the same member to both:

xfer->xferBool(&m_hasDamageWeapon);
xfer->xferBool(&m_hasDamageWeapon);

m_hasPitchLimit is declared immediately before m_hasDamageWeapon and belongs in the first slot. The record is the right size, so nothing fails loudly; the flag is simply never written and never read.

Nothing restores it afterwards. updateWeaponSet recomputes the flag behind set != m_curWeaponTemplateSet, and the load has already restored m_curWeaponTemplateSet to the saved set, so the body is skipped and the flag keeps the value derived from the weapon set the object was constructed with. isAnyWithinTargetPitch returns true from its first line when the flag is false, so a unit accepts a target outside its firing pitch and then cannot connect.

Now the first slot carries m_hasPitchLimit from version 3 and keeps the repeated m_hasDamageWeapon below it, so older saves load exactly as they did before and the record size is unchanged.

Measured by forcing a value at save time that the default weapon set cannot produce, then reading both flags back on load, with m_hasDamageWeapon as a control:

build version saved loaded
before - pitch 1, damage 0 pitch 0, damage 0
after, retail compatible saves 1 pitch 1, damage 0 pitch 0, damage 0
after 3 pitch 1, damage 0 pitch 1, damage 0

The control round trips in every case, so the record is written and read; the middle row is byte for byte the old behaviour, which is what keeps retail saves readable.

The flag is engine derived rather than authored, so how often the fault is reachable depends on whether a template set adds a pitch limit that the object's default set lacks. That data lives in the shipped archives, so this measures the transfer rather than a specific unit.

Todo:

  • A save and load restores the pitch limit flag
  • A version 1 save loads exactly as it did before the change
  • The record size is unchanged
  • Replicate to Generals

@bobtista
bobtista force-pushed the bobtista/bugfix/weaponset-pitch-limit-xfer branch 3 times, most recently from 5b32662 to d86a7c4 Compare August 14, 2026 18:52
@bobtista
bobtista force-pushed the bobtista/bugfix/weaponset-pitch-limit-xfer branch from d86a7c4 to 551a841 Compare August 14, 2026 18:52
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.

Weapon pitch limits are not restored when a save is loaded

1 participant