• src/doors/clans-src/src/alliancem.c clans.c defines.h empire.c fight.c

    From Deuc¿@VERT to Git commit to main/sbbs/master on Thu Mar 12 13:45:22 2026
    https://gitlab.synchro.net/main/sbbs/-/commit/4cd8e7ca7682f15f6366766a
    Modified Files:
    src/doors/clans-src/src/alliancem.c clans.c defines.h empire.c fight.c ibbs.c items.c language.c mcomp.c menus2.c myopen.h pcedit.c quests.c scores.c spells.c structs.h user.c village.c voting.c
    Log Message:
    Replace magic numbers with named constants for maintainability

    This audit identifies and replaces hard-coded numeric literals with
    named constants, improving code readability and reducing the risk of
    copy-paste drift when values need to change.

    Changes grouped by category:

    1. sizeof() safety fixes (5 locations):
    - Replace fgets/EncryptRead/Write hardcoded sizes with sizeof()
    - Files: ibbs.c, user.c, clans.c, myopen.h

    2. New constants in defines.h (~20):
    - Game data: DATE_STR_SIZE, MAX_SPELLS_IN_EFFECT, MAX_LANG_STRINGS
    - Gameplay: MAX_VAULT_WITHDRAWALS, MAX_TAX_RATE, MAX_CONSCRIPTION_RATE
    - PC stats: TRAIN_MAX_HP/SP, ITEM_MAX_HP/SP, MAX_ATTRIBUTE_VALUE
    - Combat: ATTACK_INDEX_WINDOW, point award constants

    3. Local #defines:
    - fight.c: DEATH_THRESHOLD, MORTAL_WOUND_THRESHOLD, DEFAULT_SPELL_OFFSET
    - empire.c: FOOTMEN_PER_BARRACKS, AXEMEN_PER_BARRACKS, KNIGHTS_PER_BARRACKS

    4. ~80+ magic number replacements across 13 source files:
    - MAX_PARTY_SIZE: ~20 occurrences (party slot loops and file offsets)
    - MAX_SPELLS_IN_EFFECT: ~10 occurrences (spell loop bounds)
    - DATE_STR_SIZE: ~12 occurrences (date string I/O)
    - Barracks multipliers: 9 occurrences (army capacity checks)
    - Combat points: 9 occurrences (victory/defeat awards)
    - HP/SP caps: 11 occurrences (training and item bonuses)

    All 496 unit and integration tests pass.
    Build completes with zero errors and zero warnings.

    Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

    ---
    ■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net