aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-03-13 18:04:04 +0100
committermetamuffin <metamuffin@disroot.org>2026-03-13 18:04:04 +0100
commit0b1fbcf11a0e019d152726e0a40b18b95a97e601 (patch)
tree46e53b9a11da024f0ed9bec913dd5457851980f3
parent6c3bbc12c9c07e64c6719b260ce8c2371c0c27a0 (diff)
downloadhurrycurry-0b1fbcf11a0e019d152726e0a40b18b95a97e601.tar
hurrycurry-0b1fbcf11a0e019d152726e0a40b18b95a97e601.tar.bz2
hurrycurry-0b1fbcf11a0e019d152726e0a40b18b95a97e601.tar.zst
send vote timeout and remove ballot when players leave
-rw-r--r--server/protocol/src/lib.rs1
-rw-r--r--server/src/vote.rs5
-rw-r--r--test-client/protocol.ts2
3 files changed, 7 insertions, 1 deletions
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index 903f707a..6d299497 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -327,6 +327,7 @@ pub enum PacketC {
initiated_by: PlayerID,
subject: VoteSubject,
message: Message,
+ timeout: f32,
},
VoteUpdated {
total: usize,
diff --git a/server/src/vote.rs b/server/src/vote.rs
index da823f3a..e9d7c118 100644
--- a/server/src/vote.rs
+++ b/server/src/vote.rs
@@ -51,6 +51,9 @@ impl VoteState {
self.cast_cooldown.remove(&player);
self.initiate_cooldown.remove(&player);
self.voting_players.remove(&player);
+ if let Some(a) = &mut self.active {
+ a.ballots.remove(&player);
+ }
self.update();
}
pub fn prime_client(&self, init: &mut Vec<PacketC>) {
@@ -59,6 +62,7 @@ impl VoteState {
initiated_by: active.initiated_by,
subject: active.subject.clone(),
message: subject_to_message(&active.subject),
+ timeout: active.timeout,
});
}
}
@@ -89,6 +93,7 @@ impl VoteState {
initiated_by: player,
message: subject_to_message(&subject),
subject,
+ timeout: 30.,
});
self.update();
}
diff --git a/test-client/protocol.ts b/test-client/protocol.ts
index e6902b8a..26c7f47b 100644
--- a/test-client/protocol.ts
+++ b/test-client/protocol.ts
@@ -79,7 +79,7 @@ export type PacketC =
| { type: "effect2", location: ItemLocation, name: string } // Player sent an effect
| { type: "server_message", message: Message, error: boolean } // Text message from the server
| { type: "server_hint", message?: Message, position?: IVec2, player: PlayerID } // Hint message from server with optional position. Message is unset to clear previous message
- | { type: "vote_started", initiated_by: PlayerID, subject: VoteSubject }
+ | { type: "vote_started", initiated_by: PlayerID, subject: VoteSubject, message: Message, timeout: float }
| { type: "vote_updated", total: int, agree: int, reject: int }
| { type: "vote_ended", result: boolean }
| { type: "score" } & Score // Supplies information for score OSD