|
@ -140,14 +140,16 @@ pub struct PatchServerState { |
|
|
patch_file_tree: PatchFileTree,
|
|
|
patch_file_tree: PatchFileTree,
|
|
|
patch_file_lookup: HashMap<u32, PatchFile>,
|
|
|
patch_file_lookup: HashMap<u32, PatchFile>,
|
|
|
patch_file_info: Vec<FileInfoReply>,
|
|
|
patch_file_info: Vec<FileInfoReply>,
|
|
|
|
|
|
patch_motd: String,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl PatchServerState {
|
|
|
impl PatchServerState {
|
|
|
pub fn new(patch_file_tree: PatchFileTree, patch_file_lookup: HashMap<u32, PatchFile>) -> PatchServerState {
|
|
|
|
|
|
|
|
|
pub fn new(patch_file_tree: PatchFileTree, patch_file_lookup: HashMap<u32, PatchFile>, patch_motd: String) -> PatchServerState {
|
|
|
PatchServerState {
|
|
|
PatchServerState {
|
|
|
patch_file_tree: patch_file_tree,
|
|
|
patch_file_tree: patch_file_tree,
|
|
|
patch_file_lookup: patch_file_lookup,
|
|
|
patch_file_lookup: patch_file_lookup,
|
|
|
patch_file_info: Vec::new(),
|
|
|
patch_file_info: Vec::new(),
|
|
|
|
|
|
patch_motd: patch_motd,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -174,7 +176,7 @@ impl ServerState for PatchServerState { |
|
|
Box::new(vec![SendPatchPacket::RequestLogin(RequestLogin {})].into_iter().map(move |pkt| (id, pkt)))
|
|
|
Box::new(vec![SendPatchPacket::RequestLogin(RequestLogin {})].into_iter().map(move |pkt| (id, pkt)))
|
|
|
},
|
|
|
},
|
|
|
RecvPatchPacket::LoginReply(_pkt) => {
|
|
|
RecvPatchPacket::LoginReply(_pkt) => {
|
|
|
let mut p = vec![SendPatchPacket::Message(Message::new("hello player".to_string()))];
|
|
|
|
|
|
|
|
|
let mut p = vec![SendPatchPacket::Message(Message::new(self.patch_motd.to_string()))];
|
|
|
p.append(&mut get_file_list_packets(&self.patch_file_tree));
|
|
|
p.append(&mut get_file_list_packets(&self.patch_file_tree));
|
|
|
p.push(SendPatchPacket::PatchEndList(PatchEndList {}));
|
|
|
p.push(SendPatchPacket::PatchEndList(PatchEndList {}));
|
|
|
Box::new(p.into_iter().map(move |pkt| (id, pkt)))
|
|
|
Box::new(p.into_iter().map(move |pkt| (id, pkt)))
|
|
@ -395,3 +397,12 @@ pub fn load_config() -> PatchConfig { |
|
|
};
|
|
|
};
|
|
|
config
|
|
|
config
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn load_motd() -> String {
|
|
|
|
|
|
let mut motd: String = "Welcome to Elseware!".to_string();
|
|
|
|
|
|
|
|
|
|
|
|
if let Ok(m) = fs::read_to_string("patch.motd") {
|
|
|
|
|
|
motd = m.clone();
|
|
|
|
|
|
}
|
|
|
|
|
|
motd
|
|
|
|
|
|
}
|