diag_tp_probe.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """一次性诊断: 登录→盟重→发 CS3031+CS1011@act_move,2→dump 全部收帧 60s。"""
  2. from __future__ import annotations
  3. import sys
  4. import time
  5. from pathlib import Path
  6. ROOT = Path(__file__).resolve().parents[2]
  7. sys.path.insert(0, str(ROOT / "protocol_bot" / "src"))
  8. import requests
  9. from pbot.config import Account
  10. from pbot.game.session import enter_world
  11. from pbot.login.box_client import enter_game_client, login
  12. from pbot.transport.gateway import login_gate_with_retry
  13. from pbot.world.update import WorldUpdater
  14. PORTS = (8021, 8061, 8001, 8041)
  15. def main() -> int:
  16. http = requests.Session()
  17. http.trust_env = False
  18. http.verify = False
  19. jwt, uid = login(Account(username="longwu988", password="Longwu1988"))
  20. _ = enter_game_client(http, jwt, 14558825)
  21. key32, sid, rname, tkey, gport = login_gate_with_retry(
  22. 14558825, jwt, uid, "凌风踏雪", PORTS)
  23. stop = [False]
  24. conn, world, updater = enter_world(14558825, rname, tkey, sid, gport, uid,
  25. stop=stop)
  26. print(f"[出生] {world.me.map_name} @({world.me.x},{world.me.y})")
  27. try:
  28. _ = conn.send_frame(
  29. 3031, 0, 0, 0, sid,
  30. (ROOT / "protocol_bot" / "assets" / "cs3031_full.bin").read_bytes())
  31. print("[CS3031] 已发, 5s 后发 1011")
  32. t0 = time.time()
  33. while time.time() - t0 < 5:
  34. for f in conn.recv_frames(0.2):
  35. before = dict(world.frame_counts)
  36. updater.apply(world, f)
  37. print(f" << {f.msg_id} recog={f.recog} p1={f.p1} p2={f.p2} "
  38. f"p3={f.p3} body[:60]={f.body[:60]!r}")
  39. _ = before
  40. _ = conn.send_frame(
  41. 1011, 0, 0, 0, sid,
  42. b'{"UserID":"999999999","Act":"@act_move,2","index":999999999}')
  43. print("[CS1011 @act_move,2] 已发, 收 60s")
  44. t1 = time.time()
  45. while time.time() - t1 < 60:
  46. for f in conn.recv_frames(0.2):
  47. if f.msg_id == 60000:
  48. continue
  49. updater.apply(world, f)
  50. print(f" << {f.msg_id} recog={f.recog} p1={f.p1} p2={f.p2} "
  51. f"p3={f.p3} body[:80]={f.body[:80]!r}")
  52. print(f"[终态] {world.me.map_name} @({world.me.x},{world.me.y})")
  53. print(f"[帧计数] {sorted(world.frame_counts.items(), key=lambda kv: -kv[1])[:15]}")
  54. finally:
  55. stop[0] = True
  56. conn.close()
  57. return 0
  58. if __name__ == "__main__":
  59. sys.exit(main())