The user report: pillars visible on the map but locked, and clicking a teleport does nothing (client never sends EnterScene). Root cause: mapDefaultEntranceMap covers only 115 of 371 floors - the GetSceneMapInfo reply had no unlocked teleports for the missing floors (mostly new-region 2xxxxx maps), so the client locked the pillars and never initiated the teleport. - findEntryForFloor: resolve entry by searching config names P*_F<floor> directly, with mapDefaultEntranceMap as the first chance - GetSceneMapInfo: use the new resolver and merge teleports.json keys into unlocked_teleport_list for every floor - EnterScene: floor ids resolve through the same path; a teleport id arriving via scene_identifier (MDAIDPPKOPO.PLIDNBMCIJH) now also resolves the destination entry - loadScene: exact teleport position from teleports.json when the res config has no inline teleport with that id
66 lines
6.3 KiB
Markdown
66 lines
6.3 KiB
Markdown
# 2026-10-07 — พอร์ตเซิร์ฟเวอร์เป็นภาษา Go + แก้บัคกล้องหลุด (SceneCastSkill)
|
|
|
|
## สรุปงานวันนี้
|
|
|
|
### 1. พบต้นเหตุจริงของบัค "กดตีแล้วกล้องหลุดจากตัวละคร"
|
|
- `SceneCastSkillCsReq` handler เดิม (Rust battle.rs) ตอบ `battle_info` + `monster_battle_info`
|
|
ให้ client เข้า battle กับ target ที่ผ่าน filter หลวม `id > 30000 || id < 1000`
|
|
- filter นี้รวม **avatar entity ของผู้เล่นเอง** (1-4) เข้าไปด้วย → client เริ่ม battle transition
|
|
กับ "monster" ที่ไม่มีอยู่จริง → กล้อง battle ไม่มี target → หลุดจากตัวละคร
|
|
- กรณี arena (entry >= 3000000) โค้ดเดิมยังหลอก target เป็น 30001 เสมออีกชั้น
|
|
|
|
### 2. พอร์ตทั้งเซิร์ฟเวอร์เป็นภาษา Go → `C:\Users\Phitchayut\Desktop\GaC-hkrpg-go` (commit 59ea97b)
|
|
- สาเหตุที่เปลี่ยนภาษา: (1) คำแนะนำจากเพื่อนให้ใช้ GO แทน (Firefly Shelter ที่เวิร์กเป็น Go
|
|
แต่ปิด source) (2) พบว่าโค้ด Rust commit สุดท้าย **แตกตัวกับ proto ใน repo ตัวเอง** —
|
|
ใช้ชื่อ message เก่า (`PveBattleResultCsReq`, `QuickStartCocoonStageCsReq`, `GateServer`,
|
|
`GetGachaInfoCsReq`, `GroupRefreshInfo`, `LineupSlot`) ที่ไม่มีใน proto 4.6.51 แล้ว
|
|
- ตัว Go ผูกทุก handler กับชื่อจริงใน proto (handler ที่ proto ไม่มี → log+skip ไม่ panic)
|
|
|
|
### 3. สิ่งที่สร้าง/พอร์ต
|
|
- `pkg/kcp` — mihoyo KCP (header 28 ไบต์ conv+token) port จาก kcp.rs 1:1 + ใช้นาฬิกา ms
|
|
(Rust ใช้วินาที ทำ RTT/resend เพี้ยน) + UDP loopback test ผ่าน
|
|
- `protocol/proto` — generate Go protobuf จาก proto 4.6.51 (4,932 messages) +
|
|
cmdid map 2,114 ids generate จาก `// CmdID:` comments
|
|
- gameserver ครบ: handshake 0xFF/0x145/0x194, packet framing 0x9D74C714/0xD7A152C8,
|
|
login flow, scene load (props/NPCs/monsters + MonsterEntities tracking), lineup,
|
|
avatar/skin, missions, tutorials (1249+855), bag/equip, challenge ครบ
|
|
(StartChallenge 1787 / Tierce 8973 / Peak 8948 / raw replies ทุกตัว)
|
|
- sdkserver: query_dispatch/query_gateway (Gateserver pb + base64), hotfix fetch,
|
|
auth endpoints, SRTools upload
|
|
- **FIX SceneCastSkill**: เก็บ monster entity จริงต่อ session (`Session.MonsterEntities`)
|
|
ตีไม่โดน monster จริง = ตอบ retcode 0 ไม่เข้า battle → กล้องไม่หลุด
|
|
- smoke test จำลอง client เต็มรูปแบบผ่าน UDP จริง: handshake → PlayerGetToken →
|
|
SceneCastSkill ทั้งสองกรณี — **PASS ทั้งหมด**
|
|
- ใช้ data files เดิมทุกไฟล์ (save ไม่พัง) — เปิดด้วย `run_go.bat`
|
|
|
|
### 4. เครื่องมือที่ช่วย
|
|
- `tools/firefly_dump` (ที่ user เตรียมไว้) — symbol dump ของ Firefly binary ใช้ยืนยัน
|
|
สถาปัตยกรรม + ยืนยันว่า Firefly ปิด source ไม่มี code ให้ก็อป
|
|
- ติดตั้ง Go 1.27.0 (winget) + protoc-gen-go ใหม่ใน session นี้
|
|
|
|
### 5. การจัดการเอกสาร
|
|
- ลบ `GLM_FIX_PROMPT.md`, `PROMPT.md`, `HANDOFF.md` (หมดอายุ — เนื้อหาจำเป็นย้ายเข้า SKILL.md)
|
|
- อัพเดต `SKILL.md` (เพิ่มหัวข้อ 10-12: proto desync, บัคกล้อง, สถาปัตยกรรม Go)
|
|
- ก็อป SKILL.md → `tools/AI TOOLBOX/skills/hkrpg-ps-version-update/SKILL.md` ทั้งสองโปรเจกต์
|
|
|
|
## สิ่งที่ต้องทำต่อ
|
|
1. **ทดสอบกับ client จริง** — เปิด `run_go.bat` (GaC-hkrpg-go) แล้ว login ด้วย hosts/proxy เดิม
|
|
2. Gacha handlers ถูก skip (proto 4.6.51 เปลี่ยนชื่อ GetGachaInfoCsReq/DoGachaCsReq) — หาชื่อใหม่จาก dump
|
|
3. ถ้า client ฟ้อง cmd ไหน "Unknown" ให้เช็ค `gameserver.log` แล้วเติม handler ในตัว Go
|
|
|
|
## เพิ่มเติม (รอบแก้เสาวาป — 01:3x)
|
|
|
|
**อาการ:** เสาวาปในแมพใหม่ๆ มองเห็นในแมพแต่ไม่เปิด + กดวาปไม่ไป (client ไม่ส่ง EnterScene เลย)
|
|
|
|
**ต้นเหตุ:** `mapDefaultEntranceMap` ใน res.json ครอบคลุมแค่ 115/371 ฟลอร์ — โค้ด GetSceneMapInfo
|
|
และ EnterScene resolution พึ่งมันทั้งคู่ ฟลอร์ที่ไม่อยู่ในนี้ = ไม่มีรายชื่อเสาปลดล็อคส่งกลับ
|
|
→ client ล็อคเสา และไม่เริ่มวาป
|
|
|
|
**แก้ (commit 0fdadd0):**
|
|
- `findEntryForFloor` — หา entry จากชื่อ config `P*_F<floor>` โดยตรง (mapDefaultEntranceMap เป็น first chance)
|
|
- GetSceneMapInfo รวมรายชื่อเสาจาก teleports.json ทุกฟลอร์
|
|
- EnterScene: teleport id ผ่าน scene_identifier (MDAIDPPKOPO.PLIDNBMCIJH) resolve ปลายทางได้
|
|
- loadScene: ใช้ตำแหน่ง teleport จาก teleports.json ตรงๆ ถ้า res ไม่มี id นั้น
|
|
|
|
**บทเรียน:** data index บางตัวใน res.json ไม่ครอบคลุมทุกแมพ — ต้องมี fallback ค้นจากชื่อ config / teleports.json เสมอ
|