Skip to content

Commit

Permalink
[WorldController] '/save' and '/load' now use 'saves' folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jun 18, 2020
1 parent bfe48f6 commit eb4370e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ openminer_server
# Misc
*.dat
*.zip
saves
test_atlas.png
config/client.lua
config/keys.lua
Expand Down
7 changes: 5 additions & 2 deletions source/server/world/WorldController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*
* =====================================================================================
*/
#include <filesystem>
#include <fstream>

#include "Registry.hpp"
Expand All @@ -49,7 +50,7 @@ void WorldController::update() {
void WorldController::load(const std::string &name) {
gkDebug() << ("Loading '" + name + "'...").c_str();

std::ifstream file(name + ".dat", std::ofstream::binary);
std::ifstream file("saves/" + name + ".dat", std::ofstream::binary);

if (file.is_open()) {
file.seekg(0, file.end);
Expand Down Expand Up @@ -101,7 +102,9 @@ void WorldController::load(const std::string &name) {
void WorldController::save(const std::string &name) {
gkDebug() << ("Saving '" + name + "'...").c_str();

std::ofstream file(name + ".dat", std::ofstream::binary | std::ofstream::trunc);
std::filesystem::create_directory("saves");

std::ofstream file("saves/" + name + ".dat", std::ofstream::binary | std::ofstream::trunc);

Network::Packet save;
for (auto &world : m_worldList) {
Expand Down

0 comments on commit eb4370e

Please sign in to comment.