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: JGRPP's NGRF chunk doesn't contain length indicators for fixed-size arrays #456

Merged
merged 1 commit into from
Mar 30, 2024

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Mar 30, 2024

Before TABLE chunks, SlArray (fixed-size arrays) weren't prefixed with a length indicator. But with the migration to TABLE chunks, they are. This is because otherwise there is no information in the savegame about the length of these fields, and would still require knowledge of the OpenTTD versions that created these chunks.

But, vanilla documented poorly that this was a change made, and with JGR's efforts in JGRPP to switch to TABLE chunks, this was overlooked. Now this doesn't show up when saving/loading games in-game, as everything is compatible. Although trying to load a JGRPP's savegame in Vanilla will also cause trouble.

Either way, BaNaNaS should just be able to load scenarios, no matter what OpenTTD produced them. As such, this proposed change.

It first detects a chunk that is JGRPP specific, which indicates what features are active. We use this for JGRPP to signal to us when the length indicator is there or not; for now the assumption is that table_newgrf_sl == 1 means it is not there, and that any newer versions do contain it. When version 1 is detected, ident.md5sum and param are hardcoded to their values as in JGRPP:

https://github.com/JGRennison/OpenTTD-patches/blob/9f7d25e02d5a4e86a88ebe9a6c83998fdcf7827e/src/sl/newgrf_sl.cpp#L83

PS: It has to be noted, although we detect this issue with the NGRF chunk, there might be other chunks effected. But this codebase only actually reads a very select few chunks, so not relevant for this repository.

JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this pull request Mar 30, 2024
@TrueBrain TrueBrain merged commit f9aed81 into OpenTTD:main Mar 30, 2024
16 checks passed
@TrueBrain TrueBrain deleted the workaround-jgrpp branch March 30, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant