Fix some deprecation warnings (#920)
Namely: - [[deprecated("Use PlaneAdapter<std::vector>")]] - [[deprecated("Use operator[](Vec2)")]]
This commit is contained in:
parent
0f95ce82f8
commit
c8bc8a7285
File diff suppressed because it is too large
Load Diff
@ -54,31 +54,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Item>
|
|
||||||
struct [[deprecated("Use PlaneAdapter<std::vector>")]] Plane: PlaneAdapter<std::vector<Item>>
|
|
||||||
{
|
|
||||||
[[deprecated("Use operator[](Vec2)")]]
|
|
||||||
Item *operator [](int y)
|
|
||||||
{
|
|
||||||
return &*PlaneAdapter<std::vector<Item>>::RowIterator(Vec2(0, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
[[deprecated("Use operator[](Vec2)")]]
|
|
||||||
const Item *operator [](int y) const
|
|
||||||
{
|
|
||||||
return &*PlaneAdapter<std::vector<Item>>::RowIterator(Vec2(0, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
[[deprecated("Use PlaneAdapter<std::vector>")]]
|
|
||||||
Plane() = default;
|
|
||||||
|
|
||||||
[[deprecated("Use PlaneAdapter<std::vector>")]]
|
|
||||||
Plane(int newWidth, int newHeight, Item defaultVal):
|
|
||||||
PlaneAdapter<std::vector<Item>>(Vec2(newWidth, newHeight), defaultVal)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class GameSave
|
class GameSave
|
||||||
{
|
{
|
||||||
// number of pixels translated. When translating CELL pixels, shift all CELL grids
|
// number of pixels translated. When translating CELL pixels, shift all CELL grids
|
||||||
@ -88,8 +63,7 @@ class GameSave
|
|||||||
std::pair<bool, std::vector<char>> serialiseOPS() const;
|
std::pair<bool, std::vector<char>> serialiseOPS() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int blockWidth = 0;
|
Vec2<int> blockSize = { 0, 0 };
|
||||||
int blockHeight = 0;
|
|
||||||
bool fromNewerVersion = false;
|
bool fromNewerVersion = false;
|
||||||
int majorVersion = 0;
|
int majorVersion = 0;
|
||||||
int minorVersion = 0;
|
int minorVersion = 0;
|
||||||
@ -104,15 +78,15 @@ public:
|
|||||||
//Simulation data
|
//Simulation data
|
||||||
int particlesCount = 0;
|
int particlesCount = 0;
|
||||||
std::vector<Particle> particles;
|
std::vector<Particle> particles;
|
||||||
Plane<unsigned char> blockMap;
|
PlaneAdapter<std::vector<unsigned char>> blockMap;
|
||||||
Plane<float> fanVelX;
|
PlaneAdapter<std::vector<float>> fanVelX;
|
||||||
Plane<float> fanVelY;
|
PlaneAdapter<std::vector<float>> fanVelY;
|
||||||
Plane<float> pressure;
|
PlaneAdapter<std::vector<float>> pressure;
|
||||||
Plane<float> velocityX;
|
PlaneAdapter<std::vector<float>> velocityX;
|
||||||
Plane<float> velocityY;
|
PlaneAdapter<std::vector<float>> velocityY;
|
||||||
Plane<float> ambientHeat;
|
PlaneAdapter<std::vector<float>> ambientHeat;
|
||||||
Plane<unsigned char> blockAir;
|
PlaneAdapter<std::vector<unsigned char>> blockAir;
|
||||||
Plane<unsigned char> blockAirh;
|
PlaneAdapter<std::vector<unsigned char>> blockAirh;
|
||||||
|
|
||||||
//Simulation Options
|
//Simulation Options
|
||||||
bool waterEEnabled = false;
|
bool waterEEnabled = false;
|
||||||
@ -141,14 +115,14 @@ public:
|
|||||||
|
|
||||||
int pmapbits = 8; // default to 8 bits for older saves
|
int pmapbits = 8; // default to 8 bits for older saves
|
||||||
|
|
||||||
GameSave(int width, int height);
|
GameSave(Vec2<int> newBlockSize);
|
||||||
GameSave(const std::vector<char> &data, bool newWantAuthors = true);
|
GameSave(const std::vector<char> &data, bool newWantAuthors = true);
|
||||||
void setSize(int width, int height);
|
void setSize(Vec2<int> newBlockSize);
|
||||||
// return value is [ fakeFromNewerVersion, gameData ]
|
// return value is [ fakeFromNewerVersion, gameData ]
|
||||||
std::pair<bool, std::vector<char>> Serialise() const;
|
std::pair<bool, std::vector<char>> Serialise() const;
|
||||||
vector2d Translate(vector2d translate);
|
vector2d Translate(vector2d translate);
|
||||||
void Transform(matrix2d transform, vector2d translate);
|
void Transform(matrix2d transform, vector2d translate);
|
||||||
void Transform(matrix2d transform, vector2d translate, vector2d translateReal, int newWidth, int newHeight);
|
void Transform(matrix2d transform, vector2d translate, vector2d translateReal, Vec2<int> newPartSize);
|
||||||
|
|
||||||
void Expand(const std::vector<char> &data);
|
void Expand(const std::vector<char> &data);
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ void RenderView::NotifyColourChanged(RenderModel * sender)
|
|||||||
void RenderView::OnDraw()
|
void RenderView::OnDraw()
|
||||||
{
|
{
|
||||||
Graphics * g = GetGraphics();
|
Graphics * g = GetGraphics();
|
||||||
g->DrawFilledRect(RectSized({ 0, 0 }, WINDOW), 0x000000_rgb);
|
g->DrawFilledRect(WINDOW.OriginRect(), 0x000000_rgb);
|
||||||
if(ren)
|
if(ren)
|
||||||
{
|
{
|
||||||
ren->clearScreen();
|
ren->clearScreen();
|
||||||
|
@ -58,7 +58,7 @@ std::unique_ptr<VideoBuffer> SaveRenderer::Render(const GameSave *save, bool dec
|
|||||||
ren->RenderBegin();
|
ren->RenderBegin();
|
||||||
ren->RenderEnd();
|
ren->RenderEnd();
|
||||||
|
|
||||||
tempThumb = std::make_unique<VideoBuffer>(Vec2(save->blockWidth, save->blockHeight) * CELL);
|
tempThumb = std::make_unique<VideoBuffer>(save->blockSize * CELL);
|
||||||
tempThumb->BlendImage(ren->Data(), 0xFF, ren->Size().OriginRect());
|
tempThumb->BlendImage(ren->Data(), 0xFF, ren->Size().OriginRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +31,9 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
auto save = std::unique_ptr<GameSave>(new GameSave(*originalSave));
|
auto save = std::unique_ptr<GameSave>(new GameSave(*originalSave));
|
||||||
|
|
||||||
//Align to blockMap
|
//Align to blockMap
|
||||||
int blockX = (fullX + CELL/2)/CELL;
|
auto blockP = Vec2{ (fullX + CELL / 2) / CELL, (fullY + CELL / 2) / CELL };
|
||||||
int blockY = (fullY + CELL/2)/CELL;
|
fullX = blockP.X * CELL;
|
||||||
fullX = blockX*CELL;
|
fullY = blockP.Y * CELL;
|
||||||
fullY = blockY*CELL;
|
|
||||||
unsigned int pmapmask = (1<<save->pmapbits)-1;
|
unsigned int pmapmask = (1<<save->pmapbits)-1;
|
||||||
|
|
||||||
int partMap[PT_NUM];
|
int partMap[PT_NUM];
|
||||||
@ -305,31 +304,28 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
signs.push_back(tempSign);
|
signs.push_back(tempSign);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int saveBlockX = 0; saveBlockX < save->blockWidth; saveBlockX++)
|
for (auto bpos : save->blockSize.OriginRect())
|
||||||
{
|
{
|
||||||
for(int saveBlockY = 0; saveBlockY < save->blockHeight; saveBlockY++)
|
if(save->blockMap[bpos])
|
||||||
{
|
{
|
||||||
if(save->blockMap[saveBlockY][saveBlockX])
|
bmap[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->blockMap[bpos];
|
||||||
{
|
fvx[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->fanVelX[bpos];
|
||||||
bmap[saveBlockY+blockY][saveBlockX+blockX] = save->blockMap[saveBlockY][saveBlockX];
|
fvy[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->fanVelY[bpos];
|
||||||
fvx[saveBlockY+blockY][saveBlockX+blockX] = save->fanVelX[saveBlockY][saveBlockX];
|
|
||||||
fvy[saveBlockY+blockY][saveBlockX+blockX] = save->fanVelY[saveBlockY][saveBlockX];
|
|
||||||
}
|
}
|
||||||
if (includePressure)
|
if (includePressure)
|
||||||
{
|
{
|
||||||
if (save->hasPressure)
|
if (save->hasPressure)
|
||||||
{
|
{
|
||||||
pv[saveBlockY+blockY][saveBlockX+blockX] = save->pressure[saveBlockY][saveBlockX];
|
pv[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->pressure[bpos];
|
||||||
vx[saveBlockY+blockY][saveBlockX+blockX] = save->velocityX[saveBlockY][saveBlockX];
|
vx[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->velocityX[bpos];
|
||||||
vy[saveBlockY+blockY][saveBlockX+blockX] = save->velocityY[saveBlockY][saveBlockX];
|
vy[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->velocityY[bpos];
|
||||||
}
|
}
|
||||||
if (save->hasAmbientHeat)
|
if (save->hasAmbientHeat)
|
||||||
hv[saveBlockY+blockY][saveBlockX+blockX] = save->ambientHeat[saveBlockY][saveBlockX];
|
hv[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->ambientHeat[bpos];
|
||||||
if (save->hasBlockAirMaps)
|
if (save->hasBlockAirMaps)
|
||||||
{
|
{
|
||||||
air->bmap_blockair[saveBlockY+blockY][saveBlockX+blockX] = save->blockAir[saveBlockY][saveBlockX];
|
air->bmap_blockair[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->blockAir[bpos];
|
||||||
air->bmap_blockairh[saveBlockY+blockY][saveBlockX+blockX] = save->blockAirh[saveBlockY][saveBlockX];
|
air->bmap_blockairh[blockP.Y + bpos.Y][blockP.X + bpos.X] = save->blockAirh[bpos];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,7 +346,6 @@ std::unique_ptr<GameSave> Simulation::Save(bool includePressure)
|
|||||||
|
|
||||||
std::unique_ptr<GameSave> Simulation::Save(bool includePressure, int fullX, int fullY, int fullX2, int fullY2)
|
std::unique_ptr<GameSave> Simulation::Save(bool includePressure, int fullX, int fullY, int fullX2, int fullY2)
|
||||||
{
|
{
|
||||||
int blockX, blockY, blockX2, blockY2, blockW, blockH;
|
|
||||||
//Normalise incoming coords
|
//Normalise incoming coords
|
||||||
int swapTemp;
|
int swapTemp;
|
||||||
if(fullY>fullY2)
|
if(fullY>fullY2)
|
||||||
@ -367,16 +362,11 @@ std::unique_ptr<GameSave> Simulation::Save(bool includePressure, int fullX, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Align coords to blockMap
|
//Align coords to blockMap
|
||||||
blockX = fullX/CELL;
|
auto blockP = Vec2{ fullX / CELL, fullY / CELL };
|
||||||
blockY = fullY/CELL;
|
auto blockP2 = Vec2{ (fullX2 + CELL) / CELL, (fullY2 + CELL) / CELL };
|
||||||
|
auto blockS = blockP2 - blockP;
|
||||||
|
|
||||||
blockX2 = (fullX2+CELL)/CELL;
|
auto newSave = std::make_unique<GameSave>(blockS);
|
||||||
blockY2 = (fullY2+CELL)/CELL;
|
|
||||||
|
|
||||||
blockW = blockX2-blockX;
|
|
||||||
blockH = blockY2-blockY;
|
|
||||||
|
|
||||||
auto newSave = std::make_unique<GameSave>(blockW, blockH);
|
|
||||||
auto &possiblyCarriesType = Particle::PossiblyCarriesType();
|
auto &possiblyCarriesType = Particle::PossiblyCarriesType();
|
||||||
auto &properties = Particle::GetProperties();
|
auto &properties = Particle::GetProperties();
|
||||||
newSave->frameCount = frameCount;
|
newSave->frameCount = frameCount;
|
||||||
@ -397,8 +387,8 @@ std::unique_ptr<GameSave> Simulation::Save(bool includePressure, int fullX, int
|
|||||||
if (parts[i].type && x >= fullX && y >= fullY && x <= fullX2 && y <= fullY2)
|
if (parts[i].type && x >= fullX && y >= fullY && x <= fullX2 && y <= fullY2)
|
||||||
{
|
{
|
||||||
Particle tempPart = parts[i];
|
Particle tempPart = parts[i];
|
||||||
tempPart.x -= blockX*CELL;
|
tempPart.x -= blockP.X * CELL;
|
||||||
tempPart.y -= blockY*CELL;
|
tempPart.y -= blockP.Y * CELL;
|
||||||
if (elements[tempPart.type].Enabled)
|
if (elements[tempPart.type].Enabled)
|
||||||
{
|
{
|
||||||
particleMap.insert(std::pair<unsigned int, unsigned int>(i, storedParts));
|
particleMap.insert(std::pair<unsigned int, unsigned int>(i, storedParts));
|
||||||
@ -461,31 +451,28 @@ std::unique_ptr<GameSave> Simulation::Save(bool includePressure, int fullX, int
|
|||||||
if(signs[i].text.length() && signs[i].x >= fullX && signs[i].y >= fullY && signs[i].x <= fullX2 && signs[i].y <= fullY2)
|
if(signs[i].text.length() && signs[i].x >= fullX && signs[i].y >= fullY && signs[i].x <= fullX2 && signs[i].y <= fullY2)
|
||||||
{
|
{
|
||||||
sign tempSign = signs[i];
|
sign tempSign = signs[i];
|
||||||
tempSign.x -= blockX*CELL;
|
tempSign.x -= blockP.X * CELL;
|
||||||
tempSign.y -= blockY*CELL;
|
tempSign.y -= blockP.Y * CELL;
|
||||||
*newSave << tempSign;
|
*newSave << tempSign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int saveBlockX = 0; saveBlockX < newSave->blockWidth; saveBlockX++)
|
for (auto bpos : newSave->blockSize.OriginRect())
|
||||||
{
|
{
|
||||||
for(int saveBlockY = 0; saveBlockY < newSave->blockHeight; saveBlockY++)
|
if(bmap[bpos.Y + blockP.Y][bpos.X + blockP.X])
|
||||||
{
|
{
|
||||||
if(bmap[saveBlockY+blockY][saveBlockX+blockX])
|
newSave->blockMap[bpos] = bmap[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
{
|
newSave->fanVelX[bpos] = fvx[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->blockMap[saveBlockY][saveBlockX] = bmap[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->fanVelY[bpos] = fvy[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->fanVelX[saveBlockY][saveBlockX] = fvx[saveBlockY+blockY][saveBlockX+blockX];
|
|
||||||
newSave->fanVelY[saveBlockY][saveBlockX] = fvy[saveBlockY+blockY][saveBlockX+blockX];
|
|
||||||
}
|
}
|
||||||
if (includePressure)
|
if (includePressure)
|
||||||
{
|
{
|
||||||
newSave->pressure[saveBlockY][saveBlockX] = pv[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->pressure[bpos] = pv[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->velocityX[saveBlockY][saveBlockX] = vx[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->velocityX[bpos] = vx[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->velocityY[saveBlockY][saveBlockX] = vy[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->velocityY[bpos] = vy[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->ambientHeat[saveBlockY][saveBlockX] = hv[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->ambientHeat[bpos] = hv[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->blockAir[saveBlockY][saveBlockX] = air->bmap_blockair[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->blockAir[bpos] = air->bmap_blockair[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
newSave->blockAirh[saveBlockY][saveBlockX] = air->bmap_blockairh[saveBlockY+blockY][saveBlockX+blockX];
|
newSave->blockAirh[bpos] = air->bmap_blockairh[bpos.Y + blockP.Y][bpos.X + blockP.X];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includePressure || ensureDeterminism)
|
if (includePressure || ensureDeterminism)
|
||||||
|
Reference in New Issue
Block a user