CleverRaven / Cataclysm-DDA

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

Freezers turning off for no reason #69089

Closed Terrorforge closed 1 week ago

Terrorforge commented 8 months ago

Describe the bug

I set up some freezers in my base, filled them with berries, and turned them on. Then I slept, went out to raid an apartment building for materials and just generally played the game, and when I came back they were turned off. I have over 6kW of solar power coming in stored in half a dozen large storage batteries (plus a few medium ones) and nothing on the grid except two freezers, so it can't just be a matter of running out of power.

I've seen others complain about the same problem, but I was unable to find any previous bug reports.

Attach save file

Mindssachusetts-trimmed.tar.gz This is just after I turned them back on. The freezers are attached to the workshop station just to the NE by extension cord, the workshop station is connected by outdoor extension cord to the solar panel/battery assembly to the SW.

Steps to reproduce

Unclear. Haven't been able to reproduce except by continuing to play the game with freezers running in my base. May be something that happens when you spend time away, may be something that happens when you spend time there. I'll try to keep an eye on it as my playthrough ontinues.

Expected behavior

Appliances stay turned on until turned off or they run out of power.

Screenshots

No response

Versions and configuration

Additional context

No response

Terrorforge commented 8 months ago

It happened again. I noticed it after a portal storm, but who knows if that's actually related.

image Empty batteries are definitely not the issue.

Kanexan commented 8 months ago

I've had this happen as well, seemingly at random. I wondered if it might have something to do with NPCs, but I don't think they can interact with furniture like that.

Terrorforge commented 8 months ago

I don't have any NPCs around, so probably not that.

Also fwiw it's not just my freezers. My stereo, which I normally keep on 24/7, also turned off randomly.

keampe commented 8 months ago

Two questions for you:

  1. When this happens, have you been far enough away that the freezer would be outside your reality bubble?
  2. When you return to base do your freezer/stereo enter the reality bubble before your batteries?

What might be happening is that as you leave or return your appliances may be in the reality bubble but not your batteries and so the game thinks that the appliances aren't powered.

Terrorforge commented 8 months ago

I don't check often enough that I can confidently say they were working when I left the reality bubble and then tthey were turned off when I came back. I tried intentionally approaching my base in such a way that the appliances enter the reality bubble before the batteries, but that doesn't trigger the effect.

Golfavel commented 8 months ago

It could be related to z-levels; I can (mostly) consistently reproduce it in this save here following the instructions provided: Clara-trimmed.tar.gz

  1. Notice the plugged-in refridgerator and freezer directly north-west and north-east of the player, along with the batteries having plenty of power and being within the same overmap tile
  2. Five overmap tiles south there is a house, go to it
  3. Go down the stairs within the house
  4. Wait (optional, but seems to increase chance of disconnection)
  5. Head back to the starting position
  6. Notice the disconnected appliances

I have had this same setup disconnect while exploring on the same z-level, but I couldn't get anything reproducible like this. My only other guess is maybe due the connected vehicle outside being slightly outside of the overmap tile?

gisaku33 commented 8 months ago

I'm not sure what causes it, but connecting things only by extension cords prevents it from happening. My minifreezer directly adjacent to my batteries shuts off all the time, but my fridges/lights with only cords always work.

Terrorforge commented 8 months ago

My freezers are connected via extension cord and they still shut off.

Golfavel commented 8 months ago

Okay so I kept having my setup disconnect so I investigated further; it's pretty bad how short of a distance you can go before they start breaking off, it seems to be dependent on direction, and it seems to only occur during either the time the player approaches or leaves the network (teleporting far distances to and from it doesn't seem to cause disconnects) (going directly diagonally from the network (e.g., going from OMT [0, 0'85, 0'87] to [0, 0'86, 0'88]) also seems to not disconnect): Clara_debug-trimmed.tar.gz

  1. Notice the plugged-in refrigerator and freezer
  2. Walk along any street excluding westward (left) until you reach the lines of cotton balls
  3. Wait either on or past (in appropriate direction) the cotton balls for a recommended 5 minutes or more (in-game).
  4. Go back to the appliances
  5. Notice disconnect

Bonus test:

  1. There is a note at the upper corner of the nearby refugee center known as "TESTINGWAYPOINT". Autotravel to it (do not teleport)
  2. Wait any duration of time
  3. Walk back to the appliances
  4. Notice connections still in-tact
harperers commented 8 months ago

I've been having the same issue, so here's a save of my world. I did some testing but it never seemed to be consistent what turns off or not, but something usually does. Erving-trimmed.tar.gz

  1. Check the freezers and nearby lamps to see they are turned on
  2. Leave the area in any way, making sure to get the entire base out of the reality bubble
  3. Go back to the appliances and notice that a random amount of them have been turned off.

Sometimes doing this led to none of them turning off but that never happened twice in a row for me.

KnifeFightBears commented 5 months ago

I have had this issue recently and was able to mitigate it by connecting my freezer and fridge to batteries from both sides along the same horizontal row. I seemed to be having issues any time the freezer left my reality bubble. It seems like it's happening when the power source is in my reality bubble but the freezer is not

pwalsh0 commented 5 months ago

I also mitigated this by putting batteries next to my fridge.

