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

improve campaign file extension handling #6443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Goober5000
Copy link
Contributor

@Goober5000 Goober5000 commented Nov 28, 2024

As discovered by WouterSmits, campaigns with periods in their filenames caused issues with FSO's campaign handling. Specifically, in The Babylon Project, the EA-Minbari war v1.0.fc2 campaign would not save progress because FSO expected EA-Minbari war v1.fc2 in certain places. This is because the _splitpath() function attempted to remove an extension from a filename that already had it removed. For most campaigns this did not matter, but WouterSmits found a campaign where it did.

To solve this, there is now a new util::get_file_part() function to remove the path without removing the extension. This replaces _splitpath() for campaign files, as well as the similar clean_filename() and GetFilePart() functions in other places. All code paths were inspected for any chance of inadvertent extension adding, and Assertions were added to verify future code. The only potential problem area was player:loadCampaignSavefile() which now pre-removes the campaign extension if needed.

Fixes campaign progress not being saved in Tales of EAS Janus: EA-Minbari War

@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. Requested by Active Mod A feature request that has been requested by a mod that is actively in development. labels Nov 28, 2024
@Goober5000 Goober5000 added this to the Release 25.0 milestone Nov 28, 2024
As discovered by WouterSmits, campaigns with periods in their filenames caused issues with FSO's campaign handling.  Specifically, in The Babylon Project, the EA-Minbari war v1.0.fc2 campaign would not save progress because FSO expected EA-Minbari war v1.fc2 in certain places.  This is because the `_splitpath()` function attempted to remove an extension from a filename that already had it removed.  For most campaigns this did not matter, but WouterSmits found a campaign where it did.

To solve this, there is now a new `util::get_file_part()` function to remove the path without removing the extension.  This replaces `_splitpath()` for campaign files, as well as the similar `clean_filename()` and `GetFilePart()` functions in other places.  All code paths were inspected for any chance of inadvertent extension adding, and Assertions were added to verify future code.  The only potential problem area was `player:loadCampaignSavefile()` which now pre-removes the campaign extension if needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A fix for bugs, not-a-bugs, and/or regressions. Requested by Active Mod A feature request that has been requested by a mod that is actively in development.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants