Files

8.6 KiB
Raw Permalink Blame History

บันทึกความจำ 2026-10-16: แก้ไขปัญหา Calyx (ดอกไม้) เข้าต่อสู้ไม่ได้ / Network Flood Loop / REST API Gateway สำหรับ GaC-Srtool

1. REST API Gateway (port 21000)

  • นำหน้าเว็บ HTML Dashboard ภายในออกตามความต้องการของผู้ใช้ เพื่อเตรียมรองรับ GaC-Srtool ภายนอก
  • สร้าง REST API Gateway (internal/sdkserver/api.go) พร้อม CORS Header:
    • GET / และ GET /dashboard: ดูรายการ API ทั้งหมด
    • GET, POST /api/freesr: อ่าน/เขียน freesr-data.json ทั้งหมด
    • GET, POST /api/freesr/avatars: จัดการเลเวล, ปลดดาว, รีลิกส์, Ex-Rank
    • GET, POST /api/persistent: อ่าน/เขียนไฟล์ persistent
    • POST /api/exrank/toggle: เปิด/ปิด Ex-Rank รายตัวหรือทุกตัว
    • POST /api/avatar/rank: ปรับ Eidolon (0-6)
    • POST /api/avatar/max_all: แม็กซ์ตัวละครทุกตัว
    • POST /api/teleport: วาปตำแหน่ง/ฉาก
    • GET /api/status: สรุปสถานะเซิร์ฟเวอร์, จำนวนตัวละคร, ทีมปัจจุบัน

2. แก้ปัญหา Calyx (ดอกไม้) เข้าไม่ได้ และ Network Flood Loop

  • สาเหตุที่ 1 (Network Flood Loop & Battle Reset):
    • ใน handlers_scene.go ที่ฟังก์ชัน SceneEntityMove มีการเรียก player.SavePersistent() ทุกเฟรมที่มีการเคลื่อนที่ของผู้เล่น
    • ใน gateway.go ฟังก์ชัน watchFreesrData เฝ้าดูการเปลี่ยนแปลงของไฟล์ persistent ทุก 1 วินาที
    • เมื่อผู้เล่นขยับ persistent ถูกเขียนซ้ำตลอดเวลา ทำให้ watchFreesrData สั่ง session.SyncPlayer() ทุกวินาที
    • SyncPlayer() ยิงแพ็กเก็ต PlayerSyncScNotify ขนาดกว่า 60KB (ประกอบด้วย DelRelicList, DelEquipmentList, AvatarSync) ล้างไอเทมและรีเซ็ตตัวละครกลับมาเป็นสถานะ Overworld ขัดจังหวะการโหลดเข้าสู่การต่อสู้ Calyx
  • สาเหตุที่ 2 (NullReferenceException ใน GetCurBattleInfo):
    • ใน handlers_battle.go ฟังก์ชัน GetCurBattleInfo มีโค้ด fallback ปลอมที่สร้าง battleInfo ส่งกลับด้วย retcode 0 แม้ไม่ได้อยู่ในการต่อสู้
    • ทำให้ Client เมื่อเรียก GetCurBattleInfoCsReq เกิด crash NRE ใน AdventureModule._OnGetCurBattleInfoScRsp (RVA 0xceb7e65) เนื่องจาก Battle Module ภายในยังไม่ถูก initialize
  • สาเหตุที่ 3 (การตัดและบิดเบือน MonsterWaveList ใน Calyx):
    • ใน StartCocoonStage และ StartQuickCocoonStage มีการบังคับตัดเวฟ MonsterWaveList[:1] และเซ็ต w.WaveId = 1 ให้กับทุกเวฟ ทำให้โครงสร้างเวฟของ Client เสียหาย
  • การแก้ไข:
    1. แก้ gateway.go: ให้ watchFreesrData เฝ้าดูเฉพาะ freesr-data.json เท่านั้น (ไม่ดู persistent) เหมือนโครงสร้างต้นฉบับ
    2. แก้ handlers_scene.go: นำ player.SavePersistent() ออกจาก SceneEntityMove เพื่อหยุดการเขียนดิสก์และลูป Network flood โดยสิ้นเชิง
    3. แก้ handlers_battle.go:
      • ใน GetCurBattleInfo ตัด fallback ปลอมออก หากไม่มี Token ใน CURRENT_BATTLE ให้ตอบ RET_BATTLE_STAGE_NOT_MATCH (2000) ป้องกัน NRE
      • ใน StartCocoonStage และ StartQuickCocoonStage ส่ง battleInfo ที่สมบูรณ์พร้อมเวฟที่ถูกต้อง และเพิ่ม Log แสดงค่า CocoonId, Wave, WorldLevel
    4. คอมไพล์ gameserver-go.exe ใหม่และรีสตาร์ทกระบวนการ

