CleverRaven / Cataclysm-DDA

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

Smart engine controller keep turn on and off the car engine repeatedly #65292

Open Proxima-b opened 1 year ago

Proxima-b commented 1 year ago

Describe the bug

So the smart engine controller does suppose to turn on the car engine so it can recharge the battery when it's below the low threshold. However in practice, it turns the engine on and off repeatedly when the charge is below the high threshold, and continues to do so when the charge drops below the low threshold, and it did not charge the battery sufficiently

================================================================

Edit: I tested the situation around, it only seem to happen when the solar panel is working.

Attach save file

N/A

Steps to reproduce

  1. Make a vehicle with an engine, a generater, a smart engine controller, a battery and some energy consuming devices.
  2. set the SEC low threshold at 50% and high at 95% and turn it on, do not drive the vehicle
  3. drop the charge to below 95% or below 50%
  4. Install a solar panel and wait until daylight.
  5. Start wait and observe the issue happening

Expected behavior

The SEC turns on the engine steadely when the charge is below the low threshold, and turns it one when the charge is above high threshold (while not driving the car)

Screenshots

bug

Versions and configuration

latest experimental

Additional context

No response

irwiss commented 1 year ago

Can't seem to reproduce on my side, can you attach a save?

Karol1223 commented 1 year ago

I can confirm this has been happening on my save with the smart engine controller as well. It kept turning the engine on and off repeatedly.

Proxima-b commented 1 year ago

Come to the Lab.zip

Proxima-b commented 1 year ago

Can't seem to reproduce on my side, can you attach a save?

I've uploaded my save, but I seem to found the issue. It only happens when the solar panel is installed and working in the daylight.

irwiss commented 1 year ago

/confirm

Nerezza commented 1 week ago

Still an issue in 0.H release candidate. I've looked into the smart controller's code and believe I've found where the bug is triggering, but I couldn't figure out the trigger myself.

https://github.com/CleverRaven/Cataclysm-DDA/blob/1692e4a77779bea48bbd7620cfb0eba48db8ecf2/src/vehicle_move.cpp#L422-L429

This part of the code is for if a vehicle has fuel and electric engines, this part handles turning engines off immediately after turning engines on. I assume the logic here is choosing the wrong engines to turn off for some reason.

Smart controllers used for automatically turning on/off power generation (like in a power generator) are running fine btw, that's handled elsewhere.