mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 03:40:05 +00:00
Add verbosity levels.
This commit is contained in:
parent
756074cc62
commit
e99feb03d5
@ -1,5 +1,9 @@
|
||||
# should the server print every packet it receives?
|
||||
verbose=false
|
||||
# verbosity level
|
||||
# 0 = mostly silence
|
||||
# 1 = debug prints and unknown packets
|
||||
# 2 = print all packets except LIVE_CHECK and movement
|
||||
# 3 = print all packets
|
||||
verbosity=1
|
||||
|
||||
# Login Server configuration
|
||||
[login]
|
||||
|
@ -17,8 +17,7 @@ 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;
|
||||
printPacket(data, CL2LS);
|
||||
|
||||
switch (data->type) {
|
||||
case P_CL2LS_REQ_LOGIN: {
|
||||
@ -280,7 +279,8 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||
if (settings::VERBOSITY)
|
||||
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -352,6 +352,28 @@ void CNServer::kill() {
|
||||
connections.clear();
|
||||
}
|
||||
|
||||
void CNServer::printPacket(CNPacketData *data, int type) {
|
||||
if (settings::VERBOSITY < 2)
|
||||
return;
|
||||
|
||||
if (settings::VERBOSITY < 3) switch (data->type) {
|
||||
case P_CL2LS_REP_LIVE_CHECK:
|
||||
case P_CL2FE_REP_LIVE_CHECK:
|
||||
case P_CL2FE_REQ_PC_MOVE:
|
||||
case P_CL2FE_REQ_PC_JUMP:
|
||||
case P_CL2FE_REQ_PC_SLOPE:
|
||||
case P_CL2FE_REQ_PC_MOVEPLATFORM:
|
||||
case P_CL2FE_REQ_PC_MOVETRANSPORTATION:
|
||||
case P_CL2FE_REQ_PC_ZIPLINE:
|
||||
case P_CL2FE_REQ_PC_JUMPPAD:
|
||||
case P_CL2FE_REQ_PC_LAUNCHER:
|
||||
case P_CL2FE_REQ_PC_STOP:
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "OpenFusion: received " << Defines::p2str(type, data->type) << " (" << data->type << ")" << std::endl;
|
||||
}
|
||||
|
||||
void CNServer::newConnection(CNSocket* cns) {} // stubbed
|
||||
void CNServer::killConnection(CNSocket* cns) {} // stubbed
|
||||
void CNServer::onTimer() {} // stubbed
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define MAX_PACKETSIZE 8192
|
||||
#define DEBUGLOG(x) x
|
||||
#define DEBUGLOG(x) if (settings::VERBOSITY) {x};
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
@ -38,6 +38,9 @@
|
||||
#include <list>
|
||||
#include <queue>
|
||||
|
||||
#include "Defines.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
||||
#include "mingw/mingw.mutex.h"
|
||||
#else
|
||||
@ -147,6 +150,7 @@ public:
|
||||
|
||||
void start();
|
||||
void kill();
|
||||
static void printPacket(CNPacketData *data, int type);
|
||||
virtual void newConnection(CNSocket* cns);
|
||||
virtual void killConnection(CNSocket* cns);
|
||||
virtual void onTimer(); // called every 2 seconds
|
||||
|
@ -18,13 +18,11 @@ 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;
|
||||
|
||||
printPacket(data, CL2FE);
|
||||
|
||||
if (ShardPackets.find(data->type) != ShardPackets.end())
|
||||
ShardPackets[data->type](sock, data);
|
||||
else
|
||||
else if (settings::VERBOSITY)
|
||||
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "contrib/INIReader.hpp"
|
||||
|
||||
// defaults :)
|
||||
bool settings::VERBOSE = false;
|
||||
int settings::VERBOSITY = 1;
|
||||
|
||||
int settings::LOGINPORT = 8001;
|
||||
bool settings::LOGINRANDCHARACTERS = false;
|
||||
@ -32,7 +32,7 @@ void settings::init() {
|
||||
return;
|
||||
}
|
||||
|
||||
VERBOSE = reader.GetBoolean("", "verbose", VERBOSE);
|
||||
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
||||
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
||||
LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS);
|
||||
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace settings {
|
||||
extern bool VERBOSE;
|
||||
extern int VERBOSITY;
|
||||
extern int LOGINPORT;
|
||||
extern bool LOGINRANDCHARACTERS;
|
||||
extern int SHARDPORT;
|
||||
|
Loading…
Reference in New Issue
Block a user