Skip to content

Commit

Permalink
fix!: Use cfg to ignore files for specific builds
Browse files Browse the repository at this point in the history
  • Loading branch information
PraxTube committed Jan 10, 2024
1 parent e422b16 commit 5e7a48f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/ui/leaderboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const HOST: &str = "rancic.org";
const PORT: &str = "3434";
const LEADERBOARD_COUNT: usize = 7;

#[derive(Default)]
struct LeaderboardEntry {
name: String,
score: String,
Expand Down
23 changes: 17 additions & 6 deletions src/ui/leaderboard/request/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[cfg(not(target_arch = "wasm32"))]
mod request_desktop;
#[cfg(target_arch = "wasm32")]
mod request_wasm;

use bevy::prelude::*;
Expand Down Expand Up @@ -64,12 +66,21 @@ fn string_to_leaderboard(s: &str) -> LeaderboardData {
let mut result = Vec::new();
for row in rows {
let values: Vec<&str> = row.split(',').collect();
result.push(LeaderboardEntry {
name: values[0].to_string(),
score: values[1].to_string(),
kills: values[2].to_string(),
time: format_time(values[3].parse().unwrap_or_default()),
});
let entry = if values.len() != 4 {
error!(
"The leaderboard entry doesn't have exaclty 4 entries, {:?}",
values
);
LeaderboardEntry::default()
} else {
LeaderboardEntry {
name: values[0].to_string(),
score: values[1].to_string(),
kills: values[2].to_string(),
time: format_time(values[3].parse().unwrap_or_default()),
}
};
result.push(entry);
}
LeaderboardData(result)
}
Expand Down
2 changes: 2 additions & 0 deletions src/ui/leaderboard/request/request_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn post_request(request: &str) -> String {
println!("Response:\n{}", response);
response
} else {
error!("Failed to connect to the server");
"Failed to connect to the server".to_string()
}
}
Expand Down Expand Up @@ -67,6 +68,7 @@ fn get_request(request: &str) -> String {

response
} else {
error!("Failed to connect to the server");
"Failed to connect to the server".to_string()
}
}
Expand Down
1 change: 1 addition & 0 deletions src/world/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use bevy::prelude::*;
use bevy::render::camera::ScalingMode;
#[cfg(not(target_arch = "wasm32"))]
use bevy::render::view::screenshot::ScreenshotManager;
#[cfg(not(target_arch = "wasm32"))]
use bevy::window::{PrimaryWindow, WindowMode};
use bevy_kira_audio::prelude::AudioReceiver;
use bevy_rapier2d::dynamics::Velocity;
Expand Down

0 comments on commit 5e7a48f

Please sign in to comment.