Skip to content

Alpha cleanup: strip debug output, dedupe config, document what's broken - #6

Open
Daraan wants to merge 10 commits into
DScript-2from
cleanup-alpha
Open

Alpha cleanup: strip debug output, dedupe config, document what's broken#6
Daraan wants to merge 10 commits into
DScript-2from
cleanup-alpha

Conversation

@Daraan

@Daraan Daraan commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Executes docs/ALPHA_CLEANUP_PLAN.md — batches 1, 2 and 4. No gameplay behaviour changes and no bug fixes; those stay tracked in docs/OPEN_TASKS.md.

Batches 3 (dead code) and 5 (naming/style) were deliberately left out, scoping this pass to what a player or mission author actually sees. Both are still valid as written in the plan.

1. Log spam — the release blocker

~35 development print() sites removed or gated across DScript Core.nut, DScript SFX.nut, DScript File&Blob.nut and DScript_ModdingTools.nut. With kUseIngameLog = true players saw these on screen; everyone else got a spammed monolog.txt / Thief2.log. Genuine diagnostics were converted to DPrint (or the DMissionDebug gate the persistence code already uses) rather than deleted.

Three sites beyond the plan's list, same defect class: DTrapSetQVar's two kDoPrint DPrints and DPersistentSaveTrap's one defaulted to mode kMonolog|kUI — i.e. an on-screen DarkUI.TextMessage in the shipped game. Now Debug-gated. A leftover top-level scratch snippet at the end of DScript_ModdingTools.nut printed "nope" on every compile; removed.

Where a print was the entire body of a loop, an if, or a handler override, the scaffolding went with it — a bare foreach would otherwise have swallowed the following return. Where the structure carries meaning it was kept and commented: FindFileInPath's branches (T-67's bug half untouched) and DTrigQVar.OnDarkGameModeChange, whose empty handler exists to stop the message reaching OnMessage.

2. Packaging and config

  • DSConfigDefault.nut:117-227 deleted — a verbatim duplicate of DSConfigDefAutoTxt.nut, so enum eDAutoTxtRepl was in the const table twice and the model/texture tables were built twice per load. The only change in this PR that alters what gets compiled — script_reload right after it.
  • const kReplyMessage now declared only in the Fix layer; DSConfigMyFM.nut shows the override syntax as a comment, like its Example file.
  • .gitignore: backup\ / obj\ used backslashes, so neither was ignored.

3. Docs

  • New docs/KNOWN_ISSUES.md — the user-facing half of the two review waves. An alpha with 141 statically-confirmed defects has to tell authors that DHub, DHitScanTrap, the persistent-save family, DTrigQVar and DImUndercover's modes do not work, that DRay dies on its second activation, which scripts break under Copies, and that SS2 is untested.
  • README rewritten — it still advertised "v1.0 is coming" and the old branch. Now: what V2 is, the pre-alpha caveat, the intended shipped file set, config-layer load order, DromEd commands, Notepad++ language file.
  • Seven stale code comments corrected, including a pasted pre-API-11 ObjRaycast signature (BOOL bSkipMesh) that contradicts the code below it, and a Help2 string advertising a parameter that does not exist.

4. Tooling

  • tools/latin1_patch.pyDScript Core.nut is ISO-8859-1 and § is a literal case label in DCheckString. UTF-8-assuming editors silently turn it into U+FFFD; this happened during the pass and was caught and reverted. This script edits as latin-1 and refuses to write if the high-byte census changes.
  • tools/check_files.py — run after any .nut edit. Reports encoding, line endings, high-byte census and bracket balance against a git ref.

Running the checker immediately found pre-existing damage: 6 U+FFFD in DScript File&Blob.nut from an earlier UTF-8 conversion. Restored from the still-CP1252 backup/ copy — a fold-marker banner and one comment, no code.

Verification

Nothing here has been run — nothing in this repo can be. What was checked automatically: every .nut file's bracket balance is byte-identical to the pre-PR baseline, encodings and line endings are unchanged, and no file contains U+FFFD.

Still needed in DromEd:

script_reload      # after each commit; especially the config-dedupe one

Acceptance for the log work: start a test mission with several DScript objects, play two minutes, confirm monolog.txt is empty unless a Design Note sets Debug=1.

Follow-ups left open

