Delete le monde infini et la sauvegarde de chunk.

This commit is contained in:
MarcEricMartel
2023-08-28 17:39:55 -04:00
parent 2f8a5893f0
commit 3b5a56189e
4 changed files with 12 additions and 12 deletions

View File

@@ -2,11 +2,11 @@
#include "world.h"
Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
pos << CHUNK_PATH << x << '_' << y << ".chunk";
std::ifstream input(pos.str(), std::fstream::binary);
//std::ostringstream pos; // V<>rifie l'existence d'un fichier .chunk avec sa position.
//pos << CHUNK_PATH << x << '_' << y << ".chunk";
//std::ifstream input(pos.str(), std::fstream::binary);
if (input.fail()) {
//if (input.fail()) {
OpenSimplexNoise::Noise simplex = OpenSimplexNoise::Noise(SEED);
m_blocks.Reset(BTYPE_AIR);
@@ -61,7 +61,7 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
// break;
// }
// }
}
/* }
else {
input.seekg(0, std::ios_base::end);
int size = input.tellg();
@@ -75,11 +75,11 @@ Chunk::Chunk(unsigned int x, unsigned int y) : m_posX(x), m_posY(y) {
for (int iz = 0; iz < CHUNK_SIZE_Z; ++iz)
for (int iy = 0; iy < CHUNK_SIZE_Y; ++iy)
m_blocks.Set(ix, iy, iz, data[ix + (iz * CHUNK_SIZE_X) + (iy * CHUNK_SIZE_Z * CHUNK_SIZE_X)]);
}
}*/
}
Chunk::~Chunk() {
if (m_isModified) {
/*if (m_isModified) {
char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z];
for (int x = 0; x < CHUNK_SIZE_X; ++x)
@@ -93,7 +93,7 @@ Chunk::~Chunk() {
std::ofstream output(pos.str(), std::fstream::binary);
output.write(data, sizeof(data));
output.close();
}
}*/
}
void Chunk::RemoveBlock(int x, int y, int z, World* world) {