using log calls

This commit is contained in:
2022-07-14 18:32:32 +02:00
parent 66376eaeda
commit d6fbb58da8
8 changed files with 39 additions and 38 deletions

View File

@@ -3,11 +3,10 @@
#include "protocol/Protocol.h"
#include "game/BaseGame.h"
#include "misc/Random.h"
#include "misc/Compression.h"
#include "misc/Format.h"
#include <cmath>
#include "misc/Compression.h"
#include <iostream>
namespace td {
namespace game {
@@ -63,11 +62,11 @@ bool World::LoadMap(const protocol::WorldDataPacket* worldData) {
bool World::LoadMapFromFile(const std::string& fileName) {
DataBuffer buffer;
if (!buffer.ReadFile(fileName)) {
std::cerr << "Failed to load map from file " << fileName << " !\n";
utils::LOG(utils::format("[ERROR] : Failed to load map from file %s", fileName.c_str()));
return false;
}
std::cout << "Read file : " << fileName << " (File size : " << buffer.GetSize() << ")" << std::endl;
utils::LOG(utils::format("Read file : %s (File size : %u)", fileName.c_str(), buffer.GetSize()));
DataBuffer mapHeaderPacketBuffer = utils::Decompress(buffer);
DataBuffer mapDataPacketBuffer = utils::Decompress(buffer);
@@ -91,11 +90,11 @@ bool World::SaveMap(const std::string& fileName) const {
DataBuffer mapHeaderCompressed = utils::Compress(headerPacket.Serialize(false));
DataBuffer mapDataCompressed = utils::Compress(dataPacket.Serialize(false));
std::cout << "Header Packet Size : " << mapHeaderCompressed.GetSize() << std::endl;
std::cout << "World Data Packet Size : " << mapDataCompressed.GetSize() << std::endl;
utils::LOG(utils::format("Header Packet Size : %u", mapHeaderCompressed.GetSize()));
utils::LOG(utils::format("World Data Packet Size : %u", mapDataCompressed.GetSize()));
DataBuffer buffer = mapHeaderCompressed << mapDataCompressed;
std::cout << "Total Size : " << buffer.GetSize() << std::endl;
utils::LOG(utils::format("Total Size : %u", buffer.GetSize()));
return buffer.WriteFile(fileName);
}