What Where
Batch 3 — dead/commented-out code, ~20 sites plan Batch 3, unchanged
Batch 5 — naming/style unification plan Batch 5, unchanged
T-67 — the > operator still opens an unvalidated path; only the prints went OPEN_TASKS.md
T-04 — DConfig* vs DSConfig* naming scheme; only the comment was corrected OPEN_TASKS.md
Keep KNOWN_ISSUES.md in sync as Group B/E bugs get fixed OPEN_TASKS.md T-87
All 141 confirmed bugs OPEN_TASKS.md, docs/review/

🤖 Generated with Claude Code

Daraan added 10 commits August 4, 2026 20:02
Brings in the long-diverged Scripts-in-progress history: removes the
legacy DScript.nut / DSEditorScripts.nut monolith files, adds
DSConfigFix/DSConfigMyFM "Example" variants, updates DSConfigDefault.nut,
DScript SFX/Overlays/File&Blob.nut and DScript_ModdingTools.nut, and adds
squirrel_script reference docs under DOC/.
Development traces that reached players: with kUseIngameLog the log tail is
drawn on screen, otherwise they spam monolog.txt / Thief2.log.

- DCheckString: remove the unconditional prints in the '/' ping-back, '>'
  file and radius branches (hottest function in the framework). Where a
  print was the only body of a loop or if, the scaffolding goes with it; the
  FindFileInPath branches keep their structure and get TODO comments.
- DBaseTrap constructor: drop the never-true DTrigger compare and its print.
- DBaseFunction: "_script NOT SET" now goes through
  DPrint(..., kDoPrint, ePrintTo.kMonolog) instead of a bare print.
- DScript.SetQVar: comment out the ungated INFO print. The string was built
  on every QVar write.
- DScriptHandler: remove the stray self/MissionInitialized/Object.Exists
  prints.
- DTrapSetQVar: remove the DID BEGIN/DID SIM/InitQVarFromProp traces and the
  OnBeginScript override that existed only for its print. Its two "Setting x
  to y" DPrints lose kDoPrint, so they honour <ScriptName>Debug like the rest
  of the framework - the first one defaulted to mode kMonolog|kUI and wrote
  an on-screen message in the shipped game.
- DScript.Quest: remove the per-subscribe and per-QVar-change traces.
- DTrigQVar.OnDarkGameModeChange: print replaced by a comment; the empty
  handler is kept on purpose so the message is not passed on to OnMessage.

No gameplay behaviour changed. Refs T-60, T-61, T-62, T-67.
DScript SFX.nut
- DDirector: remove the seven dev prints (speed, link data, waypoint index,
  "Will not start", "Path[0]", ...).
- DUseInventoryMaster.OnContained: fold the message into the DPrint that
  already gated it, instead of a raw print behind if (DPrint("")).

DScript File&Blob.nut
- dCSV.createCSVMatrix: remove the per-construction separator print. dump()
  keeps its prints, printing is what it is for.
- DPersistentSaveSimple / DPersistentSave: remove the IsOn, map/name, raw
  slot data and MissData dumps.
- cDSaveHandler.GetSaveRaw: the two slot-shuffling diagnostics are kept but
  gated behind DMissionDebug, following the DMissionFingerPrint convention a
  few lines above.
- DPersistentSaveTrap: drop kDoPrint from the "Event Data is" DPrint (mode
  defaulted to kMonolog|kUI, so it wrote an on-screen message in game) and
  remove the typeof print next to it.

DScript_ModdingTools.nut
- Remove the leftover scratch snippet at the end of the file. It ran at
  top level on every compile and printed "yes"/"nope" unconditionally.
- The remaining prints in this editor-only file are the tools' own output
  (DDumpModels progress, DumpTable, DImportObj errors, DPerformanceTest
  results) and are left alone.

No gameplay behaviour changed. Refs T-63.
- DSConfigDefault.nut: remove the Auto Texture Replacement block (lines
  117-227). It was a verbatim duplicate of DSConfigDefAutoTxt.nut, which
  means enum eDAutoTxtRepl was declared twice in the const table and
  gDModTable/gDTexTable were built twice on every load. The dedicated file is
  the one that stays; a pointer comment is left behind. The only content the
  duplicate had that the dedicated file lacked - the note that
  FindFileInPath does not check subfolders - is ported over.
- DSConfigMyFM.nut: kReplyMessage was declared const here and in
  DSConfigFix.nut. The Fix layer keeps the declaration, this file now shows
  the override syntax as a comment, like DSConfigFix Example.nut does.
- .gitignore: backup\ / obj\ used backslashes, so neither directory was
  actually ignored. Now backup/ and obj/.

