# disconnect_world_reset_test —— 40250 SetOffLinePhase/Destroy 清理边界。 # 显式断开不能只销毁 socket;保留 GameScene 时必须通知 presentation owner 清空旧世界。 extends SceneTree var _failures := 0 func _check(ok: bool, message: String) -> void: if not ok: _failures += 1 printerr("FAIL: " + message) func _init() -> void: var client := M2Client.new() get_root().add_child(client) var resets := [0] client.world_reset.connect(func() -> void: resets[0] += 1) # The client is offline here, so this checks the public lifecycle contract: # explicit disconnect always gives the retained scene one synchronous reset # notification, while remaining idempotent at the transport layer. client.disconnect_from_server() _check(resets[0] == 1, "explicit disconnect emits one world_reset for retained scene cleanup") client.disconnect_from_server() _check(resets[0] == 2, "repeated explicit disconnect emits one reset per lifecycle boundary") client.free() if _failures == 0: print("PASS: disconnect_world_reset_test") quit(0) else: printerr("%d check(s) failed" % _failures) quit(1)