Files

9.0 KiB

LOCAL editor — addon, launcher, snapshots and undo

The editor uses existing Source GM commands and read-only host snapshots. It is LOCAL-only: the launcher installs loose files in the LOCAL client; do not put OctoEditor on a patch channel. No server commands, hooks, protocols, native binaries or Blizzard function replacements are added.

At the start of an editor session, before changes:

python3 ops/editor/spawn_export.py snapshot /path/to/session-baseline.json

After editing:

python3 ops/editor/spawn_export.py diff /path/to/session-baseline.json /path/to/session-changes.sql

Both reads use the existing LOCAL-only tw_world_query.py connection helper, which keeps credentials out of output. The snapshot briefly takes read locks on both spawn tables, reads every numeric column and primary GUID, and releases the locks when the query connection exits. It preserves database numeric text through hex encoding. Output files are opened exclusively; an existing baseline or SQL export is never overwritten. No export command applies SQL to a database. --current snapshot.json permits an entirely offline comparison.

The SQL contains explicit column lists, ordinary INSERTs, and UPDATE/DELETE predicates matching the full old row using MySQL null-safe equality. This protects against overwriting or deleting a changed target row, but a mismatching target can produce zero affected rows: the person applying the reviewed SQL must check affected-row results. No transaction/rollback promise is made for MyISAM tables. The snapshot covers the whole two-table world, so changes from another editor during the session also appear in the diff; use an isolated LOCAL editing session.

editor-spawn-export-tests / editor-spawn-export verifies SQL round trips against an in-memory fixture, old-value guards, precision/null handling, schema changes, invalid numeric data and truncated snapshot refusal. No live baseline or database changes were made while developing the exporter.

Stage1 facing: turn the GM character with the keyboard/mouse. Persistent creature movement uses .npc spawn move GUID; ordinary .npc move is temporary. Gameobjects use .gobject move GUID followed by .gobject turn GUID, both existing commands. Creature targets are cleared before GUID-directed edits because the Source move handler otherwise prefers the selected creature.

Deleted-row restore helper

spawn_undo.py reads the addon export as data (never executes Lua), checks the full row against the current LOCAL schema and occupied GUIDs, and emits an ordinary INSERT for manual review. It does not apply SQL or issue server commands. It supports creature and gameobject, preserves every numeric column as decimal text, and supports an explicitly chosen unused replacement GUID.

python3 ops/editor/spawn_undo.py /path/to/SavedVariables/OctoEditorUndo.lua /path/to/restore.sql --entry 1
# Add --new-guid 123456 only when a different unused GUID is desired.
# Tests/offline review: --current /path/to/current-snapshot.json

The addon must export OctoEditorUndo as a standalone SavedVariables file with this data-only contract (shown shortened; real exports require ALL current columns in database order):

OctoEditorUndo = {
  format = 1,
  rows = {
    { table = "creature", columns = {"guid", "id", "position_x", "orientation"},
      values = {"77", "100", "-12.345678901234567", "0"} },
  },
}

Keep at most 20 complete deleted-row records, numbered from 1. Every value must be a numeric string; SQL NULL uses the string "NULL". Preserve values from the complete pre-delete row; never reconstruct missing fields from .npc add defaults or Lua floating-point formatting. The helper accepts WoW's bracketed table keys, trailing commas and line comments, but refuses executable Lua, escaped strings, sparse arrays, partial rows and extra assignments. Flush SavedVariables via logout/reload before reading them. This format remains supported for standalone deleted-row exports. The editor itself uses the format-2 session contract below, with host snapshots and complete copied delete rows.

Stop other LOCAL editing before applying the reviewed SQL. Confirm one affected row. Restore SQL is database-only: restart LOCAL mangosd before inspecting the restored spawn, so its in-memory spawn/grid cache is rebuilt. The helper deliberately makes no promise that a SQL INSERT immediately changes a loaded grid; it performs no restart itself. A racing GUID collision fails at INSERT rather than replacing any existing row. Do not apply the export to another database or assume transactions roll back MyISAM changes.

