Cataclysm-dda: Filling Tanks Maxes Capacity

Created on 9 May 2020  路  4Comments  路  Source: CleverRaven/Cataclysm-DDA

Describe the bug

Filling a vehicle tank seems to fill it to the brim regardless of the amount you're putting in the tank.

I experienced this while pulling water from a puddle into a 60L tank. When I checked it later, it had filled 2 tanks completely to 60L of water, despite only trying to fill one. I've also experienced this while taking a tank with 1.1L of gasoline and siphoning from a 5.3L tank. It filled the 1.1L tank all the way to 60L even though it should have gone to 6.4L. That sounds confusing, there should be a gif below showing it.

Steps To Reproduce

I'll be honest, I didn't have time to try and reproduce this. I'd assume it's as easy as siphoning from one tank to another, presumably it would max them all out.

Expected behavior

When siphoning from a tank it should combine the values of the two tanks, not max it out to 60L

Screenshots

Here's a GIF. My humvee has 1.1 liters. When I siphon the 5.3 liters from the other tank to the humvee, it actually fills the humvee all the way to 60L. The 1.1 part is spliced in from earlier in the video as I hadn't checked my vehicle in a while, so it probably had a little less than 1.1L at the time of filling because I had to drive over there, but I figure that's most likely irrelevant and the filling to full is the concern.

buggifsmall

Versions and configuration

  • OS: Windows

    • OS Version: 10.0 1903

  • Game Version: 0.E-1933-gdba5bd1 [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    No Fungal Monsters [No_Fungi]
    ]

Additional context

Again, don't have time to fool around testing this right now, sorry, normally I would at least set it up and see if it's easily reproducible.

<Bug> Containers Vehicles

All 4 comments

I can confirm this. I filled a car's entire fuel tank with just a glass bottle of gasoline.

I also had this problem. I believe it only happened when filling a tank from a container for me, vehicle to vehicle seemed to work fine.

Here is a hotfix, for src/vehicle_part.cpp:387:

bool vehicle_part::fill_with( item &liquid, int qty )
{
    if( !is_tank() || !can_reload( liquid ) ) {
        return false;
    }

    // hotfix for issue #40369
    // remove this once proper fix is implemented
    int tmp = qty == INT_MAX ? liquid.charges : qty;

    liquid.charges -= base.fill_with( *liquid.type, tmp );
    return true;
}

I made a fix for this issue.

Some notes,

vehicle.h defines bool fill_with( item &liquid, int qty = INT_MAX )
character.cpp uses auto &tank = veh_interact::select_part( veh, sel, title ); then tank.fill_with( liquid ); not using qty
qty is thus a INT_MAX value

The fix I employed was to do as follows

Change vehicle.h fill_with( item &liquid, int qty )to bool fill_with( item &liquid )
Check for remaining capacity of output tank
Deduct the total used from the input tank given the remaining capacity as max else just the total charges
Update the liquid.charges to reflect amount used

src/vehicle_part.cpp:387:

bool vehicle_part::fill_with( item &liquid )
{
    if( !is_tank() || !can_reload( liquid ) ) {
        return false;
    }

    int charges_max = base.ammo_capacity(item::find_type(base.ammo_current() )->ammo->type ) - base.ammo_remaining();
    int qty = liquid.charges;

    if (charges_max < liquid.charges) {
        qty = liquid.charges - charges_max;
    }

    liquid.charges -= qty;
    base.fill_with( *liquid.type, qty );
    return true;
}

There is an issue though in that when the output vehicle has multiple tanks it will only fill a small portion at a time using a rubber hose but there is no lost fuel. I am not clear on how to resolve this at this time as it only takes multiple attempts to completely move the liquids over.

Any help on this would be useful.

Was this page helpful?
0 / 5 - 0 ratings