Skip to content

Commit e905a4c

Browse files
committed
Server/ShipEnvironment: Release atmosphere on despawn
1 parent f9e7a6e commit e905a4c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/ServerLib/ServerShipEnvironment.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,26 @@ namespace tsom
101101

102102
if (m_exteriorEnvironment)
103103
{
104+
// Release atmosphere from every area to the exterior atmosphere
105+
if (m_exteriorEnvironment && m_exteriorEntity)
106+
{
107+
auto& outsideNode = m_exteriorEntity.get<Nz::NodeComponent>();
108+
Nz::Vector3f outsidePosition = outsideNode.GetPosition();
109+
110+
ServerAtmosphere* outsideAtmosphere = m_exteriorEnvironment->GetAtmosphereAtPosition(outsidePosition);
111+
if (outsideAtmosphere)
112+
{
113+
for (auto&& [chunkIndices, chunkData] : m_chunkData)
114+
{
115+
for (const auto& area : chunkData.areas->areas)
116+
{
117+
for (auto&& [gasType, amount] : area.atmosphere.GetGasAmounts().iter_kv())
118+
outsideAtmosphere->IncreaseGasAmount(gasType, amount);
119+
}
120+
}
121+
}
122+
}
123+
104124
// Move every switchable entity out of the ship before destroying it (otherwise the entities will be destroyed)
105125
EnvironmentTransform outsideTransform(Nz::Vector3f::Zero(), Nz::Quaternionf::Identity());
106126
Nz::Vector3f outsideVelocity = Nz::Vector3f::Zero();

0 commit comments

Comments
 (0)