If you put up a tent (i used regular one), light from the outside will shine inside
Same thing happens with vehicles
Alternative -
It should be dark in the tent or vehicle when you close its door
Confirmed that this problem happens even with experimental z level vision turned off.
Also noticed that if you have a truck (for example) with opaque doors, walls all around and roof (including tiles that has walls) it will still be bright inside
The truck thing was already reported I believe, but I can't find it now.
Both are probably related to PR #42830
Well, i added vehicle part to my post anyway
In my experience, most tents IRL are fairly translucent and will still allow an appreciable amount of light in. I have comfortably read a book and played cards in a larger tent during the daytime without a light. Not saying that there isn't a bug to be addressed here, but something to consider.
Im 100% sure you used to be able to sleep inside without any blindfolds
Oh, I meant IRL, not in game. Editing original to indicate that.
Ah, yeah, irl they are pretty thin. If you set one up in a forest you will have a hard time reading, but if sun is shining on the tent directly - its bright enough inside
Another problem i just encounered - i was chilling in the tent on the roof, waiting for darkness so i could sneak away from some flaming eyes, and one eye decided to fly above my tent. It was visible to me, and it was able to do his bullshit to me. Even though tent roof should have stopped him
If nobody picks this up within the next couple of days, I'll fix it. I'm familiar with sunlight cache code.
Ok, while thinking of the best way to fix this, I've discovered a fundamental problem.
Current semantics of the "INDOORS" flag (if implemented according to spec) essentially prohibits skylights (see #42008). Without adding additional flags and/or other hacks to support skylights specifically, we can either have the shade inside the tents/vehicles or working skylights.
So, I have two options:
An easy option to fix tents and vehicles (by checking outside_cache
in build_sunlight_cache
) and break skylights (hopefully without breaking #31851).
Second approach is much more involved and consists of two parts:
outside_cache
is built (make it rely on the presence of the real roof above, not just on the "INDOORS" flag).@kevingranade and @jbytheway , I believe you might have some valuable input on this.
Something along the lines of your second solution is probably ultimately what we need. Currently INDOORS
is overloaded with multiple meanings. It's used e.g. for determining where rain falls as well as lighting effects. IMO it should be entirely divorced from all lighting effects.
Still, I don't think this implies that we need a new cache. There are two notable chunks of code which are relevant to sunlight:
map::build_sunlight_cache
. This was most recently changed in #42830 to cause light to spread out by one tile per level. This ensures that walls are lit up, but (I suspect) introduced the bug with vehicles because now it's lighting up squares in the walls of vehicles which weren't previously being lit. Potentially this is also what broke tents.map::generate_lightmap
. Currently this casts from any outside square to an adjacent indoors square, but I think it should be changed to instead cast from any sufficiently bright square to any substantially darker adjacent square, so long as the first tile not opaque.Back when sunlight casting was originally introduced (#30250) Kevin planned to have the sunlight come in at an angle, rather than directly downwards. I'm actually working on implementing that right now, which would be a fairly major change to the first point here. Along the way I was rather expecting to basically revert #42830 and fix the "dark walls" issue by something more along the lines of my suggestion in the second point here.
These changes I'm working on are a major feature that shouldn't land before 0.F release, so we probably need a need a different fix for 0.F. And we should probably look for the least disruptive fix, since we are in feature freeze. My instinct is that the simplest fix would be to revert #42830 (hopefully fixing the vehicles and tents issues) and fix the dark-walls-bug in a different by tweaking map::generate_lightmap
to cast light sideways into walls in the same way it is currently cast into windows.
But any of these changes need unit tests, so we should get #42835 merged before any attempt to fix this.
A good place to start would be to revert #42830 locally and test my hypothesis that it fixes the vehicle and/or tent issues. It would be very helpful if you could try that.
@jbytheway , thanks for your comment.
I think the quick and dirty fix for tents and trucks doesn't require reverting #42830.
It's basically adding here following condition:
if (!outside_cache[x][y] && !outside_cache[prev_x][prev_y]) {
continue;
}
This is what I suggested as the approach â„–1.
I just tested it and it works: fixes trucks and tents, doesn't break #31851, but breaks skylights (revert of the #42830 will break them too).
Do you think such fix would suffice for now?
A good place to start would be to revert #42830 locally and test my hypothesis that it fixes the vehicle and/or tent issues. It would be very helpful if you could try that.
Yes, you are correct, reverting #42830 will fix trucks and tents as well, this bug was introduced here, specifically by removing && outside_cache[x][y]
part from the if clause.
I think we can find something that doesn't break skylights. It would suffice to check "is this tile inside a vehicle or tent" here instead. It's just a question of whether that would be too slow. Maybe vehicles and tents should be taken into account when building the floor cache, and set the tiles above them to be floored?
Well, yes, that can work well enough for vehicles, but that would be a HUGE hack for tents.
Currently tents are single-tile-high and their floors have the infamous "INDOORS" flag, that is supposed to mean that there is a fake "roof" above them. We can distinguish tent floor from other "INDOORS" floors by adding another flag that would share semantics with "INDOORS", but you understand why I'm reluctant to suggest that.
Alternatively we can just make tents 3d, i.e. add real roof above them. However this also seems a bit involved.
My instinct is in fact that a new flag for "has an opaque ceiling that isn't represented by a floor in the tile above" is the easiest short-term solution. I don't have a good sense for how messy it would be to make tents have real roofs. Not sure we'd want that anyway, since they're not walkable-on.
But probably we should let @kevingranade weigh in.
Well, yes, that can work well enough for vehicles, but that would be a HUGE hack for tents.
Bear with me here as I'm aware that this idea sounds phenomenally dumb, buuuut... Why not just make tents foldable vehicles? Use wire for the frames for minimum durability with "plastic sheet" walls, roof and door. It would work essentially the same from the players perspective and this would also limit the scope of the problem solely to vehicles for now until 0.F. As far as I'm aware they are the only item that deploys like this where light casting is a concern. Tents always seemed a little hacky to me anyways with how any damage would immediately turn it into the useless broken tent item. Changing them to vehicles would allow survivors to repair their tent or even craft their own.
One thing i dont like about vehicles is how you cant really put items on the ground. You instead put items inside the tile. And I dont know how things like rollmats will work with tent-vehicles.
(and you already can repair tents and create your own)
One thing i dont like about vehicles is how you cant really put items on the ground. You instead put items inside the tile. And I dont know how things like rollmats will work with tent-vehicles.
(and you already can repair tents and create your own)
A simple solution to that problem would be to create a "plastic sheet" tent floor part (filling the same role as an aisle) with a high storage volume but basically no durability (to prevent it from being used as vehicle storage). I was also unaware that broken tents could be fixed but what I was more referring too when I said create their own was the creation of custom sized tents with other foldable amenities (battery powered lights, funnel and tank, etc.).
Vehicles are a nasty thing to maintain, and any "quasi-vehicle" ideas tend to get shot down for that reason.
It very much sounds like the best option is to have the tent code place a roof over the tent, that's how we handle this kind of thing now.
That can either be an explicit roof entry or an entry that just gets inferred by build_transparency_cache().
Likewise vehicles should get roof entries when the transparency cache is rebuilt.
Ok, sounds like a plan.
The only issue though, currently transparency_cache
implies "horizontal transparency" in addition to "vertical transparency". If roofs above tents and vehicles are to set the transparency cache, they would block vision and horizontal light in the corresponding z-level.
I'll try to evaluate floor_cache
for that purpose instead.
I have no experience with coding and stuff like that, but wouldnt creating a roof over a tent cause problems if you try to set up a tent in a building? You know, with a normal roof above you
I have no experience with coding and stuff like that, but wouldnt creating a roof over a tent cause problems if you try to set up a tent in a building? You know, with a normal roof above you
Just going to tack onto this that there is a setup tent spawned by default in Mil. Surplus stores so this is going to be a fairly common thing.
I also found tents in random basements
That might be an issue if we used explicit roofs, but it shouldn't be a problem with inferred roofs. So I guess that suggests using the latter approach.
Most helpful comment
It very much sounds like the best option is to have the tent code place a roof over the tent, that's how we handle this kind of thing now.
That can either be an explicit roof entry or an entry that just gets inferred by build_transparency_cache().
Likewise vehicles should get roof entries when the transparency cache is rebuilt.