1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Detect air-only blocks instead of day/night differences (#14264)

* Detect air-only blocks instead day/night differences

* Write !is_air into the former day-night-diff bit on disk, so that old server can still read maps written by new servers

* Only set is_air bit when reading from disk
This commit is contained in:
lhofhansl 2024-02-22 21:47:42 -08:00 committed by GitHub
parent 0d30a3071a
commit 0d4b489545
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 52 additions and 75 deletions

View file

@ -60,7 +60,7 @@ enum ModReason : u32 {
MOD_REASON_STATIC_DATA_ADDED = 1 << 13,
MOD_REASON_STATIC_DATA_REMOVED = 1 << 14,
MOD_REASON_STATIC_DATA_CHANGED = 1 << 15,
MOD_REASON_EXPIRE_DAYNIGHTDIFF = 1 << 16,
MOD_REASON_EXPIRE_IS_AIR = 1 << 16,
MOD_REASON_VMANIP = 1 << 17,
MOD_REASON_UNKNOWN = 1 << 18,
};
@ -310,20 +310,19 @@ public:
// Copies data from VoxelManipulator getPosRelative()
void copyFrom(VoxelManipulator &dst);
// Update day-night lighting difference flag.
// Sets m_day_night_differs to appropriate value.
// These methods don't care about neighboring blocks.
void actuallyUpdateDayNightDiff();
// Update is air flag.
// Sets m_is_air to appropriate value.
void actuallyUpdateIsAir();
// Call this to schedule what the previous function does to be done
// when the value is actually needed.
void expireDayNightDiff();
void expireIsAirCache();
inline bool getDayNightDiff()
inline bool isAir()
{
if (m_day_night_differs_expired)
actuallyUpdateDayNightDiff();
return m_day_night_differs;
if (m_is_air_expired)
actuallyUpdateIsAir();
return m_is_air;
}
bool onObjectsActivation();
@ -517,8 +516,8 @@ public:
private:
// Whether day and night lighting differs
bool m_day_night_differs = false;
bool m_day_night_differs_expired = true;
bool m_is_air = false;
bool m_is_air_expired = true;
/*
- On the server, this is used for telling whether the