From e64c23d50d7f313dae29c0d1fd97878737580140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sat, 9 Dec 2023 00:38:12 +0100 Subject: [PATCH] Limit access to the LatentHeat property to LATENTHEAT builds --- src/simulation/Element.cpp | 90 +++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/src/simulation/Element.cpp b/src/simulation/Element.cpp index ccf217cd9..ec46e4353 100644 --- a/src/simulation/Element.cpp +++ b/src/simulation/Element.cpp @@ -55,46 +55,58 @@ Element::Element(): std::vector const &Element::GetProperties() { - static std::vector properties = { - { "Name", StructProperty::String, offsetof(Element, Name ) }, - { "Colour", StructProperty::Colour, offsetof(Element, Colour ) }, - { "Color", StructProperty::Colour, offsetof(Element, Colour ) }, - { "MenuVisible", StructProperty::Integer, offsetof(Element, MenuVisible ) }, - { "MenuSection", StructProperty::Integer, offsetof(Element, MenuSection ) }, - { "Enabled", StructProperty::Integer, offsetof(Element, Enabled ) }, - { "Advection", StructProperty::Float, offsetof(Element, Advection ) }, - { "AirDrag", StructProperty::Float, offsetof(Element, AirDrag ) }, - { "AirLoss", StructProperty::Float, offsetof(Element, AirLoss ) }, - { "Loss", StructProperty::Float, offsetof(Element, Loss ) }, - { "Collision", StructProperty::Float, offsetof(Element, Collision ) }, - { "Gravity", StructProperty::Float, offsetof(Element, Gravity ) }, - { "NewtonianGravity", StructProperty::Float, offsetof(Element, NewtonianGravity ) }, - { "Diffusion", StructProperty::Float, offsetof(Element, Diffusion ) }, - { "HotAir", StructProperty::Float, offsetof(Element, HotAir ) }, - { "Falldown", StructProperty::Integer, offsetof(Element, Falldown ) }, - { "Flammable", StructProperty::Integer, offsetof(Element, Flammable ) }, - { "Explosive", StructProperty::Integer, offsetof(Element, Explosive ) }, - { "Meltable", StructProperty::Integer, offsetof(Element, Meltable ) }, - { "Hardness", StructProperty::Integer, offsetof(Element, Hardness ) }, - { "PhotonReflectWavelengths", StructProperty::UInteger, offsetof(Element, PhotonReflectWavelengths ) }, - { "CarriesTypeIn", StructProperty::UInteger, offsetof(Element, CarriesTypeIn ) }, - { "Weight", StructProperty::Integer, offsetof(Element, Weight ) }, - { "Temperature", StructProperty::Float, offsetof(Element, DefaultProperties.temp ) }, - { "HeatConduct", StructProperty::UChar, offsetof(Element, HeatConduct ) }, - { "LatentHeat", StructProperty::UInteger, offsetof(Element, LatentHeat ) }, - { "Description", StructProperty::String, offsetof(Element, Description ) }, - { "State", StructProperty::Removed, 0 }, - { "Properties", StructProperty::Integer, offsetof(Element, Properties ) }, - { "LowPressure", StructProperty::Float, offsetof(Element, LowPressure ) }, - { "LowPressureTransition", StructProperty::TransitionType, offsetof(Element, LowPressureTransition ) }, - { "HighPressure", StructProperty::Float, offsetof(Element, HighPressure ) }, - { "HighPressureTransition", StructProperty::TransitionType, offsetof(Element, HighPressureTransition ) }, - { "LowTemperature", StructProperty::Float, offsetof(Element, LowTemperature ) }, - { "LowTemperatureTransition", StructProperty::TransitionType, offsetof(Element, LowTemperatureTransition ) }, - { "HighTemperature", StructProperty::Float, offsetof(Element, HighTemperature ) }, - { "HighTemperatureTransition", StructProperty::TransitionType, offsetof(Element, HighTemperatureTransition) } + struct DoOnce + { + std::vector properties; + + DoOnce() + { + properties = { + { "Name", StructProperty::String, offsetof(Element, Name ) }, + { "Colour", StructProperty::Colour, offsetof(Element, Colour ) }, + { "Color", StructProperty::Colour, offsetof(Element, Colour ) }, + { "MenuVisible", StructProperty::Integer, offsetof(Element, MenuVisible ) }, + { "MenuSection", StructProperty::Integer, offsetof(Element, MenuSection ) }, + { "Enabled", StructProperty::Integer, offsetof(Element, Enabled ) }, + { "Advection", StructProperty::Float, offsetof(Element, Advection ) }, + { "AirDrag", StructProperty::Float, offsetof(Element, AirDrag ) }, + { "AirLoss", StructProperty::Float, offsetof(Element, AirLoss ) }, + { "Loss", StructProperty::Float, offsetof(Element, Loss ) }, + { "Collision", StructProperty::Float, offsetof(Element, Collision ) }, + { "Gravity", StructProperty::Float, offsetof(Element, Gravity ) }, + { "NewtonianGravity", StructProperty::Float, offsetof(Element, NewtonianGravity ) }, + { "Diffusion", StructProperty::Float, offsetof(Element, Diffusion ) }, + { "HotAir", StructProperty::Float, offsetof(Element, HotAir ) }, + { "Falldown", StructProperty::Integer, offsetof(Element, Falldown ) }, + { "Flammable", StructProperty::Integer, offsetof(Element, Flammable ) }, + { "Explosive", StructProperty::Integer, offsetof(Element, Explosive ) }, + { "Meltable", StructProperty::Integer, offsetof(Element, Meltable ) }, + { "Hardness", StructProperty::Integer, offsetof(Element, Hardness ) }, + { "PhotonReflectWavelengths", StructProperty::UInteger, offsetof(Element, PhotonReflectWavelengths ) }, + { "CarriesTypeIn", StructProperty::UInteger, offsetof(Element, CarriesTypeIn ) }, + { "Weight", StructProperty::Integer, offsetof(Element, Weight ) }, + { "Temperature", StructProperty::Float, offsetof(Element, DefaultProperties.temp ) }, + { "HeatConduct", StructProperty::UChar, offsetof(Element, HeatConduct ) }, + { "Description", StructProperty::String, offsetof(Element, Description ) }, + { "State", StructProperty::Removed, 0 }, + { "Properties", StructProperty::Integer, offsetof(Element, Properties ) }, + { "LowPressure", StructProperty::Float, offsetof(Element, LowPressure ) }, + { "LowPressureTransition", StructProperty::TransitionType, offsetof(Element, LowPressureTransition ) }, + { "HighPressure", StructProperty::Float, offsetof(Element, HighPressure ) }, + { "HighPressureTransition", StructProperty::TransitionType, offsetof(Element, HighPressureTransition ) }, + { "LowTemperature", StructProperty::Float, offsetof(Element, LowTemperature ) }, + { "LowTemperatureTransition", StructProperty::TransitionType, offsetof(Element, LowTemperatureTransition ) }, + { "HighTemperature", StructProperty::Float, offsetof(Element, HighTemperature ) }, + { "HighTemperatureTransition", StructProperty::TransitionType, offsetof(Element, HighTemperatureTransition) } + }; + if constexpr (LATENTHEAT) + { + properties.push_back({ "LatentHeat", StructProperty::UInteger, offsetof(Element, LatentHeat) }); + } + } }; - return properties; + static DoOnce doOnce; + return doOnce.properties; } int Element::legacyUpdate(UPDATE_FUNC_ARGS) {