Anesthesia, but it's vibecoded slop
  • Python 76.1%
  • HTML 20.1%
  • CSS 3.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-19 16:11:16 +01:00
conf Rename to Anesthesia Vibeslop and improve write capture 2026-11-19 13:45:38 +01:00
Configurations Add accounts/profiles, unique config system, UI, and migrations 2026-11-19 13:32:42 +01:00
Database Add accounts/profiles, unique config system, UI, and migrations 2026-11-19 13:32:42 +01:00
scripts lelelel 2026-11-19 16:11:16 +01:00
tracks Add accounts/profiles, unique config system, UI, and migrations 2026-11-19 13:32:42 +01:00
webui Rename to Anesthesia Vibeslop and improve write capture 2026-11-19 13:45:38 +01:00
.gitignore lelelel 2026-11-19 16:11:16 +01:00
app.py lelelel 2026-11-19 16:11:16 +01:00
config.py Add Czech README and lively simulated rankings 2026-11-19 14:26:58 +01:00
events.py Add accounts/profiles, unique config system, UI, and migrations 2026-11-19 13:32:42 +01:00
music.py Skolni claudak 2026-11-19 11:19:25 +01:00
pfx_to_pem.py lelelel 2026-11-19 16:11:16 +01:00
protocol.py initial commit 2026-11-18 22:54:05 +01:00
ranking.py Add Czech README and lively simulated rankings 2026-11-19 14:26:58 +01:00
README.cs.md lelelel 2026-11-19 16:11:16 +01:00
README.md lelelel 2026-11-19 16:11:16 +01:00
requirements.txt initial commit 2026-11-18 22:54:05 +01:00
smoke_test.py initial commit 2026-11-18 22:54:05 +01:00
store.py Add accounts/profiles, unique config system, UI, and migrations 2026-11-19 13:32:42 +01:00
unlocks.py Add accounts/profiles, unique config system, UI, and migrations 2026-11-19 13:32:42 +01:00

Anesthesia Vibeslop (Python / Flask)

English | Česky

