mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +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?
|
# verbosity level
|
||||||
verbose=false
|
# 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 Server configuration
|
||||||
[login]
|
[login]
|
||||||
|
@ -17,8 +17,7 @@ CNLoginServer::CNLoginServer(uint16_t p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||||
if (settings::VERBOSE)
|
printPacket(data, CL2LS);
|
||||||
std::cout << "OpenFusion: received " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
|
||||||
|
|
||||||
switch (data->type) {
|
switch (data->type) {
|
||||||
case P_CL2LS_REQ_LOGIN: {
|
case P_CL2LS_REQ_LOGIN: {
|
||||||
@ -280,6 +279,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if (settings::VERBOSITY)
|
||||||
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -352,6 +352,28 @@ void CNServer::kill() {
|
|||||||
connections.clear();
|
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::newConnection(CNSocket* cns) {} // stubbed
|
||||||
void CNServer::killConnection(CNSocket* cns) {} // stubbed
|
void CNServer::killConnection(CNSocket* cns) {} // stubbed
|
||||||
void CNServer::onTimer() {} // stubbed
|
void CNServer::onTimer() {} // stubbed
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MAX_PACKETSIZE 8192
|
#define MAX_PACKETSIZE 8192
|
||||||
#define DEBUGLOG(x) x
|
#define DEBUGLOG(x) if (settings::VERBOSITY) {x};
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -38,6 +38,9 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
|
#include "Defines.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
||||||
#include "mingw/mingw.mutex.h"
|
#include "mingw/mingw.mutex.h"
|
||||||
#else
|
#else
|
||||||
@ -147,6 +150,7 @@ public:
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
void kill();
|
void kill();
|
||||||
|
static void printPacket(CNPacketData *data, int type);
|
||||||
virtual void newConnection(CNSocket* cns);
|
virtual void newConnection(CNSocket* cns);
|
||||||
virtual void killConnection(CNSocket* cns);
|
virtual void killConnection(CNSocket* cns);
|
||||||
virtual void onTimer(); // called every 2 seconds
|
virtual void onTimer(); // called every 2 seconds
|
||||||
|
@ -18,13 +18,11 @@ CNShardServer::CNShardServer(uint16_t p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||||
if (settings::VERBOSE)
|
printPacket(data, CL2FE);
|
||||||
std::cout << "OpenFusion: received " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
if (ShardPackets.find(data->type) != ShardPackets.end())
|
if (ShardPackets.find(data->type) != ShardPackets.end())
|
||||||
ShardPackets[data->type](sock, data);
|
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;
|
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "contrib/INIReader.hpp"
|
#include "contrib/INIReader.hpp"
|
||||||
|
|
||||||
// defaults :)
|
// defaults :)
|
||||||
bool settings::VERBOSE = false;
|
int settings::VERBOSITY = 1;
|
||||||
|
|
||||||
int settings::LOGINPORT = 8001;
|
int settings::LOGINPORT = 8001;
|
||||||
bool settings::LOGINRANDCHARACTERS = false;
|
bool settings::LOGINRANDCHARACTERS = false;
|
||||||
@ -32,7 +32,7 @@ void settings::init() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE = reader.GetBoolean("", "verbose", VERBOSE);
|
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
||||||
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
||||||
LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS);
|
LOGINRANDCHARACTERS = reader.GetBoolean("login", "randomcharacters", LOGINRANDCHARACTERS);
|
||||||
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace settings {
|
namespace settings {
|
||||||
extern bool VERBOSE;
|
extern int VERBOSITY;
|
||||||
extern int LOGINPORT;
|
extern int LOGINPORT;
|
||||||
extern bool LOGINRANDCHARACTERS;
|
extern bool LOGINRANDCHARACTERS;
|
||||||
extern int SHARDPORT;
|
extern int SHARDPORT;
|
||||||
|
Loading…
Reference in New Issue
Block a user