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

Codechange: Store industry cargo data in vector instead of array. #12159

Merged
merged 5 commits into from
Apr 1, 2024

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Feb 22, 2024

Motivation / Problem

Industries store data for 16 incoming and 16 outgoing cargos. Most of the time these are empty as original specs only permitted 2 or 3 of each.

#10541 wants to extend the industry cargo history from 2 periods to 25 periods, which would make the industry data size increase quite a bit.

Description

Replace fixed accepts and produced arrays with vectors. This allows the cargo data to be sized more appropriately.

Limitations

This does not have much memory impact by itself, but is useful for #10541.

Does not rename types, so e.g. ProducedCargoArray is now a vector...

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Copy link
Member

@2TallTyler 2TallTyler left a comment

Choose a reason for hiding this comment

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

If you're going to go to all this trouble of making this very nice, wide-ranging PR, why not rename types while you're at it? (Honest question, not a suggestion.) 😄

src/saveload/afterload.cpp Outdated Show resolved Hide resolved
@PeterN
Copy link
Member Author

PeterN commented Feb 27, 2024

If you're going to go to all this trouble of making this very nice, wide-ranging PR, why not rename types while you're at it? (Honest question, not a suggestion.) 😄

Mainly because it makes a PR bigger and changes lines that otherwise aren't changed. But I've done it now.

@PeterN PeterN force-pushed the industry-vector branch 2 times, most recently from 1bd351a to 0aef410 Compare March 2, 2024 07:42
@PeterN PeterN merged commit 3de8853 into OpenTTD:master Apr 1, 2024
15 checks passed
@PeterN PeterN deleted the industry-vector branch April 1, 2024 20:35
@glx22 glx22 added backport requested This PR should be backport to current release (RC / stable) and removed backport requested This PR should be backport to current release (RC / stable) labels Apr 9, 2024
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

4 participants