refactor
This commit is contained in:
@@ -32,11 +32,11 @@ public:
|
||||
};
|
||||
|
||||
WorldConverter::WorldConverter(
|
||||
const fs::path& folder,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
std::shared_ptr<ContentLUT> lut
|
||||
)
|
||||
: wfile(std::make_unique<WorldFiles>(folder)),
|
||||
: wfile(worldFiles),
|
||||
lut(std::move(lut)),
|
||||
content(content) {
|
||||
fs::path regionsFolder =
|
||||
@@ -56,13 +56,13 @@ WorldConverter::~WorldConverter() {
|
||||
}
|
||||
|
||||
std::shared_ptr<Task> WorldConverter::startTask(
|
||||
const fs::path& folder,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
const std::shared_ptr<ContentLUT>& lut,
|
||||
const runnable& onDone,
|
||||
bool multithreading
|
||||
) {
|
||||
auto converter = std::make_shared<WorldConverter>(folder, content, lut);
|
||||
auto converter = std::make_shared<WorldConverter>(worldFiles, content, lut);
|
||||
if (!multithreading) {
|
||||
converter->setOnComplete([=]() {
|
||||
converter->write();
|
||||
|
||||
@@ -22,7 +22,7 @@ struct convert_task {
|
||||
};
|
||||
|
||||
class WorldConverter : public Task {
|
||||
std::unique_ptr<WorldFiles> wfile;
|
||||
std::shared_ptr<WorldFiles> wfile;
|
||||
std::shared_ptr<ContentLUT> const lut;
|
||||
const Content* const content;
|
||||
std::queue<convert_task> tasks;
|
||||
@@ -33,7 +33,7 @@ class WorldConverter : public Task {
|
||||
void convertRegion(const fs::path& file) const;
|
||||
public:
|
||||
WorldConverter(
|
||||
const fs::path& folder,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
std::shared_ptr<ContentLUT> lut
|
||||
);
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
uint getWorkDone() const override;
|
||||
|
||||
static std::shared_ptr<Task> startTask(
|
||||
const fs::path& folder,
|
||||
const std::shared_ptr<WorldFiles>& worldFiles,
|
||||
const Content* content,
|
||||
const std::shared_ptr<ContentLUT>& lut,
|
||||
const runnable& onDone,
|
||||
|
||||
@@ -34,7 +34,6 @@ class WorldFiles {
|
||||
bool doWriteLights = true;
|
||||
|
||||
fs::path getWorldFile() const;
|
||||
fs::path getIndicesFile() const;
|
||||
fs::path getPacksFile() const;
|
||||
|
||||
void writeWorldInfo(const WorldInfo& info);
|
||||
@@ -45,6 +44,7 @@ public:
|
||||
~WorldFiles();
|
||||
|
||||
fs::path getPlayerFile() const;
|
||||
fs::path getIndicesFile() const;
|
||||
fs::path getResourcesFile() const;
|
||||
void createDirectories();
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ regfile::regfile(fs::path filename) : file(std::move(filename)) {
|
||||
file.read(header, REGION_HEADER_SIZE);
|
||||
|
||||
// avoid of use strcmp_s
|
||||
if (std::string(header, strlen(REGION_FORMAT_MAGIC)) !=
|
||||
if (std::string(header, std::strlen(REGION_FORMAT_MAGIC)) !=
|
||||
REGION_FORMAT_MAGIC) {
|
||||
throw std::runtime_error("invalid region file magic number");
|
||||
}
|
||||
version = header[8];
|
||||
if (uint(version) > REGION_FORMAT_VERSION) {
|
||||
if (static_cast<uint>(version) > REGION_FORMAT_VERSION) {
|
||||
throw illegal_region_format(
|
||||
"region format " + std::to_string(version) + " is not supported"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user