|
|
@@ -187,6 +187,9 @@ class Host:
|
|
|
def _delete_role(self, role_uid: str, timeout: float) -> bool:
|
|
|
"""CS102 删角色(LoginProxy:RequestDeleteRole, body=UserID, p3=0, tail 严格递增)。
|
|
|
返回是否收到 523(成功)。"""
|
|
|
+ # 522 后立即发 102 服务器静默丢弃(实测); 停顿 ~2s 才被受理。
|
|
|
+ time.sleep(1.5)
|
|
|
+ self.pump(0.5)
|
|
|
self._tail += 1
|
|
|
self._send(102, 0, 0, 0, 0, self._tail, role_uid.encode())
|
|
|
deadline = time.time() + timeout
|
|
|
@@ -275,10 +278,14 @@ class Host:
|
|
|
# 删一个非目标角色腾槽(CS102 tail 严格递增, p3=0), 再原名重试;
|
|
|
# 删无可删才换名。523/524 等待在 _delete_role 内完成。
|
|
|
lst = (roles or {}).get("list") or []
|
|
|
- victim = next((c for c in lst if c.get("chr") != name), None)
|
|
|
- if victim is not None:
|
|
|
- if not self._delete_role(victim["UserID"], timeout):
|
|
|
- name = "萌新" + str(random.randint(1000, 9999))
|
|
|
+ # 服务器只允许删 last=1(当前选中)角色 — 删其它静默无响应(实测)。
|
|
|
+ # LoginProxy:916 删除后 DelRoleByID(GetSelectedRoleID()) 同一语义。
|
|
|
+ victim = next((c for c in lst
|
|
|
+ if c.get("chr") != name and c.get("last") == 1),
|
|
|
+ None)
|
|
|
+ if victim is not None and self._delete_role(victim["UserID"],
|
|
|
+ timeout):
|
|
|
+ lst.remove(victim) # 防下轮重复删同一已删角色(重复删静默)
|
|
|
else:
|
|
|
name = "萌新" + str(random.randint(1000, 9999))
|
|
|
continue
|