Skip to content

fix: replace tascii ASCII-encoding with numeric format in write_one_object#3174

Merged
bylins merged 3 commits intomasterfrom
fix/flagdata-numeric-save
Apr 18, 2026
Merged

fix: replace tascii ASCII-encoding with numeric format in write_one_object#3174
bylins merged 3 commits intomasterfrom
fix/flagdata-numeric-save

Conversation

@kvirund
Copy link
Copy Markdown
Collaborator

@kvirund kvirund commented Apr 17, 2026

Summary

Closes #3165

  • Adds FlagData::to_numeric_string() that serializes four plane values as space-separated integers ("p0 p1 p2 p3"), eliminating per-bit iteration and snprintf loops.
  • Updates FlagData::from_string() to detect and parse the new format; legacy ASCII letter+digit encoding and old packed-number format continue to work (full backward compatibility with existing saves).
  • Rewrites the five flag blocks in write_one_object() (Affs / Anti / Nofl / Extr / Wear) to use direct FlagData::operator!= + to_numeric_string() — no temporary char buffers, no tascii + strcmp round-trips.
  • Fixes CLAUDE.md: documents Release as the correct CMAKE_BUILD_TYPE for development (Test is CI/Docker only).

Before

Each object write called tascii() ×10 (5 flag groups × 2: object + proto), each doing 4×30 = 120 iterations with strlen()/snprintf() per set bit, then strcmp.

After

Each flag group: one operator!= (4 integer comparisons), and on difference — one to_numeric_string() (4 std::to_string calls). No temporary buffers.

Test plan

  • 13 new unit tests for to_numeric_string(), new numeric from_string(), round-trips, and legacy format compatibility (FlagData.* suite)
  • Full test suite: 365/365 passed

🤖 Generated with Claude Code

kvirund and others added 3 commits April 17, 2026 16:27
…bject

FlagData flags were saved as per-bit letter+digit strings (e.g. "a0b2 "),
requiring two tascii() calls + strcmp per flag group on every object write.
With large clan chests this caused measurable save lag (up to ~0.14 s).

Changes:
- Add FlagData::to_numeric_string() - writes four plane values as
  space-separated integers ("p0 p1 p2 p3"), no per-bit iteration.
- Update FlagData::from_string() to detect and parse the new format;
  legacy ASCII and packed-number formats continue to work (backward compat).
- Rewrite write_one_object() flag blocks (Affs/Anti/Nofl/Extr/Wear) to
  use direct FlagData::operator!= comparison and to_numeric_string(),
  eliminating temporary char buffers and O(120) tascii loops per save.
- Fix CLAUDE.md: document Release as the correct CMAKE_BUILD_TYPE for
  development builds (Test is CI/Docker only).

Fixes #3165

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bylins bylins merged commit 1014ed8 into master Apr 18, 2026
20 checks passed
@bylins bylins deleted the fix/flagdata-numeric-save branch April 18, 2026 05:22
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.

32. Clan system: ingredients chests saving 0.144088 seconds. time Thu Apr 16 12:31:05 2026

2 participants