Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
756 changes: 419 additions & 337 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ num-derive.workspace = true
derive_more.workspace = true
bwapi_wrapper = { path = "bwapi_wrapper", version = "3.6.3" }
winapi = { version = "0.3", features = ["winbase", "memoryapi", "handleapi"] }
libc = "0.2"
memchr = "2.7"
rstar = "0.12"
itertools = "0.14"
Expand Down
5 changes: 0 additions & 5 deletions bwapi_wrapper/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ impl ParseCallbacks for FromPrimitiveDerive {
}

fn main() {
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows" {
panic!(
"RSBWAPI does not yet support targeting OpenBW, please compile with a Windows target."
);
}
println!("cargo::rerun-if-changed=bwapi");

// The bindgen::Builder is the main entry point
Expand Down
137 changes: 136 additions & 1 deletion bwapi_wrapper/src/tech_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) struct TechTypeData {
pub(crate) race: Race,
pub(crate) name: &'static str,
}
pub(crate) static TECH_TYPE_DATA: [TechTypeData; 38] = [
pub(crate) static TECH_TYPE_DATA: [TechTypeData; 47] = [
TechTypeData {
mineral_price: 100,
gas_price: 100,
Expand Down Expand Up @@ -591,6 +591,141 @@ pub(crate) static TECH_TYPE_DATA: [TechTypeData; 38] = [
race: Race::Terran,
name: "Healing",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_35",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_36",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_37",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_38",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_39",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_40",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_41",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_42",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
what_uses: &[],
research_time: 0,
energy_cost: 0,
weapon: WeaponType::None,
targets_unit: false,
targets_position: false,
order: Order::None,
what_researches: UnitType::None,
required_unit: UnitType::None,
race: Race::None,
name: "Unused_43",
},
TechTypeData {
mineral_price: 0,
gas_price: 0,
Expand Down
117 changes: 116 additions & 1 deletion bwapi_wrapper/src/upgrade_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) struct UpgradeTypeData {
pub(crate) upgrade_time_factor: i32,
pub(crate) name: &'static str,
}
pub(crate) static UPGRADE_TYPE_DATA: [UpgradeTypeData; 54] = [
pub(crate) static UPGRADE_TYPE_DATA: [UpgradeTypeData; 63] = [
UpgradeTypeData {
what_uses: &[
UnitType::Terran_Marine,
Expand Down Expand Up @@ -654,6 +654,26 @@ pub(crate) static UPGRADE_TYPE_DATA: [UpgradeTypeData; 54] = [
upgrade_time_factor: 0,
name: "Khaydarin_Core",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_45",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_46",
},
UpgradeTypeData {
what_uses: &[UnitType::Protoss_Corsair],
gas_price_factor: 0,
Expand All @@ -664,6 +684,16 @@ pub(crate) static UPGRADE_TYPE_DATA: [UpgradeTypeData; 54] = [
upgrade_time_factor: 0,
name: "Argus_Jewel",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_48",
},
UpgradeTypeData {
what_uses: &[UnitType::Protoss_Dark_Archon],
gas_price_factor: 0,
Expand All @@ -674,6 +704,16 @@ pub(crate) static UPGRADE_TYPE_DATA: [UpgradeTypeData; 54] = [
upgrade_time_factor: 0,
name: "Argus_Talisman",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_50",
},
UpgradeTypeData {
what_uses: &[UnitType::Terran_Medic],
gas_price_factor: 0,
Expand Down Expand Up @@ -714,6 +754,56 @@ pub(crate) static UPGRADE_TYPE_DATA: [UpgradeTypeData; 54] = [
upgrade_time_factor: 0,
name: "Charon_Boosters",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_55",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_56",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_57",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_58",
},
UpgradeTypeData {
what_uses: &[],
gas_price_factor: 0,
max_repeats: 0,
race: Race::None,
mineral_price_factor: 0,
what_upgrades: UnitType::None,
upgrade_time_factor: 0,
name: "Upgrade_59",
},
UpgradeTypeData {
what_uses: &[
UnitType::Terran_Vulture_Spider_Mine,
Expand Down Expand Up @@ -789,3 +879,28 @@ impl UpgradeType {
self.d().name
}
}

#[cfg(test)]
mod row_tests {
use super::*;
use num_traits::FromPrimitive;

#[test]
fn every_upgrade_and_tech_reads_its_own_row() {
for id in 0..UpgradeType::MAX as i32 {
if let Some(upgrade) = UpgradeType::from_i32(id) {
assert_eq!(upgrade.name(), format!("{upgrade:?}"));
}
}
for id in 0..TechType::MAX as i32 {
if let Some(tech) = TechType::from_i32(id) {
assert_eq!(tech.name(), format!("{tech:?}"));
}
}
for id in 0..WeaponType::MAX as i32 {
if let Some(weapon) = WeaponType::from_i32(id) {
assert_eq!(weapon.name(), format!("{weapon:?}"));
}
}
}
}
Loading
Loading