Cataclysm-dda: Infinite diesel from the Heavy Duty Cargo Truck

Created on 17 Jan 2019  Â·  18Comments  Â·  Source: CleverRaven/Cataclysm-DDA

To Reproduce
Steps to reproduce the behavior:

  1. Find a Heavy Duty Cargo Truck
  2. Check out its vehicle tanks containing 0.0L of diesel each
  3. Siphon the fuel to your car
  4. Skip the warnings about siphoning zero fuel
  5. Enjoy free 250mL of fuel
  6. Repeat

Versions and configuration(please complete the following information):
0.C-36545-g93068257bf-dirty

<Exploit> Vehicles

Most helpful comment

Awesome, mentioning it was on a bridge led to the solution :+1:
It turns out what's happening is
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/json/road_vehicles.json#L210
is the only vehicle placement that sets fuel quantity to 0.
Spawning on a bridge was a red herring, but that is the only place where it happens.

What's happening in more detail is that https://github.com/CleverRaven/Cataclysm-DDA/blob/4d93e13a84ac8229c7cd03dadaed86ffe086e5b1/src/mapgen.cpp#L6903 is called with veh_fuel = 0, which then calls vehicle::vehicle() -> vehicle::init_state() with the same value, which then calls https://github.com/CleverRaven/Cataclysm-DDA/blob/34cad8d74c0bd104af76c09f7040dd3417b94cde/src/vehicle_part.cpp#L217 with a 0 qty argument.

It sets the fuel type correctly, and sets the quantity of contained fuel to 0, which is invalid because a lot of code uses the fact that the fuel type is set to determine that there is fuel in the tank. (ammo type actually for dumb historical reasons).

The fix is adding some sanity checking code in vehicle_part::set_ammo() to un-set the fuel state properly if qty == 0.

All 18 comments

After saving and reloading, the truck contains 0.3L of diesel in each tank and works as intended.

Could be closed then?

No.

Could not reproduce in 0.C-37094-g5da8e39

How do i spawn myself a vehicle?

Debug menu. You need to bind the key for that menu yourself

It spawns with filled tanks and like newâ„¢ this way. I guess the mapgen's damaging logic is at work there.

What condition were the tanks in? Do you have an affected save? I'd like to explore the generated world more to see if I can come across another similarly affected vehicle. It would be useful if we had a previously affected vehicle to compare with.

I was not able to replicate in 0.c-37236-g0f1d6c1

I don't know what else to say except i already did. No, as re-loading made them work properly, and i went forward with the game. It was an usual forsaken truck in the middle of a bridge.

Ah! A bridge, I believe there are some existing issues about spawning on bridges causing problems.

Awesome, mentioning it was on a bridge led to the solution :+1:
It turns out what's happening is
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/json/road_vehicles.json#L210
is the only vehicle placement that sets fuel quantity to 0.
Spawning on a bridge was a red herring, but that is the only place where it happens.

What's happening in more detail is that https://github.com/CleverRaven/Cataclysm-DDA/blob/4d93e13a84ac8229c7cd03dadaed86ffe086e5b1/src/mapgen.cpp#L6903 is called with veh_fuel = 0, which then calls vehicle::vehicle() -> vehicle::init_state() with the same value, which then calls https://github.com/CleverRaven/Cataclysm-DDA/blob/34cad8d74c0bd104af76c09f7040dd3417b94cde/src/vehicle_part.cpp#L217 with a 0 qty argument.

It sets the fuel type correctly, and sets the quantity of contained fuel to 0, which is invalid because a lot of code uses the fact that the fuel type is set to determine that there is fuel in the tank. (ammo type actually for dumb historical reasons).

The fix is adding some sanity checking code in vehicle_part::set_ammo() to un-set the fuel state properly if qty == 0.

Fixed by #28108

Found a similar Motorcycle with infinite gasoline on a crossroads in a town near a Wreckage.

Could you provide a savegame?

https://my.mixtape.moe/aonxts.tar.xz standing next to it, now having 0.3L (since i have already saved and loaded the game after noticing it).

Just encountered the same problem with a Flatbed Truck at a regional dump.
2019.07.09.zip

Reproduced again with a humvee on a bridge. The behaviour is the same as in https://github.com/CleverRaven/Cataclysm-DDA/issues/27681#issuecomment-468152708
Save:
2020.02.10.zip

Also observed on a police road block (with gasoline):
2020.03.02.zip

Was this page helpful?
0 / 5 - 0 ratings