Files
metin2-server/tools/ava2-itemshop
shenlei bb0963210e feat: support Linux/ARM cross-platform build and AVA2 feature updates
- Port server core and libraries to Linux and 32-bit ARM (armhf):
  * Replace FreeBSD kqueue with Linux epoll in libthecore fdwatch
  * Fix unaligned float and 64-bit int memory stores in utils.h str_to_number to avoid ARM VFP alignment fault (SIGBUS)
  * Fix getopt loop variable type in main.cpp (char -> int) to eliminate infinite loop caused by default unsigned char on ARM
  * Add -fsigned-char and multi-architecture flags to Makefiles (x86_64 -m32, i386, and ARM armhf)
  * Update libsql for modern MariaDB client library (removed reconnect field) and C++20 concept/syntax compatibility
  * Replace Win32 xdirent with standard POSIX dirent on Unix/Linux
  * Include xmd5 in libthecore on non-FreeBSD platforms
- AVA2 unlock features and tools:
  * Material stacking up to 2000 count, refine material resolution and test suites
  * AVA2 ticket shop and point drop configuration updates
2026-11-11 00:59:49 -08:00
..

Native AVA2 item shop

Active UI is uiitemshopnew.py. GC93 retains the native catalogue/log layouts; GD/DG76 transports authenticated account/character requests to the DB coordinator. Purchase requests add a durable random token and the confirmed item/total quote.

data/ava2-itemshop/original-products.tsv contains all 217 original offers recovered from the supplied MySQL56 archive. source.json records hashes. No prices are invented. compatibility.json records 55 absent prototypes, 55 ITEM_NONE placeholders and 107 actual types needing item-system verification. verified-products.json selects 49 existing implemented mount, mount-skin, fixed-enchant and third-hand products.

Generate migration SQL with explicit configured schema names, review it and back up account/award data before executing it:

python3 tools/ava2-itemshop/migrate.py --player player_sb --account account_sb --output /tmp/itemshop.sql
python3 tools/ava2-itemshop/enable_verified.py --player player_sb --output /tmp/itemshop-enable.sql

The migration uses InnoDB for account, catalogue, orders and awards. Account/player SQL configurations must target the same MySQL host and port. Purchase failures leave all four unchanged. A transaction temporarily disables reconnect and caps lock waits at three seconds, restoring the original connection options afterwards. Unknown COMMIT outcomes retry the same order. Unique (account_id,token) orders survive process restarts.

The old prototype loader indexed vector pointers before sorting; it now sorts before building the index so lookup keys always match their templates.

Awards use the existing mall redemption path; non-stackable purchases create separate award rows. New clients use revision mt20261020. Legacy clients cannot request GC93. No web recharge service or wheel reward service is enabled.

Acceptance evidence: metin2-client/docs/AVA2-ITEMSHOP.md and metin2-client/audit/evidence/itemshop/.

Production release, 2026-10-20 (server CEST)

203 now runs the verified sbtest game/db pair: game 56975b48aa2fd40389c57eab84d017b0a2518cf6e1b573d967bf239f4ae04aba, db dc940401fe6ccc3410c8d90ce98d2a5bad2e2c023279665bcd664c008d011699. The deployment retains the existing native battle pass, wiki, calendar and other cumulative game changes. The release delta is the native shop, DB prototype-index fix, transactional schema and 49 enabled original offers. The remaining 168 offers, recharge and wheel services stay disabled. Production 70002 was still ITEM_NONE; its text/SQL prototype is now ITEM_USE/USE_SPECIAL, matching the tested third-hand implementation. Other prototypes were not replaced with test data.

Deployment package: /root/deploy-features/20261020-itemshop. Backup: /root/backup-itemshop/20261020-014955 (old binaries, original prototype, full account/player SQL dump and pre-deployment error-log offsets). deploy.py gracefully stops game/auth, then db; backs up SQL before migration; starts db first and then auth and all 13 production game cores. sbtest remains independent.

Read-only health check:

/usr/local/bin/python3.9 /root/deploy-features/20261020-itemshop/deploy.py check

Binary rollback:

/usr/local/bin/python3.9 /root/deploy-features/20261020-itemshop/deploy.py rollback --backup /root/backup-itemshop/20261020-014955

Rollback retains InnoDB, coins, orders, awards and the compatible third-hand prototype. Never restore the pre-release SQL dump over subsequent player purchases.

CH1 acceptance with a temporary ordinary account verified all 49 catalogue entries/icons, insufficient funds without an order, a 99-coin purchase, same-token replay without another charge/order, purchase history and mall redemption into inventory. Test account, character, coins, orders, awards and items were removed; its one test sale was subtracted without resetting other sales. Existing players received no test currency. db/auth/13 cores remained healthy after cleanup. macOS release bundle and connected Android client's APK/resources were updated; Android in-game purchase acceptance is not claimed by this release.

2026-10-20 safety fixes (not deployed)

build_isolated.py now requires a reviewed --dependency-manifest: JSON with source_sha256 from source_digest(source) and archives mapping every source-relative .a path to SHA-256. The manifest binds reviewed dependency provenance to the exact server/extern sources; generating hashes alone does not certify provenance. FreeBSD is required. A fresh game-release, db-release, game-warnings or db-warnings directory is created beneath --output; reusing a target/mode directory fails. Source/dependency mismatches also fail. --warnings removes -w, enables format/conversion diagnostics and makes format/narrowing warnings errors. Build evidence and binary hashes are written to the new directory. FreeBSD validation remains required.

