CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.26k stars 4.11k forks source link

Inconsistent minireactor behavior when powering vehicle's appliances #19776

Closed Aivean closed 7 years ago

Aivean commented 7 years ago
  1. Active and loaded minireactor doesn't charge vehicle's batteries
  2. Although reactor enables propulsion and usage of some appliances (such as lights and minifridge) using hotplate (RV kitchen, chem lab) is not possible when battery is at 0%

It seems sensible that all appliances should behave in consistent manner, i.e. either all of them should be powered by minireactor or none of them. Another possible solution would be to make reactor charge batteries (appliances in that case will drain power from batteries).

Reactor is loaded and active, batteries don't charge: image

Hotplate is not active in crafting menu: image

Steps to reproduce:

Build:

image Mac OS Tiles, downloaded from here http://dev.narc.ro/cataclysm/jenkins-latest/OSX/Tiles/

Also reproducible in older builds (several days old).

Save:

appliances_bug2016-12-16_02.18.27.tar.gz

CoroNaut commented 7 years ago

The entire vehicle system needs overhaul, add this to the checklist. :D

kevingranade commented 7 years ago

The problem here is the reactor is acting like neither an engine nor a battery. if it acts like an engine it should top off batteries, if it's a battery it should be redefined as such so you can run your hotplates off of it. I favor the first aporoach, it should just produce power all the time.

Aivean commented 7 years ago

Meanwhile I found what prevents using appliances by examining:

https://github.com/CleverRaven/Cataclysm-DDA/blob/014111e6a3a6286061bd97301982d68a4757423b/src/pickup.cpp#L59

    if( ( has_kitchen || has_chemlab ) && veh->fuel_left( "battery" ) > 0 ) {
        selectmenu.addentry( USE_HOTPLATE, true, 'h', _( "Use the hotplate" ) );
    }

Everywhere where fuel_left( "battery" ) is checked, it should look like fuel_left( "battery", true, true), i.e. should check also connected vehicles and reactors.

Still looking for the part that prevents crafting.

Maybe I'll submit pull request later if I manage to compile tiles build.

Aivean commented 7 years ago

Second place (crafting interface):

https://github.com/CleverRaven/Cataclysm-DDA/blob/67668987fee36729cac0c24d9d7c99e8a29063a8/src/inventory.cpp#L382

        if (kpart >= 0) {
            item hotplate("hotplate", 0);
            hotplate.charges = veh->fuel_left("battery", true);
            hotplate.item_tags.insert("PSEUDO");
            add_item(hotplate);

Same issue, fuel_left should have third parameter, which enables reactor use.

Aivean commented 7 years ago

Please check my PR