Python implementation of a local server for Groove Coaster 4MAX / 4EX, designed to be protocol- and data-compatible with GC-local-server-rewrite (C#).

It includes game endpoint compatibility, live score rankings, unlock/keys management, a web account/profile system (with per-card profile modes and shared profiles across multiple cards), event support, and a CG-inspired Frutiger Aero web UI.

Highlights

  • Unique config/runtime layout (not the C# Configurations/-style folder structure as the primary system):
    • conf/settings.json — single unified config (paths, server, game counts/rewards, ranking, unlock defaults, events, matching, auth, web accounts)
    • saves/ — runtime save data (card.db3, captures)
    • tracks/ — music databases (e.g. music474omni.db3)
    • events/ — event files served to the game
    • certs/ — TLS cert/key PEMs
    • webui/ — web UI templates/assets
    • Legacy import/fallback: if conf/settings.json is missing, settings are imported once from legacy Configurations/*.json (when present). Legacy Database/, data/, and wwwroot/events/ are also used as fallbacks for existing files to ease migration.
  • Accounts, profiles, and card linking (new system, CG-like concept)
    • Web account registration/login (/ui/login, /ui/register, /ui/account)
    • Multiple profiles per account, each customizable (name + custom fields like nickname/comment/favorites) and set to an unlock mode
    • Two profile modes per card (toggle):
      • Everything Unlocked — all content treated as available for linked cards
      • Progressive — keys/coins/unlocks tracked progressively
    • Multiple cards can link to the same profile (shared progressive state: unlock bitsets/coins/key progress are profile-scoped when linked)
    • Cards can be linked/unlinked/claimed from the account page and toggled between your full/progressive profiles from the card page
    • Unlinked cards follow the configurable default mode (unlocks.default_mode in conf/settings.json)
  • Score rankings (live, computed from card data): world/global, shop/tenpo, monthly (30 days), and play-number/hit charts (4098,4119,6657,6661,6663,6664,6665,6666) with C#-compatible behavior; web views for World, Monthly, All-time, Daily (24h), Weekly (7d)
  • Unlocks/keys base: progressive unlock bitsets, coin storage, unlock rewards/key tracking (ReadUnlockReward/ReadUnlockKeynum/WriteUnlockKeynum), unlock-all-music actions, key set/grant UI, auto-grant option
  • Events: C#-compatible server/data.php behavior and event file serving from configured events directory (toggle/preview in UI)
  • Web UI: CG-inspired sidebar layout with a custom Frutiger Aero theme (not derived from the old server UI). Pages: Home, Cards, Card detail, Rankings, Unlocks & Keys, Events, Music DB, About, Account/Login/Register/Profile edit
  • Migration tooling: scripts/migrate_card_db.py (C# → canonical superset schema) and scripts/migrate_music_db.py (inspect/normalize; omnimix DBs like music474omni.db3 are compatible)

Project layout

Path Purpose
app.py Flask app: game routes, ranking, web UI, accounts/profiles, HTTP/HTTPS launcher
config.py Unified config system (conf/settings.json) with legacy import/fallback
store.py SQLite store (saves/card.db3): card data, C#-compatible tables, accounts/profiles/links, profile-scoped progression state
unlocks.py Unlock modes/bitsets, coins, key rewards, profile-vs-card state resolution
ranking.py Live ranking/hit-chart computation
events.py Event distribution manager
music.py Music DB loader + compatibility inspection
protocol.py XML/wire helpers
webui/ Templates and static assets
scripts/ migrate_card_db.py, migrate_music_db.py
conf/settings.json Primary configuration (created/imported on first run)
saves/, tracks/, events/, certs/ Runtime data, music DBs, event files, TLS certs

cg.html in the repo root (if present) is a confidential layout reference and is not used by the application.

Setup & run

pip install -r requirements.txt

# Optional: create TLS PEMs if you have a PFX bundle (see HTTPS/TLS notes below)
# python3 pfx_to_pem.py certs

# Run (needs privileges for :443/:80)
python3 app.py

# Unprivileged testing
GC_HTTP_PORT=8080 GC_HTTPS_PORT=8443 python3 app.py
  • Web UI: http://<host>/ (and /ui/*)
  • HTTPS starts only if certs/cert.pem and certs/cert.key exist
  • conf/settings.json controls ports/paths/game settings; env vars GC_HTTP_PORT/GC_HTTPS_PORT override ports
  • Request capture for development: files are written to saves/captures/ (gitignored).
    • GC_CAPTURE=write (recommended): record only card write/register requests (/service/card/cardn.cgi, cmd 768/512). Each capture includes parsed metadata and the decoded game payload (.json + raw .bin + .data.xml/.data.txt), which is ideal for implementing proper write handlers later.
    • GC_CAPTURE=1 (or all): record all HTTP requests.
    • Example: GC_CAPTURE=write GC_HTTP_PORT=8080 GC_HTTPS_PORT=8443 python3 app.py
    • To share captures for analysis, zip saves/captures/ (note: captures may contain card IDs, MACs, names, and play/save data).

HTTPS / TLS and certify.php troubleshooting

The game contacts GET /server/certify.php over HTTPS (NESYS-style). If the client/cabinet log shows a request to Alive.txt succeeding but then errcode=12175 / WinHttpSendRequest() 0x00002F8F for access=certify.php, the TLS handshake or certificate validation failed.

  1. Provide valid cert/key PEMs

    • Place cert.pem and cert.key in certs/ (HTTPS is not started without them).
    • To convert the bundled C# server PFX files (same certs used by GC-local-server-rewrite):
      # put cert.pfx and root.pfx in certs/, then:
      python3 pfx_to_pem.py certs
      
      This writes certs/cert.pem, certs/cert.key, and certs/root.pem.
    • Verify conversion and key/cert pairing: python3 scripts/check_certs.py
      • The leaf cert should include NESYS SANs like cert.nesys.jp, data.nesys.jp, proxy.nesys.jp, nesys.taito.co.jp, fjm170920zero.nesica.net and the private key must match.
  2. Trust the root CA on the client/cabinet

    • The server cert is issued by Taito Arcade Machine CA (certs/root.pem). The client must trust this CA (e.g. import root.pem/root.pfx into the machine's trusted root store as done for the C# server). An untrusted chain commonly causes WinHTTP 12175.
  3. Hostname/DNS/hosts mapping

    • Ensure the cabinet resolves the NESYS hostnames it connects to (e.g. cert.nesys.jp, nesys.taito.co.jp, fjm170920zero.nesica.net) to this server's IP, and that the HTTPS port (default 443) is reachable.
  4. Legacy TLS compatibility

    • The server enables a permissive TLS configuration for legacy clients (TLS 1.0+ and relaxed cipher/security levels where supported by OpenSSL). On startup it logs certificate subject/SAN/fingerprint and HTTPS status.
    • If handshakes still fail, confirm the client OS allows TLS 1.0/legacy ciphers (very old Windows images may have them disabled) and check server logs at the time of the certify.php request.

certs/*.pem, certs/*.key, and certs/*.pfx are gitignored; keep private keys/cert bundles out of commits.

Accounts & profiles

  • Create an account in the web UI, then create/use profiles (default "Everything Unlocked" and "Progressive" are created for convenience).
  • Link one or more game cards to a profile; cards linked to the same profile share progressive state (unlocks/coins/keys). Toggle a card between your full/progressive profiles from the card page or reassign on the account page.
  • Unlinked cards use unlocks.default_mode from conf/settings.json.

Card DB migration

scripts/migrate_card_db.py migrates/normalizes card DBs (including C# GC-local-server-rewrite DBs) into this server's canonical superset schema (core card tables, C# naming/timestamp normalization, unlock/coin/shop/key tables preserved when present, plus tables required by this server).

python3 scripts/migrate_card_db.py --src /path/to/card.db3 --dst saves/card.db3
python3 scripts/migrate_card_db.py --src /path/to/card.db3 --in-place

Music DB compatibility

Omnimix and standard music DBs from GC-local-server-rewrite (e.g. music474omni.db3) are compatible. Required tables: music_unlock, music_extra, music_aou with core columns; optional columns like calc_flag/RecordId are tolerated.

python3 scripts/migrate_music_db.py --src tracks/music474omni.db3
python3 scripts/migrate_music_db.py --src /path/to/music.db3 --dst tracks/music.db3 --add-calc-flag

Events

Configure events in conf/settings.json (events.enabled, events.files[{file,index}]) or via the Events page. Place files in events/. GET /server/data.php follows C#-compatible behavior (count/nexttime, per-file URL/not_before/not_after/md5/index with index rules).

Properly implementing unlocking, item count tracking, and coins (status & what’s needed)

The server provides a working base (modes/toggles, profile-scoped progressive bitsets and coin storage, key progress read/write/persist/grant hooks, unlock-all-music, UI management, and C#-compatible reads for unlock state/coins/rewards in many paths) but full fidelity requires deeper, protocol-accurate persistence and state transitions:

  1. Per-item ownership/count state (not just bitsets)
    • Store per (profile/card, item_type, item_id): owned/unlocked, item_num/quantity (for consumable "Item" types), use_flag/equipped, new_flag, timestamps. A scaffold table (profile_item_state) exists, but reads/writes must be wired to it.
    • Update card read handlers (avatar/item/skin/title/navigator/sound_effect, etc.) to return the actual stored per-item records/counts (today item_num/flags are largely synthesized) matching the client’s expected schema.
  2. Persist game write requests
    • Implement handlers for currently no-op write types (e.g. avatar/item/skin/title/navigator/music/sound_effect/coin/unlock/cond) by parsing the <data> payloads and applying deltas/sets to stored state. This requires confirming exact per-type field schemas from captures/protocol behavior.
  3. Coins (current/total/monthly) correctness
    • Apply coin deltas from gameplay writes, purchases, and reward grants atomically in the correct scope (profile when linked, card otherwise); handle monthly/period resets if the client/protocol expects them; keep read values consistent with writes.
  4. Key/unlock rewards semantics
    • Persist full unlock_keynum fields as reported/required (reward_count, flags), increment keys according to the actual game-reported events/rules, and grant rewards idempotently with correct side effects (unlock item/song/avatar/navigator or add coins) exactly once per reward, respecting mode/profile scope.
  5. Song/content unlock details
    • Beyond the music unlock bitset and global use_flag, maintain per-song/card progress rows the game expects (e.g. card_detail pcol1=10 reward/unlock rows, play flags) consistently with unlock/reward actions and gameplay writes.
  6. Shop/purchases (if used)
    • Validate catalog/shop items, check/unlock ownership, deduct coins, and record purchases transactionally.
  7. Catalog/config accuracy & migration
    • Ensure item/avatar/title/etc counts and unlock reward definitions match the client version; backfill/migrate existing card/profile state from legacy/C# data; keep behavior consistent with captured protocol expectations.

In short: the framework, storage, mode/profile model, and key/coin/unlock plumbing are in place; "proper" completion means replacing synthesized reads and no-op writes with protocol-accurate, fully persisted per-entity state transitions and economy/reward logic, validated against real client traffic.

Notes / limitations

  • Online matching/relay is not implemented.
  • HTTPS requires compatible PEM certs in certs/.
  • Full unlock/item-count/coin fidelity depends on implementing the per-type read/write persistence described above against the game protocol.