The wear40 planner now binds database/server identity, a persistent target UUID, item identity/state, quickslots and a plan checksum. --apply requires --offline --backup-id ID. Reuse the exact saved v2 plan for interrupted runs; old unbound plans are rejected. A completed marker is rechecked against actual data and schema; corrupt extra is rejected before mutation. Backups and stopping writers remain operational prerequisites, not facts inferred from command success.

Offline shop mutation and startup expiry cleanup are explicitly closed in game/db until durable custody/payment/delivery orders and crash recovery are implemented and accepted. Stored assets are preserved. This closure is a containment measure, not completion of offline trading.

Pending-reward journal maintenance

PointJournal keeps its own durable pending set. Startup recovery and the retry event compact a log above 1 MiB when enough completed history can be removed. Compaction retains every pending token/request/time, writes a new file exclusively, fsyncs it, atomically renames it and fsyncs the directory. It does not cap the queue at 4096 entries. Do not pass a subset of runtime requests to replace the journal; there is deliberately no such API.

Keep the .lock sidecar in place for the writer's lifetime. Stop old binaries before upgrading a process that uses the same journal path; mixed old/new concurrent writers are unsupported. An I/O error pauses issuance, retaining a complete recovery source; fix the storage problem and preserve journal evidence before restarting. A corrupt log is not automatically truncated or compacted. These changes have standalone fault tests, including ELF32 probes, and do not replace real database/process-crash acceptance.

2026-10-26: increased rewards, no daily cap

Current production/sbtest rules, explicitly selected by the user: monsters and bosses have a 50% chance to award 3–5 points; stones always award 15–30 points. points_daily_cap=0 means unlimited daily earnings, not zero earnings. The minimum target level of 1 and maximum overlevel gap of 15 remain. The profile in points-wide.json and the rollout tool defaults both use these values. The 2026-10-25 profile below is historical and has been superseded.

Applied through authenticated EVENT commands to production's 13 cores and isolated channel5 without restarting or replacing any process. SQL and every core's event log match all nine settings. Backups of the prior states are under /root/deploy-features/20261026-point-drops-increase/: production uses production-before.json, and the selected sbtest rollout uses sbtest-selected-before.json. The initial sbtest-before.json preserves the older 5%/1, 3–8, cap-500 profile before a temporary suggested profile; production was updated directly from that older profile to the selected 50% profile.

Ten point-related tests passed, including actual DB-handler code with a prior daily total above 500, repeated 30-point awards with cap zero, and same-token deduplication. This is a configuration/settlement test record, not a claim of a controlled live kill after the change. Details and runtime evidence: metin2-client/docs/POINT-DROPS-INCREASE-20261026.md.

2026-10-25: restore missing point-drop flags (historical)

The current production/sbtest game and db already include point rewards, but both quest tables had no points_* event flags. Missing chance flags mean zero chance, so neither monsters/bosses nor stones could award shop points. The then-approved rules were enabled on production's 13 cores and isolated channel5 on 2026-10-25: 5% for monsters/bosses (1 point), 100% for stones (3–8), target at most 15 levels below the character, and 500 points per account/day. Points credit the account wallet; they are not ground items. No restart or binary replacement was needed.

configure_point_drops.py defaults to a read-only plan. It verifies DB_PORT, explicit player/account schemas and transactional tables, then uses the existing authenticated admin EVENT channel so db persists and broadcasts the flags to all connected cores. It first sets both chances to zero, applies limits/eligibility, and enables the approved chances last. An exact match is a no-op. Credentials are read locally from CONFIG and excluded from output/backups. For a core bound to its LAN address, use --host while retaining the loopback source allowlist.

# On 203; omit --apply/--backup to inspect only.
python3.9 configure_point_drops.py \
  --config /usr/metin2/server/channel1/first/CONFIG \
  --db-config /usr/metin2/server/db/conf.txt \
  --player player --account account --db-port 15000 --host 192.168.21.203 \
  --apply --backup /root/deploy-features/20261025-point-drops/NEW-before.json

Production backup: /root/deploy-features/20261025-point-drops/production-before.json. Isolated backup: sbtest-before-r2.json in the same directory. To restore the previous disabled state, add --restore BACKUP with the same explicit target and a new --backup output. Absent flags restore as zero-valued disabled flags; wallet balances and reward history are preserved. The first sbtest attempt against a loopback-only destination was refused before any flags changed.

Verification: five rollout guard tests plus seven existing eligibility, settlement, completion and journal tests passed. SQL contains all nine expected flags, and each of the 13 production cores plus channel5 logged the same values without changing PIDs. No controlled post-change kill is claimed by this rollout; reward ledgers were still empty at the observation checkpoint. Evidence and client-facing notes: metin2-client/docs/POINT-DROPS-ENABLE-20261025.md.

Strict builds also promote -Wshorten-64-to-32 to an error. The broader strict warning gate is still failing on legacy code; see the maintenance evidence for the exact blockers.