New world format, fixes
This commit is contained in:
+6
-4
@@ -10,11 +10,12 @@
|
||||
#include "../objects/Player.h"
|
||||
#include "../physics/PhysicsSolver.h"
|
||||
#include "../window/Camera.h"
|
||||
#include "../world/LevelEvents.h"
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
World::World(std::string name, std::string directory, int seed) : name(name), seed(seed) {
|
||||
wfile = new WorldFiles(directory, REGION_VOL * (CHUNK_VOL * 2 + 8));
|
||||
wfile = new WorldFiles(directory, REGION_VOL * (CHUNK_DATA_LEN * 2 + 8));
|
||||
}
|
||||
|
||||
World::~World(){
|
||||
@@ -24,11 +25,11 @@ World::~World(){
|
||||
void World::write(Level* level) {
|
||||
Chunks* chunks = level->chunks;
|
||||
|
||||
for (unsigned int i = 0; i < chunks->volume; i++) {
|
||||
for (size_t i = 0; i < chunks->volume; i++) {
|
||||
shared_ptr<Chunk> chunk = chunks->chunks[i];
|
||||
if (chunk == nullptr || !chunk->isUnsaved())
|
||||
continue;
|
||||
wfile->put((const ubyte*)chunk->voxels, chunk->x, chunk->z);
|
||||
wfile->put(chunk.get());
|
||||
}
|
||||
|
||||
wfile->write();
|
||||
@@ -37,7 +38,8 @@ void World::write(Level* level) {
|
||||
|
||||
Level* World::loadLevel(Player* player) {
|
||||
ChunksStorage* storage = new ChunksStorage();
|
||||
Level* level = new Level(this, player, new Chunks(16, 16, 0, 0), storage, new PhysicsSolver(vec3(0, -19.6f, 0)));
|
||||
LevelEvents* events = new LevelEvents();
|
||||
Level* level = new Level(this, player, new Chunks(16, 16, 0, 0, events), storage, new PhysicsSolver(vec3(0, -19.6f, 0)), events);
|
||||
wfile->readPlayer(player);
|
||||
|
||||
Camera* camera = player->camera;
|
||||
|
||||
Reference in New Issue
Block a user