Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 11ab3c4ea2f: Vehicles could not be refitted to cargo IDs higher than 32. #7134

Merged
merged 1 commit into from Jan 29, 2019

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Jan 29, 2019

This shuffles the bit packing around to give more space to cargo ID.

@andythenorth
Copy link
Contributor

andythenorth commented Jan 29, 2019

PR fixes the vehicle refit bug found here: https://www.tt-forums.net/viewtopic.php?p=1217911#p1217911

I looked at the patch and it looks sane to me, but I didn't check if all the changes to bit counts are correct.

@PeterN
Copy link
Member Author

PeterN commented Jan 29, 2019

@andythenorth Technically 8 bits is too many, however by specifying that many bits we will get an error message if CargoID is out of range, rather than it being silently wrapped at 32 (or 64)

Additionally the scripting interface only provides for CargoID and subtype parameters, so is not affected by the shuffling.

@PeterN
Copy link
Member Author

PeterN commented Jan 29, 2019

In the bit packing, the following changes are made:

  • Bit 5 is moved to bit 24
  • Bit 6 is moved to bit 25
  • CargoID increased from bits 0-4 to 0-7

Copy link
Contributor

@planetmaker planetmaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, let's fix this bug :)

@PeterN PeterN merged commit 48fb575 into OpenTTD:master Jan 29, 2019
@PeterN PeterN deleted the fix-cargo-refit branch January 29, 2019 17:57
@PeterN
Copy link
Member Author

PeterN commented Jan 29, 2019

This is incomplete for autorefitting, however in trying to follow the flow for autorefit it seems it was buggy before. Trying to work out what values are valid :-)

CT_AUTO_REFIT = 0xFD, which would have been truncated to cargo type 0x1D with the original bit packing, which may or may not be valid depending on NewGRFs in use.

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.

None yet

3 participants