Maybe a crude fix for this is to give appliances a small built-in battery - just to cover this small time when the edge of reality bubble is moving over it.

Xelat84 commented 3 months ago

Need to check if that issue was fixed with this PR https://github.com/CleverRaven/Cataclysm-DDA/pull/71889 Beside of that, workaround that seemed to work for me is placing one-tile vehicle with battery next to my freezer, and connect it to freezer with jumper cable, and to cellar set of batteries and solar panels on the roof with extension cords. Around 30 in-game days and no disconnections yet, but now I'm also playing with fix mentioned above, so not sure I will spot this issue again any time soon.

I-am-Erk commented 3 months ago

Can anyone confirm if this is still going on? Sounds like it's been hard to place, but if it's been fixed then we should backport the fix to stable.

kween-kobold commented 3 months ago

Can confirm, its happening with me. Plenty of power but my fridge and freezer turn off when I leave the bubble. Played around with it for a bit, all the grid is on one map tile: image The grid is split in two, with the batteries on one grid and the appliances on the other. Perhaps both grids need at least one battery? This is the before: image And this is after, added a battery to the bottom left of the grid. Seems to have fixed it. image

I-am-Erk commented 3 months ago

Does your building span multiple overmap tiles? Could it be shutting off when one battery leaves the bubble?

Edit; looks like you already addressed that nevermind.

I've kept this on the blocker list but I have a feeling it might be hard to track down, we'll try to get it fixed for H though

kween-kobold commented 3 months ago

May not address the root cause, but perhaps adding a reveal wall wiring option for doors would prevent us from having to make split grids? Or an option to run wiring across floors? Unless the decorative wiring does that I'm not sure.

I-am-Erk commented 3 months ago

It wouldn't be a big deal to add the ability to run wires in other spots, no, particularly not doors. It's mostly a matter of displaying it nicely.

Void-Seeker commented 3 months ago

I have batteries and freezers on the same grid, although they are not adjacent. They still turn off. What's interesting is that charge station next to the freezers is NOT turning off when i leave reality bubble. Charge station, AFAIK, only drains power when it is actually charging something, so that might be the reason.

kween-kobold commented 3 months ago

What if appliances all had a small 5 charge battery in them that allowed them to run for a moment without power as things load in? Sorry if this is the wrong place to suggest something like that just trying to think of ways to fix it.

I-am-Erk commented 3 months ago

Perhaps something like that. Likely, we need some way to clearly capture the entire power grid before unloading it, and cache that information. But before making solutions someone needs to clearly catch the problem without doubt.

Brambor commented 1 month ago

To debug I want to add debugmsg( _( "Your fridge/freezer turned off!" ) ) to remove most of the frustration. Not to be merged but for myself. It could leak information the player maybe shouldn't know.

ShnitzelX2 commented 2 weeks ago

Using this setup to test:

image

I placed watches on just the freezer and fridge vehicle parts' "enabled" values. I turned them on (along with the two lamps and the battery charger) to make sure the watches worked, and autotraveled north. Sure enough, when I got about four overmap tiles away from them the watches triggered: the fridge watch had expired, but the freezer watch was still loaded and registered a negative power value, with "enabled" set to false. I went back to check on the power grid and everything was turned off, and I got a message for one of the lamps running out of power.

So I repeated this about 20 times, always starting from the same spot and autotraveling to the same spot. I put watches on the freezer, fridge, and right lamp. The order that those three appliances turn off -- if they turn off at all -- is usually different. Rarely, nothing will turn off at all. It is very, very bizarre to me that sometimes the right lamp will turn off, but not the left lamp.

What is consistent, though, is that if appliances get disabled, they are always disabled at the edge of the reality bubble, both coming and going from the starting location.

To confirm, the cache vehicle list before and after the watches were triggered: app2_3 You'll notice that the power grid was unloaded before the watch was triggered. app2_2

The code executing the disabling was, as you'd expect, the VP enable check.

appliance2

ShnitzelX2 commented 2 weeks ago

To follow up, I've identified the bug precisely.

In power_parts(), called for every vehicle on every turn, we need to convert the power usage of e.g. a freezer to "battery units", or what you see displayed on a power grid battery in-game. That's done in this function:

int vehicle::power_to_energy_bat( const units::power power, const time_duration &d ) const
{
    units::energy produced = power * d;
    int produced_kj = roll_remainder( units::to_millijoule( produced ) / 1000000.0 );
    return produced_kj;
}

For those not familiar (like myself), roll_remainder will take the decimal portion of a float and use it as the probability to round to the nearest integer. Because appliances' power usage values provided to roll_remainder are so small (usually not exceeding -0.04), roll_remainder will usually roll them to zero; this means that these appliances are not using power, and if they're not using power, then we currently say that they don't need to be disabled.

Occasionally (and most importantly, randomly), roll_remainder will roll the values to -1, power usage is registered, and the appliance turns off like it's supposed to.

Placing your power grid adjacent to an appliance avoids this issue because it's likely impossible to unload both the grid and the appliance at the same time.

TL;DR: in all its hilarity, the bug is not that the devices were turning OFF, but rather that they were staying ON.

So there's really two issues here: 1) There's currently no way to keep appliances powered when the power grid is unloaded 2) They don't turn off correctly anyways because of the roll_remainder issue