diff --git a/config.ini b/config.ini index c479216..5586a25 100644 --- a/config.ini +++ b/config.ini @@ -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 diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index e8c96ff..1ba5651 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -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)) diff --git a/src/CNShardServer.cpp b/src/CNShardServer.cpp index a043f4a..6aa26b4 100644 --- a/src/CNShardServer.cpp +++ b/src/CNShardServer.cpp @@ -3,6 +3,7 @@ #include "CNShardServer.hpp" #include "PlayerManager.hpp" #include "CNShared.hpp" +#include "settings.hpp" #include #include @@ -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); diff --git a/src/settings.cpp b/src/settings.cpp index 59dff6d..4922f5d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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); diff --git a/src/settings.hpp b/src/settings.hpp index 7efe1de..6ab94aa 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -2,6 +2,7 @@ #define _SETT_HPP namespace settings { + extern bool VERBOSE; extern int LOGINPORT; extern bool LOGINRANDCHARACTERS; extern int SHARDPORT;