Chunks reload fix
This commit is contained in:
parent
c518580577
commit
50aa5fdc70
@ -104,7 +104,7 @@ LevelScreen::~LevelScreen() {
|
|||||||
|
|
||||||
std::cout << "-- writing world" << std::endl;
|
std::cout << "-- writing world" << std::endl;
|
||||||
World* world = level->world;
|
World* world = level->world;
|
||||||
world->write(level, !engine->getSettings().debug.generatorTestMode);
|
world->write(level);
|
||||||
|
|
||||||
delete level;
|
delete level;
|
||||||
delete world;
|
delete world;
|
||||||
@ -118,7 +118,7 @@ void LevelScreen::updateHotkeys() {
|
|||||||
level->player->debug = !level->player->debug;
|
level->player->debug = !level->player->debug;
|
||||||
}
|
}
|
||||||
if (Events::jpressed(keycode::F5)) {
|
if (Events::jpressed(keycode::F5)) {
|
||||||
level->chunks->clear();
|
level->chunks->saveAndClear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ void LevelScreen::update(float delta) {
|
|||||||
updateHotkeys();
|
updateHotkeys();
|
||||||
}
|
}
|
||||||
if (settings.graphics.backlight != backlight) {
|
if (settings.graphics.backlight != backlight) {
|
||||||
level->chunks->clear();
|
level->chunks->saveAndClear();
|
||||||
backlight = settings.graphics.backlight;
|
backlight = settings.graphics.backlight;
|
||||||
}
|
}
|
||||||
level->updatePlayer(delta, !inputLocked, hud->isPause(), !inputLocked);
|
level->updatePlayer(delta, !inputLocked, hud->isPause(), !inputLocked);
|
||||||
|
|||||||
@ -338,10 +338,11 @@ bool Chunks::putChunk(shared_ptr<Chunk> chunk) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chunks::clear(){
|
void Chunks::saveAndClear(){
|
||||||
for (size_t i = 0; i < volume; i++){
|
for (size_t i = 0; i < volume; i++){
|
||||||
Chunk* chunk = chunks[i].get();
|
Chunk* chunk = chunks[i].get();
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
|
worldFiles->put(chunk);
|
||||||
events->trigger(EVT_CHUNK_HIDDEN, chunk);
|
events->trigger(EVT_CHUNK_HIDDEN, chunk);
|
||||||
}
|
}
|
||||||
chunks[i] = nullptr;
|
chunks[i] = nullptr;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public:
|
|||||||
void translate(int x, int z);
|
void translate(int x, int z);
|
||||||
void resize(int newW, int newD);
|
void resize(int newW, int newD);
|
||||||
|
|
||||||
void clear();
|
void saveAndClear();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* VOXELS_CHUNKS_H_ */
|
#endif /* VOXELS_CHUNKS_H_ */
|
||||||
|
|||||||
@ -28,7 +28,7 @@ World::~World(){
|
|||||||
delete wfile;
|
delete wfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::write(Level* level, bool writeChunks) {
|
void World::write(Level* level) {
|
||||||
Chunks* chunks = level->chunks;
|
Chunks* chunks = level->chunks;
|
||||||
|
|
||||||
for (size_t i = 0; i < chunks->volume; i++) {
|
for (size_t i = 0; i < chunks->volume; i++) {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public:
|
|||||||
EngineSettings& settings);
|
EngineSettings& settings);
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
void write(Level* level, bool writeChunks);
|
void write(Level* level);
|
||||||
Level* load(EngineSettings& settings, const Content* content);
|
Level* load(EngineSettings& settings, const Content* content);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user