# Fuel consumption glitch

**URL:** https://discourse.cataclysmdda.org/t/fuel-consumption-glitch/265
**Category:** The Garage
**Created:** [February 25, 2013, 1:12pm UTC](https://discourse.cataclysmdda.org/t/fuel-consumption-glitch/265 "2013-02-25T13:12:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![paalpeyz](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@paalpeyz](https://discourse.cataclysmdda.org/u/paalpeyz)
#### Post date: [February 25, 2013, 1:12pm UTC](https://discourse.cataclysmdda.org/t/fuel-consumption-glitch/265/1 "2013-02-25T13:12:18Z")

</div>

There is a small glitch, such that fuel is not always consumed properly:  
If there is more than one fuel tank of the same type, and the first fuel tank in the list is empty, no fuel is consumed. For example one can build a vehicle with an electric motor and 2 storage batteries. Fill each of them with 1 battery and drive infinitely.

The following patch should fix the issue.

```auto
diff --git a/vehicle.cpp b/vehicle.cpp
index 1d33b4a..7be92f8 100644
--- a/vehicle.cpp
+++ b/vehicle.cpp
@@ -1026,10 +1026,16 @@ void vehicle::consume_fuel ()
                     (part_info(p).fuel_type == (elec? (j? AT_BATT : AT_PLUT) : ftypes[ft])))
                 {
                     parts[p].amount -= amnt;
- if (parts[p].amount < 0)
+ if (parts[p].amount < 0) 
+ {
+ amnt = -parts[p].amount;
                         parts[p].amount = 0;
- found = true;
- break;
+ }
+ else 
+ {
+ found = true;
+ break;
+ }
                 }
             if (found)
                 break;
```
