Skip to content

Commit

Permalink
improve error printing, in-game detection, enter to exit
Browse files Browse the repository at this point in the history
  • Loading branch information
IceDynamix committed Mar 15, 2024
1 parent 3f24a94 commit b293724
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 8 deletions.
105 changes: 105 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license = "MIT"
[dependencies]
base64 = "0.22.0"
clap = { version = "4.5.2", features = ["derive"] }
color-eyre = "0.6.3"
pcap = "1.2.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
Expand All @@ -18,4 +19,4 @@ ureq = { version = "2.9.6", features = ["json"] }

[dependencies.reliquary]
git = "https://github.com/IceDynamix/reliquary"
tag = "v0.1.0"
tag = "v0.1.0"
20 changes: 13 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ fn main() {
)
.init();

color_eyre::install().unwrap();

let args = Args::parse();
debug!(?args);

Expand All @@ -53,6 +55,9 @@ fn main() {
serde_json::to_writer_pretty(&file, &export).unwrap();
info!("wrote output to {}", &args.output.display());
}

info!("press enter to close");
std::io::stdin().read_line(&mut String::new()).unwrap();
}

#[instrument(skip_all)]
Expand All @@ -72,8 +77,8 @@ fn file_capture<E>(args: &Args, mut exporter: E, mut sniffer: GameSniffer) -> Op
if commands.is_empty() {
invalid += 1;

if invalid >= 10 {
error!("received 10 packets that could not be segmented");
if invalid >= 50 {
error!("received 50 packets that could not be segmented");
warn!("you probably started capturing when you were already in-game");
warn!("the capture needs to start on the main menu screen before hyperdrive");
return None;
Expand Down Expand Up @@ -115,6 +120,7 @@ fn live_capture<E>(args: &Args, mut exporter: E, mut sniffer: GameSniffer) -> Op
}

let mut invalid = 0;
let mut warning_sent = false;

info!("instructions: go to main menu screen and go into train hyperdrive");
info!("listening with a timeout of {} seconds...", args.timeout);
Expand All @@ -126,14 +132,14 @@ fn live_capture<E>(args: &Args, mut exporter: E, mut sniffer: GameSniffer) -> Op
if commands.is_empty() {
invalid += 1;

if invalid >= 10 {
error!("received a large number of packets that could not be segmented");
if invalid >= 25 && !warning_sent {
error!("received a large number of packets that could not be parsed");
warn!("you probably started capturing when you were already in-game");
warn!("please go to the main menu screen and re-enter the game");
invalid = -50;
warn!("please log out and log back in");
warning_sent = true;
}
} else {
invalid -= 1;
invalid -= 10;

for command in commands {
exporter.read_command(command);
Expand Down

0 comments on commit b293724

Please sign in to comment.