|
@ -8,12 +8,12 @@ use crc::{crc32, Hasher32}; |
|
|
use libpso::{PacketParseError, PSOPacket};
|
|
|
use libpso::{PacketParseError, PSOPacket};
|
|
|
use libpso::packet::patch::*;
|
|
|
use libpso::packet::patch::*;
|
|
|
use libpso::crypto::pc::PSOPCCipher;
|
|
|
use libpso::crypto::pc::PSOPCCipher;
|
|
|
|
|
|
use ron::de::from_str;
|
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
|
use crate::common::network::{PacketNetworkError};
|
|
|
use crate::common::network::{PacketNetworkError};
|
|
|
use crate::common::serverstate::{RecvServerPacket, SendServerPacket, ServerState, OnConnect, ClientId};
|
|
|
use crate::common::serverstate::{RecvServerPacket, SendServerPacket, ServerState, OnConnect, ClientId};
|
|
|
|
|
|
|
|
|
pub const PATCH_PORT: u16 = 11000;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
|
pub enum PatchError {
|
|
|
pub enum PatchError {
|
|
|
PacketNetworkError(PacketNetworkError),
|
|
|
PacketNetworkError(PacketNetworkError),
|
|
@ -371,3 +371,27 @@ impl Iterator for SendFileIterator { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
|
|
pub struct PatchConfig {
|
|
|
|
|
|
pub path: String,
|
|
|
|
|
|
pub ip: String,
|
|
|
|
|
|
pub port: u16,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn load_config() -> PatchConfig {
|
|
|
|
|
|
let ini_file = match fs::File::open(std::path::Path::new("patch.ron")) {
|
|
|
|
|
|
Err(err) => panic!("Failed to open patch.ron config file. \n{}", err),
|
|
|
|
|
|
Ok(ini_file) => ini_file,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let mut s = String::new();
|
|
|
|
|
|
if let Err(err) = (&ini_file).read_to_string(&mut s) {
|
|
|
|
|
|
panic!("Failed to read patch.ron config file. \n{}", err);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let config: PatchConfig = match from_str(s.as_str()) {
|
|
|
|
|
|
Ok(config) => config,
|
|
|
|
|
|
Err(err) => panic!("Failed to load values from patch.ron \n{}",err),
|
|
|
|
|
|
};
|
|
|
|
|
|
config
|
|
|
|
|
|
}
|