CleverRaven / Cataclysm-DDA

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

Engines can be started without a charged battery #42207

Open DatMeg opened 4 years ago

DatMeg commented 4 years ago

Describe the bug

Despite being essential parts to operating a vehicle, the Car Battery, and Alternator are indeed optional additions! Reduce the weight of your mini deathmobile by cutting out frivolous parts! All you need is an Engine, and a tank of fuel attached to each other. Add some controls and watch the magic happen. If it refuses to function, simply change the engine configuration and give it that little nudge to turn it over!

Jokes aside. It seems the Engine Configuration Menu bypasses checks for a Battery, or Alternator, as long as there is fuel attached to the engine.

Steps To Reproduce

  1. Build a vehicle, with nothing but an engine (V-Twin), fuel tank, and controls
  2. Fuel the vehicle
  3. Try to turn on the vehicle normally, and find that it doesn't work
  4. Go to the engine config menu, and toggle it off, then on again
  5. Find that it turns on (momentarily)
  6. Add an alternator, or generator and repeat 3 & 4. It will turn on, and stay on.
  7. Add a dead battery and repeat 3 & 4 once more and find that it will now charge

Expected behavior

Even if I use Magiclysm, there are some things that probably shouldn't feel like magic.

Screenshots

image

Versions and configuration

Alex-Folts commented 4 years ago

It is not as simple as it seems:

i think rules should be like:

in both cases above it should require electric power, not certain parts. Alternator and batteries is not mandatory parts as you can provide electric power for start and for continuous work of the engine in alternative ways(solar panels, cable to another vehicle etc), but engine should stop if it have no electric power available, and ofc should not start if no electric power available.

Alex-Folts commented 4 years ago

I did some tests and look in vehicle code - all work as intended, there is no bug.

Small engines like on screenshot(in the description of the issue) can start without vehicle have any battery, it assumed that this is engine with manual starter, for work it require electric energy source(on screenshot it is an alternator, but can also be a battery or reactor), when no electric source available(for example battery got completely discharged) engine will stop. Larger engines work similar but also required electric power to start(so far only battery accepted as starter electric energy source) and consumes battery power even if fail to start, engine wont start if battery have 0 or insufficient charge.

All behavior above realistic and it work as intended.

Aivean commented 4 years ago

@Alex-Folts , there is indeed a bug. I've also stumbled upon it before.

Look here: https://github.com/CleverRaven/Cataclysm-DDA/blob/70028b7295ebaa7a805607295db89157c2f9df34/src/vehicle_use.cpp#L363

control_engines uses toggle_specific_part which doesn't check for any faults. If you have one working engine, using "engine control menu", you can start the second one immediately, no matter how faulty it is.

It should use vehicle::start_engine( int e, bool turn_on ) instead.

Alex-Folts commented 4 years ago

control_engines uses toggle_specific_part which doesn't check for any faults. If you have one working engine, using "engine control menu", you can start the second one immediately, no matter how faulty it is.

Yes i hadnt tested vehicle with 2 or more engines, but it is different bug.

int-ua commented 3 years ago

Please update title to better reflect the issue. Something like "Engines can be started without a charged battery"