Compare commits
18 Commits
triggerbot
...
64ebd83016
| Author | SHA1 | Date | |
|---|---|---|---|
| 64ebd83016 | |||
| 5f99e03b4c | |||
| d6719b0d54 | |||
| 363db1c56a | |||
| 61ea504f28 | |||
| bd8de00f10 | |||
| e6ca121b86 | |||
| 067fff4ef8 | |||
| 7bdc3fbaa3 | |||
| 30fcdde828 | |||
| 5e97135970 | |||
| 504d54bbeb | |||
| 235c3a6151 | |||
| f2824af426 | |||
| ec679b22cb | |||
|
|
c86216ec6e | ||
|
|
02c3ac8dde | ||
|
|
f3f08cbede |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/target
|
/target
|
||||||
/src/dma/cs2dumper/offsets_mod.rs
|
/src/dma/cs2dumper/offsets_mod.rs
|
||||||
/src/dma/cs2dumper/client_mod.rs
|
/src/dma/cs2dumper/client_mod.rs
|
||||||
/src/dma/cs2dumper/engine2_mod.rs
|
/src/dma/cs2dumper/engine2_mod.rs
|
||||||
|
dump.sh
|
||||||
|
|||||||
563
Cargo.lock
generated
563
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
36
Cargo.toml
36
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "radarflow"
|
name = "radarflow"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
authors = ["Janek S <development@superyu.xyz"]
|
authors = ["Janek S <development@superyu.xyz"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -8,39 +8,39 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# memory
|
# memory
|
||||||
memflow = "0.2.1"
|
memflow = "0.2.3"
|
||||||
memflow-native = { git = "https://github.com/memflow/memflow-native" }
|
memflow-native = { git = "https://github.com/memflow/memflow-native" }
|
||||||
dataview = "1.0.1"
|
dataview = "1.0.1"
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
log = "0.4.21"
|
log = "0.4.22"
|
||||||
simple_logger = "4.3.3"
|
simple_logger = "5.0.0"
|
||||||
|
|
||||||
# error handling
|
# error handling
|
||||||
anyhow = "1.0.81"
|
anyhow = "1.0.93"
|
||||||
|
|
||||||
# derive stuff
|
# derive stuff
|
||||||
enum-primitive-derive = "0.3.0"
|
enum-primitive-derive = "0.3.0"
|
||||||
num-traits = "0.2.18"
|
num-traits = "0.2.19"
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.133"
|
||||||
clap = { version = "4.5.4", features = ["derive", "string"] }
|
clap = { version = "4.5.21", features = ["derive", "string"] }
|
||||||
|
|
||||||
# tokio
|
# tokio
|
||||||
tokio = { version = "1.37.0", features = ["full"] }
|
tokio = { version = "1.37.0", features = ["full"] }
|
||||||
|
|
||||||
# networking
|
# networking
|
||||||
axum = { version = "0.7.5", features = ["ws"] }
|
axum = { version = "0.7.9", features = ["ws"] }
|
||||||
tower-http = { version = "0.5.2", features = ["fs"] }
|
tower-http = { version = "0.6.2", features = ["fs"] }
|
||||||
tower = "0.4.13"
|
tower = "0.5.1"
|
||||||
local-ip-address = "0.6.1"
|
local-ip-address = "0.6.3"
|
||||||
|
|
||||||
# other
|
# other
|
||||||
itertools = "0.12.1"
|
itertools = "0.13.0"
|
||||||
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
reqwest = { version = "0.12.2", features = ["blocking"] }
|
reqwest = { version = "0.12.9", features = ["blocking"] }
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.133"
|
||||||
vergen = { version = "8.3.1", features = ["build", "cargo", "git", "gitcl", "rustc", "si"] }
|
vergen-gitcl = { version = "1.0.0", features = ["build", "cargo", "rustc",] }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Before you begin, install the necessary memflow plugins using memflowup from the
|
|||||||
The needed Plugins are `memflow-qemu` and `memflow-win32`
|
The needed Plugins are `memflow-qemu` and `memflow-win32`
|
||||||
|
|
||||||
Clone the repo on your vm host:
|
Clone the repo on your vm host:
|
||||||
`git clone https://github.com/superyu1337/radarflow2.git`
|
`git clone https://git.deadzone.lol/Wizzard/radarflow2-kvm.git`
|
||||||
|
|
||||||
Run radarflow:
|
Run radarflow:
|
||||||
`cargo run --release`
|
`cargo run --release`
|
||||||
@@ -38,7 +38,7 @@ Check the dlopen documentation for all possible import paths.
|
|||||||
```
|
```
|
||||||
|
|
||||||
Clone the repo on your attacking pc:
|
Clone the repo on your attacking pc:
|
||||||
`git clone https://github.com/superyu1337/radarflow2.git`
|
`git clone https://git.deadzone.lol/Wizzard/radarflow2-kvm.git`
|
||||||
|
|
||||||
Run radarflow:
|
Run radarflow:
|
||||||
`cargo run --release -- --connector pcileech`
|
`cargo run --release -- --connector pcileech`
|
||||||
|
|||||||
20
build.rs
20
build.rs
@@ -1,7 +1,7 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vergen::EmitBuilder;
|
use vergen_gitcl::{Emitter, GitclBuilder};
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Serialize)]
|
#[derive(Clone, Deserialize, Serialize)]
|
||||||
struct InfoJson {
|
struct InfoJson {
|
||||||
@@ -36,29 +36,27 @@ fn build_number() -> Result<(), Box<dyn Error>> {
|
|||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
download(
|
download(
|
||||||
"https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/client.dll.rs",
|
"https://raw.githubusercontent.com/a2x/cs2-dumper/refs/heads/main/output/client_dll.rs",
|
||||||
"./src/dma/cs2dumper/client_mod.rs"
|
"./src/dma/cs2dumper/client_mod.rs"
|
||||||
).expect("Failed to download build file \"client.dll.rs\"");
|
).expect("Failed to download build file \"client.dll.rs\"");
|
||||||
|
|
||||||
download(
|
download(
|
||||||
"https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/offsets.rs",
|
"https://raw.githubusercontent.com/a2x/cs2-dumper/refs/heads/main/output/offsets.rs",
|
||||||
"./src/dma/cs2dumper/offsets_mod.rs"
|
"./src/dma/cs2dumper/offsets_mod.rs"
|
||||||
).expect("Failed to download build file \"offsets.rs\"");
|
).expect("Failed to download build file \"offsets.rs\"");
|
||||||
|
|
||||||
download(
|
download(
|
||||||
"https://raw.githubusercontent.com/a2x/cs2-dumper/main/output/engine2.dll.rs",
|
"https://raw.githubusercontent.com/a2x/cs2-dumper/refs/heads/main/output/engine2_dll.rs",
|
||||||
"./src/dma/cs2dumper/engine2_mod.rs"
|
"./src/dma/cs2dumper/engine2_mod.rs"
|
||||||
).expect("Failed to download build file \"engine2.dll.rs\"");
|
).expect("Failed to download build file \"engine2.dll.rs\"");
|
||||||
|
|
||||||
build_number()?;
|
build_number()?;
|
||||||
|
|
||||||
EmitBuilder::builder()
|
let gitcl = GitclBuilder::all_git()?;
|
||||||
.git_sha(true)
|
|
||||||
.git_commit_date()
|
|
||||||
.cargo_debug()
|
Emitter::new()
|
||||||
.cargo_target_triple()
|
.add_instructions(&gitcl)?
|
||||||
.rustc_semver()
|
|
||||||
.rustc_llvm_version()
|
|
||||||
.emit()?;
|
.emit()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use memflow::plugins::Inventory;
|
|||||||
use crate::dma::Connector;
|
use crate::dma::Connector;
|
||||||
const PORT_RANGE: std::ops::RangeInclusive<usize> = 8000..=65535;
|
const PORT_RANGE: std::ops::RangeInclusive<usize> = 8000..=65535;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser, Clone)]
|
||||||
#[command(author, version = version(), about, long_about = None)]
|
#[command(author, version = version(), about, long_about = None)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
/// Specifies the connector type for DMA
|
/// Specifies the connector type for DMA
|
||||||
@@ -45,7 +45,11 @@ fn version() -> String {
|
|||||||
avail.join(", ")
|
avail.join(", ")
|
||||||
};
|
};
|
||||||
|
|
||||||
format!(" {pkg_ver} (rev {git_hash})\nCommit Date: {commit_date}\nAvailable Connectors: {avail_cons}")
|
format!(
|
||||||
|
"{pkg_ver} (rev {git_hash})\n\
|
||||||
|
Commit Date: {commit_date}\n\
|
||||||
|
Available Connectors: {avail_cons}\n"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn port_in_range(s: &str) -> Result<u16, String> {
|
fn port_in_range(s: &str) -> Result<u16, String> {
|
||||||
|
|||||||
55
src/comms.rs
55
src/comms.rs
@@ -16,12 +16,18 @@ pub struct PlayerData {
|
|||||||
has_awp: bool,
|
has_awp: bool,
|
||||||
|
|
||||||
#[serde(rename = "isScoped")]
|
#[serde(rename = "isScoped")]
|
||||||
is_scoped: bool
|
is_scoped: bool,
|
||||||
|
|
||||||
|
#[serde(rename = "playerName")]
|
||||||
|
player_name: String,
|
||||||
|
|
||||||
|
#[serde(rename = "weaponId")]
|
||||||
|
weapon_id: i16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlayerData {
|
impl PlayerData {
|
||||||
pub fn new(pos: Vec3, yaw: f32, player_type: PlayerType, has_bomb: bool, has_awp: bool, is_scoped: bool) -> PlayerData {
|
pub fn new(pos: Vec3, yaw: f32, player_type: PlayerType, has_bomb: bool, has_awp: bool, is_scoped: bool, player_name: String, weapon_id: i16) -> PlayerData {
|
||||||
PlayerData { pos, yaw, player_type, has_bomb, has_awp, is_scoped }
|
PlayerData { pos, yaw, player_type, has_bomb, has_awp, is_scoped, player_name, weapon_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +51,20 @@ pub enum EntityData {
|
|||||||
Bomb(BombData)
|
Bomb(BombData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct CheatOptions {
|
||||||
|
#[serde(rename = "revealMoney")]
|
||||||
|
pub reveal_money: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CheatOptions {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
reveal_money: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct RadarData {
|
pub struct RadarData {
|
||||||
freq: usize,
|
freq: usize,
|
||||||
@@ -77,16 +97,30 @@ pub struct RadarData {
|
|||||||
#[serde(rename(serialize = "entityData"))]
|
#[serde(rename(serialize = "entityData"))]
|
||||||
player_data: Vec<EntityData>,
|
player_data: Vec<EntityData>,
|
||||||
|
|
||||||
#[serde(rename = "triggerbot_shoot")]
|
#[serde(rename = "options")]
|
||||||
triggerbot_shoot: bool,
|
options: CheatOptions,
|
||||||
|
|
||||||
//#[serde(rename(serialize = "localYaw"))]
|
#[serde(skip)]
|
||||||
//local_yaw: f32,
|
pub money_reveal_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
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, bomb_defuse_end: f32, triggerbot_shoot: bool,) -> 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_end: 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, bomb_defuse_end, triggerbot_shoot }
|
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_end,
|
||||||
|
options: CheatOptions::default(),
|
||||||
|
money_reveal_enabled: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -103,7 +137,8 @@ impl RadarData {
|
|||||||
bomb_being_defused: false,
|
bomb_being_defused: false,
|
||||||
bomb_defuse_length: 0.0,
|
bomb_defuse_length: 0.0,
|
||||||
bomb_defuse_end: 0.0,
|
bomb_defuse_end: 0.0,
|
||||||
triggerbot_shoot: false,
|
options: CheatOptions::default(),
|
||||||
|
money_reveal_enabled: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ impl DmaCtx {
|
|||||||
let mut team = 0i32;
|
let mut team = 0i32;
|
||||||
let mut clipping_weapon = 0u64;
|
let mut clipping_weapon = 0u64;
|
||||||
let mut is_scoped = 0u8;
|
let mut is_scoped = 0u8;
|
||||||
let mut crosshair_id = 0u8;
|
let mut player_name_ptr = 0u64;
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut batcher = MemoryViewBatcher::new(&mut self.process);
|
let mut batcher = MemoryViewBatcher::new(&mut self.process);
|
||||||
@@ -107,19 +107,33 @@ impl DmaCtx {
|
|||||||
batcher.read_into(controller + cs2dumper::client::C_BaseEntity::m_iTeamNum, &mut team);
|
batcher.read_into(controller + cs2dumper::client::C_BaseEntity::m_iTeamNum, &mut team);
|
||||||
batcher.read_into(pawn + cs2dumper::client::C_CSPlayerPawnBase::m_pClippingWeapon, &mut clipping_weapon);
|
batcher.read_into(pawn + cs2dumper::client::C_CSPlayerPawnBase::m_pClippingWeapon, &mut clipping_weapon);
|
||||||
batcher.read_into(pawn + cs2dumper::client::C_CSPlayerPawn::m_bIsScoped, &mut is_scoped);
|
batcher.read_into(pawn + cs2dumper::client::C_CSPlayerPawn::m_bIsScoped, &mut is_scoped);
|
||||||
batcher.read_into(pawn + cs2dumper::client::C_CSPlayerPawnBase::m_iIDEntIndex, &mut crosshair_id);
|
batcher.read_into(controller + cs2dumper::client::CCSPlayerController::m_sSanitizedPlayerName, &mut player_name_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let player_name = if player_name_ptr != 0 {
|
||||||
|
let mut name_buffer = [0u8; 32];
|
||||||
|
self.process.read_raw_into(player_name_ptr.into(), &mut name_buffer)?;
|
||||||
|
|
||||||
|
let name_len = name_buffer.iter().position(|&c| c == 0).unwrap_or(name_buffer.len());
|
||||||
|
String::from_utf8_lossy(&name_buffer[..name_len]).to_string()
|
||||||
|
} else {
|
||||||
|
match team {
|
||||||
|
2 => format!("T Player"),
|
||||||
|
3 => format!("CT Player"),
|
||||||
|
_ => format!("Unknown Player"),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let team = TeamID::from_i32(team);
|
let team = TeamID::from_i32(team);
|
||||||
|
|
||||||
let has_awp = {
|
let (has_awp, weapon_id) = {
|
||||||
let clipping_weapon: Address = clipping_weapon.into();
|
let clipping_weapon: Address = clipping_weapon.into();
|
||||||
let items_def_idx_addr = clipping_weapon + cs2dumper::client::C_EconEntity::m_AttributeManager
|
let items_def_idx_addr = clipping_weapon + cs2dumper::client::C_EconEntity::m_AttributeManager
|
||||||
+ cs2dumper::client::C_AttributeContainer::m_Item + cs2dumper::client::C_EconItemView::m_iItemDefinitionIndex;
|
+ cs2dumper::client::C_AttributeContainer::m_Item + cs2dumper::client::C_EconItemView::m_iItemDefinitionIndex;
|
||||||
|
|
||||||
let items_def_idx: i16 = self.process.read(items_def_idx_addr)?;
|
let items_def_idx: i16 = self.process.read(items_def_idx_addr)?;
|
||||||
|
|
||||||
items_def_idx == 9
|
(items_def_idx == 9, items_def_idx)
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(BatchedPlayerData {
|
Ok(BatchedPlayerData {
|
||||||
@@ -129,7 +143,8 @@ impl DmaCtx {
|
|||||||
health,
|
health,
|
||||||
has_awp,
|
has_awp,
|
||||||
is_scoped: is_scoped != 0,
|
is_scoped: is_scoped != 0,
|
||||||
crosshair_id
|
player_name,
|
||||||
|
weapon_id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +196,8 @@ impl DmaCtx {
|
|||||||
let mut data_vec: Vec<(Address, u64, Vec<(u64, i32)>)> = data_vec
|
let mut data_vec: Vec<(Address, u64, Vec<(u64, i32)>)> = data_vec
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(pawn, _, wep_count, wep_base)| {
|
.map(|(pawn, _, wep_count, wep_base)| {
|
||||||
let weps = (0..wep_count).into_iter().map(|idx| (0u64, idx)).collect();
|
let safe_count = if wep_count < 0 || wep_count > 32 { 0 } else { wep_count };
|
||||||
|
let weps = (0..safe_count).into_iter().map(|idx| (0u64, idx)).collect();
|
||||||
(pawn, wep_base, weps)
|
(pawn, wep_base, weps)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
@@ -191,7 +207,7 @@ impl DmaCtx {
|
|||||||
data_vec.iter_mut().for_each(|(_, wep_base, wep_data_vec)| {
|
data_vec.iter_mut().for_each(|(_, wep_base, wep_data_vec)| {
|
||||||
wep_data_vec.iter_mut().for_each(|(_, idx)| {
|
wep_data_vec.iter_mut().for_each(|(_, idx)| {
|
||||||
let b: Address = (*wep_base).into();
|
let b: Address = (*wep_base).into();
|
||||||
batcher.read_into(b + * idx * 0x4, idx);
|
batcher.read_into(b + u64::saturating_mul(*idx as u64, 0x4), idx);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
drop(batcher);
|
drop(batcher);
|
||||||
@@ -255,5 +271,6 @@ pub struct BatchedPlayerData {
|
|||||||
pub health: u32,
|
pub health: u32,
|
||||||
pub has_awp: bool,
|
pub has_awp: bool,
|
||||||
pub is_scoped: bool,
|
pub is_scoped: bool,
|
||||||
pub crosshair_id: u8,
|
pub player_name: String,
|
||||||
|
pub weapon_id: i16,
|
||||||
}
|
}
|
||||||
144
src/dma/mod.rs
144
src/dma/mod.rs
@@ -4,17 +4,28 @@ use memflow::{mem::MemoryView, os::Process, types::Address};
|
|||||||
|
|
||||||
use crate::{enums::PlayerType, comms::{EntityData, PlayerData, RadarData, ArcRwlockRadarData, BombData}};
|
use crate::{enums::PlayerType, comms::{EntityData, PlayerData, RadarData, ArcRwlockRadarData, BombData}};
|
||||||
|
|
||||||
|
use crate::money_reveal::MoneyReveal;
|
||||||
|
|
||||||
use self::{context::DmaCtx, threaddata::CsData};
|
use self::{context::DmaCtx, threaddata::CsData};
|
||||||
|
|
||||||
mod context;
|
pub mod context;
|
||||||
mod threaddata;
|
pub mod threaddata;
|
||||||
mod cs2dumper;
|
mod cs2dumper;
|
||||||
|
|
||||||
pub use context::Connector;
|
pub use context::Connector;
|
||||||
|
|
||||||
pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_device: String, skip_version: bool) -> anyhow::Result<()> {
|
pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_device: String, skip_version: bool) -> anyhow::Result<()> {
|
||||||
let mut ctx = DmaCtx::setup(connector, pcileech_device, skip_version)?;
|
let mut ctx = DmaCtx::setup(connector, pcileech_device, skip_version)?;
|
||||||
let mut data = CsData { recheck_bomb_holder: true, ..Default::default() };
|
let mut data = CsData {
|
||||||
|
recheck_bomb_holder: true,
|
||||||
|
money_reveal_enabled: false,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut money_reveal = MoneyReveal::new();
|
||||||
|
if let Err(e) = money_reveal.init(&mut ctx.process, &ctx.client_module) {
|
||||||
|
log::warn!("Failed to initialize money reveal: {}", e);
|
||||||
|
}
|
||||||
|
|
||||||
// For read timing
|
// For read timing
|
||||||
let mut last_bomb_dropped = false;
|
let mut last_bomb_dropped = false;
|
||||||
@@ -47,6 +58,17 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
|
|
||||||
data.update_common(&mut ctx);
|
data.update_common(&mut ctx);
|
||||||
|
|
||||||
|
{
|
||||||
|
let radar = radar_data.read().await;
|
||||||
|
if radar.money_reveal_enabled != data.money_reveal_enabled {
|
||||||
|
data.money_reveal_enabled = radar.money_reveal_enabled;
|
||||||
|
|
||||||
|
if let Err(e) = money_reveal.toggle(&mut ctx.process) {
|
||||||
|
log::warn!("Failed to toggle money reveal: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Bomb update
|
// Bomb update
|
||||||
if (data.bomb_dropped && !last_bomb_dropped) || (data.bomb_planted && !last_bomb_planted) {
|
if (data.bomb_dropped && !last_bomb_dropped) || (data.bomb_planted && !last_bomb_planted) {
|
||||||
data.update_bomb(&mut ctx);
|
data.update_bomb(&mut ctx);
|
||||||
@@ -76,10 +98,18 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(_, pawn)| pawn)
|
.map(|(_, pawn)| pawn)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
pawns.push(data.local_pawn.into());
|
|
||||||
|
|
||||||
|
pawns.push(data.local_pawn.into());
|
||||||
|
|
||||||
|
let prev_holder = data.bomb_holder;
|
||||||
|
|
||||||
data.bomb_holder = ctx.get_c4_holder(pawns, data.entity_list.into(), &data);
|
data.bomb_holder = ctx.get_c4_holder(pawns, data.entity_list.into(), &data);
|
||||||
|
|
||||||
|
if data.bomb_holder.is_some() && prev_holder.is_none() {
|
||||||
|
log::debug!("Bomb picked up by player");
|
||||||
|
data.bomb_dropped = false;
|
||||||
|
}
|
||||||
|
|
||||||
data.recheck_bomb_holder = false;
|
data.recheck_bomb_holder = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,18 +168,25 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
|
|
||||||
// Bomb
|
// Bomb
|
||||||
if data.bomb_dropped || data.bomb_planted {
|
if data.bomb_dropped || data.bomb_planted {
|
||||||
let node = ctx.process.read_addr64(
|
if let Ok(node) = ctx.process.read_addr64(
|
||||||
data.bomb + cs2dumper::client::C_BaseEntity::m_pGameSceneNode as u64
|
data.bomb + cs2dumper::client::C_BaseEntity::m_pGameSceneNode as u64
|
||||||
).unwrap();
|
) {
|
||||||
let pos = ctx.process.read(node + cs2dumper::client::CGameSceneNode::m_vecAbsOrigin).unwrap();
|
if let Ok(pos) = ctx.process.read(node + cs2dumper::client::CGameSceneNode::m_vecAbsOrigin) {
|
||||||
|
entity_data.push(EntityData::Bomb(BombData::new(pos, data.bomb_planted)));
|
||||||
entity_data.push(EntityData::Bomb(BombData::new(pos, data.bomb_planted)));
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local player
|
// Local player
|
||||||
let local_data = ctx.batched_player_read(
|
let local_data = match ctx.batched_player_read(
|
||||||
data.local.into(), data.local_pawn.into()
|
data.local.into(), data.local_pawn.into()
|
||||||
).unwrap();
|
) {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to read local player data: {}", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if local_data.health > 0 {
|
if local_data.health > 0 {
|
||||||
let has_bomb = match data.bomb_holder {
|
let has_bomb = match data.bomb_holder {
|
||||||
@@ -160,12 +197,14 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
entity_data.push(
|
entity_data.push(
|
||||||
EntityData::Player(
|
EntityData::Player(
|
||||||
PlayerData::new(
|
PlayerData::new(
|
||||||
local_data.pos,
|
local_data.pos,
|
||||||
local_data.yaw,
|
local_data.yaw,
|
||||||
PlayerType::Local,
|
PlayerType::Local,
|
||||||
has_bomb,
|
has_bomb,
|
||||||
local_data.has_awp,
|
local_data.has_awp,
|
||||||
local_data.is_scoped
|
local_data.is_scoped,
|
||||||
|
local_data.player_name,
|
||||||
|
local_data.weapon_id
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -173,39 +212,47 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
|
|
||||||
// Other players
|
// Other players
|
||||||
for (controller, pawn) in &data.players {
|
for (controller, pawn) in &data.players {
|
||||||
let player_data = ctx.batched_player_read(*controller, *pawn).unwrap();
|
match ctx.batched_player_read(*controller, *pawn) {
|
||||||
|
Ok(player_data) => {
|
||||||
|
if player_data.health < 1 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if player_data.health < 1 {
|
let has_bomb = match data.bomb_holder {
|
||||||
continue;
|
Some(bh) => *pawn == bh,
|
||||||
}
|
None => false,
|
||||||
|
};
|
||||||
|
|
||||||
let has_bomb = match data.bomb_holder {
|
let player_type = {
|
||||||
Some(bh) => *pawn == bh,
|
if local_data.team != player_data.team {
|
||||||
None => false,
|
PlayerType::Enemy
|
||||||
};
|
} else if local_data.team == player_data.team {
|
||||||
|
PlayerType::Team
|
||||||
|
} else {
|
||||||
|
PlayerType::Unknown
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let player_type = {
|
entity_data.push(
|
||||||
if local_data.team != player_data.team {
|
EntityData::Player(
|
||||||
PlayerType::Enemy
|
PlayerData::new(
|
||||||
} else if local_data.team == player_data.team {
|
player_data.pos,
|
||||||
PlayerType::Team
|
player_data.yaw,
|
||||||
} else {
|
player_type,
|
||||||
PlayerType::Unknown
|
has_bomb,
|
||||||
|
player_data.has_awp,
|
||||||
|
player_data.is_scoped,
|
||||||
|
player_data.player_name,
|
||||||
|
player_data.weapon_id
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to read player data: {}", e);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
entity_data.push(
|
|
||||||
EntityData::Player(
|
|
||||||
PlayerData::new(
|
|
||||||
player_data.pos,
|
|
||||||
player_data.yaw,
|
|
||||||
player_type,
|
|
||||||
has_bomb,
|
|
||||||
player_data.has_awp,
|
|
||||||
player_data.is_scoped
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut radar = radar_data.write().await;
|
let mut radar = radar_data.write().await;
|
||||||
@@ -220,12 +267,14 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
data.bomb_exploded,
|
data.bomb_exploded,
|
||||||
data.bomb_being_defused,
|
data.bomb_being_defused,
|
||||||
data.bomb_defuse_length,
|
data.bomb_defuse_length,
|
||||||
bomb_defuse_end,
|
bomb_defuse_end
|
||||||
local_data.crosshair_id != 0 && local_data.crosshair_id != 255
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
radar.money_reveal_enabled = data.money_reveal_enabled;
|
||||||
} else {
|
} else {
|
||||||
let mut radar = radar_data.write().await;
|
let mut radar = radar_data.write().await;
|
||||||
*radar = RadarData::empty(freq);
|
*radar = RadarData::empty(freq);
|
||||||
|
radar.money_reveal_enabled = data.money_reveal_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_tick_count = data.tick_count;
|
last_tick_count = data.tick_count;
|
||||||
@@ -240,5 +289,10 @@ pub async fn run(radar_data: ArcRwlockRadarData, connector: Connector, pcileech_
|
|||||||
thread::sleep(Duration::from_millis(1));
|
thread::sleep(Duration::from_millis(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cleanup_result = money_reveal.ensure_disabled(&mut ctx.process);
|
||||||
|
if let Err(e) = cleanup_result {
|
||||||
|
log::warn!("Failed to cleanup money reveal: {}", e);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ pub struct CsData {
|
|||||||
// Common
|
// Common
|
||||||
pub local: u64,
|
pub local: u64,
|
||||||
pub local_pawn: u64,
|
pub local_pawn: u64,
|
||||||
pub is_dead: bool,
|
// pub is_dead: bool, // TODO: Why is this here?
|
||||||
pub tick_count: i32,
|
pub tick_count: i32,
|
||||||
pub freeze_period: bool,
|
pub freeze_period: bool,
|
||||||
pub round_start_count: u8,
|
pub round_start_count: u8,
|
||||||
@@ -38,6 +38,7 @@ pub struct CsData {
|
|||||||
pub bomb_defuse_length: f32,
|
pub bomb_defuse_length: f32,
|
||||||
pub bomb_exploded: bool,
|
pub bomb_exploded: bool,
|
||||||
pub bomb_defused: bool,
|
pub bomb_defused: bool,
|
||||||
|
pub money_reveal_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -104,10 +105,12 @@ impl CsData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if self.bomb_planted {
|
} else if self.bomb_planted {
|
||||||
let bomb = ctx.get_plantedc4()
|
match ctx.get_plantedc4() {
|
||||||
.expect("Failed to get planted bomb");
|
Ok(bomb) => self.bomb = bomb,
|
||||||
|
Err(e) => {
|
||||||
self.bomb = bomb;
|
log::warn!("Failed to get planted bomb: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +172,7 @@ impl CsData {
|
|||||||
{
|
{
|
||||||
// Globals
|
// Globals
|
||||||
let tick_count_addr = (self.globals + 0x40).into();
|
let tick_count_addr = (self.globals + 0x40).into();
|
||||||
let map_addr = (self.globals + 0x188).into();
|
let map_addr = (self.globals + 384).into();
|
||||||
|
|
||||||
// Gamerules
|
// Gamerules
|
||||||
let bomb_dropped_addr = (self.gamerules + cs2dumper::client::C_CSGameRules::m_bBombDropped as u64).into();
|
let bomb_dropped_addr = (self.gamerules + cs2dumper::client::C_CSGameRules::m_bBombDropped as u64).into();
|
||||||
@@ -178,7 +181,7 @@ impl CsData {
|
|||||||
let round_start_count_addr = (self.gamerules + cs2dumper::client::C_CSGameRules::m_nRoundStartCount as u64).into();
|
let round_start_count_addr = (self.gamerules + cs2dumper::client::C_CSGameRules::m_nRoundStartCount as u64).into();
|
||||||
|
|
||||||
// Game Entity System
|
// Game Entity System
|
||||||
let highest_index_addr = (self.game_ent_sys + cs2dumper::offsets::client_dll::dwGameEntitySystem_getHighestEntityIndex as u64).into();
|
let highest_index_addr = (self.game_ent_sys + cs2dumper::offsets::client_dll::dwGameEntitySystem_highestEntityIndex as u64).into();
|
||||||
|
|
||||||
let mut batcher = ctx.process.batcher();
|
let mut batcher = ctx.process.batcher();
|
||||||
batcher.read_into(
|
batcher.read_into(
|
||||||
@@ -237,7 +240,7 @@ impl CsData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let map_string = ctx.process.read_char_string_n(map_ptr.into(), 32).unwrap_or(String::from("<empty>"));
|
let map_string = ctx.process.read_utf8_lossy(map_ptr.into(), 32).unwrap_or(String::from("<empty>"));
|
||||||
|
|
||||||
self.map = map_string;
|
self.map = map_string;
|
||||||
self.bomb_dropped = bomb_dropped != 0;
|
self.bomb_dropped = bomb_dropped != 0;
|
||||||
|
|||||||
15
src/main.rs
15
src/main.rs
@@ -13,6 +13,9 @@ mod comms;
|
|||||||
mod dma;
|
mod dma;
|
||||||
mod websocket;
|
mod websocket;
|
||||||
|
|
||||||
|
mod pattern;
|
||||||
|
mod money_reveal;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let cli: Cli = Cli::parse();
|
let cli: Cli = Cli::parse();
|
||||||
@@ -29,6 +32,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let radar_clone = radar_data.clone();
|
let radar_clone = radar_data.clone();
|
||||||
|
|
||||||
let dma_handle = tokio::spawn(async move {
|
let dma_handle = tokio::spawn(async move {
|
||||||
if let Err(err) = dma::run(radar_clone, cli.connector, cli.pcileech_device, cli.skip_version).await {
|
if let Err(err) = dma::run(radar_clone, cli.connector, cli.pcileech_device, cli.skip_version).await {
|
||||||
log::error!("Error in dma thread: [{}]", err.to_string());
|
log::error!("Error in dma thread: [{}]", err.to_string());
|
||||||
@@ -37,20 +41,23 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let web_path = cli.web_path.clone();
|
||||||
|
let port = cli.port;
|
||||||
|
|
||||||
let _websocket_handle = tokio::spawn(async move {
|
let _websocket_handle = tokio::spawn(async move {
|
||||||
if let Ok(my_local_ip) = local_ip_address::local_ip() {
|
if let Ok(my_local_ip) = local_ip_address::local_ip() {
|
||||||
let address = format!("http://{}:{}", my_local_ip, cli.port);
|
let address = format!("http://{}:{}", my_local_ip, port);
|
||||||
println!("Launched webserver at {}", address);
|
println!("Launched webserver at {}", address);
|
||||||
} else {
|
} else {
|
||||||
let address = format!("http://0.0.0.0:{}", cli.port);
|
let address = format!("http://0.0.0.0:{}", port);
|
||||||
println!("launched webserver at {}", address);
|
println!("launched webserver at {}", address);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = websocket::run(cli.web_path, cli.port, radar_data).await {
|
if let Err(err) = websocket::run(web_path, port, radar_data).await {
|
||||||
log::error!("Error in ws server: [{}]", err.to_string());
|
log::error!("Error in ws server: [{}]", err.to_string());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dma_handle.await?;
|
dma_handle.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
96
src/money_reveal.rs
Normal file
96
src/money_reveal.rs
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
use memflow::{mem::MemoryView, types::Address, os::ModuleInfo};
|
||||||
|
use crate::pattern::pattern_scan;
|
||||||
|
|
||||||
|
const BUF_SIZE: usize = 3;
|
||||||
|
|
||||||
|
pub struct MoneyReveal {
|
||||||
|
pub is_enabled: bool,
|
||||||
|
pub address: Option<Address>,
|
||||||
|
original_bytes: Option<[u8; BUF_SIZE]>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MoneyReveal {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
is_enabled: false,
|
||||||
|
address: None,
|
||||||
|
original_bytes: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init(&mut self, mem: &mut impl MemoryView, client_module: &ModuleInfo) -> anyhow::Result<()> {
|
||||||
|
self.address = self.find_function(mem, client_module)?;
|
||||||
|
log::info!("Money reveal function found at: {:?}", self.address);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggle(&mut self, mem: &mut impl MemoryView) -> anyhow::Result<bool> {
|
||||||
|
if let Some(addr) = self.address {
|
||||||
|
if self.is_enabled {
|
||||||
|
if let Some(original) = self.original_bytes {
|
||||||
|
self.restore(mem, addr, original)?;
|
||||||
|
self.original_bytes = None;
|
||||||
|
self.is_enabled = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let original = self.patch(mem, addr)?;
|
||||||
|
self.original_bytes = Some(original);
|
||||||
|
self.is_enabled = true;
|
||||||
|
}
|
||||||
|
Ok(self.is_enabled)
|
||||||
|
} else {
|
||||||
|
Err(anyhow::anyhow!("Money reveal not initialized"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ensure_disabled(&mut self, mem: &mut impl MemoryView) -> anyhow::Result<()> {
|
||||||
|
if self.is_enabled {
|
||||||
|
if let Some(addr) = self.address {
|
||||||
|
if let Some(original) = self.original_bytes {
|
||||||
|
self.restore(mem, addr, original)?;
|
||||||
|
self.is_enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_function(&self, mem: &mut impl MemoryView, module: &ModuleInfo) -> anyhow::Result<Option<Address>> {
|
||||||
|
let is_hltv = pattern_scan(
|
||||||
|
mem,
|
||||||
|
module,
|
||||||
|
"48 83 EC 28 48 8B 0D ?? ?? ?? ?? 48 8B 01 FF 90 ?? ?? ?? ?? 84 C0 75 0D"
|
||||||
|
)?;
|
||||||
|
|
||||||
|
if is_hltv.is_none() {
|
||||||
|
Ok(pattern_scan(
|
||||||
|
mem,
|
||||||
|
module,
|
||||||
|
"B0 01 C3 28 48 8B 0D ?? ?? ?? ?? 48 8B 01 FF 90 ?? ?? ?? ?? 84 C0 75 0D"
|
||||||
|
)?)
|
||||||
|
} else {
|
||||||
|
Ok(is_hltv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn patch(&self, mem: &mut impl MemoryView, location: Address) -> anyhow::Result<[u8; BUF_SIZE]> {
|
||||||
|
let mut original_buf = [0u8; BUF_SIZE];
|
||||||
|
mem.read_into(location, &mut original_buf)?;
|
||||||
|
|
||||||
|
let new_buf: [u8; BUF_SIZE] = [
|
||||||
|
0xB0, 0x01, // MOV AL,1
|
||||||
|
0xC3 // RET
|
||||||
|
];
|
||||||
|
|
||||||
|
log::debug!("Patching memory for money reveal");
|
||||||
|
mem.write(location, &new_buf)?;
|
||||||
|
|
||||||
|
Ok(original_buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn restore(&self, mem: &mut impl MemoryView, location: Address, original: [u8; BUF_SIZE]) -> anyhow::Result<()> {
|
||||||
|
log::debug!("Restoring memory for money reveal");
|
||||||
|
mem.write(location, &original)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
51
src/pattern.rs
Normal file
51
src/pattern.rs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
use std::io::Read;
|
||||||
|
use log::warn;
|
||||||
|
use memflow::{os::ModuleInfo, mem::MemoryView, types::Address};
|
||||||
|
|
||||||
|
fn pattern_to_bytes(pattern: String) -> Vec<Option<u8>> {
|
||||||
|
pattern.split(' ')
|
||||||
|
.fold(Vec::new(), |mut accum, str| {
|
||||||
|
if str == "??" {
|
||||||
|
accum.push(None);
|
||||||
|
} else {
|
||||||
|
let byte = u8::from_str_radix(str, 16).unwrap();
|
||||||
|
accum.push(Some(byte));
|
||||||
|
}
|
||||||
|
|
||||||
|
accum
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pattern_scan(mem: &mut impl MemoryView, module: &ModuleInfo, sig: &str) -> anyhow::Result<Option<Address>> {
|
||||||
|
let pattern_bytes = pattern_to_bytes(sig.to_owned());
|
||||||
|
let mut cursor = mem.cursor();
|
||||||
|
|
||||||
|
log::debug!("Searching \"{}\" for pattern: \"{}\"", module.name, sig);
|
||||||
|
|
||||||
|
for i in 0..module.size {
|
||||||
|
let mut found = true;
|
||||||
|
cursor.set_address(module.base + i);
|
||||||
|
|
||||||
|
let mut buf = vec![0u8; pattern_bytes.len()];
|
||||||
|
|
||||||
|
if let Err(_) = cursor.read(&mut buf) {
|
||||||
|
warn!("Encountered read error while scanning for pattern");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (idx, byte) in buf.iter().enumerate() {
|
||||||
|
if let Some(pat_byte) = pattern_bytes[idx] {
|
||||||
|
if *byte != pat_byte {
|
||||||
|
found = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
|
return Ok(Some(module.base + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
@@ -25,29 +25,43 @@ async fn ws_handler(ws: WebSocketUpgrade, State(state): State<AppState>) -> Resp
|
|||||||
async fn handle_socket(mut socket: WebSocket, state: AppState) {
|
async fn handle_socket(mut socket: WebSocket, state: AppState) {
|
||||||
while let Some(msg) = socket.recv().await {
|
while let Some(msg) = socket.recv().await {
|
||||||
if let Ok(msg) = msg {
|
if let Ok(msg) = msg {
|
||||||
if msg == Message::Text("requestInfo".to_string()) {
|
if let Ok(text) = msg.to_text() {
|
||||||
let str = {
|
if text == "requestInfo" {
|
||||||
let data = state.data_lock.read().await;
|
let str = {
|
||||||
|
let data = state.data_lock.read().await;
|
||||||
|
|
||||||
match serde_json::to_string(&*data) {
|
match serde_json::to_string(&*data) {
|
||||||
Ok(json) => json,
|
Ok(json) => json,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Could not serialize data into json: {}", e.to_string());
|
log::error!("Could not serialize data into json: {}", e.to_string());
|
||||||
log::error!("Sending \"error\" instead");
|
log::error!("Sending \"error\" instead");
|
||||||
"error".to_string()
|
"error".to_string()
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if socket.send(Message::Text(str)).await.is_err() {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
} else if text == "toggleMoneyReveal" {
|
||||||
|
let new_value = {
|
||||||
|
let mut data = state.data_lock.write().await;
|
||||||
|
data.money_reveal_enabled = !data.money_reveal_enabled;
|
||||||
|
data.money_reveal_enabled
|
||||||
|
};
|
||||||
|
|
||||||
//println!("{str}");
|
let response = serde_json::json!({
|
||||||
|
"action": "toggleMoneyReveal",
|
||||||
|
"status": "success",
|
||||||
|
"enabled": new_value
|
||||||
|
});
|
||||||
|
|
||||||
if socket.send(Message::Text(str)).await.is_err() {
|
if socket.send(Message::Text(response.to_string())).await.is_err() {
|
||||||
// client disconnected
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// client disconnected
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
webradar/assets/image/background.png
Normal file
BIN
webradar/assets/image/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 MiB |
BIN
webradar/assets/image/de_train_radar_psd.png
Executable file
BIN
webradar/assets/image/de_train_radar_psd.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
@@ -3,6 +3,5 @@
|
|||||||
"pos_y": 2887.0,
|
"pos_y": 2887.0,
|
||||||
"scale": 7.0,
|
"scale": 7.0,
|
||||||
"rotate": 0,
|
"rotate": 0,
|
||||||
"zoom": 0.0,
|
"zoom": 0.0
|
||||||
"altitude_split": -495
|
|
||||||
}
|
}
|
||||||
7
webradar/assets/json/de_train.json
Executable file
7
webradar/assets/json/de_train.json
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"pos_x": -2308.0,
|
||||||
|
"pos_y": 2078.0,
|
||||||
|
"scale": 4.082077,
|
||||||
|
"rotate": 0,
|
||||||
|
"zoom": 0.0
|
||||||
|
}
|
||||||
@@ -3,6 +3,5 @@
|
|||||||
"pos_y": 1762.0,
|
"pos_y": 1762.0,
|
||||||
"scale": 4.0,
|
"scale": 4.0,
|
||||||
"rotate": 0,
|
"rotate": 0,
|
||||||
"zoom": 0.0,
|
"zoom": 0.0
|
||||||
"altitude_split": 11700
|
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,18 @@
|
|||||||
<input type="checkbox" onclick="toggleStats()" id="statsCheck" name="stats"/>
|
<input type="checkbox" onclick="toggleStats()" id="statsCheck" name="stats"/>
|
||||||
<label for="statsCheck">Stats</label>
|
<label for="statsCheck">Stats</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" onclick="toggleNames()" id="namesCheck" name="names"/>
|
||||||
|
<label for="namesCheck">Player Names</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" onclick="toggleGuns()" id="gunsCheck" name="guns"/>
|
||||||
|
<label for="gunsCheck">Weapons</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" onclick="toggleMoneyReveal()" id="moneyReveal" name="money"/>
|
||||||
|
<label for="moneyReveal">Money Reveal (DANGEROUS!)</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<canvas id="canvas"></canvas>
|
<canvas id="canvas"></canvas>
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
// Colors
|
// Colors
|
||||||
const localColor = "#109856"
|
const localColor = "#109856"
|
||||||
const localLowerColor = "#064024"
|
|
||||||
const teamColor = "#68a3e5"
|
const teamColor = "#68a3e5"
|
||||||
const teamLowerColor = "#2c4969"
|
|
||||||
const enemyColor = "#ec040b"
|
const enemyColor = "#ec040b"
|
||||||
const enemyLowerColor = "#4f0002"
|
|
||||||
const bombColor = "#eda338"
|
const bombColor = "#eda338"
|
||||||
const textColor = "#d1d1d1"
|
const textColor = "#d1d1d1"
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
shouldZoom = true
|
shouldZoom = false
|
||||||
drawStats = false
|
|
||||||
|
drawStats = true
|
||||||
|
drawNames = true
|
||||||
|
drawGuns = true
|
||||||
|
|
||||||
// Common
|
// Common
|
||||||
canvas = null
|
canvas = null
|
||||||
@@ -31,6 +31,53 @@ zoomSet = false
|
|||||||
safetyBound = 50
|
safetyBound = 50
|
||||||
boundingRect = null
|
boundingRect = null
|
||||||
|
|
||||||
|
// Weapon IDs
|
||||||
|
const weaponIdMap = {
|
||||||
|
1: "DEAGLE",
|
||||||
|
2: "DUALIES",
|
||||||
|
3: "FIVE-SEVEN",
|
||||||
|
4: "GLOCK",
|
||||||
|
7: "AK-47",
|
||||||
|
8: "AUG",
|
||||||
|
9: "AWP",
|
||||||
|
10: "FAMAS",
|
||||||
|
11: "G3SG1",
|
||||||
|
13: "GALIL",
|
||||||
|
14: "M249",
|
||||||
|
16: "M4A4",
|
||||||
|
17: "MAC-10",
|
||||||
|
19: "P90",
|
||||||
|
23: "MP5",
|
||||||
|
24: "UMP",
|
||||||
|
25: "XM1014",
|
||||||
|
26: "BIZON",
|
||||||
|
27: "MAG-7",
|
||||||
|
28: "NEGEV",
|
||||||
|
29: "SAWED-OFF",
|
||||||
|
30: "TEC-9",
|
||||||
|
31: "ZEUS",
|
||||||
|
32: "P2000",
|
||||||
|
33: "MP7",
|
||||||
|
34: "MP9",
|
||||||
|
35: "NOVA",
|
||||||
|
36: "P250",
|
||||||
|
38: "SCAR-20",
|
||||||
|
39: "SG 553",
|
||||||
|
40: "SCOUT",
|
||||||
|
60: "M4A1-S",
|
||||||
|
61: "USP-S",
|
||||||
|
63: "CZ75",
|
||||||
|
64: "REVOLVER",
|
||||||
|
43: "FLASH",
|
||||||
|
44: "HE",
|
||||||
|
45: "SMOKE",
|
||||||
|
46: "MOLOTOV",
|
||||||
|
47: "DECOY",
|
||||||
|
48: "INCENDIARY",
|
||||||
|
49: "C4",
|
||||||
|
0: "KNIFE"
|
||||||
|
};
|
||||||
|
|
||||||
// networking
|
// networking
|
||||||
websocket = null
|
websocket = null
|
||||||
if (location.protocol == 'https:') {
|
if (location.protocol == 'https:') {
|
||||||
@@ -38,11 +85,11 @@ if (location.protocol == 'https:') {
|
|||||||
} else {
|
} else {
|
||||||
websocketAddr = `ws://${window.location.host}/ws`
|
websocketAddr = `ws://${window.location.host}/ws`
|
||||||
}
|
}
|
||||||
websocketAddr = "ws://192.168.0.235:8000/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);
|
||||||
const degreesToRadians = (degrees) => degrees * (Math.PI/180);
|
const degreesToRadians = (degrees) => degrees * (Math.PI / 180);
|
||||||
function makeBoundingRect(x1, y1, x2, y2, aspectRatio) {
|
function makeBoundingRect(x1, y1, x2, y2, aspectRatio) {
|
||||||
const topLeftX = x1;
|
const topLeftX = x1;
|
||||||
const topLeftY = y1;
|
const topLeftY = y1;
|
||||||
@@ -95,7 +142,7 @@ function boundingCoordinates(coordinates, boundingRect) {
|
|||||||
const newX = (coordinates.x - boundingRect.x) / xScale;
|
const newX = (coordinates.x - boundingRect.x) / xScale;
|
||||||
const newY = (coordinates.y - boundingRect.y) / yScale;
|
const newY = (coordinates.y - boundingRect.y) / yScale;
|
||||||
|
|
||||||
return {x: newX, y: newY};
|
return { x: newX, y: newY };
|
||||||
}
|
}
|
||||||
|
|
||||||
function boundingScale(value, boundingRect) {
|
function boundingScale(value, boundingRect) {
|
||||||
@@ -110,7 +157,113 @@ function mapCoordinates(coordinates) {
|
|||||||
offset_x /= map.scale;
|
offset_x /= map.scale;
|
||||||
offset_y /= -map.scale;
|
offset_y /= -map.scale;
|
||||||
|
|
||||||
return {x: offset_x, y: offset_y}
|
return { x: offset_x, y: offset_y }
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPlayerBomb(pos, playerType) {
|
||||||
|
if (!map) return;
|
||||||
|
|
||||||
|
if (zoomSet) {
|
||||||
|
pos = boundingCoordinates(mapCoordinates(pos), boundingRect);
|
||||||
|
textSize = boundingScale(10, boundingRect);
|
||||||
|
} else {
|
||||||
|
pos = mapCoordinates(pos);
|
||||||
|
textSize = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
const textY = pos.y + (drawNames ? (drawGuns ? 50 : 35) : (drawGuns ? 35 : 20));
|
||||||
|
|
||||||
|
ctx.fillStyle = bombColor;
|
||||||
|
|
||||||
|
ctx.font = `${textSize}px Arial`;
|
||||||
|
ctx.textAlign = "center";
|
||||||
|
ctx.textBaseline = "top";
|
||||||
|
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.strokeStyle = "black";
|
||||||
|
ctx.strokeText("[C4]", pos.x, textY);
|
||||||
|
ctx.fillText("[C4]", pos.x, textY);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPlayerName(pos, playerName, playerType, hasAwp, hasBomb, isScoped) {
|
||||||
|
if (!map) return;
|
||||||
|
|
||||||
|
if (zoomSet) {
|
||||||
|
pos = boundingCoordinates(mapCoordinates(pos), boundingRect);
|
||||||
|
textSize = boundingScale(12, boundingRect);
|
||||||
|
} else {
|
||||||
|
pos = mapCoordinates(pos);
|
||||||
|
textSize = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
const textY = pos.y + 20;
|
||||||
|
|
||||||
|
let displayName = playerName;
|
||||||
|
if (playerType === "Local") {
|
||||||
|
displayName = "YOU";
|
||||||
|
ctx.fillStyle = localColor;
|
||||||
|
} else if (playerType === "Team") {
|
||||||
|
ctx.fillStyle = teamColor;
|
||||||
|
} else if (playerType === "Enemy") {
|
||||||
|
ctx.fillStyle = enemyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isScoped) {
|
||||||
|
displayName += " [SCOPED]";
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.font = `${textSize}px Arial`;
|
||||||
|
ctx.textAlign = "center";
|
||||||
|
ctx.textBaseline = "top";
|
||||||
|
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.strokeStyle = "black";
|
||||||
|
ctx.strokeText(displayName, pos.x, textY);
|
||||||
|
|
||||||
|
ctx.fillText(displayName, pos.x, textY);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWeaponName(weaponId) {
|
||||||
|
if (weaponIdMap[weaponId]) {
|
||||||
|
return weaponIdMap[weaponId];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weaponId >= 500) {
|
||||||
|
return "KNIFE";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "WEAPON";
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPlayerWeapon(pos, playerType, weaponId) {
|
||||||
|
if (!map) return;
|
||||||
|
|
||||||
|
if (zoomSet) {
|
||||||
|
pos = boundingCoordinates(mapCoordinates(pos), boundingRect);
|
||||||
|
textSize = boundingScale(10, boundingRect);
|
||||||
|
} else {
|
||||||
|
pos = mapCoordinates(pos);
|
||||||
|
textSize = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
const textY = pos.y + (drawNames ? 35 : 20);
|
||||||
|
|
||||||
|
let weaponName = getWeaponName(weaponId);
|
||||||
|
|
||||||
|
if (weaponId === 9) {
|
||||||
|
ctx.fillStyle = "orange";
|
||||||
|
} else {
|
||||||
|
ctx.fillStyle = textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.font = `${textSize}px Arial`;
|
||||||
|
ctx.textAlign = "center";
|
||||||
|
ctx.textBaseline = "top";
|
||||||
|
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.strokeStyle = "black";
|
||||||
|
ctx.strokeText(`[${weaponName}]`, pos.x, textY);
|
||||||
|
ctx.fillText(`[${weaponName}]`, pos.x, textY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
@@ -135,15 +288,14 @@ function render() {
|
|||||||
} else {
|
} else {
|
||||||
mapCords = mapCoordinates(data.Player.pos)
|
mapCords = mapCoordinates(data.Player.pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
minX = Math.min(minX, mapCords.x);
|
minX = Math.min(minX, mapCords.x);
|
||||||
minY = Math.min(minY, mapCords.y);
|
minY = Math.min(minY, mapCords.y);
|
||||||
maxX = Math.max(maxX, mapCords.x);
|
maxX = Math.max(maxX, mapCords.x);
|
||||||
maxY = Math.max(maxY, mapCords.y);
|
maxY = Math.max(maxY, mapCords.y);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
boundingRect = makeBoundingRect(minX - safetyBound, minY - safetyBound, maxX + safetyBound, maxY + safetyBound, image.width / image.height)
|
||||||
boundingRect = makeBoundingRect(minX-safetyBound, minY-safetyBound, maxX+safetyBound, maxY+safetyBound, image.width/image.height)
|
|
||||||
|
|
||||||
zoomSet = true
|
zoomSet = true
|
||||||
} else if (zoomSet) {
|
} else if (zoomSet) {
|
||||||
@@ -157,42 +309,54 @@ function render() {
|
|||||||
if (data.Bomb !== undefined) {
|
if (data.Bomb !== undefined) {
|
||||||
drawBomb(data.Bomb.pos, data.Bomb.isPlanted)
|
drawBomb(data.Bomb.pos, data.Bomb.isPlanted)
|
||||||
} else {
|
} else {
|
||||||
let fillStyle = localLowerColor
|
let fillStyle = localColor
|
||||||
|
|
||||||
if (map && map.altitude_split && data.Player.pos.z < map.altitude_split) {
|
switch (data.Player.playerType) {
|
||||||
|
case "Team":
|
||||||
|
fillStyle = teamColor
|
||||||
|
break;
|
||||||
|
|
||||||
switch (data.Player.playerType) {
|
case "Enemy":
|
||||||
case "Team":
|
fillStyle = enemyColor
|
||||||
fillStyle = teamLowerColor
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case "Enemy":
|
|
||||||
fillStyle = enemyLowerColor
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fillStyle = localColor
|
|
||||||
switch (data.Player.playerType) {
|
|
||||||
case "Team":
|
|
||||||
fillStyle = teamColor
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Enemy":
|
|
||||||
fillStyle = enemyColor
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawEntity(
|
drawEntity(
|
||||||
data.Player.pos,
|
data.Player.pos,
|
||||||
fillStyle,
|
fillStyle,
|
||||||
data.Player.isDormant,
|
data.Player.isDormant,
|
||||||
data.Player.hasBomb,
|
data.Player.hasBomb,
|
||||||
data.Player.yaw,
|
data.Player.yaw,
|
||||||
data.Player.hasAwp,
|
data.Player.hasAwp,
|
||||||
data.Player.playerType,
|
data.Player.playerType,
|
||||||
data.Player.isScoped
|
data.Player.isScoped
|
||||||
)
|
);
|
||||||
|
|
||||||
|
if (drawNames && !data.Player.isDormant) {
|
||||||
|
drawPlayerName(
|
||||||
|
data.Player.pos,
|
||||||
|
data.Player.playerName,
|
||||||
|
data.Player.playerType,
|
||||||
|
data.Player.hasAwp,
|
||||||
|
data.Player.hasBomb,
|
||||||
|
data.Player.isScoped
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawGuns && !data.Player.isDormant) {
|
||||||
|
drawPlayerWeapon(
|
||||||
|
data.Player.pos,
|
||||||
|
data.Player.playerType,
|
||||||
|
data.Player.weaponId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.Player.hasBomb && !data.Player.isDormant) {
|
||||||
|
drawPlayerBomb(
|
||||||
|
data.Player.pos,
|
||||||
|
data.Player.playerType
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -200,13 +364,13 @@ function render() {
|
|||||||
if (radarData != null) {
|
if (radarData != null) {
|
||||||
if (radarData.bombPlanted && !radarData.bombExploded && radarData.bombDefuseTimeleft >= 0) {
|
if (radarData.bombPlanted && !radarData.bombExploded && radarData.bombDefuseTimeleft >= 0) {
|
||||||
|
|
||||||
let maxWidth = 1024-128-128;
|
let maxWidth = 1024 - 128 - 128;
|
||||||
let timeleft = radarData.bombDefuseTimeleft;
|
let timeleft = radarData.bombDefuseTimeleft;
|
||||||
|
|
||||||
// Base bar
|
// Base bar
|
||||||
ctx.fillStyle = "black"
|
ctx.fillStyle = "black"
|
||||||
ctx.fillRect(128, 16, maxWidth, 16)
|
ctx.fillRect(128, 16, maxWidth, 16)
|
||||||
|
|
||||||
// Bomb timer
|
// Bomb timer
|
||||||
if (radarData.bombBeingDefused) {
|
if (radarData.bombBeingDefused) {
|
||||||
if (radarData.bombCanDefuse) {
|
if (radarData.bombCanDefuse) {
|
||||||
@@ -218,14 +382,14 @@ function render() {
|
|||||||
ctx.fillStyle = bombColor
|
ctx.fillStyle = bombColor
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.fillRect(130, 18, (maxWidth-2) * (timeleft / 40), 12)
|
ctx.fillRect(130, 18, (maxWidth - 2) * (timeleft / 40), 12)
|
||||||
|
|
||||||
ctx.font = "24px Arial";
|
ctx.font = "24px Arial";
|
||||||
ctx.textAlign = "center"
|
ctx.textAlign = "center"
|
||||||
ctx.textBaseline = "middle"
|
ctx.textBaseline = "middle"
|
||||||
ctx.fillStyle = textColor
|
ctx.fillStyle = textColor
|
||||||
ctx.fillText(`${timeleft.toFixed(1)}s`, 1024/2, 28+24);
|
ctx.fillText(`${timeleft.toFixed(1)}s`, 1024 / 2, 28 + 24);
|
||||||
|
|
||||||
// Defuse time lines
|
// Defuse time lines
|
||||||
ctx.strokeStyle = "black"
|
ctx.strokeStyle = "black"
|
||||||
ctx.lineWidth = 2
|
ctx.lineWidth = 2
|
||||||
@@ -238,8 +402,8 @@ function render() {
|
|||||||
|
|
||||||
// Normal defuse
|
// Normal defuse
|
||||||
ctx.beginPath()
|
ctx.beginPath()
|
||||||
ctx.moveTo(130 + (maxWidth-2) * (10 / 40), 16)
|
ctx.moveTo(130 + (maxWidth - 2) * (10 / 40), 16)
|
||||||
ctx.lineTo(130 + (maxWidth-2) * (10 / 40), 32)
|
ctx.lineTo(130 + (maxWidth - 2) * (10 / 40), 32)
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
|
|
||||||
// Defuse stamp line
|
// Defuse stamp line
|
||||||
@@ -247,8 +411,8 @@ function render() {
|
|||||||
console.log(radarData.bombDefuseEnd)
|
console.log(radarData.bombDefuseEnd)
|
||||||
ctx.strokeStyle = "green"
|
ctx.strokeStyle = "green"
|
||||||
ctx.beginPath()
|
ctx.beginPath()
|
||||||
ctx.moveTo(130 + (maxWidth-2) * (radarData.bombDefuseEnd / 40), 16)
|
ctx.moveTo(130 + (maxWidth - 2) * (radarData.bombDefuseEnd / 40), 16)
|
||||||
ctx.lineTo(130 + (maxWidth-2) * (radarData.bombDefuseEnd / 40), 32)
|
ctx.lineTo(130 + (maxWidth - 2) * (radarData.bombDefuseEnd / 40), 32)
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,12 +424,12 @@ function render() {
|
|||||||
ctx.textAlign = "center"
|
ctx.textAlign = "center"
|
||||||
ctx.textBaseline = "middle"
|
ctx.textBaseline = "middle"
|
||||||
ctx.fillStyle = textColor
|
ctx.fillStyle = textColor
|
||||||
ctx.fillText("Not on a server", 1024/2, 1024/2);
|
ctx.fillText("Not on a server", 1024 / 2, 1024 / 2);
|
||||||
} else {
|
} else {
|
||||||
ctx.font = "100px Arial";
|
ctx.font = "100px Arial";
|
||||||
ctx.textAlign = "center"
|
ctx.textAlign = "center"
|
||||||
ctx.fillStyle = textColor
|
ctx.fillStyle = textColor
|
||||||
ctx.fillText("Disconnected", 1024/2, 1024/2);
|
ctx.fillText("Disconnected", 1024 / 2, 1024 / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,26 +471,39 @@ function drawBomb(pos, planted) {
|
|||||||
|
|
||||||
if (zoomSet) {
|
if (zoomSet) {
|
||||||
pos = boundingCoordinates(mapCoordinates(pos), boundingRect)
|
pos = boundingCoordinates(mapCoordinates(pos), boundingRect)
|
||||||
size = boundingScale(5, boundingRect);
|
size = boundingScale(8, boundingRect);
|
||||||
} else {
|
} else {
|
||||||
pos = mapCoordinates(pos)
|
pos = mapCoordinates(pos)
|
||||||
size = 5
|
size = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(pos.x, pos.y, size, 0, 2 * Math.PI);
|
ctx.arc(pos.x, pos.y, size, 0, 2 * Math.PI);
|
||||||
ctx.fillStyle = bombColor;
|
ctx.fillStyle = bombColor;
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.strokeStyle = "black";
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
ctx.font = size * 1.2 + "px Arial";
|
||||||
|
ctx.textAlign = "center";
|
||||||
|
ctx.textBaseline = "middle";
|
||||||
|
ctx.fillStyle = "white";
|
||||||
|
ctx.fillText("C4", pos.x, pos.y);
|
||||||
|
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
|
|
||||||
if (planted && ((new Date().getTime() / 1000) % 1) > 0.5) {
|
if (planted && ((new Date().getTime() / 1000) % 1) > 0.5) {
|
||||||
ctx.strokeStyle = enemyColor
|
ctx.strokeStyle = enemyColor
|
||||||
ctx.lineWidth = 1;
|
ctx.lineWidth = 3;
|
||||||
ctx.stroke()
|
ctx.beginPath();
|
||||||
|
ctx.arc(pos.x, pos.y, size + 4, 0, 2 * Math.PI);
|
||||||
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, isScoped) {
|
function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, isScoped, playerName) {
|
||||||
if (map == null)
|
if (map == null)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -348,7 +525,7 @@ function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, i
|
|||||||
ctx.font = "20px Arial";
|
ctx.font = "20px Arial";
|
||||||
ctx.textAlign = "center"
|
ctx.textAlign = "center"
|
||||||
ctx.fillStyle = fillStyle
|
ctx.fillStyle = fillStyle
|
||||||
ctx.fillText("?", pos.x, pos.y);
|
ctx.fillText("?", pos.x, pos.y);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (hasAwp) {
|
if (hasAwp) {
|
||||||
@@ -379,14 +556,6 @@ function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, i
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasBomb) {
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(pos.x, pos.y, circleRadius / 2, 0, 2 * Math.PI);
|
|
||||||
ctx.fillStyle = bombColor;
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
|
|
||||||
// Calculate arrowhead points
|
// Calculate arrowhead points
|
||||||
@@ -402,9 +571,9 @@ function drawEntity(pos, fillStyle, dormant, hasBomb, yaw, hasAwp, playerType, i
|
|||||||
const arrowCornerY2 = pos.y - distance * Math.sin((yaw + arrowWidth) * (Math.PI / 180))
|
const arrowCornerY2 = pos.y - distance * Math.sin((yaw + arrowWidth) * (Math.PI / 180))
|
||||||
|
|
||||||
|
|
||||||
const cicleYaw = 90-yaw
|
const cicleYaw = 90 - yaw
|
||||||
const startAngle = degreesToRadians(cicleYaw-arrowWidth)-Math.PI/2
|
const startAngle = degreesToRadians(cicleYaw - arrowWidth) - Math.PI / 2
|
||||||
const endAngle = degreesToRadians(cicleYaw+arrowWidth)-Math.PI/2
|
const endAngle = degreesToRadians(cicleYaw + arrowWidth) - Math.PI / 2
|
||||||
|
|
||||||
// Draw arrow
|
// Draw arrow
|
||||||
|
|
||||||
@@ -478,36 +647,44 @@ function connect() {
|
|||||||
console.log("[radarflow] Connection established")
|
console.log("[radarflow] Connection established")
|
||||||
websocket.send("requestInfo");
|
websocket.send("requestInfo");
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onmessage = (event) => {
|
socket.onmessage = (event) => {
|
||||||
if (event.data == "error") {
|
if (event.data == "error") {
|
||||||
console.log("[radarflow] Server had an unknown error")
|
console.log("[radarflow] Server had an unknown error")
|
||||||
} else {
|
} else {
|
||||||
let data = JSON.parse(event.data);
|
try {
|
||||||
radarData = data;
|
let data = JSON.parse(event.data);
|
||||||
freq = data.freq;
|
radarData = data;
|
||||||
|
freq = data.freq;
|
||||||
|
|
||||||
if (data.ingame == false) {
|
if (data.money_reveal_enabled !== undefined) {
|
||||||
mapName = null
|
document.getElementById("moneyReveal").checked = data.money_reveal_enabled;
|
||||||
entityData = null
|
|
||||||
|
|
||||||
if (loaded)
|
|
||||||
unloadMap()
|
|
||||||
} else {
|
|
||||||
if (!loaded) {
|
|
||||||
mapName = data.mapName
|
|
||||||
entityData = data.entityData
|
|
||||||
loadMap(mapName)
|
|
||||||
} else {
|
|
||||||
entityData = data.entityData
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
update = true
|
if (data.ingame == false) {
|
||||||
requestAnimationFrame(render);
|
mapName = null
|
||||||
|
entityData = null
|
||||||
|
|
||||||
|
if (loaded)
|
||||||
|
unloadMap()
|
||||||
|
} else {
|
||||||
|
if (!loaded) {
|
||||||
|
mapName = data.mapName
|
||||||
|
entityData = data.entityData
|
||||||
|
loadMap(mapName)
|
||||||
|
} else {
|
||||||
|
entityData = data.entityData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update = true
|
||||||
|
requestAnimationFrame(render);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("[radarflow] Error parsing server message:", e, event.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onclose = (event) => {
|
socket.onclose = (event) => {
|
||||||
if (event.wasClean) {
|
if (event.wasClean) {
|
||||||
console.log("[radarflow] connection closed");
|
console.log("[radarflow] connection closed");
|
||||||
@@ -519,11 +696,11 @@ function connect() {
|
|||||||
websocket = null
|
websocket = null
|
||||||
unloadMap()
|
unloadMap()
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
connect();
|
connect();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.onerror = (error) => {
|
socket.onerror = (error) => {
|
||||||
console.log(`[radarflow] websocket error: ${error}`);
|
console.log(`[radarflow] websocket error: ${error}`);
|
||||||
};
|
};
|
||||||
@@ -537,8 +714,11 @@ function connect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addEventListener("DOMContentLoaded", (e) => {
|
addEventListener("DOMContentLoaded", (e) => {
|
||||||
document.getElementById("zoomCheck").checked = true;
|
document.getElementById("zoomCheck").checked = false;
|
||||||
|
document.getElementById("statsCheck").checked = true;
|
||||||
|
document.getElementById("namesCheck").checked = true;
|
||||||
|
document.getElementById("gunsCheck").checked = true;
|
||||||
|
document.getElementById("moneyReveal").checked = false;
|
||||||
|
|
||||||
canvas = document.getElementById('canvas');
|
canvas = document.getElementById('canvas');
|
||||||
canvas.width = 1024;
|
canvas.width = 1024;
|
||||||
@@ -556,4 +736,18 @@ function toggleZoom() {
|
|||||||
|
|
||||||
function toggleStats() {
|
function toggleStats() {
|
||||||
drawStats = !drawStats
|
drawStats = !drawStats
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleNames() {
|
||||||
|
drawNames = !drawNames
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleGuns() {
|
||||||
|
drawGuns = !drawGuns
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleMoneyReveal() {
|
||||||
|
if (websocket && websocket.readyState === WebSocket.OPEN) {
|
||||||
|
websocket.send("toggleMoneyReveal");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,9 @@ body {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: #000000; /* Change the background color as needed */
|
background-color: #000000; /* Change the background color as needed */
|
||||||
|
background-image: url('assets/image/background.png');
|
||||||
|
background-repeat: repeat;
|
||||||
|
background-size: 128px 128px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#canvasContainer {
|
#canvasContainer {
|
||||||
@@ -23,12 +26,27 @@ canvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#settingsHolder {
|
#settingsHolder {
|
||||||
visibility: hidden;
|
visibility: visible;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: inherit;
|
top: 50%;
|
||||||
left: inherit;
|
left: 0;
|
||||||
width: inherit;
|
transform: translateY(-50%);
|
||||||
height: 20%;
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settingsHolder .settings {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
color: white;
|
||||||
|
visibility: visible;
|
||||||
|
opacity: 0.8;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: rgba(25, 25, 25, 0.7);
|
||||||
|
border-radius: 5px;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
#settingsHolder:hover .settings {
|
#settingsHolder:hover .settings {
|
||||||
|
|||||||
Reference in New Issue
Block a user