format: reformat project

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov
2024-08-03 19:53:48 +03:00
committed by Pugemon
parent 736cd175d5
commit bbf33e8e4d
202 changed files with 7389 additions and 5609 deletions
+33 -30
View File
@@ -1,49 +1,48 @@
#include "World.hpp"
#include "Level.hpp"
#include <glm/glm.hpp>
#include <memory>
#include <utility>
#include "../settings.hpp"
#include "../content/Content.hpp"
#include "../content/ContentLUT.hpp"
#include "../debug/Logger.hpp"
#include "../files/WorldFiles.hpp"
#include "../items/Inventories.hpp"
#include "../objects/Player.hpp"
#include "../objects/Entities.hpp"
#include "../objects/Player.hpp"
#include "../settings.hpp"
#include "../voxels/Chunk.hpp"
#include "../voxels/Chunks.hpp"
#include "../voxels/ChunksStorage.hpp"
#include "../world/WorldGenerators.hpp"
#include "Level.hpp"
#include <memory>
#include <glm/glm.hpp>
#include <utility>
static debug::Logger logger("world");
const float DAYIME_SPECIFIC_SPEED = 1.0f/1440.0f; //1.0f/60.0f/24.0f;
const float DAYIME_SPECIFIC_SPEED = 1.0f / 1440.0f; // 1.0f/60.0f/24.0f;
world_load_error::world_load_error(const std::string& message)
: std::runtime_error(message) {
}
World::World(
std::string name,
std::string name,
std::string generator,
const fs::path& directory,
uint64_t seed,
uint64_t seed,
EngineSettings& settings,
const Content* content,
const std::vector<ContentPack>& packs
) : name(std::move(name)),
generator(std::move(generator)),
seed(seed),
content(content),
packs(packs),
wfile(std::make_unique<WorldFiles>(directory, settings.debug))
{}
)
: name(std::move(name)),
generator(std::move(generator)),
seed(seed),
content(content),
packs(packs),
wfile(std::make_unique<WorldFiles>(directory, settings.debug)) {
}
World::~World(){
World::~World() {
}
void World::updateTimers(float delta) {
@@ -74,7 +73,7 @@ void World::write(Level* level) {
level->chunks->saveAll();
nextEntityId = level->entities->peekNextID();
wfile->write(this, content);
auto playerFile = dynamic::Map();
auto& players = playerFile.putList("players");
for (const auto& object : level->objects) {
@@ -92,7 +91,7 @@ std::unique_ptr<Level> World::create(
const std::string& generator,
const fs::path& directory,
uint64_t seed,
EngineSettings& settings,
EngineSettings& settings,
const Content* content,
const std::vector<ContentPack>& packs
) {
@@ -109,7 +108,13 @@ std::unique_ptr<Level> World::load(
const std::vector<ContentPack>& packs
) {
auto world = std::make_unique<World>(
".", WorldGenerators::getDefaultGeneratorID(), directory, 0, settings, content, packs
".",
WorldGenerators::getDefaultGeneratorID(),
directory,
0,
settings,
content,
packs
);
auto& wfile = world->wfile;
@@ -131,8 +136,8 @@ std::unique_ptr<Level> World::load(
for (size_t i = 0; i < players->size(); i++) {
auto player = level->spawnObject<Player>(
level.get(),
glm::vec3(0, DEF_PLAYER_Y, 0),
DEF_PLAYER_SPEED,
glm::vec3(0, DEF_PLAYER_Y, 0),
DEF_PLAYER_SPEED,
level->inventories->create(DEF_PLAYER_INVENTORY_SIZE),
0
);
@@ -150,10 +155,9 @@ std::unique_ptr<Level> World::load(
}
std::shared_ptr<ContentLUT> World::checkIndices(
const fs::path& directory,
const Content* content
const fs::path& directory, const Content* content
) {
fs::path indicesFile = directory/fs::path("indices.json");
fs::path indicesFile = directory / fs::path("indices.json");
if (fs::is_regular_file(indicesFile)) {
return ContentLUT::create(indicesFile, content);
}
@@ -170,8 +174,7 @@ void World::setGenerator(const std::string& generator) {
bool World::hasPack(const std::string& id) const {
for (auto& pack : packs) {
if (pack.id == id)
return true;
if (pack.id == id) return true;
}
return false;
}
@@ -205,7 +208,7 @@ void World::deserialize(dynamic::Map* root) {
generator = WorldGenerators::getDefaultGeneratorID();
}
if (auto verobj = root->map("version")) {
int major=0, minor=-1;
int major = 0, minor = -1;
verobj->num("major", major);
verobj->num("minor", minor);
logger.info() << "world version: " << major << "." << minor;
@@ -232,7 +235,7 @@ std::unique_ptr<dynamic::Map> World::serialize() const {
root->put("name", name);
root->put("generator", generator);
root->put("seed", static_cast<integer_t>(seed));
auto& timeobj = root->putMap("time");
timeobj.put("day-time", daytime);
timeobj.put("day-time-speed", daytimeSpeed);