EggXP 1.3 - Egg, Inc. account and mission history viewer
========================================================

Runs on Windows XP SP3 and every later version (32-bit exe, also fine on x64).
Single EggXP.exe file, no installer, and no DLLs beyond the ones Windows ships.

LOOK
  The UI is custom-drawn in an iOS 6 (2012) style: glossy nav bar and toolbar,
  bar buttons, pinstripe grouped tables, ON/OFF switch, segmented control.
  Everything is software-rendered with plain GDI (src/skin.c), so it looks the
  same on every Windows version from XP SP3 up.

GAME ICONS
  Ships, targets, every artifact/stone/ingredient tier, egg types, SE/PE/TE/GE,
  epic research, boosts, permits, grades... are shown with their in-game icons
  and names. Icons are not bundled: EggXP downloads the ones it needs from the
  community CDN eggincassets.pages.dev and caches them in EggXP-cache\icons.

USING IT
  1. Run EggXP.exe, type your EID (EI followed by digits), press Enter or click Fetch.
  2. It downloads your game backup, lists every completed/archived mission, then
     downloads the loot for each one (4 at a time, up to 5 retries each).
  3. Click a mission to see what it dropped, or pick "Lifetime totals" to see
     every item you've ever pulled, grouped by item, tier and rarity.
     Click any column header to sort.
  4. "Export CSV..." writes one row per dropped item (mission, ship, duration,
     level, capacity, target, launch/return time, item, kind, tier, rarity,
     server ID). The file is UTF-8 with a BOM so Excel opens it cleanly.
  Stop halts the download; Fetch again resumes where it left off.

  Account tab: Soul Eggs, Prophecy Eggs, Truth Eggs (per Virtue egg), Golden
    Eggs (balance/earned/spent), Shell scripts, piggy bank, Earnings Bonus and
    farmer role, prestiges, highest egg, drone takedowns, contract grade/CXP/
    soul power, crafting XP, inventory, Eggs of Virtue resets, current home
    farm, every epic research level and owned boost. The line above the tabs
    shows SE / PE / TE / GE / EB at a glance. Ctrl+A, Ctrl+C copies rows.
  All backup data tab: every field the server returned, decoded and named from
    ei.proto (enums by name, big numbers in game notation, timestamps as dates).
    Expand nodes to explore; Ctrl+C copies a line.
  "Save all data..." writes the summary plus the complete decoded backup to a
    UTF-8 text file.

  EB uses the community formula (same as EggLedger):
    EB% = SE x (10 + Soul Food) x (1.05 + Prophecy Bonus/100)^PE x 1.01^TE
  Farmer roles follow the usual community scale (Farmer I ... Infinifarmer).

WHAT IT TALKS TO
  Same unofficial API that EggLedger uses, on https://ctx-dot-auxbrainhome.appspot.com
    POST /ei/bot_first_contact      -> your full game backup (mission list)
    POST /ei_afx/complete_mission   -> the loot for one mission
  Bodies are form-encoded data=<base64 protobuf>. The client identifies itself
  as the iOS game client 1.35.7 (build 111343, client version 72), like EggLedger.
  This isn't sanctioned by Auxbrain; use it at your own risk.

NOTES FOR XP
  * TLS: XP's own SChannel only does TLS 1.0, which Google's servers reject.
    EggXP does TLS 1.2 in-process with BearSSL and an embedded copy of the
    Mozilla root store (121 roots, including Google Trust Services
    GTS Root R1/R3/R4). It never touches the Windows certificate store, so an
    out-of-date XP root store doesn't matter.
  * The PC's date/time must be roughly correct, or certificate validation
    fails ("certificate is expired or not yet valid").
  * IPv4 only, direct connection (no HTTP proxy support).
  * Cache: each mission's raw server reply is saved to EggXP-cache\<EID>\ next
    to the exe (or %APPDATA%\EggXP\cache if that folder isn't writable), so a
    re-fetch only downloads new missions. Delete the folder to force a full
    re-download.
  * The last EID is remembered in HKCU\Software\EggXP\LastEID (plain text).
    Your EID is effectively the key to your account data, so the box masks
    it unless "Show" is ticked.

BUILDING
  On Linux with MinGW-w64 (Debian/Ubuntu: apt install mingw-w64):
      ./build.sh
  This produces EggXP.exe: statically linked, PE subsystem 5.01, msvcrt.dll CRT.
  Built with -mincoming-stack-boundary=2: 32-bit Windows threads only get 4-byte
  stack alignment, and BearSSL's AES-NI/SSE code crashes without it (the 1.0 bug).
  If ei.proto changes, regenerate the field tables with:
      pip install grpcio-tools && python3 tools/gen_schema.py
  src/cli.c is a console test harness for the core code. It isn't part of
  EggXP.exe.

SOURCE LAYOUT
  src/app.c     window, layout, worker threads, cache, CSV / text export
  src/skin.c    iOS 6 renderer and custom controls
  src/net.c     sockets + BearSSL TLS 1.2 + small HTTP/1.1 keep-alive client
  src/ei.c      hand-written protobuf requests/responses, display names
  src/util.c    buffers, base64, protobuf reader/writer
  src/pbx.c     schema-driven decoder for the backup + account stats
  src/icons.c   icon downloader / cache / scaler     src/png.c  PNG decoder
  src/assets.c  game IDs -> names + icon paths (assets.inc from tools/gen_assets.py)
  src/ei_schema.inc       field/enum tables generated from proto/ei.proto
  src/trust_anchors.inc   Mozilla root store (generated with BearSSL's "brssl ta")
  third_party/BearSSL     TLS library (MIT license, see its LICENSE.txt)
  third_party/tinf        zlib inflate (zlib license, see its LICENSE)

Field numbers come from the community ei.proto (github.com/carpetsage/egg).
The protocol details come from EggLedger (github.com/DavidArthurCole/EggLedger).
