feat(client): 锁定终局结果并接入 Windows 签名构建
构建客户端 / 检查(类型 + 单元测试) (push) Canceled after 0s
构建客户端 / Linux x64(deb + AppImage) (push) Canceled after 0s
构建客户端 / Windows x64(NSIS 安装包) (push) Canceled after 0s
构建客户端 / macOS 通用(.app + .dmg) (push) Canceled after 0s

- fix(match): 首次归零结束对局并撤销双方扣血许可,裁判结果同步后不再改判

- fix(hud): 蓝方低血量始终保留队伍颜色

- build(windows): 校验代码签名身份和时间戳,明确标注未签名测试包

- docs(version): 说明发布标签基线与语义版本迭代
This commit is contained in:
sloray committed 2026-10-31 10:18:09 +08:00
1 parent 338efa5c2e
commit dac763eb3e
26 files changed
+823 -229

No files matched your search

+2 -2
View File
@@ -135,7 +135,7 @@ fn spawn_armor(state: Arc<AppState>) {
hits = [0, 1];
dead_for = [0; 2];
}
let scripted = reset_epoch == 0 || state.demo_damage_enabled();
let scripted = state.demo_damage_enabled();
for (slot, (board, team, port)) in boards.iter().enumerate() {
if scripted {
ticks[slot] += 1;
@@ -144,7 +144,7 @@ fn spawn_armor(state: Arc<AppState>) {
if hp[slot] == 0 {
// 打空之后停一会儿再重置:让界面上的胜负横幅真的能被看到。
dead_for[slot] += 1;
if reset_epoch == 0 && dead_for[slot] >= 10 {
if reset_epoch == 0 && scripted && dead_for[slot] >= 10 {
hp[slot] = 100;
dead_for[slot] = 0;
ticks[slot] = 0;
+62 -11
View File
@@ -27,8 +27,7 @@ use cam_core::password;
use cam_core::receiver::{Discovery, LatestFrames, Receiver};
use cam_core::slots::SlotAllocator;
use cam_core::snapshot::{
resolve_outcomes, ArmorBoardDto, CameraDto, CameraStatsDto, ConfigView, HitDto, SlotsDto,
Snapshot, TeamHealthDto,
ArmorBoardDto, CameraDto, CameraStatsDto, ConfigView, HitDto, SlotsDto, Snapshot, TeamHealthDto,
};
use cam_core::stats::{FpsWindow, DEFAULT_WINDOW};
use cam_core::ArmorSource;
@@ -59,6 +58,7 @@ pub struct AppState {
match_clock: Mutex<MatchClock>,
match_socket: Option<std::net::UdpSocket>,
match_error: Mutex<Option<String>>,
match_changed: tokio::sync::Notify,
resetting: AtomicBool,
pub demo_reset_epoch: AtomicUsize,
discovery: Arc<Discovery>,
@@ -91,7 +91,19 @@ impl AppState {
}
pub fn demo_damage_enabled(&self) -> bool {
self.match_view().phase == "running"
let phase = self.match_view().phase;
phase == "running"
|| (phase == "idle" && self.demo_reset_epoch.load(Ordering::Acquire) == 0)
}
/// 接收路径只更新核心终局并唤醒发送任务,不等待网络、UI 或写盘。
fn observe_match_health(&self) -> bool {
let health = [self.health_for(0), self.health_for(1)];
let hp = health.map(|entry| if entry.available { entry.hp } else { None });
self.match_clock
.lock()
.expect("match clock poisoned")
.finish_on_health(hp, self.match_now())
}
pub fn match_action(&self, action: MatchAction) -> Result<(), String> {
@@ -311,6 +323,7 @@ impl AppState {
match_clock: Mutex::new(MatchClock::new(role == Role::Referee, session, 0)),
match_socket,
match_error: Mutex::new(match_error),
match_changed: tokio::sync::Notify::new(),
resetting: AtomicBool::new(false),
demo_reset_epoch: AtomicUsize::new(0),
discovery,
@@ -351,6 +364,21 @@ impl AppState {
}
}
}));
let weak = Arc::downgrade(self);
self.armor
.set_match_result_sink(Arc::new(move |packet, ip| {
if let Some(state) = weak.upgrade() {
if !state.demo
&& state
.match_clock
.lock()
.expect("match clock poisoned")
.receive_result(packet, ip, state.match_now())
{
state.match_changed.notify_one();
}
}
}));
let video = self.video.clone();
let recordings = Arc::clone(&self.recordings);
@@ -363,9 +391,17 @@ impl AppState {
let tx = self.tx.clone();
let tracker = Arc::new(Mutex::new(HealthTracker::new()));
let weak = Arc::downgrade(self);
// 装甲板的 sink:把"现在多少血"派生为"刚刚掉了几点",立刻推给界面。
self.armor.set_sink(Arc::new(move |report| {
if report.hp == 0 {
if let Some(state) = weak.upgrade() {
if state.observe_match_health() {
state.match_changed.notify_one();
}
}
}
let hit = tracker
.lock()
.expect("health tracker mutex poisoned")
@@ -426,8 +462,10 @@ impl AppState {
let mut ticker = tokio::time::interval(SNAPSHOT_INTERVAL);
loop {
ticker.tick().await;
state_for_loop.tick();
tokio::select! {
_ = ticker.tick() => state_for_loop.tick(),
_ = state_for_loop.match_changed.notified() => state_for_loop.tick_match(),
}
state_for_loop.push_snapshot();
}
});
@@ -643,12 +681,12 @@ impl AppState {
/// 推进帧率窗口与槽位分配。
fn tick_match(&self) {
self.observe_match_health();
if !self.demo && self.config().role_chosen {
let packet = self
.match_clock
.lock()
.expect("match clock poisoned")
.broadcast(self.match_now());
let (packet, result) = {
let mut clock = self.match_clock.lock().expect("match clock poisoned");
(clock.broadcast(self.match_now()), clock.result_packet())
};
if let (Some(socket), Some(packet)) = (&self.match_socket, packet) {
if let Some(bytes) = packet.encode() {
let config = self.config();
@@ -667,9 +705,19 @@ impl AppState {
.send_damage_controls(socket, &packet, participants)
.err();
let reset_error = self.armor.send_reset_controls(socket, &packet).err();
let result_error =
result.and_then(|result| result.encode()).and_then(|bytes| {
socket
.send_to(
&bytes,
(std::net::Ipv4Addr::BROADCAST, protocol::ARMOR_PORT),
)
.err()
});
let error = sync_error
.or(damage_error)
.or(reset_error)
.or(result_error)
.map(|err| format!("比赛状态发送失败:{err}。请检查网络和防火墙"));
*self.match_error.lock().expect("match error poisoned") = error;
}
@@ -782,7 +830,10 @@ impl AppState {
let mut health = vec![self.health_for(0), self.health_for(1)];
// 胜负是**两边合起来**才能算出来的东西,所以在这里补一步。
resolve_outcomes(&mut health);
self.match_clock
.lock()
.expect("match clock poisoned")
.apply_outcomes(&mut health);
Snapshot {
match_clock: self.match_view(),
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "RMIC-2026",
"version": "0.3.0",
"version": "0.4.0",
"identifier": "com.simbarobotics.rmic2026",
"build": {
"beforeDevCommand": "pnpm dev",