feat(client): 锁定终局结果并接入 Windows 签名构建
- fix(match): 首次归零结束对局并撤销双方扣血许可,裁判结果同步后不再改判 - fix(hud): 蓝方低血量始终保留队伍颜色 - build(windows): 校验代码签名身份和时间戳,明确标注未签名测试包 - docs(version): 说明发布标签基线与语义版本迭代
This commit is contained in:
26 files changed
+823
-229
No files matched your search
@@ -94,3 +94,102 @@ fn udp_snapshot_routes_to_follower_without_polluting_armor_health() {
|
||||
store.datagram(&packet, from);
|
||||
assert_eq!(follower.lock().unwrap().view(1000).remaining_ms, 160_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn knockout_revokes_both_boards_and_result_survives_late_winner_death() {
|
||||
let tx = UdpSocket::bind((Ipv4Addr::LOCALHOST, 0)).unwrap();
|
||||
let store = ArmorHealthStore::new();
|
||||
let boards: Vec<_> = (1..=2)
|
||||
.map(|id| {
|
||||
let socket = UdpSocket::bind((Ipv4Addr::LOCALHOST, 0)).unwrap();
|
||||
socket
|
||||
.set_read_timeout(Some(Duration::from_secs(2)))
|
||||
.unwrap();
|
||||
store.datagram(
|
||||
&protocol::ArmorHealth {
|
||||
team: id - 1,
|
||||
index: 0,
|
||||
hp: 100,
|
||||
}
|
||||
.encode_from(u32::from(id)),
|
||||
socket.local_addr().unwrap(),
|
||||
);
|
||||
socket
|
||||
})
|
||||
.collect();
|
||||
let mut clock = MatchClock::new(true, 80, 0);
|
||||
clock.action(MatchAction::Prepare, 0).unwrap();
|
||||
clock.action(MatchAction::SkipPreparation, 100).unwrap();
|
||||
clock
|
||||
.action(MatchAction::Countdown { seconds: 1 }, 100)
|
||||
.unwrap();
|
||||
let state = clock.broadcast(1100).unwrap();
|
||||
let mut buf = [0; 512];
|
||||
store
|
||||
.send_damage_controls(&tx, &state, [Some(1), Some(2)])
|
||||
.unwrap();
|
||||
for board in &boards {
|
||||
let (n, _) = board.recv_from(&mut buf).unwrap();
|
||||
assert!(
|
||||
protocol::ArmorDamageControl::decode(&buf[..n])
|
||||
.unwrap()
|
||||
.enabled
|
||||
);
|
||||
}
|
||||
assert!(clock.finish_on_health([Some(0), Some(10)], 2100));
|
||||
let state = clock.broadcast(2100).unwrap();
|
||||
store
|
||||
.send_damage_controls(&tx, &state, [Some(1), Some(2)])
|
||||
.unwrap();
|
||||
for board in &boards {
|
||||
let (n, _) = board.recv_from(&mut buf).unwrap();
|
||||
assert!(
|
||||
!protocol::ArmorDamageControl::decode(&buf[..n])
|
||||
.unwrap()
|
||||
.enabled
|
||||
);
|
||||
}
|
||||
assert!(!clock.finish_on_health([Some(0), Some(0)], 2200));
|
||||
let follower = Arc::new(Mutex::new(MatchClock::new(false, 2, 0)));
|
||||
let reader = ArmorHealthStore::new();
|
||||
let follow = follower.clone();
|
||||
reader.set_match_result_sink(Arc::new(move |result, ip| {
|
||||
follow.lock().unwrap().receive_result(result, ip, 2100);
|
||||
}));
|
||||
let rx = UdpSocket::bind((Ipv4Addr::LOCALHOST, 0)).unwrap();
|
||||
rx.set_read_timeout(Some(Duration::from_secs(2))).unwrap();
|
||||
tx.send_to(
|
||||
&clock.result_packet().unwrap().encode().unwrap(),
|
||||
rx.local_addr().unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let (n, from) = rx.recv_from(&mut buf).unwrap();
|
||||
reader.datagram(&buf[..n], from);
|
||||
assert_eq!(follower.lock().unwrap().view(2100).phase, "finished");
|
||||
assert!(reader.boards().is_empty());
|
||||
for (index, board) in boards.iter().enumerate() {
|
||||
reader.datagram(
|
||||
&protocol::ArmorHealth {
|
||||
team: index as u8,
|
||||
index: 0,
|
||||
hp: 0,
|
||||
}
|
||||
.encode_from(index as u32 + 1),
|
||||
board.local_addr().unwrap(),
|
||||
);
|
||||
}
|
||||
let names = ["红队".into(), "蓝队".into()];
|
||||
let mut health = [
|
||||
cam_core::snapshot::TeamHealthDto::present(0, Some(1), [0; 4], 25, &names),
|
||||
cam_core::snapshot::TeamHealthDto::present(1, Some(2), [0; 4], 25, &names),
|
||||
];
|
||||
follower.lock().unwrap().apply_outcomes(&mut health);
|
||||
assert_eq!(
|
||||
health[0].outcome,
|
||||
Some(cam_core::snapshot::MatchOutcome::Defeat)
|
||||
);
|
||||
assert_eq!(
|
||||
health[1].outcome,
|
||||
Some(cam_core::snapshot::MatchOutcome::Victory)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user