diff options
-rw-r--r-- | src/Info.cpp | 55 | ||||
-rw-r--r-- | src/MinedMap.cpp | 9 | ||||
-rw-r--r-- | src/World/Block.hpp | 2 |
3 files changed, 32 insertions, 34 deletions
diff --git a/src/Info.cpp b/src/Info.cpp index ed25847..eef2b0e 100644 --- a/src/Info.cpp +++ b/src/Info.cpp @@ -30,7 +30,6 @@ #include <cstdio> #include <cstring> #include <string> -#include <unistd.h> namespace MinedMap { @@ -38,64 +37,64 @@ namespace MinedMap { void Info::writeJSON(const char *filename) const { const std::string tmpfile = std::string(filename) + ".tmp"; - FILE *f = fopen(tmpfile.c_str(), "w"); + FILE *f = std::fopen(tmpfile.c_str(), "w"); if (!f) { std::fprintf(stderr, "Unable to open %s: %s\n", tmpfile.c_str(), std::strerror(errno)); return; } - fprintf(f, "{\n"); - fprintf(f, " \"mipmaps\" : [\n"); + std::fprintf(f, "{\n"); + std::fprintf(f, " \"mipmaps\" : [\n"); for (size_t level = 0; level < regions.size(); level++) { int minX, maxX, minZ, maxZ; std::tie(minX, maxX, minZ, maxZ) = getBounds(level); - fprintf(f, " {\n"); - fprintf(f, " \"info\" : {\n"); - fprintf(f, " \"minX\" : %i,\n", minX); - fprintf(f, " \"maxX\" : %i,\n", maxX); - fprintf(f, " \"minZ\" : %i,\n", minZ); - fprintf(f, " \"maxZ\" : %i\n", maxZ); - fprintf(f, " },\n"); - fprintf(f, " \"regions\" : [\n"); + std::fprintf(f, " {\n"); + std::fprintf(f, " \"info\" : {\n"); + std::fprintf(f, " \"minX\" : %i,\n", minX); + std::fprintf(f, " \"maxX\" : %i,\n", maxX); + std::fprintf(f, " \"minZ\" : %i,\n", minZ); + std::fprintf(f, " \"maxZ\" : %i\n", maxZ); + std::fprintf(f, " },\n"); + std::fprintf(f, " \"regions\" : [\n"); for (int z = minZ; z <= maxZ; z++) { - fprintf(f, " ["); + std::fprintf(f, " ["); for (int x = minX; x <= maxX; x++) { - fprintf(f, "%s", regions[level].count(std::make_pair(x, z)) ? "true" : "false"); + std::fprintf(f, "%s", regions[level].count(std::make_pair(x, z)) ? "true" : "false"); if (x < maxX) - fprintf(f, ", "); + std::fprintf(f, ", "); } if (z < maxZ) - fprintf(f, "],\n"); + std::fprintf(f, "],\n"); else - fprintf(f, "]\n"); + std::fprintf(f, "]\n"); } - fprintf(f, " ]\n"); + std::fprintf(f, " ]\n"); if (level < regions.size() - 1) - fprintf(f, " },\n"); + std::fprintf(f, " },\n"); else - fprintf(f, " }\n"); + std::fprintf(f, " }\n"); } - fprintf(f, " ],\n"); - fprintf(f, " \"spawn\" : {\n"); - fprintf(f, " \"x\" : %li,\n", (long)spawnX); - fprintf(f, " \"z\" : %li\n", (long)spawnZ); - fprintf(f, " }\n"); - fprintf(f, "}\n"); + std::fprintf(f, " ],\n"); + std::fprintf(f, " \"spawn\" : {\n"); + std::fprintf(f, " \"x\" : %li,\n", (long)spawnX); + std::fprintf(f, " \"z\" : %li\n", (long)spawnZ); + std::fprintf(f, " }\n"); + std::fprintf(f, "}\n"); - fclose(f); + std::fclose(f); if (std::rename(tmpfile.c_str(), filename) < 0) { std::fprintf(stderr, "Unable to save %s: %s\n", filename, std::strerror(errno)); - unlink(tmpfile.c_str()); + std::remove(tmpfile.c_str()); } } diff --git a/src/MinedMap.cpp b/src/MinedMap.cpp index 8624636..0193bbc 100644 --- a/src/MinedMap.cpp +++ b/src/MinedMap.cpp @@ -45,7 +45,6 @@ #include <fcntl.h> #include <sys/stat.h> #include <sys/time.h> -#include <unistd.h> namespace MinedMap { @@ -100,11 +99,11 @@ static void writeImage(const std::string &output, const uint8_t *data, bool colo if (std::rename(tmpfile.c_str(), output.c_str()) < 0) { std::fprintf(stderr, "Unable to save %s: %s\n", output.c_str(), std::strerror(errno)); - unlink(tmpfile.c_str()); + std::remove(tmpfile.c_str()); } } catch (const std::exception& ex) { - unlink(tmpfile.c_str()); + std::remove(tmpfile.c_str()); throw; } } @@ -223,11 +222,11 @@ static bool makeMipmap(const std::string &dir, size_t level, size_t x, size_t z, if (std::rename(tmpfile.c_str(), output.c_str()) < 0) { std::fprintf(stderr, "Unable to save %s: %s\n", output.c_str(), std::strerror(errno)); - unlink(tmpfile.c_str()); + std::remove(tmpfile.c_str()); } } catch (const std::exception& ex) { - unlink(tmpfile.c_str()); + std::remove(tmpfile.c_str()); throw; } diff --git a/src/World/Block.hpp b/src/World/Block.hpp index b636f06..81d8b27 100644 --- a/src/World/Block.hpp +++ b/src/World/Block.hpp @@ -26,7 +26,7 @@ #pragma once -#include <stdint.h> +#include <cstdint> namespace MinedMap { |