update WorldConverter (WIP)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "delegates.hpp"
|
||||
#include "interfaces/Task.hpp"
|
||||
#include "files/world_regions_fwd.hpp"
|
||||
#include "typedefs.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@@ -14,32 +15,59 @@ class Content;
|
||||
class ContentReport;
|
||||
class WorldFiles;
|
||||
|
||||
enum class convert_task_type { region, player };
|
||||
enum class ConvertTaskType {
|
||||
/// @brief rewrite voxels region indices
|
||||
VOXELS,
|
||||
/// @brief rewrite inventories region indices
|
||||
INVENTORIES,
|
||||
/// @brief rewrite player
|
||||
PLAYER,
|
||||
/// @brief refresh region file version
|
||||
UPGRADE_SIMPLE,
|
||||
/// @brief rewrite voxels region file to new format
|
||||
UPGRADE_VOXELS,
|
||||
};
|
||||
|
||||
struct convert_task {
|
||||
convert_task_type type;
|
||||
struct ConvertTask {
|
||||
ConvertTaskType type;
|
||||
fs::path file;
|
||||
|
||||
/// @brief region coords
|
||||
int x, z;
|
||||
};
|
||||
|
||||
class WorldConverter : public Task {
|
||||
std::shared_ptr<WorldFiles> wfile;
|
||||
std::shared_ptr<ContentReport> const report;
|
||||
const Content* const content;
|
||||
std::queue<convert_task> tasks;
|
||||
std::queue<ConvertTask> tasks;
|
||||
runnable onComplete;
|
||||
uint tasksDone = 0;
|
||||
bool upgradeMode;
|
||||
|
||||
void upgradeSimple(const fs::path& file, int x, int z) const;
|
||||
void upgradeVoxels(const fs::path& file, int x, int z) const;
|
||||
void convertPlayer(const fs::path& file) const;
|
||||
void convertRegion(const fs::path& file) const;
|
||||
void convertVoxels(const fs::path& file, int x, int z) const;
|
||||
void convertInventories(const fs::path& file, int x, int z) const;
|
||||
|
||||
void addRegionsTasks(
|
||||
RegionLayerIndex layerid,
|
||||
ConvertTaskType taskType
|
||||
);
|
||||
|
||||
void createUpgradeTasks();
|
||||
void createConvertTasks();
|
||||
public:
|
||||
WorldConverter(
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
std::shared_ptr<ContentReport> report
|
||||
std::shared_ptr<ContentReport> report,
|
||||
bool upgradeMode
|
||||
);
|
||||
~WorldConverter();
|
||||
|
||||
void convert(const convert_task& task) const;
|
||||
void convert(const ConvertTask& task) const;
|
||||
void convertNext();
|
||||
void setOnComplete(runnable callback);
|
||||
void write();
|
||||
@@ -56,6 +84,7 @@ public:
|
||||
const Content* content,
|
||||
const std::shared_ptr<ContentReport>& report,
|
||||
const runnable& onDone,
|
||||
bool upgradeMode,
|
||||
bool multithreading
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user