feat: auto-exit in --headless --exec mode when script completes
Closes #127 Previously, `./mcrogueface --headless --exec <script>` would hang indefinitely after the script completed because the game loop ran continuously. This required external timeouts and explicit mcrfpy.exit() calls in every automation script. This commit adds automatic exit detection for headless+exec mode: - Added `auto_exit_after_exec` flag to McRogueFaceConfig - Set flag automatically when both --headless and --exec are present - Game loop exits when no timers remain (timers.empty()) Benefits: - Documentation generation scripts work without explicit exit calls - Testing scripts don't need timeout wrappers - Clean process termination for automation - Backward compatible (scripts with mcrfpy.exit() continue working) Changes: - src/McRogueFaceConfig.h: Add auto_exit_after_exec flag - src/main.cpp: Set flag and recreate engine with modified config - src/GameEngine.cpp: Check timers.empty() in game loop - ROADMAP.md: Mark Phase 7 as complete (2025-10-30) - CLAUDE.md: Add instruction about closing issues with commit messages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4e94291cfb
commit
8f8b72da4a
|
|
@ -501,4 +501,5 @@ After modifying C++ inline documentation with MCRF_* macros:
|
|||
4. **Generation** → HTML/Markdown/Stub files created with transformed links
|
||||
5. **No drift**: Impossible for docs and code to disagree - they're the same file!
|
||||
|
||||
The macro system ensures complete, consistent documentation across all Python bindings.
|
||||
The macro system ensures complete, consistent documentation across all Python bindings.
|
||||
- Close issues automatically in gitea by adding to the commit message "closes #X", where X is the issue number. This associates the issue closure with the specific commit, so granular commits are preferred. You should only use the MCP tool to close issues directly when discovering that the issue is already complete; when committing changes, always such "closes" (or the opposite, "reopens") references to related issues. If on a feature branch, the issue will be referenced by the commit, and when merged to master, the issue will be actually closed (or reopened).
|
||||
|
|
@ -80,9 +80,10 @@ For detailed task tracking and current priorities, see the [Gitea issue tracker]
|
|||
**Status**: Complete
|
||||
**Key Issues**: #50 (Grid backgrounds), #6 (RenderTexture), #8 (Viewport rendering)
|
||||
|
||||
### Phase 7: Documentation & Distribution
|
||||
**Status**: In Progress
|
||||
### Phase 7: Documentation & Distribution ✅
|
||||
**Status**: Complete (2025-10-30)
|
||||
**Key Issues**: #85 (Docstrings), #86 (Parameter docs), #108 (Type stubs), #97 (API docs)
|
||||
**Completed**: All classes and functions converted to MCRF_* macro system with automated HTML/Markdown/man page generation
|
||||
|
||||
See [current open issues](https://gamedev.ffwf.net/gitea/john/McRogueFace/issues?state=open) for active work.
|
||||
|
||||
|
|
|
|||
|
|
@ -284,6 +284,11 @@ void GameEngine::run()
|
|||
if (!headless && window && !window->isOpen()) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
// In headless exec mode, auto-exit when no timers remain
|
||||
if (config.auto_exit_after_exec && timers.empty()) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up before exiting the run loop
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ struct McRogueFaceConfig {
|
|||
// Screenshot functionality for headless mode
|
||||
std::string screenshot_path;
|
||||
bool take_screenshot = false;
|
||||
|
||||
// Auto-exit when no timers remain (for --headless --exec automation)
|
||||
bool auto_exit_after_exec = false;
|
||||
};
|
||||
|
||||
#endif // MCROGUEFACE_CONFIG_H
|
||||
|
|
@ -196,6 +196,14 @@ int run_python_interpreter(const McRogueFaceConfig& config, int argc, char* argv
|
|||
}
|
||||
else if (!config.exec_scripts.empty()) {
|
||||
// With --exec, run the game engine after scripts execute
|
||||
// In headless mode, auto-exit when no timers remain
|
||||
McRogueFaceConfig mutable_config = config;
|
||||
if (mutable_config.headless) {
|
||||
mutable_config.auto_exit_after_exec = true;
|
||||
}
|
||||
delete engine;
|
||||
engine = new GameEngine(mutable_config);
|
||||
McRFPy_API::game = engine;
|
||||
engine->run();
|
||||
McRFPy_API::api_shutdown();
|
||||
delete engine;
|
||||
|
|
|
|||
Loading…
Reference in New Issue