mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Merge pull request #32 from dongresource/work
-Wall, #pragma once, nanoSummonHandler() cleanup, verbosity levels
This commit is contained in:
commit
55add82843
4
Makefile
4
Makefile
@ -1,6 +1,6 @@
|
|||||||
CXX=clang++
|
CXX=clang++
|
||||||
# -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!)
|
# -w suppresses all warnings (the part that's commented out helps me find memory leaks, it ruins performance though!)
|
||||||
CXXFLAGS=-std=c++17 -O3 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address
|
CXXFLAGS=-Wall -std=c++17 -O3 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address
|
||||||
LDFLAGS=-lpthread
|
LDFLAGS=-lpthread
|
||||||
# specifies the name of our exectuable
|
# specifies the name of our exectuable
|
||||||
SERVER=bin/fusion
|
SERVER=bin/fusion
|
||||||
@ -11,7 +11,7 @@ PROTOCOL_VERSION?=104
|
|||||||
|
|
||||||
# Windows-specific
|
# Windows-specific
|
||||||
WIN_CXX=x86_64-w64-mingw32-g++
|
WIN_CXX=x86_64-w64-mingw32-g++
|
||||||
WIN_CXXFLAGS=-std=c++17 -O3 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address
|
WIN_CXXFLAGS=-Wall -std=c++17 -O3 -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) #-g3 -fsanitize=address
|
||||||
WIN_LDFLAGS=-static -lws2_32 -lwsock32
|
WIN_LDFLAGS=-static -lws2_32 -lwsock32
|
||||||
WIN_SERVER=bin/winfusion.exe
|
WIN_SERVER=bin/winfusion.exe
|
||||||
|
|
||||||
|
@ -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: {
|
||||||
@ -27,7 +26,6 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sP_CL2LS_REQ_LOGIN* login = (sP_CL2LS_REQ_LOGIN*)data->buf;
|
sP_CL2LS_REQ_LOGIN* login = (sP_CL2LS_REQ_LOGIN*)data->buf;
|
||||||
INITSTRUCT(sP_LS2CL_REP_LOGIN_SUCC, resp);
|
INITSTRUCT(sP_LS2CL_REP_LOGIN_SUCC, resp);
|
||||||
uint64_t cachedKey = sock->getEKey(); // so we can still send the resp packet with the correct key
|
|
||||||
int charCount = 2; // send 4 randomly generated characters for now
|
int charCount = 2; // send 4 randomly generated characters for now
|
||||||
|
|
||||||
DEBUGLOG(
|
DEBUGLOG(
|
||||||
@ -281,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;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _CNLS_HPP
|
#pragma once
|
||||||
#define _CNLS_HPP
|
|
||||||
|
|
||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
#include "Defines.hpp"
|
#include "Defines.hpp"
|
||||||
@ -24,5 +23,3 @@ public:
|
|||||||
void newConnection(CNSocket* cns);
|
void newConnection(CNSocket* cns);
|
||||||
void killConnection(CNSocket* cns);
|
void killConnection(CNSocket* cns);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -63,7 +63,7 @@ int CNSocketEncryption::decryptData(uint8_t* buffer, uint8_t* key, int size) {
|
|||||||
|
|
||||||
// ========================================================[[ CNPacketData ]]========================================================
|
// ========================================================[[ CNPacketData ]]========================================================
|
||||||
|
|
||||||
CNPacketData::CNPacketData(void* b, uint32_t t, int l): buf(b), type(t), size(l) {}
|
CNPacketData::CNPacketData(void* b, uint32_t t, int l): buf(b), size(l), type(t) {}
|
||||||
|
|
||||||
// ========================================================[[ CNSocket ]]========================================================
|
// ========================================================[[ CNSocket ]]========================================================
|
||||||
|
|
||||||
@ -361,6 +361,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,8 +1,7 @@
|
|||||||
#ifndef _CNP_HPP
|
#pragma once
|
||||||
#define _CNP_HPP
|
|
||||||
|
|
||||||
#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>
|
||||||
@ -39,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
|
||||||
@ -148,9 +150,8 @@ 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
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _CNSS_HPP
|
#pragma once
|
||||||
#define _CNSS_HPP
|
|
||||||
|
|
||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
#include "Defines.hpp"
|
#include "Defines.hpp"
|
||||||
@ -21,5 +20,3 @@ public:
|
|||||||
void killConnection(CNSocket* cns);
|
void killConnection(CNSocket* cns);
|
||||||
void onTimer();
|
void onTimer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
There's some data shared between the Login Server and the Shard Server. Of course all of this needs to be thread-safe. No mucking about on this one!
|
There's some data shared between the Login Server and the Shard Server. Of course all of this needs to be thread-safe. No mucking about on this one!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CNSD_HPP
|
#pragma once
|
||||||
#define _CNSD_HPP
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -19,5 +18,3 @@ namespace CNSharedData {
|
|||||||
Player getPlayer(int64_t sk);
|
Player getPlayer(int64_t sk);
|
||||||
void erasePlayer(int64_t sk);
|
void erasePlayer(int64_t sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
@ -2,8 +2,7 @@
|
|||||||
CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CNS_HPP
|
#pragma once
|
||||||
#define _CNS_HPP
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// codecvt_* is deprecated in C++17 and MSVC will throw an annoying warning because of that.
|
// codecvt_* is deprecated in C++17 and MSVC will throw an annoying warning because of that.
|
||||||
@ -45,5 +44,3 @@ uint64_t getTime();
|
|||||||
#else
|
#else
|
||||||
#error Invalid PROTOCOL_VERSION
|
#error Invalid PROTOCOL_VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _CM_HPP
|
#pragma once
|
||||||
#define _CM_HPP
|
|
||||||
|
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
|
|
||||||
@ -10,5 +9,3 @@ namespace ChatManager {
|
|||||||
void emoteHandler(CNSocket* sock, CNPacketData* data);
|
void emoteHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void menuChatHandler(CNSocket* sock, CNPacketData* data);
|
void menuChatHandler(CNSocket* sock, CNPacketData* data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _IM_HPP
|
#pragma once
|
||||||
#define _IM_HPP
|
|
||||||
|
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
|
|
||||||
@ -9,5 +8,3 @@ namespace ItemManager {
|
|||||||
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
|
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _NPCMANAGER_HPP
|
#pragma once
|
||||||
#define _NPCMANAGER_HPP
|
|
||||||
|
|
||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
@ -20,5 +19,3 @@ namespace NPCManager {
|
|||||||
void npcWarpManager(CNSocket* sock, CNPacketData* data);
|
void npcWarpManager(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -93,14 +93,13 @@ void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
sNano nano = plr.plr.Nanos[nanoId];
|
sNano nano = plr.plr.Nanos[nanoId];
|
||||||
|
|
||||||
// Send to other players
|
// Send to other players
|
||||||
for (CNSocket *s : PlayerManager::players[sock].viewable) {
|
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
|
||||||
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt);
|
|
||||||
|
|
||||||
pkt.iPC_ID = plr.plr.iID;
|
pkt1.iPC_ID = plr.plr.iID;
|
||||||
pkt.Nano = nano;
|
pkt1.Nano = nano;
|
||||||
|
|
||||||
s->sendPacket((void*)&pkt, P_FE2CL_NANO_ACTIVE, sizeof(sP_FE2CL_NANO_ACTIVE));
|
for (CNSocket *s : PlayerManager::players[sock].viewable)
|
||||||
}
|
s->sendPacket((void*)&pkt1, P_FE2CL_NANO_ACTIVE, sizeof(sP_FE2CL_NANO_ACTIVE));
|
||||||
|
|
||||||
// update player
|
// update player
|
||||||
plr.plr.nano = nanoId;
|
plr.plr.nano = nanoId;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _NM_HPP
|
#pragma once
|
||||||
#define _NM_HPP
|
|
||||||
|
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
|
|
||||||
@ -17,5 +16,3 @@ namespace NanoManager {
|
|||||||
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
|
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
|
||||||
void resetNanoSkill(CNSocket* sock, int16_t nanoId);
|
void resetNanoSkill(CNSocket* sock, int16_t nanoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
@ -1,5 +1,4 @@
|
|||||||
#ifndef _PM_HPP
|
#pragma once
|
||||||
#define _PM_HPP
|
|
||||||
|
|
||||||
#include "Player.hpp"
|
#include "Player.hpp"
|
||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
@ -44,5 +43,3 @@ namespace PlayerManager {
|
|||||||
void heartbeatPlayer(CNSocket* sock, CNPacketData* data);
|
void heartbeatPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void exitGame(CNSocket* sock, CNPacketData* data);
|
void exitGame(CNSocket* sock, CNPacketData* data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -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,8 +1,7 @@
|
|||||||
#ifndef _SETT_HPP
|
#pragma once
|
||||||
#define _SETT_HPP
|
|
||||||
|
|
||||||
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;
|
||||||
@ -17,5 +16,3 @@ namespace settings {
|
|||||||
|
|
||||||
void init();
|
void init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user