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

Solar Panels Providing Power When Underground #63376

Open ChromePoptart opened 1 year ago

ChromePoptart commented 1 year ago

Describe the bug

I've modified and dug out around the basement of a hunting lodge to create a space to park my mobile base during the winter. One big concern I had when planning for this strategy was power generation, given that the vehicle wouldn't be getting any power from its solar panels while underground. Having found a few CASRGs to provide constant power while underground, I went ahead and carved out the base.

I notice now that, after moving my vehicle underground, its solar panels are still generating power. I would expect that the power reported in the 'Examine vehicle' screen would remain constantly at -580W (the vehicle has 4x120W freezers and 1x100W refrigerator) throughout the day/night cycle. Additionally, given that I have 5 CASRGs connected to the vehicle, I would expect examining any one of them would constantly show a 'Grid battery power flow' of 75W (5x131W - 580W).

In case it's relevant, I will add that I did use the map editor to change terrain tiles at surface level (level 0) when digging out terrain in the hunting lodge basement (level -1) caused the ceiling terrain to fall and open air to be exposed. Maybe it's possible that doing this made there appear visually like the basement was completely covered when looking at it on level 0, but didn't correctly set flags for the map editor-altered terrain to correctly obscure sunlight.

For reference, here's what the level 0 terrain looks like now: image

[Side note -- let me know if a separate report should be created for this] One of 'Grid battery power flow' or 'Appliance power consumption' seems to be wrong for CASRGs, since the five individual CASRGs each show 'Appliance power consumption' of 130W yet the five of them linked together reports total output of 655W (5x131W). Is this maybe an effect of having to calculate 'Reactor power output' separately from 'Appliance power consumption'? image

Steps to reproduce

I haven't tried reproducing this outside of my current game's state. I suppose it could be tested in a new, fresh game via debug menu by teleporting to level -1, using map editor to clear an area of tiles, spawn in a vehicle with solar panels, and then check the vehicle's power flow at various times/levels of sunlight.

I also haven't tested if solar panels obscured via other method (i.e., pulling into a level 0 garage with a roof or other obscuring tiles over it) still produce power.

Expected behavior

Solar panels should produce no power when obscuring terrain is present above them. (I'm not sure how complicated the math here gets with sun angle and z-levels. For example, what if a vehicle on level 0 is not obscured by any level 1 terrain, but then there is obscuring terrain at level 2? Seems like there wouldn't be light more much of the day, but some might hit when the sun is at a low enough angle for incident light to pass under the obscuring level 2 terrain and through the open level 1 terrain.)

Screenshots

No response

Versions and configuration

Additional context

No response

ChromePoptart commented 1 year ago

I believe I figured out the cause for this unexpected behavior. After poking around using the map editor, I realized that the "floor" terrain tiles (what was left after I used "Deconstruct Simple Furniture" to remove carpet from the original hunting lodge basement tiles) have the "roof" flag set to "yes", whereas the "dirt" terrain tiles (left after digging out walls and solid earth around the basement) instead have the "roof" flag set to "no". I used the map editor to change all of the "dirt" tiles under the vehicle to "floor", and the power generated by the solar panels immediately dropped to zero.

So, the issue here seems to be that determining whether or not a tile has a roof over it is determined by the terrain on the tile itself and not based on what terrain is on the same tile but one z-level higher. I'm sure there are design considerations for why the system was implemented in this way.

image image

alp7292 commented 1 year ago

how roofs works is really weird we should have actual roofs

andrei8l commented 1 year ago

/confirmed the relevant code only checks for the INDOORS flag and your vehicle is over some t_dirt tiles which don't have the flag

https://github.com/CleverRaven/Cataclysm-DDA/blob/908472cac4573948cba92f5f72e13b2a8bc01212/src/vehicle.cpp#L7410-L7411