Skip to content

Commit

Permalink
Sync before changing stuffs.
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinityDevTech committed Jun 4, 2024
1 parent 25df615 commit ce7f7ab
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/room/creeps/local/hauler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,16 @@ pub fn execute_order(
creep.store().get_free_capacity(Some(order.resource)),
amount as i32,
);
let result = creep.withdraw(
target.unchecked_ref::<StructureStorage>(),
order.resource,
Some(amount.try_into().unwrap()),
);

let result = if target.unchecked_ref::<StructureStorage>().store().get_used_capacity(Some(order.resource)) < amount as u32 {
Err(ErrorCode::InvalidTarget)
} else {
creep.withdraw(
target.unchecked_ref::<StructureStorage>(),
order.resource,
Some(amount.try_into().unwrap()),
)
};

result
} else {
Expand Down

0 comments on commit ce7f7ab

Please sign in to comment.