Windows build fix
This commit is contained in:
parent
d349b4b65a
commit
8310b1b768
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include "../typedefs.h"
|
||||||
|
|
||||||
inline int is_box(int c) {
|
inline int is_box(int c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
|||||||
@ -77,7 +77,7 @@ void Engine::updateHotkeys() {
|
|||||||
unique_ptr<ImageData> image(Window::takeScreenshot());
|
unique_ptr<ImageData> image(Window::takeScreenshot());
|
||||||
image->flipY();
|
image->flipY();
|
||||||
path filename = enginefs::get_screenshot_file("png");
|
path filename = enginefs::get_screenshot_file("png");
|
||||||
png::write_image(filename, image.get());
|
png::write_image(filename.string(), image.get());
|
||||||
std::cout << "saved screenshot as " << filename << std::endl;
|
std::cout << "saved screenshot as " << filename << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,12 +115,12 @@ void WorldFiles::put(Chunk* chunk){
|
|||||||
region.compressedSizes[chunk_index] = compressedSize;
|
region.compressedSizes[chunk_index] = compressedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WorldFiles::getRegionFile(int x, int y) {
|
path WorldFiles::getRegionFile(int x, int y) {
|
||||||
return directory/(std::to_string(x) + "_" + std::to_string(y) + ".bin");
|
return directory/path(std::to_string(x) + "_" + std::to_string(y) + ".bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WorldFiles::getPlayerFile() {
|
path WorldFiles::getPlayerFile() {
|
||||||
return directory/"player.bin";
|
return directory/path("player.bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
ubyte* WorldFiles::getChunk(int x, int y){
|
ubyte* WorldFiles::getChunk(int x, int y){
|
||||||
@ -173,7 +173,7 @@ ubyte* WorldFiles::readChunkData(int x, int y, uint32_t& length){
|
|||||||
|
|
||||||
int chunkIndex = localY * REGION_SIZE + localX;
|
int chunkIndex = localY * REGION_SIZE + localX;
|
||||||
|
|
||||||
std::string filename = getRegionFile(regionX, regionY);
|
path filename = getRegionFile(regionX, regionY);
|
||||||
std::ifstream input(filename, std::ios::binary);
|
std::ifstream input(filename, std::ios::binary);
|
||||||
if (!input.is_open()){
|
if (!input.is_open()){
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@ -46,8 +46,8 @@ public:
|
|||||||
void writePlayer(Player* player);
|
void writePlayer(Player* player);
|
||||||
void write();
|
void write();
|
||||||
|
|
||||||
std::string getRegionFile(int x, int y);
|
std::filesystem::path getRegionFile(int x, int y);
|
||||||
std::string getPlayerFile();
|
std::filesystem::path getPlayerFile();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FILES_WORLDFILES_H_ */
|
#endif /* FILES_WORLDFILES_H_ */
|
||||||
@ -1,6 +1,8 @@
|
|||||||
#include "engine_files.h"
|
#include "engine_files.h"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <sstream>
|
||||||
|
#include "../typedefs.h"
|
||||||
|
|
||||||
namespace filesystem = std::filesystem;
|
namespace filesystem = std::filesystem;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|||||||
@ -10,8 +10,9 @@ using std::string;
|
|||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
|
using std::filesystem::path;
|
||||||
|
|
||||||
bool files::write_bytes(string filename, const char* data, size_t size) {
|
bool files::write_bytes(path filename, const char* data, size_t size) {
|
||||||
ofstream output(filename, ios::binary);
|
ofstream output(filename, ios::binary);
|
||||||
if (!output.is_open())
|
if (!output.is_open())
|
||||||
return false;
|
return false;
|
||||||
@ -20,7 +21,7 @@ bool files::write_bytes(string filename, const char* data, size_t size) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint files::append_bytes(string filename, const char* data, size_t size) {
|
uint files::append_bytes(path filename, const char* data, size_t size) {
|
||||||
ofstream output(filename, ios::binary | ios::app);
|
ofstream output(filename, ios::binary | ios::app);
|
||||||
if (!output.is_open())
|
if (!output.is_open())
|
||||||
return 0;
|
return 0;
|
||||||
@ -30,7 +31,7 @@ uint files::append_bytes(string filename, const char* data, size_t size) {
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool files::read(string filename, char* data, size_t size) {
|
bool files::read(path filename, char* data, size_t size) {
|
||||||
ifstream output(filename, ios::binary);
|
ifstream output(filename, ios::binary);
|
||||||
if (!output.is_open())
|
if (!output.is_open())
|
||||||
return false;
|
return false;
|
||||||
@ -39,7 +40,7 @@ bool files::read(string filename, char* data, size_t size) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* files::read_bytes(string filename, size_t& length) {
|
char* files::read_bytes(path filename, size_t& length) {
|
||||||
ifstream input(filename, ios::binary);
|
ifstream input(filename, ios::binary);
|
||||||
if (!input.is_open())
|
if (!input.is_open())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -53,13 +54,13 @@ char* files::read_bytes(string filename, size_t& length) {
|
|||||||
return data.release();
|
return data.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string files::read_string(string filename) {
|
std::string files::read_string(path filename) {
|
||||||
size_t size;
|
size_t size;
|
||||||
unique_ptr<char> chars (read_bytes(filename, size));
|
unique_ptr<char> chars (read_bytes(filename, size));
|
||||||
return string(chars.get(), size);
|
return string(chars.get(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool files::write_string(string filename, const string content) {
|
bool files::write_string(path filename, const string content) {
|
||||||
ofstream file(filename);
|
ofstream file(filename);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -2,15 +2,16 @@
|
|||||||
#define FILES_FILES_H_
|
#define FILES_FILES_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
namespace files {
|
namespace files {
|
||||||
extern bool write_bytes(std::string filename, const char* data, size_t size);
|
extern bool write_bytes(std::filesystem::path, const char* data, size_t size);
|
||||||
extern uint append_bytes(std::string filename, const char* data, size_t size);
|
extern uint append_bytes(std::filesystem::path, const char* data, size_t size);
|
||||||
extern bool read(std::string filename, char* data, size_t size);
|
extern bool read(std::filesystem::path, char* data, size_t size);
|
||||||
extern char* read_bytes(std::string filename, size_t& length);
|
extern char* read_bytes(std::filesystem::path, size_t& length);
|
||||||
extern std::string read_string(std::string filename);
|
extern std::string read_string(std::filesystem::path filename);
|
||||||
extern bool write_string(std::string filename, const std::string content);
|
extern bool write_string(std::filesystem::path filename, const std::string content);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FILES_FILES_H_ */
|
#endif /* FILES_FILES_H_ */
|
||||||
@ -16,7 +16,7 @@
|
|||||||
using glm::vec3;
|
using glm::vec3;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
||||||
World::World(std::string name, std::string directory, int seed, EngineSettings& settings) : name(name), seed(seed) {
|
World::World(std::string name, std::filesystem::path directory, int seed, EngineSettings& settings) : name(name), seed(seed) {
|
||||||
wfile = new WorldFiles(directory, REGION_VOL * (CHUNK_DATA_LEN * 2 + 8), settings.debug.generatorTestMode);
|
wfile = new WorldFiles(directory, REGION_VOL * (CHUNK_DATA_LEN * 2 + 8), settings.debug.generatorTestMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define WORLD_WORLD_H_
|
#define WORLD_WORLD_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
#include "../settings.h"
|
#include "../settings.h"
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ public:
|
|||||||
WorldFiles* wfile;
|
WorldFiles* wfile;
|
||||||
int seed;
|
int seed;
|
||||||
|
|
||||||
World(std::string name, std::string directory, int seed, EngineSettings& settings);
|
World(std::string name, std::filesystem::path directory, int seed, EngineSettings& settings);
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
void write(Level* level, bool writeChunks);
|
void write(Level* level, bool writeChunks);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user