Refs T-02, T-03, T-05.
New: docs/KNOWN_ISSUES.md - the user-facing half of the review findings. An
alpha with 141 statically-confirmed defects has to tell mission authors which
script classes are known-broken (DHub, DHitScanTrap, persistent save,
DTrigQVar, DImUndercover's modes, DRay's second activation, the Copies
breakage, the SS2 gaps) so they don't spend a day debugging their Design Note
for our bug.

README: rewrote for the alpha. It still advertised "v1.0 is coming" and the
scripts-in-progress branch. Now: what V2 is, the pre-alpha caveat with a link
to KNOWN_ISSUES, the intended shipped file set (including why
DT2UndercoverWeapons.nut stays - its own header makes it the opt-in companion
of DImUndercover, not legacy), the config-layer load order, the DromEd
commands and the Notepad++ language file.

Comment corrections, no code touched:
- Core.nut:3 named a nonexistent #include (DConfigDefault.nut) and referenced
  the deleted DScript.nut monolith.
- Core.nut DBaseTrap Help2 advertised DBaseTrapBlockMessage=, which does not
  exist. The real parameter is ExclusiveMessage.
- General.nut DoOn carried a pasted pre-API-11 ObjRaycast signature (BOOL
  bSkipMesh) while the code below depends on the API 11 int flags meaning -
  RenderedOnly + IgnoreAI are summed into that slot. Noted explicitly so
  nobody "fixes" the code against the comment.
- General.nut DHitScanTrap docstring now documents the ignore_set parameter
  and why its odd spelling cannot be renamed.
- General.nut StackToQVar: the comment claimed Create uses the script object
  directly, which is exactly what the if below does not do.
- File&Blob.nut _typeof: loud note that typeof reports the wrapped stream
  type on purpose and instanceof is the only reliable test.
- SFX.nut DHudCompass: put the docstring's */ and the # banner on separate
  lines like the rest of the file.
- CLAUDE.md: the engine reference lives in DOC/squirrel_script/, not
  docs/squirrel_script/.

Also tracks the alpha cleanup docs themselves (the plan, the two review waves
and OPEN_TASKS, which were untracked) and flips the OPEN_TASKS rows this pass
closed: T-02, T-03, T-05, T-60, T-61, T-62, T-63, T-86 done; T-04 and T-67
partially, with what is left noted in the row.

Refs T-04, T-67, T-86, T-87.
- ALPHA_CLEANUP_PLAN.md: status header - which batches ran, in which
  commits, every deviation from the plan and why, and what was left for the
  bug-fix wave (Batch 3 and 5 are untouched and still valid as written).
- CLAUDE.md: the encoding note was wrong. Byte histograms say only
  DScript Core.nut is still Latin-1 (45x §, 37x °); DScript File&Blob.nut and
  everything else already decode as UTF-8, though grep still needs -a on
  both. Added the concrete hazard: UTF-8 editors turn Core's high bytes into
  U+FFFD and break the case '§' label, so that one file needs a byte-safe
  latin-1 patch script.
- CLAUDE.md: refreshed the two config rows the dedupe made stale, and
  reclassified DT2UndercoverWeapons.nut - not dead legacy but the opt-in
  companion of DImUndercover, matching the README and T-01.
- OPEN_TASKS.md: T-93 re-checked and corrected the same way.
Two small scripts, written for this cleanup pass and worth keeping - there is
no other automated check in this repo.

- tools/latin1_patch.py - edits DScript Core.nut as latin-1 instead of UTF-8.
  Every replace asserts its pattern matches exactly once, and save() refuses
  to write if the high-byte census (45x §, 37x °) changed. The § in
  DCheckString's case label is load-bearing, and UTF-8-assuming editors
  silently turn it into U+FFFD.
- tools/check_files.py - run after any .nut edit. Reports encoding, line
  endings, high-byte census and bracket balance against a git ref, and fails
  on U+FFFD or on a balance that drifted from the baseline. That second check
  is the cheap way to catch a deleted debug print that was the entire body of
  a loop or an if, which silently re-parents the next statement.

Running it immediately found pre-existing damage in DScript File&Blob.nut:
6 U+FFFD, from whichever earlier pass converted that file to UTF-8. Restored
from backup/DScript File&Blob.nut, which is still CP1252 - the fold-marker
banner on line 6 (4x §) and the comment about normalising „“ quotes. Comments
and a Notepad++ fold marker only, no code involved.

CLAUDE.md documents both tools and the hazard.
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.

1 participant