editor-spawn-undo-tests / editor-spawn-undo includes the existing exporter cases plus both spawn types, exact numeric text/NULL preservation, GUID conflicts and replacement GUIDs, repeated-apply refusal, complete-row validation, hostile Lua rejection, and the offline CLI's refusal to overwrite an output. No client install or live database mutation is needed.

Launch and use (Claude LOCAL test)

ops/editor/launch_editor.sh --out /mnt/Games/@project/gateway/runtime/editor/SESSION

The launcher resolves only the existing EDITOR character in tw_char, reads tw_logon.account.rank, requires rank 3+, and refuses PROXYONE/Blesisi. For automatic character selection it requires EDITOR to be the account's only character. It never creates accounts/characters or changes ranks. An already running LOCAL client is preserved and startup is refused. The approved visible-capture harness starts a private display, then the approved login_as.py submits the account only after a login screen is observed. The known WOW51900319 retry is bounded to once. Entry requires the original character screen and EDITOR text; readiness requires the addon-owned LOCAL Editor button. A failed login preserves the client for inspection.

Before launch it saves baseline.json, prepares the template-name catalog, and starts full numeric-row captures every 15 seconds under SESSION/snapshots/. Each capture is gzip JSON; Capture.lua is replaced atomically only after the complete snapshot is saved. Failed refreshes retain the last known capture, mark status.json unhealthy, and eventually block stale addon edits. The launcher writes only its owned LOCAL addon directory and session artifacts. --prepare-only prepares files but does not launch or start the ongoing watcher.

The addon stays hidden until the actual Source .account response reports rank 3+ for the configured EDITOR character. Use the LOCAL Editor button to open it. Search by exact entry or name, choose a template, then Add. Nearby results identify the new GUID; ambiguous results require an explicit choice. Select an existing GUID through Nearby, the GUID field, or the current creature target. Move copies the GM's own position/facing. Commands are logged as submitted; a rejected server command is not reported as a confirmed database change.

After adding/moving, wait at least 20 seconds, then Refresh captured rows. This reloads the UI to read the newest host-written Capture.lua; addon Lua has no dynamic filesystem reader. The displayed age is the actual loaded capture, not an assumed host heartbeat. Move/delete require a capture newer than the last edit and at most 45 seconds old. Delete requires a second click for the same GUID and copies every captured column/value into the SavedVariables state before issuing the existing delete command.

Export session reloads the UI to flush SavedVariables. The file is WTF/Account/ACCOUNT/SavedVariables/OctoEditor.lua, containing the single OctoEditorUndo assignment. On normal client exit the launcher copies it to SESSION/OctoEditorUndo.lua. The session retains up to 200 operation records, 20 complete deleted rows, and 300 bounded log messages. Refresh/reload preserves these records. Starting a new session archives the previous SavedVariables export before initialization.

Format-2 session undo

Run outside the game after export:

python3 ops/editor/spawn_undo.py SESSION/OctoEditorUndo.lua SESSION/undo.sql --entry 3 --snapshots SESSION/snapshots

The number is the operation number shown in the undo list. The helper checks the session identity and exact pre-operation capture ID. Add undo emits a guarded DELETE only if the GUID was absent before the add; move undo emits a guarded UPDATE to the captured full row; delete undo restores the newest pre-delete capture containing that GUID. Missing captures, changed schemas, occupied restore GUIDs, mismatched entries, traversal paths and already-undone moves are refused. The format-1 standalone restore path remains supported. SQL is exported exclusively, never applied automatically. Review affected-row results and restart LOCAL mangosd after applying database-only restores so cached spawns are rebuilt.

The single editor-ui-launcher-tests / editor-ui-launcher target includes Lua command/GUID/cooldown/row-copy/undo-state tests, snapshot/Lua-data and host CLI fixtures, protected-account and ownership checks, and the existing exporter/restore regression cases. It does not launch a client or mutate a database. Real LOCAL UI/login/GM-command proof belongs to Claude.