--- a/gameServer2/src/server/room.rs Thu Jul 19 22:50:46 2018 +0300
+++ b/gameServer2/src/server/room.rs Fri Jul 20 00:02:52 2018 +0300
@@ -1,4 +1,6 @@
-use std::{iter};
+use std::{
+ iter, collections::HashMap
+};
use server::{
coretypes::{ClientId, RoomId, TeamInfo, GameCfg, GameCfg::*, Voting},
client::{HWClient}
@@ -107,6 +109,11 @@
}
}
+pub struct RoomSave {
+ pub location: String,
+ config: RoomConfig
+}
+
bitflags!{
pub struct RoomFlags: u8 {
const FIXED = 0b0000_0001;
@@ -132,6 +139,7 @@
pub teams: Vec<(ClientId, TeamInfo)>,
config: RoomConfig,
pub voting: Option<Voting>,
+ pub saves: HashMap<String, RoomSave>,
pub game_info: Option<GameInfo>
}
@@ -152,6 +160,7 @@
teams: Vec::new(),
config: RoomConfig::new(),
voting: None,
+ saves: HashMap::new(),
game_info: None
}
}
@@ -326,6 +335,15 @@
}
}
+ pub fn load_config(&mut self, name: &str) -> Option<&str> {
+ if let Some(save) = self.saves.get(name) {
+ self.config = save.config.clone();
+ Some(&save.location[..])
+ } else {
+ None
+ }
+ }
+
pub fn team_info(owner: &HWClient, team: &TeamInfo) -> Vec<String> {
let mut info = vec![
team.name.clone(),