867 lines
20 KiB
Rust
867 lines
20 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Runway {
|
|
pub len: f64,
|
|
#[serde(default)]
|
|
pub hard: bool,
|
|
#[serde(default)]
|
|
pub water: bool,
|
|
#[serde(default)]
|
|
pub hdg: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Farm {
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default)]
|
|
pub hdg: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Beach {
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default)]
|
|
pub hdg: f64,
|
|
#[serde(default)]
|
|
pub len: f64,
|
|
#[serde(default)]
|
|
pub sea: i32,
|
|
#[serde(default)]
|
|
pub name: String,
|
|
#[serde(default)]
|
|
pub elev: f64,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum PadKind {
|
|
Hospital,
|
|
City,
|
|
Remote,
|
|
Rig,
|
|
Ship,
|
|
}
|
|
|
|
impl PadKind {
|
|
pub const ALL: [PadKind; 5] = [
|
|
PadKind::Hospital,
|
|
PadKind::City,
|
|
PadKind::Remote,
|
|
PadKind::Rig,
|
|
PadKind::Ship,
|
|
];
|
|
|
|
pub const SLING_ORDER: [PadKind; 4] = [
|
|
PadKind::Remote,
|
|
PadKind::Rig,
|
|
PadKind::Ship,
|
|
PadKind::City,
|
|
];
|
|
|
|
#[inline]
|
|
pub fn attempts(self) -> usize {
|
|
match self {
|
|
PadKind::Hospital => 2,
|
|
PadKind::City => 1,
|
|
PadKind::Remote => 2,
|
|
PadKind::Rig => 2,
|
|
PadKind::Ship => 1,
|
|
}
|
|
}
|
|
|
|
#[inline]
|
|
pub fn gate(self) -> f64 {
|
|
match self {
|
|
PadKind::Hospital => 0.85,
|
|
PadKind::Rig | PadKind::Ship => 0.75,
|
|
PadKind::City | PadKind::Remote => 0.60,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Pad {
|
|
pub kind: PadKind,
|
|
#[serde(default)]
|
|
pub deck: f64,
|
|
#[serde(default)]
|
|
pub hdg: f64,
|
|
#[serde(default)]
|
|
pub small: bool,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct SeaDock {
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default)]
|
|
pub hdg: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct SeaBase {
|
|
pub dock: SeaDock,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Airport {
|
|
pub code: String,
|
|
#[serde(default)]
|
|
pub name: String,
|
|
#[serde(default)]
|
|
pub city: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default)]
|
|
pub elev: f64, // metres
|
|
/// 0 hub, 1 regional, 2 airstrip
|
|
#[serde(default = "default_size")]
|
|
pub size: u8,
|
|
#[serde(default)]
|
|
pub sched: bool,
|
|
#[serde(default)]
|
|
pub country: String,
|
|
#[serde(default)]
|
|
pub longest: f64, // metres
|
|
#[serde(default)]
|
|
pub rw: Vec<Runway>,
|
|
#[serde(default)]
|
|
pub farm: Option<Farm>,
|
|
#[serde(default)]
|
|
pub beach: Option<Beach>,
|
|
#[serde(default)]
|
|
pub pad: Option<Pad>,
|
|
#[serde(default)]
|
|
pub sea: Option<SeaBase>,
|
|
#[serde(default)]
|
|
pub marine: bool,
|
|
}
|
|
|
|
fn default_size() -> u8 {
|
|
2
|
|
}
|
|
|
|
impl Airport {
|
|
#[inline]
|
|
pub fn longest_hard_m(&self) -> f64 {
|
|
let mut best = 0.0f64;
|
|
for r in &self.rw {
|
|
if r.hard && !r.water && r.len > best {
|
|
best = r.len;
|
|
}
|
|
}
|
|
best
|
|
}
|
|
|
|
#[inline]
|
|
pub fn longest_land_m(&self) -> f64 {
|
|
let mut best = 0.0f64;
|
|
for r in &self.rw {
|
|
if !r.water && r.len > best {
|
|
best = r.len;
|
|
}
|
|
}
|
|
if best > 0.0 { best } else { self.longest }
|
|
}
|
|
|
|
#[inline]
|
|
pub fn has_hard_longest(&self) -> bool {
|
|
if self.rw.is_empty() {
|
|
return self.size <= 1;
|
|
}
|
|
let mut best_len = -1.0f64;
|
|
let mut best_hard = false;
|
|
for r in &self.rw {
|
|
if !r.water && r.len > best_len {
|
|
best_len = r.len;
|
|
best_hard = r.hard;
|
|
}
|
|
}
|
|
best_hard
|
|
}
|
|
|
|
/// Short field per Section 3.4: any runway under 800 m, or the longest runway is soft.
|
|
#[inline]
|
|
pub fn is_short_field(&self) -> bool {
|
|
if self.pad.is_some() {
|
|
return false;
|
|
}
|
|
if self.rw.is_empty() {
|
|
return self.longest < 800.0;
|
|
}
|
|
let any_under_800 = self.rw.iter().any(|r| !r.water && r.len < 800.0);
|
|
any_under_800 || !self.has_hard_longest()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_pad_only(&self) -> bool {
|
|
self.pad.is_some() && self.rw.is_empty() && self.longest <= 0.0
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_seaplane_only(&self) -> bool {
|
|
self.sea.is_some() && self.rw.iter().all(|r| r.water)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn has_usable_runway(&self, need_m: f64, hard: bool) -> bool {
|
|
if self.is_pad_only() || self.is_seaplane_only() {
|
|
return false;
|
|
}
|
|
if hard {
|
|
self.longest_hard_m() >= need_m
|
|
} else {
|
|
self.longest_land_m() >= need_m
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct RotorSpec {
|
|
#[serde(default)]
|
|
pub d: f64,
|
|
#[serde(default)]
|
|
pub big: bool,
|
|
#[serde(default)]
|
|
pub tilt: bool,
|
|
#[serde(default, rename = "hoverKw")]
|
|
pub hover_kw: f64,
|
|
#[serde(default, rename = "maxKw")]
|
|
pub max_kw: f64,
|
|
#[serde(default)]
|
|
pub sto: bool,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct HookSpec {
|
|
#[serde(default)]
|
|
pub kg: f64,
|
|
#[serde(default)]
|
|
pub line: f64,
|
|
#[serde(default)]
|
|
pub kt: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Plane {
|
|
pub id: String,
|
|
#[serde(default)]
|
|
pub name: String,
|
|
#[serde(default = "default_plane_kind")]
|
|
pub kind: String, // "piston", "turboprop", "jet", "heli", etc.
|
|
#[serde(default)]
|
|
pub seats: u32,
|
|
#[serde(default, rename = "cargoKg")]
|
|
pub cargo_kg: f64,
|
|
#[serde(default, rename = "runwayM")]
|
|
pub runway_m: f64,
|
|
#[serde(default, rename = "rangeNm")]
|
|
pub range_nm: f64,
|
|
#[serde(default, rename = "cruiseKt")]
|
|
pub cruise_kt: f64,
|
|
#[serde(default, rename = "cruiseFt")]
|
|
pub cruise_ft: f64,
|
|
#[serde(default, rename = "ceilingFt")]
|
|
pub ceiling_ft: f64,
|
|
#[serde(default, rename = "massKg")]
|
|
pub mass_kg: f64,
|
|
#[serde(default)]
|
|
pub rotor: Option<RotorSpec>,
|
|
#[serde(default)]
|
|
pub hook: Option<HookSpec>,
|
|
#[serde(default)]
|
|
pub tanker: bool,
|
|
#[serde(default)]
|
|
pub scoop: bool,
|
|
#[serde(default)]
|
|
pub snorkel: bool,
|
|
#[serde(default, rename = "tankL")]
|
|
pub tank_l: f64,
|
|
#[serde(default)]
|
|
pub drops: u32,
|
|
#[serde(default)]
|
|
pub ag: bool,
|
|
#[serde(default)]
|
|
pub historic: bool,
|
|
#[serde(default)]
|
|
pub searches: bool,
|
|
#[serde(default)]
|
|
pub nvg: bool,
|
|
#[serde(default)]
|
|
pub ramp: bool,
|
|
#[serde(default)]
|
|
pub floats: bool,
|
|
#[serde(default)]
|
|
pub amphib: bool,
|
|
#[serde(default)]
|
|
pub water_only: bool,
|
|
#[serde(default, rename = "burnGph")]
|
|
pub burn_gph: f64,
|
|
#[serde(default, rename = "upkeepNm")]
|
|
pub upkeep_nm: f64,
|
|
#[serde(default = "default_fuel_price", rename = "fuelPrice")]
|
|
pub fuel_price: f64,
|
|
}
|
|
|
|
fn default_plane_kind() -> String {
|
|
"piston".to_string()
|
|
}
|
|
|
|
fn default_fuel_price() -> f64 {
|
|
6.5
|
|
}
|
|
|
|
impl Plane {
|
|
#[inline]
|
|
pub fn is_cargo_only(&self) -> bool {
|
|
self.seats == 0
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_airliner(&self) -> bool {
|
|
self.seats > 60
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_super_large(&self) -> bool {
|
|
self.seats > 150
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_jet(&self) -> bool {
|
|
self.kind == "jet"
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_rotor(&self) -> bool {
|
|
self.rotor.is_some()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_tiltrotor(&self) -> bool {
|
|
self.rotor.as_ref().is_some_and(|r| r.tilt)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_seaplane(&self) -> bool {
|
|
self.floats || self.amphib || self.water_only
|
|
}
|
|
|
|
#[inline]
|
|
pub fn is_light_plane(&self) -> bool {
|
|
!self.is_jet() && !self.is_rotor() && self.seats <= 6 && !self.is_airliner()
|
|
}
|
|
|
|
#[inline]
|
|
pub fn effective_range_nm(&self) -> f64 {
|
|
if self.range_nm > 0.0 {
|
|
self.range_nm
|
|
} else {
|
|
500.0
|
|
}
|
|
}
|
|
|
|
#[inline]
|
|
pub fn effective_ceiling_ft(&self) -> f64 {
|
|
if self.ceiling_ft > 0.0 {
|
|
self.ceiling_ft
|
|
} else if self.is_jet() {
|
|
41_000.0
|
|
} else if self.is_rotor() {
|
|
14_000.0
|
|
} else {
|
|
16_000.0
|
|
}
|
|
}
|
|
|
|
#[inline]
|
|
pub fn effective_cruise_kt(&self) -> f64 {
|
|
if self.cruise_kt > 0.0 {
|
|
self.cruise_kt
|
|
} else {
|
|
120.0
|
|
}
|
|
}
|
|
|
|
/// Estimated flight cost per Section 7:
|
|
/// round(nm * upkeepNm + burnGph * (0.1 + nm / cruiseKt) * 0.85 * fuelPrice)
|
|
#[inline]
|
|
pub fn flight_cost(&self, nm: f64) -> i64 {
|
|
let fuel_h = 0.1 + nm / self.effective_cruise_kt();
|
|
let cost = nm * self.upkeep_nm + self.burn_gph * fuel_h * 0.85 * self.fuel_price;
|
|
cost.round() as i64
|
|
}
|
|
|
|
/// Estimated flight time in seconds per Section 7:
|
|
/// cruise profile + 20 s + 4 min per visit.
|
|
#[inline]
|
|
pub fn flight_time_secs(&self, nm: f64, visits: usize) -> f64 {
|
|
let cruise_secs = (nm / self.effective_cruise_kt()) * 3600.0;
|
|
cruise_secs + 20.0 + (visits as f64) * 240.0
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Sight {
|
|
pub name: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default = "default_sight_r")]
|
|
pub r: f64, // metres
|
|
#[serde(default)]
|
|
pub alt: f64, // feet
|
|
#[serde(default, rename = "mapOnly")]
|
|
pub map_only: bool,
|
|
#[serde(default)]
|
|
pub survey: bool,
|
|
#[serde(default)]
|
|
pub lit: bool,
|
|
}
|
|
|
|
fn default_sight_r() -> f64 {
|
|
2000.0
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Fire {
|
|
pub id: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default)]
|
|
pub hdg: f64,
|
|
#[serde(default)]
|
|
pub n: u32,
|
|
#[serde(default)]
|
|
pub t: i64,
|
|
#[serde(default)]
|
|
pub out: bool,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum EventMode {
|
|
Inside,
|
|
Into,
|
|
Out,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
|
pub struct EventBox {
|
|
pub min_lat: f64,
|
|
pub max_lat: f64,
|
|
pub min_lon: f64,
|
|
pub max_lon: f64,
|
|
}
|
|
|
|
impl EventBox {
|
|
#[inline]
|
|
pub fn contains(&self, lat: f64, lon: f64) -> bool {
|
|
lat >= self.min_lat && lat <= self.max_lat && lon >= self.min_lon && lon <= self.max_lon
|
|
}
|
|
|
|
#[inline]
|
|
pub fn center(&self) -> (f64, f64) {
|
|
(
|
|
0.5 * (self.min_lat + self.max_lat),
|
|
0.5 * (self.min_lon + self.max_lon),
|
|
)
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
|
pub struct EventRule {
|
|
#[serde(default, rename = "minKg")]
|
|
pub min_kg: Option<f64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct EventState {
|
|
pub id: String,
|
|
#[serde(default = "default_event_mode")]
|
|
pub mode: EventMode,
|
|
#[serde(rename = "box")]
|
|
pub bbox: EventBox,
|
|
#[serde(default)]
|
|
pub what: String,
|
|
#[serde(default = "default_event_kind")]
|
|
pub kind: JobKind,
|
|
#[serde(default)]
|
|
pub met: bool,
|
|
#[serde(default)]
|
|
pub rule: EventRule,
|
|
}
|
|
|
|
fn default_event_mode() -> EventMode {
|
|
EventMode::Inside
|
|
}
|
|
|
|
fn default_event_kind() -> JobKind {
|
|
JobKind::Cargo
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CompanyBase {
|
|
pub code: String,
|
|
#[serde(default)]
|
|
pub name: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default = "default_gates")]
|
|
pub gates: u32,
|
|
#[serde(default)]
|
|
pub low: bool,
|
|
}
|
|
|
|
fn default_gates() -> u32 {
|
|
1
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct CompanyState {
|
|
pub id: String,
|
|
#[serde(default)]
|
|
pub name: String,
|
|
#[serde(default)]
|
|
pub bases: Vec<CompanyBase>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct ProjectState {
|
|
pub code: String,
|
|
#[serde(default)]
|
|
pub name: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
#[serde(default)]
|
|
pub what: String,
|
|
#[serde(default)]
|
|
pub sling: bool,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct StoredJob {
|
|
pub id: String,
|
|
pub from: String,
|
|
pub to: String,
|
|
pub kind: JobKind,
|
|
#[serde(default)]
|
|
pub pax: u32,
|
|
#[serde(default)]
|
|
pub kg: u32,
|
|
#[serde(default)]
|
|
pub nm: f64,
|
|
#[serde(default)]
|
|
pub pay: i64,
|
|
#[serde(default)]
|
|
pub what: String,
|
|
#[serde(default)]
|
|
pub company: Option<String>,
|
|
#[serde(default)]
|
|
pub expires: i64,
|
|
#[serde(default)]
|
|
pub is_contract: bool,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum JobKind {
|
|
Pax,
|
|
Cargo,
|
|
Vip,
|
|
Exec,
|
|
Mail,
|
|
Medical,
|
|
Fresh,
|
|
Group,
|
|
Art,
|
|
Tour,
|
|
Sar,
|
|
Survey,
|
|
Fire,
|
|
Supply,
|
|
Materials,
|
|
Show,
|
|
Crop,
|
|
Solo,
|
|
Lift,
|
|
Banner,
|
|
Drop,
|
|
}
|
|
|
|
impl JobKind {
|
|
pub const COUNT: usize = 21;
|
|
|
|
pub const ALL: [JobKind; 21] = [
|
|
JobKind::Pax,
|
|
JobKind::Cargo,
|
|
JobKind::Vip,
|
|
JobKind::Exec,
|
|
JobKind::Mail,
|
|
JobKind::Medical,
|
|
JobKind::Fresh,
|
|
JobKind::Group,
|
|
JobKind::Art,
|
|
JobKind::Tour,
|
|
JobKind::Sar,
|
|
JobKind::Survey,
|
|
JobKind::Fire,
|
|
JobKind::Supply,
|
|
JobKind::Materials,
|
|
JobKind::Show,
|
|
JobKind::Crop,
|
|
JobKind::Solo,
|
|
JobKind::Lift,
|
|
JobKind::Banner,
|
|
JobKind::Drop,
|
|
];
|
|
|
|
#[inline(always)]
|
|
pub fn idx(self) -> usize {
|
|
self as usize
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub fn as_str(self) -> &'static str {
|
|
match self {
|
|
JobKind::Pax => "pax",
|
|
JobKind::Cargo => "cargo",
|
|
JobKind::Vip => "vip",
|
|
JobKind::Exec => "exec",
|
|
JobKind::Mail => "mail",
|
|
JobKind::Medical => "medical",
|
|
JobKind::Fresh => "fresh",
|
|
JobKind::Group => "group",
|
|
JobKind::Art => "art",
|
|
JobKind::Tour => "tour",
|
|
JobKind::Sar => "sar",
|
|
JobKind::Survey => "survey",
|
|
JobKind::Fire => "fire",
|
|
JobKind::Supply => "supply",
|
|
JobKind::Materials => "materials",
|
|
JobKind::Show => "show",
|
|
JobKind::Crop => "crop",
|
|
JobKind::Solo => "solo",
|
|
JobKind::Lift => "lift",
|
|
JobKind::Banner => "banner",
|
|
JobKind::Drop => "drop",
|
|
}
|
|
}
|
|
|
|
/// Exact Section 3.4 kind multipliers.
|
|
#[inline(always)]
|
|
pub fn multiplier(self) -> f64 {
|
|
match self {
|
|
JobKind::Pax => 1.0,
|
|
JobKind::Cargo => 0.9,
|
|
JobKind::Vip => 1.8,
|
|
JobKind::Exec => 2.2,
|
|
JobKind::Mail => 1.0,
|
|
JobKind::Medical => 1.5,
|
|
JobKind::Fresh => 1.3,
|
|
JobKind::Group => 1.3,
|
|
JobKind::Art => 2.0,
|
|
JobKind::Tour => 1.0,
|
|
JobKind::Sar => 2.0,
|
|
JobKind::Survey => 1.4,
|
|
JobKind::Fire => 1.8,
|
|
JobKind::Supply => 1.0,
|
|
JobKind::Materials => 1.0,
|
|
JobKind::Show => 2.5,
|
|
JobKind::Crop => 1.2,
|
|
JobKind::Solo => 1.0,
|
|
JobKind::Lift => 1.1,
|
|
JobKind::Banner => 1.25,
|
|
JobKind::Drop => 1.2,
|
|
}
|
|
}
|
|
|
|
/// Aerial work kinds get 1.5x base distance pay per Section 3.4.
|
|
#[inline(always)]
|
|
pub fn is_aerial(self) -> bool {
|
|
matches!(
|
|
self,
|
|
JobKind::Tour
|
|
| JobKind::Sar
|
|
| JobKind::Survey
|
|
| JobKind::Fire
|
|
| JobKind::Crop
|
|
| JobKind::Banner
|
|
| JobKind::Drop
|
|
)
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub fn is_pax_detour_eligible(self) -> bool {
|
|
matches!(self, JobKind::Pax | JobKind::Vip | JobKind::Exec | JobKind::Group)
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct Coord {
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
pub struct PhotoTarget {
|
|
pub name: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct VisitStop {
|
|
pub code: String,
|
|
pub lat: f64,
|
|
pub lon: f64,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Job {
|
|
pub id: String,
|
|
pub from: String,
|
|
pub to: String,
|
|
pub kind: JobKind,
|
|
pub pax: u32,
|
|
pub kg: u32,
|
|
pub nm: f64,
|
|
pub pay: i64,
|
|
pub expires: i64,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub what: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub season: Option<&'static str>,
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub short: bool,
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub big_charter: bool,
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub water: bool,
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub pad: bool,
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub sling: bool,
|
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
pub is_contract: bool,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub photo: Option<PhotoTarget>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub via: Option<Coord>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub work_point: Option<Coord>,
|
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
|
pub visits: Vec<VisitStop>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub company: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub event: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub deadline_min: Option<u32>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub sea_state: Option<u8>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub passes: Option<u32>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub min_runway_m: Option<f64>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub dest_elev_m: Option<f64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
|
pub struct WorldData {
|
|
#[serde(default)]
|
|
pub airports: Vec<Airport>,
|
|
#[serde(default)]
|
|
pub majors: Vec<Airport>,
|
|
#[serde(default)]
|
|
pub pads: Vec<Airport>,
|
|
#[serde(default)]
|
|
pub sea_bases: Vec<Airport>,
|
|
#[serde(default)]
|
|
pub sights: Vec<Sight>,
|
|
#[serde(default)]
|
|
pub planes: Vec<Plane>,
|
|
#[serde(default)]
|
|
pub fires: Vec<Fire>,
|
|
#[serde(default)]
|
|
pub event: Option<EventState>,
|
|
#[serde(default)]
|
|
pub company: Option<CompanyState>,
|
|
#[serde(default)]
|
|
pub projects: Vec<ProjectState>,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct BoardOptions<'a> {
|
|
pub salt: u32,
|
|
pub day_salt: u32,
|
|
pub level: u8,
|
|
pub first_solo: bool,
|
|
pub aurora_active: bool,
|
|
pub fair_weather: bool,
|
|
pub dev: bool,
|
|
pub fires: &'a [Fire],
|
|
pub event: Option<&'a EventState>,
|
|
pub company: Option<&'a CompanyState>,
|
|
pub projects: &'a [ProjectState],
|
|
pub stored: &'a [StoredJob],
|
|
}
|
|
|
|
impl<'a> Default for BoardOptions<'a> {
|
|
fn default() -> Self {
|
|
Self {
|
|
salt: 0,
|
|
day_salt: 0,
|
|
level: 0,
|
|
first_solo: false,
|
|
aurora_active: false,
|
|
fair_weather: true,
|
|
dev: false,
|
|
fires: &[],
|
|
event: None,
|
|
company: None,
|
|
projects: &[],
|
|
stored: &[],
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum SortMode {
|
|
NetPerHour,
|
|
GrossPay,
|
|
FlightTime,
|
|
CloserToEvent,
|
|
}
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub enum FilterMode<'a> {
|
|
All,
|
|
NewAirports(&'a rustc_hash::FxHashSet<String>),
|
|
Company(&'a str),
|
|
TowardsEvent(&'a EventState),
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize)]
|
|
pub struct BoardRow {
|
|
pub job: Job,
|
|
pub net_pay: i64,
|
|
pub flight_secs: f64,
|
|
pub net_per_hour: f64,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub reason: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub closer_nm: Option<f64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize)]
|
|
pub struct PartitionedBoard {
|
|
pub ok: Vec<BoardRow>,
|
|
pub off: Vec<BoardRow>,
|
|
pub no: Vec<BoardRow>,
|
|
pub refresh_mins: i64,
|
|
}
|