Skip to content

Load .0verpg.json from the current directory first - #11

Merged
su8 merged 2 commits into
su8:mainfrom
lasers:feat/config-cwd
Oct 22, 2026
Merged

su8 merged 2 commits into
su8:mainfrom
lasers:feat/config-cwd

Conversation

@lasers

@lasers lasers commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Feature

The game now looks for the config in the directory you run it from ($PWD) before $HOME:

  1. $PWD/.0verpg.json, if it exists
  2. otherwise $HOME/.0verpg.json, as before

$PWD is where your shell is when you type the command, not where the 0verpg binary is installed.

Examples

Assume the repo is cloned to ~/src/0verpg:

You run $PWD/.0verpg.json exists? Config used
cd ~/src/0verpg && ./0verpg en yes (the repo's copy) ~/src/0verpg/.0verpg.json
cd /tmp && 0verpg en no ~/.0verpg.json
cd ~ && 0verpg en yes ~/.0verpg.json (same file either way)
cd /tmp && 0verpg en, nothing in ~ either no Error: Could not open /home/you/.0verpg.json (unchanged)

Why

  • Build and play straight from the repo (make && ./0verpg en) without copying the config to ~ first.
  • Edits to the repo's .0verpg.json take effect right away when you play from the repo.

Compatibility

Installed players who run 0verpg from anywhere without a .0verpg.json keep using ~/.0verpg.json, exactly as before. If both exist, the one in $PWD wins; the README now says so.

Code

// The config in the current directory wins, so the game runs straight from the repository; otherwise use the one in HOME
std::string configHome = std::ifstream(".0verpg.json") ? std::string(".0verpg.json") : /* $HOME path as before */;

Fixes #7

Catch nlohmann::json exceptions around the game and tell the player to
copy the new .0verpg.json, instead of terminating with an uncaught
parse_error/type_error when ~/.0verpg.json predates new keys.
Translate the shop's "3. Exit Shop" with the existing "skip" key.
If ./.0verpg.json exists it is used, otherwise the one in HOME as
before. The game can now run straight from the repository without
copying the config, and existing ~/.0verpg.json setups keep working.
@lasers lasers changed the title Explain broken or outdated config instead of aborting Load .0verpg.json from the current directory first Oct 22, 2026
@su8
su8 merged commit 30725d4 into su8:main Oct 22, 2026
3 checks passed
@su8

su8 commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Hi @lasers,

Thank you so much mate.

Cheers

@su8

su8 commented Oct 22, 2026

Copy link
Copy Markdown
Owner

You are the man ! Without your help I wouldn't have thought of these problematic areas :)

Cheers mate

@lasers

lasers commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Claude. I don't know a lick of C/C++ 👅

@lasers
lasers deleted the feat/config-cwd branch October 22, 2026 23:23
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.

Old or broken ~/.0verpg.json aborts the game with an uncaught JSON exception

2 participants