using log calls
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "game/client/Client.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "misc/Format.h"
|
||||
|
||||
namespace td {
|
||||
namespace client {
|
||||
@@ -12,7 +11,7 @@ bool Client::Connect(const network::IPAddresses& addresses, std::uint16_t port)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
std::cout << "Failed to connect !\n";
|
||||
utils::LOG("Failed to connect !");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,7 +38,7 @@ void Client::Tick(std::uint64_t delta) {
|
||||
return;
|
||||
m_Connected = m_Connexion.UpdateSocket();
|
||||
if (!m_Connected) {
|
||||
std::cout << "Disconnected ! (Reason : " << m_Connexion.GetDisconnectReason() << ")\n";
|
||||
utils::LOG(utils::format("Disconnected ! (Reason : %s)", m_Connexion.GetDisconnectReason().c_str()));
|
||||
Reset();
|
||||
} else {
|
||||
m_Game->Tick(delta);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include "misc/Time.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define MIN_PLAYER_WAITING 2
|
||||
#else
|
||||
@@ -53,7 +51,7 @@ void Lobby::SendTimeRemaining() {
|
||||
void Lobby::OnPlayerJoin(std::uint8_t playerID) {
|
||||
if (m_GameStarted)
|
||||
return;
|
||||
std::cout << "(Server) Player Joined Lobby !\n";
|
||||
utils::LOG("(Server) Player Joined Lobby !");
|
||||
m_Players.push_back(playerID);
|
||||
if (m_Players.size() == MIN_PLAYER_WAITING) { // start timer if a second player join the match
|
||||
m_StartTimerTime = utils::GetTime();
|
||||
@@ -65,7 +63,7 @@ void Lobby::OnPlayerJoin(std::uint8_t playerID) {
|
||||
void Lobby::OnPlayerLeave(std::uint8_t playerID) {
|
||||
if (m_GameStarted)
|
||||
return;
|
||||
std::cout << "(Server) Player Leaved Lobby !\n";
|
||||
utils::LOG("(Server) Player Leaved Lobby !");
|
||||
|
||||
auto it = std::find(m_Players.begin(), m_Players.end(), playerID);
|
||||
if (it == m_Players.end())
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "game/server/Server.h"
|
||||
#include <iostream>
|
||||
#include "protocol/PacketFactory.h"
|
||||
|
||||
#include "misc/Format.h"
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
@@ -44,14 +45,14 @@ void Server::StopThread() {
|
||||
|
||||
bool Server::Start(std::uint16_t port) {
|
||||
if (!m_Listener.Listen(port, 10)) {
|
||||
std::cout << "Failed to bind port " << port << " !\n";
|
||||
utils::LOG(utils::format("Failed to bind port %u !", port));
|
||||
return false;
|
||||
}
|
||||
if (!m_Listener.SetBlocking(false)) {
|
||||
std::cout << "Failed to block server socket !\n";
|
||||
utils::LOG("Failed to block server socket !");
|
||||
return false;
|
||||
}
|
||||
std::cout << "Server started at port " << port << " !\n";
|
||||
utils::LOG(utils::format("Server started at port %u !", port));
|
||||
m_TickCounter.Reset();
|
||||
m_ServerRunning = true;
|
||||
StartThread();
|
||||
@@ -65,7 +66,7 @@ void Server::Clean() {
|
||||
m_Connections.clear();
|
||||
GetPlayers().clear();
|
||||
|
||||
std::cout << "Server successfully stopped !\n";
|
||||
utils::LOG("Server successfully stopped !");
|
||||
}
|
||||
|
||||
void Server::Stop() {
|
||||
|
||||
Reference in New Issue
Block a user