mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-21 21:20:04 +00:00
[refactor] Move files to core/ and servers/ subdirectories
CNProtocol, CNShared, CNStructs and Defines are now in core/. CNLoginServer, CNShardServer and Monitor are now in servers/. core/Core.hpp wraps all the core headers except for CNShared.hpp. Defines.cpp has been renamed to Packets.cpp, and so has its corresponding namespace, but not the header file. This is in preparation for upcoming changes.
This commit is contained in:
parent
e9bc2fe561
commit
a55a34e09a
31
Makefile
31
Makefile
@ -37,6 +37,12 @@ CHDR=\
|
||||
vendor/bcrypt/winbcrypt.h\
|
||||
|
||||
CXXSRC=\
|
||||
src/core/CNProtocol.cpp\
|
||||
src/core/CNShared.cpp\
|
||||
src/core/Packets.cpp\
|
||||
src/servers/CNLoginServer.cpp\
|
||||
src/servers/CNShardServer.cpp\
|
||||
src/servers/Monitor.cpp\
|
||||
src/db/init.cpp\
|
||||
src/db/login.cpp\
|
||||
src/db/shard.cpp\
|
||||
@ -44,11 +50,6 @@ CXXSRC=\
|
||||
src/db/email.cpp\
|
||||
src/Chat.cpp\
|
||||
src/CustomCommands.cpp\
|
||||
src/CNLoginServer.cpp\
|
||||
src/CNProtocol.cpp\
|
||||
src/CNShardServer.cpp\
|
||||
src/CNShared.cpp\
|
||||
src/Defines.cpp\
|
||||
src/Email.cpp\
|
||||
src/main.cpp\
|
||||
src/Missions.cpp\
|
||||
@ -67,28 +68,29 @@ CXXSRC=\
|
||||
src/Chunking.cpp\
|
||||
src/Buddies.cpp\
|
||||
src/Groups.cpp\
|
||||
src/Monitor.cpp\
|
||||
src/Racing.cpp\
|
||||
src/Vendor.cpp\
|
||||
src/Trading.cpp\
|
||||
|
||||
# headers (for timestamp purposes)
|
||||
CXXHDR=\
|
||||
src/core/CNProtocol.hpp\
|
||||
src/core/CNShared.hpp\
|
||||
src/core/CNStructs.hpp\
|
||||
src/core/Defines.hpp\
|
||||
src/core/Core.hpp\
|
||||
src/servers/CNLoginServer.hpp\
|
||||
src/servers/CNShardServer.hpp\
|
||||
src/servers/Monitor.hpp\
|
||||
src/db/Database.hpp\
|
||||
src/db/internal.hpp\
|
||||
vendor/bcrypt/BCrypt.hpp\
|
||||
vendor/INIReader.hpp\
|
||||
vendor/JSON.hpp\
|
||||
vendor/INIReader.hpp\
|
||||
vendor/JSON.hpp\
|
||||
src/db/Database.hpp\
|
||||
src/db/internal.hpp\
|
||||
src/Chat.hpp\
|
||||
src/CustomCommands.hpp\
|
||||
src/CNLoginServer.hpp\
|
||||
src/CNProtocol.hpp\
|
||||
src/CNShardServer.hpp\
|
||||
src/CNShared.hpp\
|
||||
src/CNStructs.hpp\
|
||||
src/Defines.hpp\
|
||||
src/Email.hpp\
|
||||
src/Missions.hpp\
|
||||
src/MobAI.hpp\
|
||||
@ -107,7 +109,6 @@ CXXHDR=\
|
||||
src/Chunking.hpp\
|
||||
src/Buddies.hpp\
|
||||
src/Groups.hpp\
|
||||
src/Monitor.hpp\
|
||||
src/Racing.hpp\
|
||||
src/Vendor.hpp\
|
||||
src/Trading.hpp\
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "Combat.hpp"
|
||||
|
||||
typedef void (*PowerHandler)(CNSocket*, std::vector<int>, int16_t, int16_t, int16_t, int16_t, int16_t, int32_t, int16_t);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Buddies.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Buddies.hpp"
|
||||
|
@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
namespace Buddies {
|
||||
void init();
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
namespace BuiltinCommands {
|
||||
void init();
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#define CMD_PREFIX '/'
|
||||
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
|
||||
namespace Chat {
|
||||
extern std::vector<std::string> dump;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <set>
|
||||
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNShared.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "NPC.hpp"
|
||||
#include "MobAI.hpp"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
namespace CustomCommands {
|
||||
void init();
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include "Email.hpp"
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
|
||||
#include "db/Database.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Groups.hpp"
|
||||
#include "Nanos.hpp"
|
||||
|
@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Items.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Nanos.hpp"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Player.hpp"
|
||||
#include "MobAI.hpp"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Missions.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Nanos.hpp"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Player.hpp"
|
||||
|
||||
#include "JSON.hpp"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "NPCManager.hpp"
|
||||
|
||||
enum class MobState {
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNStructs.hpp"
|
||||
#include "Chunking.hpp"
|
||||
|
||||
class BaseNPC {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "NPC.hpp"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Nanos.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "NPCManager.hpp"
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
|
||||
struct NanoData {
|
||||
int style;
|
||||
|
@ -3,8 +3,7 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "Chunking.hpp"
|
||||
|
||||
#define ACTIVE_MISSION_COUNT 6
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include "core/Core.hpp"
|
||||
#include "core/CNShared.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "db/Database.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "NPCManager.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "Missions.hpp"
|
||||
#include "Items.hpp"
|
||||
#include "Nanos.hpp"
|
||||
#include "Groups.hpp"
|
||||
#include "Chat.hpp"
|
||||
#include "db/Database.hpp"
|
||||
#include "Buddies.hpp"
|
||||
#include "Combat.hpp"
|
||||
#include "Racing.hpp"
|
||||
|
@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Chunking.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "PlayerMovement.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
static void movePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVE))
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "Racing.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Missions.hpp"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
|
||||
struct EPInfo {
|
||||
int zoneX, zoneY, EPID, maxScore, maxTime;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Nanos.hpp"
|
||||
#include "Transport.hpp"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "NPCManager.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
|
||||
#include "Items.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
@ -469,7 +469,7 @@ void CNServer::printPacket(CNPacketData *data, int type) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "OpenFusion: received " << Defines::p2str(type, data->type) << " (" << data->type << ")" << std::endl;
|
||||
std::cout << "OpenFusion: received " << Packets::p2str(type, data->type) << " (" << data->type << ")" << std::endl;
|
||||
}
|
||||
|
||||
bool CNServer::checkExtraSockets(int i) { return false; } // stubbed
|
@ -1,4 +1,4 @@
|
||||
#include "CNShared.hpp"
|
||||
#include "core/CNShared.hpp"
|
||||
|
||||
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
||||
#include "mingw/mingw.mutex.h"
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* CNShared.hpp
|
||||
* core/CNShared.hpp
|
||||
* 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!
|
||||
*/
|
||||
|
11
src/core/Core.hpp
Normal file
11
src/core/Core.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Convenience header.
|
||||
*
|
||||
* We omit CNShared, as it's only relevant to the Login and Shard servers
|
||||
* and the PlayerManager. We omit Defines, as CNProtocol already includes it.
|
||||
*/
|
||||
|
||||
#include "core/CNProtocol.hpp"
|
||||
#include "core/CNStructs.hpp"
|
@ -941,6 +941,6 @@ enum {
|
||||
N_PACKETS = N_CL2LS + N_CL2FE + N_FE2CL + N_LS2CL
|
||||
};
|
||||
|
||||
namespace Defines {
|
||||
namespace Packets {
|
||||
std::string p2str(int type, int val);
|
||||
}
|
@ -200,7 +200,7 @@ PacketMap cl2fe_map[] = {
|
||||
STRINGIFY(P_CL2FE_REQ_PC_ITEM_ENCHANT),
|
||||
};
|
||||
|
||||
std::string Defines::p2str(int type, int val) {
|
||||
std::string Packets::p2str(int type, int val) {
|
||||
switch (type) {
|
||||
case CL2LS:
|
||||
val = val - CL2LS - 1;
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "CNStructs.hpp"
|
||||
|
||||
#include "Player.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "CNLoginServer.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNLoginServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "PlayerMovement.hpp"
|
||||
#include "BuiltinCommands.hpp"
|
||||
@ -16,7 +16,7 @@
|
||||
#include "db/Database.hpp"
|
||||
#include "TableData.hpp"
|
||||
#include "Groups.hpp"
|
||||
#include "Monitor.hpp"
|
||||
#include "servers/Monitor.hpp"
|
||||
#include "Racing.hpp"
|
||||
#include "Trading.hpp"
|
||||
#include "Email.hpp"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "CNLoginServer.hpp"
|
||||
#include "CNShared.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "servers/CNLoginServer.hpp"
|
||||
#include "core/CNShared.hpp"
|
||||
#include "db/Database.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Items.hpp"
|
||||
@ -63,7 +62,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
}
|
||||
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: " << Packets::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||
break;
|
||||
/*
|
||||
* Unimplemented CL2LS packets:
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "Defines.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "Player.hpp"
|
||||
|
||||
#include <map>
|
@ -1,12 +1,11 @@
|
||||
#include "CNProtocol.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "CNShardServer.hpp"
|
||||
#include "core/Core.hpp"
|
||||
#include "db/Database.hpp"
|
||||
#include "servers/Monitor.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "MobAI.hpp"
|
||||
#include "CNShared.hpp"
|
||||
#include "core/CNShared.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "db/Database.hpp"
|
||||
#include "Monitor.hpp"
|
||||
#include "TableData.hpp" // for flush()
|
||||
|
||||
#include <iostream>
|
||||
@ -33,7 +32,7 @@ void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
if (ShardPackets.find(data->type) != ShardPackets.end())
|
||||
ShardPackets[data->type](sock, data);
|
||||
else if (settings::VERBOSITY > 0)
|
||||
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Defines::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
||||
std::cerr << "OpenFusion: SHARD UNIMPLM ERR. PacketType: " << Packets::p2str(CL2FE, data->type) << " (" << data->type << ")" << std::endl;
|
||||
|
||||
if (PlayerManager::players.find(sock) != PlayerManager::players.end())
|
||||
PlayerManager::players[sock]->lastHeartbeat = getTime();
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "Defines.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
#include <map>
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include "CNShardServer.hpp"
|
||||
#include "servers/CNShardServer.hpp"
|
||||
#include "PlayerManager.hpp"
|
||||
#include "Chat.hpp"
|
||||
#include "CNStructs.hpp"
|
||||
#include "Monitor.hpp"
|
||||
#include "servers/Monitor.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#include <cstdio>
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "CNProtocol.hpp"
|
||||
#include "core/Core.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
@ -1,7 +1,6 @@
|
||||
#include <iostream>
|
||||
#include "settings.hpp"
|
||||
#include "INIReader.hpp"
|
||||
#include "CNStructs.hpp" // for ACADEMY
|
||||
|
||||
// defaults :)
|
||||
int settings::VERBOSITY = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user