use chrono instead of std::time
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3834,6 +3834,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
name = "strafe-client"
|
||||
version = "0.11.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"glam",
|
||||
"parking_lot",
|
||||
"pollster",
|
||||
|
||||
@@ -16,6 +16,7 @@ source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"]
|
||||
roblox = ["dep:strafesnet_deferred_loader", "dep:strafesnet_rbx_loader"]
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.39"
|
||||
glam = "0.30.0"
|
||||
parking_lot = "0.12.1"
|
||||
pollster = "0.4.0"
|
||||
|
||||
@@ -4,12 +4,12 @@ use strafesnet_common::instruction::TimedInstruction;
|
||||
use strafesnet_common::session::Time as SessionTime;
|
||||
|
||||
pub struct App<'a>{
|
||||
root_time:std::time::Instant,
|
||||
root_time:chrono::DateTime<chrono::Utc>,
|
||||
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
||||
}
|
||||
impl<'a> App<'a>{
|
||||
pub fn new(
|
||||
root_time:std::time::Instant,
|
||||
root_time:chrono::DateTime<chrono::Utc>,
|
||||
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
||||
)->App<'a>{
|
||||
Self{
|
||||
@@ -18,7 +18,7 @@ impl<'a> App<'a>{
|
||||
}
|
||||
}
|
||||
fn send_timed_instruction(&mut self,instruction:Instruction){
|
||||
let time=integer::Time::from_nanos(self.root_time.elapsed().as_nanos() as i64);
|
||||
let time=integer::Time::from_nanos((chrono::Utc::now()-self.root_time).num_nanoseconds().unwrap());
|
||||
self.window_thread.send(TimedInstruction{time,instruction}).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ pub fn new(
|
||||
},
|
||||
Instruction::Resize(size,user_settings)=>{
|
||||
println!("Resizing to {:?}",size);
|
||||
let t0=std::time::Instant::now();
|
||||
//let t0=std::time::Instant::now();
|
||||
config.width=size.width.max(1);
|
||||
config.height=size.height.max(1);
|
||||
surface.configure(&device,&config);
|
||||
graphics.resize(&device,&config,&user_settings);
|
||||
println!("Resize took {:?}",t0.elapsed());
|
||||
//println!("Resize took {:?}",t0.elapsed());
|
||||
}
|
||||
Instruction::Render(frame_state)=>{
|
||||
//this has to go deeper somehow
|
||||
|
||||
@@ -188,7 +188,7 @@ pub async fn setup_and_start(title:&str){
|
||||
|
||||
println!("Entering event loop...");
|
||||
let mut app=crate::app::App::new(
|
||||
std::time::Instant::now(),
|
||||
chrono::Utc::now(),
|
||||
window_thread
|
||||
);
|
||||
event_loop.run_app(&mut app).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user