Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// NOTE: Differs from bw function in that it doesn't immediatly do one frame step.
- /// If this is called somewhere else than just zerg birth order, it should be done afterwards.
- pub unsafe fn add_military_ai(unit: Unit, region: *mut bw::AiRegion, always_this_region: bool) {
- assert!((*unit.0).ai.is_null());
- let region = if !always_this_region && (*region).state == 3 {
- // ai_region(unit.player(), unit.position()).expect("Unit out of bounds??")
- let regions = bw::ai_regions(unit.player() as u32);
- ai_region(regions, unit.position()).expect("Unit out of bounds??")
- } else {
- region
- };
- let array = (*region).military.array;
- let ai = (*array).first_free;
- if ai.is_null() {
- warn!("Military ai limit");
- return;
- }
- ListEntry::move_to(ai, &mut (*array).first_free, &mut (*region).military.first);
- (*ai).ai_type = 4; // Unnecessary?
- (*ai).parent = unit.0;
- (*ai).region = region;
- (*unit.0).ai = ai as *mut c_void;
- if unit.is_air() {
- (*region).needed_air_strength = (*region).needed_air_strength.saturating_add(1); // Why?
- }
- match (*region).state {
- 1 | 2 | 8 | 9 => update_slowest_unit_in_region(region),
- _ => (),
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement