Add some work towards having checker work with the new server
authorunC0Rr
Thu, 29 Sep 2022 16:30:02 +0200
changeset 15904 f185e7367dd3
parent 15903 212e16c60bf5
child 15905 bf92592915c6
child 15906 8f2ddbfdc0b4
Add some work towards having checker work with the new server
rust/hedgewars-server/src/core/server.rs
rust/hedgewars-server/src/core/types.rs
rust/hedgewars-server/src/handlers/checker.rs
--- a/rust/hedgewars-server/src/core/server.rs	Thu Sep 29 16:29:23 2022 +0200
+++ b/rust/hedgewars-server/src/core/server.rs	Thu Sep 29 16:30:02 2022 +0200
@@ -3,11 +3,13 @@
     client::HwClient,
     indexslab::IndexSlab,
     room::HwRoom,
-    types::{ClientId, RoomId, Voting},
+    types::{CheckerId, ClientId, RoomId, Voting},
 };
 use crate::utils;
 use hedgewars_network_protocol::types::{GameCfg, ServerVar, TeamInfo, Vote, VoteType};
 
+use crate::server::replaystorage::ReplayStorage;
+
 use bitflags::*;
 use log::*;
 use slab::Slab;
@@ -157,7 +159,7 @@
     }
 }
 
-struct HwChecker {
+pub struct HwChecker {
     pub id: ClientId,
     pub is_ready: bool,
 }
@@ -169,6 +171,10 @@
             is_ready: false,
         }
     }
+
+    pub fn set_is_ready(&mut self, ready: bool) {
+        self.is_ready = ready
+    }
 }
 
 pub struct HwServer {
@@ -178,6 +184,7 @@
     latest_protocol: u16,
     flags: ServerFlags,
     greetings: ServerGreetings,
+    replay_storage: Option<ReplayStorage>,
 }
 
 impl HwServer {
@@ -192,6 +199,7 @@
             greetings: ServerGreetings::new(),
             latest_protocol: 58,
             flags: ServerFlags::empty(),
+            replay_storage: None,
         }
     }
 
@@ -201,6 +209,11 @@
     }
 
     #[inline]
+    pub fn get_checker_mut(&mut self, checker_id: CheckerId) -> Option<&mut HwChecker> {
+        self.checkers.get_mut(checker_id)
+    }
+
+    #[inline]
     pub fn has_client(&self, client_id: ClientId) -> bool {
         self.clients.contains(client_id)
     }
--- a/rust/hedgewars-server/src/core/types.rs	Thu Sep 29 16:29:23 2022 +0200
+++ b/rust/hedgewars-server/src/core/types.rs	Thu Sep 29 16:30:02 2022 +0200
@@ -1,6 +1,7 @@
 use hedgewars_network_protocol::types::{RoomConfig, TeamInfo, VoteType};
 use serde_derive::{Deserialize, Serialize};
 
+pub type CheckerId = usize;
 pub type ClientId = usize;
 pub type RoomId = usize;
 
--- a/rust/hedgewars-server/src/handlers/checker.rs	Thu Sep 29 16:29:23 2022 +0200
+++ b/rust/hedgewars-server/src/handlers/checker.rs	Thu Sep 29 16:30:02 2022 +0200
@@ -1,16 +1,19 @@
 use log::*;
 
-use crate::core::{server::HwServer, types::ClientId};
+use crate::core::{server::HwServer, types::CheckerId};
 use hedgewars_network_protocol::messages::HwProtocolMessage;
 
 pub fn handle(
-    _server: &mut HwServer,
-    _client_id: ClientId,
+    server: &mut HwServer,
+    checker_id: CheckerId,
     _response: &mut super::Response,
     message: HwProtocolMessage,
 ) {
     match message {
         HwProtocolMessage::CheckerReady => {
+            server
+                .get_checker_mut(checker_id)
+                .map(|c| c.set_is_ready(true));
             warn!("Unimplemented")
         }
         HwProtocolMessage::CheckedOk(info) => {