Codex battle investigation correction — main affix (2026-10-16)

  • Client stack RVA 0xc4eb77c is the return address after the throw call at 0xc4eb777, reached when main-affix lookup returns null (branch at 0xc4eb2b3). It does NOT prove a null sub-affix array; that throw call would return to 0xc4eb781. Earlier interpretation is withdrawn.
  • Captured Calyx/SceneCastSkill payload and inventory UID 483: avatar 1213, relic 63095, main_affix_id 11. Reference relic main group 55 contains IDs 1–10, with 10=ImaginaryAddedRatio. Local AvatarConfig confirms Imaginary for 1213.
  • Repaired only this inventory field in freesr-data.json: 11 -> 10. No converter ID override. All 24 relic main affixes in the captured team validate against reference data. Reference lacks new relics 63295/63296, so whole inventory is not fully validated.
  • Source: Mar-7th/StarRailRes commit dbe8cdfcfb0bf657b9fe1cf92d5537f118ccb487, index_new/en/relics.json and relic_main_affixes.json.
  • Backup: ignored battle_diagnostics/main-affix-repair/. Build completed; root gameserver-go.exe/sdkserver-go.exe updated. In-game battle success still requires a new client run.
  • First readback probe reported parser property not found. V2 includes non-public fields and CodedInputStream fallback, but local diagnostic probe is disabled for the repair verification. V2 is not yet verified in client.

Handler/dispatch update against PearlSR 4.6.53 reference

  • Synced 2,690 current command names/IDs from upstream revision 005d2c12db4781071f4b5b68e8f364587886a710; generated table preserves verified old Go type aliases and fails on conflicts.
  • Source audit: all 865 existing request/response pairs and 4,435 shared message field-number sets match. This does not validate all field types/defaults or client behavior. Include oneof members (including enum-valued wrappers) when auditing; ignoring oneof produces false missing-field reports.
  • Replaced numeric raw registrations/old alias ranges with current named bindings. Removed multi-response guesses. Added missing typed Tierce lineup request8992/response8979, fields4/5; fixed cumulative reward request1747/response1748, group10 -> group12/retcode9.
  • Current schema statistics fields1/3/11 are a oneof; do not claim they are absent. Updated Go schema to oneof; statistics handler now echoes group without fabricated past scores, matching upstream.
  • Added ReplaceLineupScRsp field14; regenerated protobuf. Peak start/leave bindings restored; empty current Peak response no longer fabricates PeakID1. Challenge leave uses saved overworld scene rather than fixed destination.
  • Tutorial handlers load IDs from installed TutorialData/TutorialGuideGroup resources, removing the embedded old list. Removed unused generated activity list.
  • ClientDownloadData version51 remains because current upstream still uses51 for Lua payloads; do not infer53 from client patch. Avatar command400 response pairing remains semantically obfuscated; current adjacent schema response is used instead of spraying5 candidates, still requires client verification.
  • Added reproducible offline source sync/audit tools and docs/protocol-update.md; README/AGENTS updated. Final run.bat build completed, both root executables updated at22:16 local time. No in-game success claimed; no test suite run in this turn.

Launcher visibility preference

  • User explicitly requested visible SDK/game server consoles and launcher menu closure after5 seconds.
  • run.ps1 now launches both root server executables with WindowStyle Normal and no stdout/stderr redirection; each server console remains independent when run.bat exits.
  • Interactive menu waits5 seconds after the selected action finishes, preserving exit codes. Argument-based build/check/stop returns immediately. README/AGENTS updated. No binary rebuild needed for this script-only change; did not launch or stop running servers.