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

Debug actions #639

Merged
merged 3 commits into from
Feb 24, 2025
Merged

Debug actions #639

merged 3 commits into from
Feb 24, 2025

Conversation

NQNStudios
Copy link
Collaborator

@NQNStudios NQNStudios commented Feb 20, 2025

Debug actions changes, some of which served as feature flags examples.

Fix #635

@NQNStudios
Copy link
Collaborator Author

New commit uses a #define simply to remove some mind-numbing repetition from the massive replay_action() function.

@NQNStudios NQNStudios added enhancement game Affects the game, as opposed to the editors labels Feb 20, 2025
@CelticMinstrel
Copy link
Member

I get the intent of that macro, but I don't really like it… I'm pondering maybe making a dispatch-based system similar to the debug actions or the dialogxml pict renderers? Then you'd write functions like this:

DEFINE_REPLAYABLE_FUNCTION(handle_pick) {
	location destination = location_from_action(action);
	handle_bash_pick(destination, did_something, need_redraw, false);
}

And it would expand to something like this (somewhat pseudo-code):

static void handle_pick(const Element& action, bool& did_something, bool& need_redraw, bool& need_reprint) {
	// Avoid "unused" warnings
	(void) did_something; (void) need_redraw; (void) need_reprint;
	location destination = location_from_action(action);
	handle_bash_pick(destination, did_something, need_redraw, false);
}
static_replay_registrar_t __unique_name__("handle_pick", handle_pick);

Where static_replay_registrar_t (not the best name) is a struct whose constructor adds that function to a global map. Then for the trivial ones you can probably have a second macro that simply forwards, ignoring the XML element reference, to the overloaded function by the same name that doesn't take that parameter.

@NQNStudios
Copy link
Collaborator Author

NQNStudios commented Feb 21, 2025

I'm bearing down on bugfixes/top priorities, so this macro is all the work I'm willing to put into cleaning that part up for now. Feel free to take the debug actions and leave the macro if you want - no worries.

@CelticMinstrel CelticMinstrel merged commit ca8da46 into calref:master Feb 24, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement game Affects the game, as opposed to the editors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debug give item gives to first PC, not active combat PC
2 participants