fix
This commit is contained in:
parent
63867593ef
commit
120b30f5c7
10
src/comms.rs
10
src/comms.rs
@ -68,6 +68,9 @@ pub struct RadarData {
|
|||||||
#[serde(rename = "bombDefuseTimeleft")]
|
#[serde(rename = "bombDefuseTimeleft")]
|
||||||
bomb_defuse_timeleft: f32,
|
bomb_defuse_timeleft: f32,
|
||||||
|
|
||||||
|
#[serde(rename = "bombDefuseLeft")]
|
||||||
|
bomb_defuse_left: f32,
|
||||||
|
|
||||||
#[serde(rename = "mapName")]
|
#[serde(rename = "mapName")]
|
||||||
map_name: String,
|
map_name: String,
|
||||||
|
|
||||||
@ -79,8 +82,8 @@ pub struct RadarData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RadarData {
|
impl RadarData {
|
||||||
pub fn new(ingame: bool, map_name: String, player_data: Vec<EntityData>, freq: usize, bomb_planted: bool, bomb_cannot_defuse: bool, bomb_defuse_timeleft: f32, bomb_exploded: bool, bomb_being_defused: bool, bomb_defuse_length: f32) -> RadarData {
|
pub fn new(ingame: bool, map_name: String, player_data: Vec<EntityData>, freq: usize, bomb_planted: bool, bomb_cannot_defuse: bool, bomb_defuse_timeleft: f32, bomb_exploded: bool, bomb_being_defused: bool, bomb_defuse_length: f32, bomb_defuse_left: f32) -> RadarData {
|
||||||
RadarData { ingame, map_name, player_data, freq, bomb_planted, bomb_can_defuse: bomb_cannot_defuse, bomb_defuse_timeleft, bomb_exploded, bomb_being_defused, bomb_defuse_length }
|
RadarData { ingame, map_name, player_data, freq, bomb_planted, bomb_can_defuse: bomb_cannot_defuse, bomb_defuse_timeleft, bomb_exploded, bomb_being_defused, bomb_defuse_length, bomb_defuse_left }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns empty RadarData, it's also the same data that gets sent to clients when not ingame
|
/// Returns empty RadarData, it's also the same data that gets sent to clients when not ingame
|
||||||
@ -95,7 +98,8 @@ impl RadarData {
|
|||||||
bomb_defuse_timeleft: 0.0,
|
bomb_defuse_timeleft: 0.0,
|
||||||
bomb_exploded: false,
|
bomb_exploded: false,
|
||||||
bomb_being_defused: false,
|
bomb_being_defused: false,
|
||||||
bomb_defuse_length: 0.0
|
bomb_defuse_length: 0.0,
|
||||||
|
bomb_defuse_left: 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,18 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let bomb_defuse_left: f32 = {
|
||||||
|
if bomb_can_defuse {
|
||||||
|
if let Some(bomb_stamp) = data.bomb_planted_stamp {
|
||||||
|
data.bomb_defuse_length - defuse_stamp.elapsed().as_secs_f32()
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
last_bomb_dropped = data.bomb_dropped;
|
last_bomb_dropped = data.bomb_dropped;
|
||||||
last_bomb_planted = data.bomb_planted;
|
last_bomb_planted = data.bomb_planted;
|
||||||
|
|
||||||
@ -204,7 +216,8 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
bomb_defuse_timeleft,
|
bomb_defuse_timeleft,
|
||||||
data.bomb_exploded,
|
data.bomb_exploded,
|
||||||
data.bomb_being_defused,
|
data.bomb_being_defused,
|
||||||
data.bomb_defuse_length
|
data.bomb_defuse_length,
|
||||||
|
bomb_defuse_left
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let mut radar = radar_data.write().await;
|
let mut radar = radar_data.write().await;
|
||||||
|
@ -35,7 +35,7 @@ if (location.protocol == 'https:') {
|
|||||||
} else {
|
} else {
|
||||||
websocketAddr = `ws://${window.location.host}/ws`
|
websocketAddr = `ws://${window.location.host}/ws`
|
||||||
}
|
}
|
||||||
//websocketAddr = "ws://localhost:8001/ws"
|
websocketAddr = "ws://192.168.0.235:8000/ws"
|
||||||
|
|
||||||
// Util functions
|
// Util functions
|
||||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||||
@ -185,8 +185,6 @@ function render() {
|
|||||||
|
|
||||||
let maxWidth = 1024-128-128;
|
let maxWidth = 1024-128-128;
|
||||||
let timeleft = radarData.bombDefuseTimeleft;
|
let timeleft = radarData.bombDefuseTimeleft;
|
||||||
let canDefuse = (timeleft - radarData.bombDefuseLength) > 0
|
|
||||||
let defuseStamp = (timeleft - radarData.bombDefuseLength)
|
|
||||||
|
|
||||||
// Base bar
|
// Base bar
|
||||||
ctx.fillStyle = "black"
|
ctx.fillStyle = "black"
|
||||||
@ -228,11 +226,11 @@ function render() {
|
|||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
|
|
||||||
// Defuse stamp line
|
// Defuse stamp line
|
||||||
if (canDefuse) {
|
if (radarData.bombCanDefuse) {
|
||||||
ctx.strokeStyle = "green"
|
ctx.strokeStyle = "green"
|
||||||
ctx.beginPath()
|
ctx.beginPath()
|
||||||
ctx.moveTo(130 + (maxWidth-2) * (defuseStamp / 40), 16)
|
ctx.moveTo(130 + (maxWidth-2) * (radarData.bombDefuseLeft / 40), 16)
|
||||||
ctx.lineTo(130 + (maxWidth-2) * (defuseStamp / 40), 32)
|
ctx.lineTo(130 + (maxWidth-2) * (radarData.bombDefuseLeft / 40), 32)
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user