Skip to content

Commit

Permalink
add extra debug messages (will continue testing on another machine)
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Oct 23, 2024
1 parent 8af5f90 commit e65c157
Show file tree
Hide file tree
Showing 8 changed files with 526 additions and 298 deletions.
708 changes: 440 additions & 268 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ default-run = "bf-seeder"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rust-ini = "0.18"
serde = "1.0.152"
serde_derive = "1.0.152"
confy = "0.5.1"
winproc = "0.6.4"
winapi = { version = "0.3.9", features = ["winuser"] }
ureq = { version = "2.6.2", features = ["json"] }
rust-ini = "0.21"
serde = "1.0"
serde_derive = "1.0"
confy = "0.6"
winproc = "0.6"
winapi = { version = "0.3", features = ["winuser"] }
ureq = { version = "2.6", features = ["json"] }
chrono = "*"
hostname = "^0.3"
system_shutdown = "4.0.1"
urlencoding = "2.1.2"
directories = "4.0"
hostname = "^0.4"
system_shutdown = "4.0"
urlencoding = "2.1"
directories = "5.0"
regex = "1"
registry = "1.2.2"
registry = "1.2"
log = "0.4"
env_logger = "0.10.0"
env_logger = "0.11"

[[bin]]
name = "bf-seeder"
Expand All @@ -40,4 +40,8 @@ path = "src/ea_desktop_test.rs"

[[bin]]
name = "steam_test"
path = "src/steam_test.rs"
path = "src/steam_test.rs"

[[bin]]
name = "message_test"
path = "src/message_test.rs"
18 changes: 9 additions & 9 deletions config.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
group_id = 'aac4c3fa-8a72-11ec-80d7-0a58a9feac02'
game_location = 'E:\Program Files\Origin Games\Battlefield 1\bf1.exe'
game_location = 'C:\Program Files (x86)\Steam\steamapps\common\Battlefield 1\bf1.exe'
link2ea_location = 'C:\Program Files\Electronic Arts\EA Desktop\EA Desktop\Link2EA.exe'
hostname = 'WIN-IB228OQ723N'
hostname = "JOBSE-PC"
allow_shutdown = false
send_messages = false
usable_client = true
fullscreen_anti_afk = true
message = 'Join our discord, we are recruiting: ...'
message_server_name = ''
message_start_time_utc = '12:00'
message_stop_time_utc = '23:00'
message = "Join our discord, we are recruiting: ..."
message_server_name = ""
message_start_time_utc = "12:00"
message_stop_time_utc = "23:00"
message_timeout_mins = 8
game = 'Bf1'
launcher = 'EADesktop'
endpoint = 'https://manager-api.gametools.network'
game = "Bf1"
launcher = "Steam"
endpoint = "https://manager-api.gametools.network"
3 changes: 2 additions & 1 deletion src/actions/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn anti_afk(cfg: &structs::SeederConfig) {
let game_info = is_running(cfg);
if game_info.is_running {
minimize(&game_info);
// check minimized here??
log::debug!("Running anti-afk script...");
unsafe {
let current_forground_window = GetForegroundWindow();
let l_param = make_l_param(20, 20);
Expand All @@ -108,6 +108,7 @@ fn make_l_param(lo_word: i32, hi_word: i32) -> i32 {

pub fn send_message(to_send: String, cfg: &structs::SeederConfig) {
let game_info = is_running(cfg);
log::debug!("Sending message: {}", to_send);
if game_info.is_running {
unsafe {
SetForegroundWindow(game_info.game_process);
Expand Down
2 changes: 1 addition & 1 deletion src/ea_desktop_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
message_timeout_mins: 8,
game: structs::Games::from("bf1"),
launcher: structs::Launchers::from("ea_desktop"),
endpoint: "https://manager-api.gametools.network".into()
endpoint: "https://manager-api.gametools.network".into(),
};
cfg.game_location = actions::game::find_game(&cfg);
cfg.link2ea_location = actions::launchers::find_link2ea();
Expand Down
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@ mod input;
mod structs;

fn main() {
Builder::new()
let mut builder = Builder::from_default_env();

builder
.format(|buf, record| {
writeln!(
buf,
"{} [{}] - {}",
"{} >> {} [{}] {}",
Local::now().format("%Y-%m-%dT%H:%M:%S"),
record.module_path().unwrap_or_default(),
record.level(),
record.args()
)
})
.filter(None, LevelFilter::Info)
// no need to debug api requests by default
.filter(Some("rustls"), LevelFilter::Info)
.filter(Some("ureq"), LevelFilter::Info)
.init();
log::debug!("Running in debug mode!");

// game_running based on api, 0 == leaving servers. 1 means joining servers.
let game_running = Arc::new(atomic::AtomicU32::new(0));
Expand Down
43 changes: 43 additions & 0 deletions src/message_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use std::sync::{atomic, Arc};

use winapi::um::winuser::CF_DIB;
mod actions;
mod functions;
mod input;
mod structs;

fn main() {
let mut cfg = structs::SeederConfig {
hostname: hostname::get().unwrap().into_string().unwrap(),
group_id: "".into(),
game_location: "".into(),
link2ea_location: "".into(),
allow_shutdown: false,
send_messages: true,
usable_client: true,
fullscreen_anti_afk: true,
message: "test".into(),
message_server_name: "".into(),
message_start_time_utc: "12:00".into(),
message_stop_time_utc: "23:00".into(),
message_timeout_mins: 2,
game: structs::Games::from("bf1"),
launcher: structs::Launchers::from("steam"),
endpoint: "https://manager-api.gametools.network".into(),
};
let message_running = Arc::new(atomic::AtomicU32::new(1));

cfg.game_location = actions::game::find_game(&cfg);
cfg.link2ea_location = actions::launchers::find_link2ea();
let game_running = Arc::new(atomic::AtomicU32::new(0));
let message_timeout = Arc::new(atomic::AtomicU32::new(10));
let current_message_id = Arc::new(atomic::AtomicU32::new(0));

functions::anti_afk::start(
&cfg,
&game_running,
&message_running,
&message_timeout,
&current_message_id,
)
}
6 changes: 4 additions & 2 deletions src/steam_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ fn main() {
message_timeout_mins: 8,
game: structs::Games::from("bf1"),
launcher: structs::Launchers::from("steam"),
endpoint: "https://manager-api.gametools.network".into()
endpoint: "https://manager-api.gametools.network".into(),
};
cfg.game_location = actions::game::find_game(&cfg);
cfg.link2ea_location = actions::launchers::find_link2ea();
log::info!("{}", cfg.link2ea_location);
log::info!("{}", cfg.game_location);

actions::launchers::launch_game_steam(&cfg, "8189927460830", "soldier");
actions::launchers::launch_game_steam(&cfg, "9654489130726", "soldier");
}

0 comments on commit e65c157

Please sign in to comment.