Read config and levels from the user folder, seeded from the binary - #20
Open
Upabjojr wants to merge 3 commits into
Open
Read config and levels from the user folder, seeded from the binary#20Upabjojr wants to merge 3 commits into
Upabjojr wants to merge 3 commits into
Conversation
The game read its configuration and the shipped levels from the data
folder it was configured with at build time. When that folder was never
installed, there was nothing to fall back on but the current working
directory, which is why running from a source checkout was the only way
to start it.
Compile config/ and levels/ into the executable and extract them into
the user data folder instead, under a gamedata/ subfolder:
~/.local/share/opendungeons/gamedata/config/*.cfg
~/.local/share/opendungeons/gamedata/levels/{skirmish,multiplayer}/
cmake/GenerateBuiltinData.cmake turns the two folders into a generated
translation unit at build time, declared by source/utils/BuiltinData.h.
ResourceManager writes out every file that is not already there and then
reads the configuration and the shipped levels from that folder, so the
game no longer depends on a system wide folder existing or being
readable. Existing files are never overwritten, since the folder is the
player's and may have been edited on purpose; a digest of the embedded
data is stamped alongside them so that a build carrying different
defaults is reported rather than silently ignored. --gamedata reads them
from somewhere else, which is the convenient way to run against an
edited source tree.
Saving a level in the editor now writes to the user levels folder unless
the level already lives there, rather than over the file it was loaded
from. Editing one of the shipped levels used to modify it in place, so
the original could not be played again. This restores the intent of the
code that was left commented out in askSaveMap, comparing normalised
absolute directories rather than searching for substrings in paths.
Two supporting changes: the server mode options name a level, so they
moved to their own step that runs once the default data path is known;
and ODApplication now logs the resolved paths, which ResourceManager
cannot do itself because the log file sink does not exist yet while it
runs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 8ce9ff4926ef44287322b28e3f3e116e2ea9f228,
with the --gamedata trailing-separator check accepting '\\' as well, a fix
that in the original branch arrived with the cross-platform commit)
Comparing the stamp written into the user data folder against the one this build carries reports any difference between the two builds, including one that has no effect: a build that only adds files writes them out normally, since extractBuiltinData() skips existing files rather than all of them. Shipping a new level would have warned that the folder was kept as it is, right after correctly putting the new level in it. Count the files that exist but hold something other than what this build would have written, and warn only about those. The stamp is still written, as a record of which build populated the folder. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit 7fdc135)
Issue tomluchowski#42 asks for explicit types instead of auto. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reads config and levels from a folder the player owns, seeded from copies compiled into the executable (
BuiltinData.h), which makes the game independent of a system-wide data folder. A second commit reports outdated extracted data by comparing content rather than a timestamp, so editing extracted files on purpose stays safe while a stale extraction after an upgrade is reported.One adaptation versus the original branch, noted in the commit message: the
--gamedatatrailing-separator check accepts\\as well as/, a fix that originally arrived with the cross-platform commit (whose ResourceManager changes patch code this PR introduces).Note for merge order: trivial adjacent-lines conflicts with the editor-improvements PR (
ODServer.cpp) and the cross-platform PR (ResourceManager.cpp); whichever merges second needs a one-spot resolution.Split out of #16 so each topic can be reviewed on its own. Merging all of the split PRs reproduces the tree of #16 exactly.
🤖 Generated with Claude Code