Add support for verbose logging.

This commit is contained in:
dongresource 2020-08-22 19:39:13 +02:00
parent 43f2def80b
commit 35c622d8a2
5 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,6 @@
# should the server print every packet it receives?
verbose=false
# Login Server configuration
[login]
# must be kept in sync with loginInfo.php

View File

@ -17,6 +17,9 @@ CNLoginServer::CNLoginServer(uint16_t p) {
}
void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
if (settings::VERBOSE)
std::cout << "OpenFusion: received " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
switch (data->type) {
case P_CL2LS_REQ_LOGIN: {
if (data->size != sizeof(sP_CL2LS_REQ_LOGIN))

View File

@ -3,6 +3,7 @@
#include "CNShardServer.hpp"
#include "PlayerManager.hpp"
#include "CNShared.hpp"
#include "settings.hpp"
#include <iostream>
#include <sstream>
@ -17,6 +18,10 @@ CNShardServer::CNShardServer(uint16_t p) {
}
void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
if (settings::VERBOSE)
std::cout << "OpenFusion: received " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
if (ShardPackets.find(data->type) != ShardPackets.end())
ShardPackets[data->type](sock, data);
else
@ -24,7 +29,7 @@ void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
}
void CNShardServer::killConnection(CNSocket* cns) {
// remove from CNSharedData
// remove from CNSharedData
Player cachedPlr = PlayerManager::getPlayer(cns);
PlayerManager::removePlayer(cns);

View File

@ -3,6 +3,8 @@
#include "contrib/INIReader.hpp"
// defaults :)
bool settings::VERBOSE = false;
int settings::LOGINPORT = 8001;
bool settings::LOGINRANDCHARACTERS = false;
@ -30,6 +32,7 @@ void settings::init() {
return;
}
VERBOSE = reader.GetBoolean("", "verbose", VERBOSE);
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS);
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);

View File

@ -2,6 +2,7 @@
#define _SETT_HPP
namespace settings {
extern bool VERBOSE;
extern int LOGINPORT;
extern bool LOGINRANDCHARACTERS;
extern int SHARDPORT;