Skip to content

feat: read VPK files and version.txt migration support#60

Open
sour-dani wants to merge 27 commits intoktwrd:developfrom
Pre-Fortress-2:vpk
Open

feat: read VPK files and version.txt migration support#60
sour-dani wants to merge 27 commits intoktwrd:developfrom
Pre-Fortress-2:vpk

Conversation

@sour-dani
Copy link
Contributor

  • Reading VPK functionality
  • Support for Migrating PF2 styled version.txt version numbers to .adastral
  • Remote FileMap support for selecting what the version file is called, and if it's located in a .vpk file along with how the versions should be translated.
  • Bump version to 1.7.4 and new credits

rawra89 and others added 24 commits November 23, 2025 16:32
Add valve_pak crate for vpk support
Uses a vpk.json (temp name) for general information (determining what needs to be translated and placed in the new .adastral file and if the vpk needs to be accessed)
Added a not installed check in get_current_version so that the installer doesn't try to generate a version for a non existing mod
Panic on failing to create an .adastral version if not installed from installation
Renamed vpk.json to data.json
Add multiple utility functions for opening a version file and data.json file
Added some comments
More error handling added (there's a lot of panic! calls so it might not be the best way to handle it)
- Removed `open_json_file_content` function in place of Structs
- Created new structs: `RemoteFileMapResponse`, `RemoteFiles`, and `RemoteVersionMap`
- Create `get_file_map()` which remotely grabs `filemap.json`
- Updated `reading_mod_version_file` to now use remote `filemap.json`
- Updated `generate_version_file`, `read_mode_version_file`, `get_current_version` to `async`
- Added `filemap_url` support to `appvar.rs`
- Update `read_mod_version_file` to take a `&RemoteFiles` parameter instead of calling the API.
Mainly with the sourcemods_location checks. Only panic if it fails to create an adastral version file since it's needed to determine versioning
@sour-dani sour-dani changed the base branch from main to develop January 28, 2026 05:20
@ktwrd
Copy link
Owner

ktwrd commented Jan 30, 2026

Thanks for the PR @sour-dani and @rawra89
I'll review this when I've got the spare time. Work is super hectic, so expect some delays (like what I said in discord DMs)

@ktwrd
Copy link
Owner

ktwrd commented Feb 5, 2026

Should be able to look at this on the weekend, since I finally have some spare time 🎉

@ktwrd ktwrd self-requested a review February 5, 2026 01:41
@ktwrd ktwrd self-assigned this Feb 5, 2026
@ktwrd ktwrd added the enhancement New feature or request label Feb 5, 2026
@ktwrd ktwrd added this to the v1.8.0 milestone Feb 5, 2026
@ktwrd
Copy link
Owner

ktwrd commented Feb 21, 2026

This is good enough, I'll fix the minor issues myself in the develop branch :3

ktwrd
ktwrd previously approved these changes Feb 21, 2026
Copy link
Owner

@ktwrd ktwrd left a comment

Choose a reason for hiding this comment

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

I'll fix the issues that I pointed out in the develop branch.
@sour-dani @rawra89 Please fix the merge conflicts so I can merge this.

},

#[error("Failed to find local version '{expected}' in remote filemap.")]
RemoteFileMapLocalVersionNotFound
Copy link
Owner

Choose a reason for hiding this comment

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

Could the remote versions.json URL be included in this error?

dark-light = "2.0.0"
image = { version = "0.25.8", features = ["png"] }
valve_pak = "0.1.0"
anyhow = "1.0.100"
Copy link
Owner

Choose a reason for hiding this comment

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

Could you put a comment here saying that anyhow should never be used for returning errors, and that it should only be used as the "source" for an error
e.g:

#[error("Failed to read VPK file contents at {location}. ({error:})")]
VpkReadFailure
{
    location: String,
    error: anyhow::Error,
    backtrace: Backtrace
}

Even though it's in the CONTRIBUTING.md file, it's good to put it here anyways for future reference.

pub versions_url: String,
/// optional: url where the file mapping details are stored for upgrading
/// game versions from previous systems. e.g; `https://beans.adastral.net/filemap.json`
pub filemap_url: String
Copy link
Owner

Choose a reason for hiding this comment

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

Does the code support this being optional? filemap.json might not be used by all mods, and it would be good if this wasn't a requirement.

Preferably it would be good for it to be Option<String> so the appvar.json doesn't need to be modified if a mod doesn't use filemap.json (like Open Fortress).

@sour-dani
Copy link
Contributor Author

Review is neither stale nor dismissed. I only fixed the merge conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants