mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-01 06:00:15 +02:00
ensure air doesn't "leak" out of TTAN containers when loading stamps and saves
This commit is contained in:
@@ -352,6 +352,31 @@ void Air::Invert()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called when loading saves / stamps to ensure nothing "leaks" the first frame
|
||||||
|
void Air::RecalculateBlockAirMaps()
|
||||||
|
{
|
||||||
|
for (int i = 0; i <= sim.parts_lastActiveIndex; i++)
|
||||||
|
{
|
||||||
|
int type = sim.parts[i].type;
|
||||||
|
// Real TTAN would only block if there was enough TTAN
|
||||||
|
// but it would be more expensive and complicated to actually check that
|
||||||
|
// so just block for a frame, if it wasn't supposed to block it will continue allowing air next frame
|
||||||
|
if (type == PT_TTAN)
|
||||||
|
{
|
||||||
|
int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL;
|
||||||
|
bmap_blockair[y][x] = 1;
|
||||||
|
bmap_blockairh[y][x] = 0x8;
|
||||||
|
}
|
||||||
|
// mostly accurate insulator blocking, besides checking GEL
|
||||||
|
else if ((type == PT_HSWC && sim.parts[i].life != 10) || sim.elements[type].HeatConduct <= (rand()%250))
|
||||||
|
{
|
||||||
|
int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL;
|
||||||
|
if (!(bmap_blockairh[y][x]&0x8))
|
||||||
|
bmap_blockairh[y][x]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Air::Air(Simulation & simulation):
|
Air::Air(Simulation & simulation):
|
||||||
sim(simulation),
|
sim(simulation),
|
||||||
airMode(0),
|
airMode(0),
|
||||||
|
@@ -33,6 +33,7 @@ public:
|
|||||||
void Clear();
|
void Clear();
|
||||||
void ClearAirH();
|
void ClearAirH();
|
||||||
void Invert();
|
void Invert();
|
||||||
|
void RecalculateBlockAirMaps();
|
||||||
Air(Simulation & sim);
|
Air(Simulation & sim);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -216,6 +216,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gravWallChanged = true;
|
gravWallChanged = true;
|
||||||
|
air->RecalculateBlockAirMaps();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -533,7 +534,7 @@ SimulationSample Simulation::GetSample(int x, int y)
|
|||||||
{
|
{
|
||||||
sample.WallType = bmap[y/CELL][x/CELL];
|
sample.WallType = bmap[y/CELL][x/CELL];
|
||||||
}
|
}
|
||||||
sample.AirPressure = pv[y/CELL][x/CELL];
|
sample.AirPressure = (int)air->bmap_blockair[y/CELL][x/CELL];
|
||||||
sample.AirTemperature = hv[y/CELL][x/CELL];
|
sample.AirTemperature = hv[y/CELL][x/CELL];
|
||||||
sample.AirVelocityX = vx[y/CELL][x/CELL];
|
sample.AirVelocityX = vx[y/CELL][x/CELL];
|
||||||
sample.AirVelocityY = vy[y/CELL][x/CELL];
|
sample.AirVelocityY = vy[y/CELL][x/CELL];
|
||||||
|
Reference in New Issue
Block a user