mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-16 00:22:25 +00:00
Comms stuff
This commit is contained in:
parent
c5f739cbda
commit
c1484a698c
@ -54,6 +54,7 @@ SET(common_sources
|
||||
packet_functions.cpp
|
||||
perl_eqdb.cpp
|
||||
perl_eqdb_res.cpp
|
||||
platform.cpp
|
||||
proc_launcher.cpp
|
||||
profanity_manager.cpp
|
||||
ptimer.cpp
|
||||
@ -71,8 +72,8 @@ SET(common_sources
|
||||
textures.cpp
|
||||
timer.cpp
|
||||
unix.cpp
|
||||
world_connection.cpp
|
||||
xml_parser.cpp
|
||||
platform.cpp
|
||||
json/jsoncpp.cpp
|
||||
net/console_server.cpp
|
||||
net/console_server_connection.cpp
|
||||
@ -207,6 +208,7 @@ SET(common_headers
|
||||
unix.h
|
||||
useperl.h
|
||||
version.h
|
||||
world_connection.h
|
||||
xml_parser.h
|
||||
zone_numbers.h
|
||||
event/event_loop.h
|
||||
|
||||
@ -26,6 +26,8 @@ namespace EQ
|
||||
bool Connected() const { return m_connecting != true; }
|
||||
|
||||
std::shared_ptr<EQ::Net::TCPConnection> Handle() { return m_connection; }
|
||||
|
||||
std::string GetIdentifier() const { return m_identifier; }
|
||||
private:
|
||||
void Connect();
|
||||
void ProcessData(EQ::Net::TCPConnection *c, const unsigned char *data, size_t length);
|
||||
|
||||
@ -19,16 +19,26 @@ void EQ::Net::ServertalkServer::Listen(const ServertalkServerOptions& opts)
|
||||
});
|
||||
}
|
||||
|
||||
void EQ::Net::ServertalkServer::OnConnectionIdentified(const std::string &type, std::function<void(std::shared_ptr<ServertalkServerConnection>)> cb)
|
||||
void EQ::Net::ServertalkServer::OnConnectionIdentified(const std::string &type, IdentityCallback cb)
|
||||
{
|
||||
m_on_ident.insert(std::make_pair(type, cb));
|
||||
}
|
||||
|
||||
void EQ::Net::ServertalkServer::OnConnectionRemoved(const std::string &type, std::function<void(std::shared_ptr<ServertalkServerConnection>)> cb)
|
||||
void EQ::Net::ServertalkServer::OnConnectionRemoved(const std::string &type, IdentityCallback cb)
|
||||
{
|
||||
m_on_disc.insert(std::make_pair(type, cb));
|
||||
}
|
||||
|
||||
void EQ::Net::ServertalkServer::OnConnectionIdentified(IdentityCallback cb)
|
||||
{
|
||||
m_on_any_ident = cb;
|
||||
}
|
||||
|
||||
void EQ::Net::ServertalkServer::OnConnectionRemoved(IdentityCallback cb)
|
||||
{
|
||||
m_on_any_disc = cb;
|
||||
}
|
||||
|
||||
void EQ::Net::ServertalkServer::ConnectionDisconnected(ServertalkServerConnection *conn)
|
||||
{
|
||||
if (conn->GetIdentifier().empty()) {
|
||||
@ -51,6 +61,11 @@ void EQ::Net::ServertalkServer::ConnectionDisconnected(ServertalkServerConnectio
|
||||
if (on_disc != m_on_disc.end()) {
|
||||
on_disc->second(*iter);
|
||||
}
|
||||
|
||||
if (m_on_any_disc) {
|
||||
m_on_any_disc(*iter);
|
||||
}
|
||||
|
||||
type->second.erase(iter);
|
||||
return;
|
||||
}
|
||||
@ -70,6 +85,10 @@ void EQ::Net::ServertalkServer::ConnectionIdentified(ServertalkServerConnection
|
||||
on_ident->second(*iter);
|
||||
}
|
||||
|
||||
if (m_on_any_ident) {
|
||||
m_on_any_ident(*iter);
|
||||
}
|
||||
|
||||
if (m_ident_connections.count(conn->GetIdentifier()) > 0) {
|
||||
auto &vec = m_ident_connections[conn->GetIdentifier()];
|
||||
vec.push_back(*iter);
|
||||
|
||||
@ -36,12 +36,16 @@ namespace EQ
|
||||
class ServertalkServer
|
||||
{
|
||||
public:
|
||||
typedef std::function<void(std::shared_ptr<ServertalkServerConnection>)> IdentityCallback;
|
||||
|
||||
ServertalkServer();
|
||||
~ServertalkServer();
|
||||
|
||||
void Listen(const ServertalkServerOptions& opts);
|
||||
void OnConnectionIdentified(const std::string &type, std::function<void(std::shared_ptr<ServertalkServerConnection>)> cb);
|
||||
void OnConnectionRemoved(const std::string &type, std::function<void(std::shared_ptr<ServertalkServerConnection>)> cb);
|
||||
void OnConnectionIdentified(const std::string &type, IdentityCallback cb);
|
||||
void OnConnectionRemoved(const std::string &type, IdentityCallback cb);
|
||||
void OnConnectionIdentified(IdentityCallback cb);
|
||||
void OnConnectionRemoved(IdentityCallback cb);
|
||||
|
||||
private:
|
||||
void ConnectionDisconnected(ServertalkServerConnection *conn);
|
||||
@ -52,8 +56,10 @@ namespace EQ
|
||||
std::vector<std::shared_ptr<ServertalkServerConnection>> m_unident_connections;
|
||||
std::map<std::string, std::vector<std::shared_ptr<ServertalkServerConnection>>> m_ident_connections;
|
||||
|
||||
std::map<std::string, std::function<void(std::shared_ptr<ServertalkServerConnection>)>> m_on_ident;
|
||||
std::map<std::string, std::function<void(std::shared_ptr<ServertalkServerConnection>)>> m_on_disc;
|
||||
std::map<std::string, IdentityCallback> m_on_ident;
|
||||
std::map<std::string, IdentityCallback> m_on_disc;
|
||||
IdentityCallback m_on_any_ident;
|
||||
IdentityCallback m_on_any_disc;
|
||||
bool m_encrypted;
|
||||
bool m_allow_downgrade;
|
||||
std::string m_credentials;
|
||||
|
||||
@ -202,6 +202,7 @@
|
||||
#define ServerOP_CZSetEntityVariableByClientName 0x4012
|
||||
#define ServerOP_UCSServerStatusRequest 0x4013
|
||||
#define ServerOP_UCSServerStatusReply 0x4014
|
||||
#define ServerOP_Speech 0x4513
|
||||
/* Query Server OP Codes */
|
||||
#define ServerOP_QSPlayerLogTrades 0x5010
|
||||
#define ServerOP_QSPlayerLogHandins 0x5011
|
||||
@ -215,13 +216,14 @@
|
||||
#define ServerOP_WWMarquee 0x5019
|
||||
#define ServerOP_QSPlayerDropItem 0x5020
|
||||
|
||||
/* Routing System OP Code(s) */
|
||||
#define ServerOP_RouteTo 0x6000
|
||||
|
||||
/* Query Serv Generic Packet Flag/Type Enumeration */
|
||||
enum { QSG_LFGuild = 0 };
|
||||
enum { QSG_LFGuild_PlayerMatches = 0, QSG_LFGuild_UpdatePlayerInfo, QSG_LFGuild_RequestPlayerInfo, QSG_LFGuild_UpdateGuildInfo, QSG_LFGuild_GuildMatches,
|
||||
QSG_LFGuild_RequestGuildInfo };
|
||||
|
||||
#define ServerOP_Speech 0x4513
|
||||
|
||||
/************ PACKET RELATED STRUCT ************/
|
||||
class ServerPacket
|
||||
{
|
||||
@ -1348,6 +1350,19 @@ struct ServerSharedTaskMember_Struct { // used for various things we just need t
|
||||
#define TASKJOINOOZ_LEVEL 3
|
||||
#define TASKJOINOOZ_TIMER 4
|
||||
|
||||
struct RouteToHeader
|
||||
{
|
||||
char filter[64];
|
||||
char type[128];
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive)
|
||||
{
|
||||
archive(filter,
|
||||
type);
|
||||
}
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
||||
69
common/world_connection.cpp
Normal file
69
common/world_connection.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "world_connection.h"
|
||||
#include "eqemu_config.h"
|
||||
#include "string_util.h"
|
||||
|
||||
EQ::WorldConnection::WorldConnection(const std::string &type) {
|
||||
auto config = EQEmuConfig::get();
|
||||
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(config->WorldIP, config->WorldTCPPort, false, type, config->SharedKey));
|
||||
m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
if (m_on_connected) {
|
||||
m_on_connected();
|
||||
}
|
||||
});
|
||||
|
||||
m_connection->OnMessage(std::bind(&WorldConnection::_HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_RouteTo, std::bind(&WorldConnection::_HandleRoutedMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
EQ::WorldConnection::~WorldConnection() {
|
||||
|
||||
}
|
||||
|
||||
void EQ::WorldConnection::SendPacket(ServerPacket* pack) {
|
||||
m_connection->SendPacket(pack);
|
||||
}
|
||||
|
||||
std::string EQ::WorldConnection::GetIP() const {
|
||||
return m_connection->Handle()->RemoteIP();
|
||||
}
|
||||
|
||||
uint16 EQ::WorldConnection::GetPort() const {
|
||||
return m_connection->Handle()->RemotePort();
|
||||
}
|
||||
|
||||
bool EQ::WorldConnection::Connected() const {
|
||||
return m_connection->Connected();
|
||||
}
|
||||
|
||||
void EQ::WorldConnection::RouteMessage(const std::string &filter, const EQ::Net::Packet &p)
|
||||
{
|
||||
if (!m_connection->Connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RouteToHeader header;
|
||||
strn0cpy(header.filter, filter.data(), 64);
|
||||
strn0cpy(header.type, m_connection->GetIdentifier().data(), 128);
|
||||
|
||||
EQ::Net::DynamicPacket out;
|
||||
out.PutSerialize(0, header);
|
||||
out.PutPacket(out.Length(), p);
|
||||
}
|
||||
|
||||
void EQ::WorldConnection::_HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
{
|
||||
if (m_on_message) {
|
||||
m_on_message(opcode, p);
|
||||
}
|
||||
}
|
||||
|
||||
void EQ::WorldConnection::_HandleRoutedMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
{
|
||||
if (m_on_routed_message) {
|
||||
auto header = p.GetSerialize<RouteToHeader>(0);
|
||||
auto np = EQ::Net::StaticPacket((int8_t*)p.Data() + sizeof(RouteToHeader), p.Length() - sizeof(RouteToHeader));
|
||||
|
||||
m_on_routed_message(header.filter, header.type, np);
|
||||
}
|
||||
}
|
||||
48
common/world_connection.h
Normal file
48
common/world_connection.h
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "eq_packet_structs.h"
|
||||
#include "net/servertalk_client_connection.h"
|
||||
#include <functional>
|
||||
|
||||
namespace EQ
|
||||
{
|
||||
class WorldConnection
|
||||
{
|
||||
public:
|
||||
typedef std::function<void()> OnConnectedHandler;
|
||||
typedef std::function<void(uint16, const EQ::Net::Packet&)> OnMessageHandler;
|
||||
typedef std::function<void(const std::string&, const std::string&, EQ::Net::Packet&)> OnRoutedMessageHandler;
|
||||
|
||||
WorldConnection(const std::string &type);
|
||||
virtual ~WorldConnection();
|
||||
|
||||
void SendPacket(ServerPacket* pack);
|
||||
std::string GetIP() const;
|
||||
uint16 GetPort() const;
|
||||
bool Connected() const;
|
||||
|
||||
void SetOnConnectedHandler(OnConnectedHandler handler) {
|
||||
m_on_connected = handler;
|
||||
};
|
||||
|
||||
void SetOnMessageHandler(OnMessageHandler handler) {
|
||||
m_on_message = handler;
|
||||
};
|
||||
|
||||
void SetOnRoutedMessageHandler(OnRoutedMessageHandler handler) {
|
||||
m_on_routed_message = handler;
|
||||
}
|
||||
|
||||
void RouteMessage(const std::string &filter, const EQ::Net::Packet& p);
|
||||
|
||||
protected:
|
||||
OnConnectedHandler m_on_connected;
|
||||
OnMessageHandler m_on_message;
|
||||
OnRoutedMessageHandler m_on_routed_message;
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
|
||||
private:
|
||||
void _HandleMessage(uint16 opcode, const EQ::Net::Packet& p);
|
||||
void _HandleRoutedMessage(uint16 opcode, const EQ::Net::Packet& p);
|
||||
};
|
||||
}
|
||||
@ -25,16 +25,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "zone_launch.h"
|
||||
|
||||
WorldServer::WorldServer(std::map<std::string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config)
|
||||
: m_name(name),
|
||||
:
|
||||
WorldConnection::WorldConnection("Launcher"),
|
||||
m_name(name),
|
||||
m_config(config),
|
||||
m_zones(zones)
|
||||
{
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(config->WorldIP, config->WorldTCPPort, false, "Launcher", config->SharedKey));
|
||||
m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
OnConnected();
|
||||
});
|
||||
|
||||
m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
SetOnConnectedHandler(std::bind(&WorldServer::OnConnected, this));
|
||||
SetOnMessageHandler(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
WorldServer::~WorldServer() {
|
||||
@ -57,7 +55,7 @@ void WorldServer::OnConnected() {
|
||||
}
|
||||
}
|
||||
|
||||
void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) {
|
||||
void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
|
||||
ServerPacket tpack(opcode, p);
|
||||
ServerPacket *pack = &tpack;
|
||||
|
||||
@ -126,8 +124,6 @@ void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WorldServer::SendStatus(const char *short_name, uint32 start_count, bool running) {
|
||||
auto pack = new ServerPacket(ServerOP_LauncherZoneStatus, sizeof(LauncherZoneStatus));
|
||||
LauncherZoneStatus* it = (LauncherZoneStatus*)pack->pBuffer;
|
||||
@ -138,4 +134,4 @@ void WorldServer::SendStatus(const char *short_name, uint32 start_count, bool ru
|
||||
|
||||
m_connection->SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,28 +18,23 @@
|
||||
#ifndef WORLDSERVER_H
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "../common/world_connection.h"
|
||||
#include <queue>
|
||||
#include <map>
|
||||
|
||||
class ZoneLaunch;
|
||||
class EQEmuConfig;
|
||||
|
||||
class WorldServer {
|
||||
class WorldServer : public EQ::WorldConnection {
|
||||
public:
|
||||
WorldServer(std::map<std::string, ZoneLaunch *> &zones, const char *name, const EQEmuConfig *config);
|
||||
~WorldServer();
|
||||
|
||||
void HandleMessage(uint16 opcode, EQ::Net::Packet &p);
|
||||
|
||||
void SendStatus(const char *short_name, uint32 start_count, bool running);
|
||||
|
||||
private:
|
||||
virtual void OnConnected();
|
||||
void HandleMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
void OnConnected();
|
||||
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
const char *const m_name;
|
||||
const EQEmuConfig *const m_config;
|
||||
std::map<std::string, ZoneLaunch *> &m_zones;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "../common/packet_dump.h"
|
||||
#include "../common/rulesys.h"
|
||||
|
||||
extern WorldServer *worldserver;
|
||||
extern std::unique_ptr<WorldServer> worldserver;
|
||||
extern Database database;
|
||||
|
||||
PlayerLookingForGuild::PlayerLookingForGuild(char *Name, char *Comments, uint32 Level, uint32 Class, uint32 AACount, uint32 Timezone, uint32 TimePosted)
|
||||
|
||||
@ -39,7 +39,7 @@ Database database;
|
||||
LFGuildManager lfguildmanager;
|
||||
std::string WorldShortName;
|
||||
const queryservconfig *Config;
|
||||
WorldServer *worldserver = 0;
|
||||
std::unique_ptr<WorldServer> worldserver;
|
||||
EQEmuLogSys LogSys;
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
@ -88,8 +88,7 @@ int main() {
|
||||
}
|
||||
|
||||
/* Initial Connection to Worldserver */
|
||||
worldserver = new WorldServer;
|
||||
worldserver->Connect();
|
||||
worldserver.reset(new WorldServer());
|
||||
|
||||
/* Load Looking For Guild Manager */
|
||||
lfguildmanager.LoadDatabase();
|
||||
|
||||
@ -43,40 +43,15 @@ extern Database database;
|
||||
extern LFGuildManager lfguildmanager;
|
||||
|
||||
WorldServer::WorldServer()
|
||||
: WorldConnection::WorldConnection("QueryServ")
|
||||
{
|
||||
SetOnMessageHandler(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
WorldServer::~WorldServer()
|
||||
{
|
||||
}
|
||||
|
||||
void WorldServer::Connect()
|
||||
{
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "QueryServ", Config->SharedKey));
|
||||
m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
bool WorldServer::SendPacket(ServerPacket *pack)
|
||||
{
|
||||
m_connection->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string WorldServer::GetIP() const
|
||||
{
|
||||
return m_connection->Handle()->RemoteIP();
|
||||
}
|
||||
|
||||
uint16 WorldServer::GetPort() const
|
||||
{
|
||||
return m_connection->Handle()->RemotePort();
|
||||
}
|
||||
|
||||
bool WorldServer::Connected() const
|
||||
{
|
||||
return m_connection->Connected();
|
||||
}
|
||||
|
||||
void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
{
|
||||
switch (opcode) {
|
||||
@ -185,4 +160,4 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,20 +18,13 @@
|
||||
#ifndef WORLDSERVER_H
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
#include "../common/world_connection.h"
|
||||
|
||||
class WorldServer
|
||||
class WorldServer : public EQ::WorldConnection
|
||||
{
|
||||
public:
|
||||
WorldServer();
|
||||
~WorldServer();
|
||||
|
||||
void Connect();
|
||||
bool SendPacket(ServerPacket* pack);
|
||||
std::string GetIP() const;
|
||||
uint16 GetPort() const;
|
||||
bool Connected() const;
|
||||
virtual ~WorldServer();
|
||||
|
||||
void HandleMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
private:
|
||||
|
||||
@ -40,7 +40,7 @@ ChatChannelList *ChannelList;
|
||||
Clientlist *g_Clientlist;
|
||||
EQEmuLogSys LogSys;
|
||||
Database database;
|
||||
WorldServer *worldserver = nullptr;
|
||||
std::unique_ptr<WorldServer> worldserver;
|
||||
|
||||
const ucsconfig *Config;
|
||||
|
||||
@ -142,7 +142,7 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
worldserver = new WorldServer;
|
||||
worldserver.reset(new WorldServer());
|
||||
|
||||
while(RunLoops) {
|
||||
|
||||
|
||||
@ -47,16 +47,16 @@ void Client50ToServerSayLink(std::string& serverSayLink, const std::string& clie
|
||||
void Client55ToServerSayLink(std::string& serverSayLink, const std::string& clientSayLink);
|
||||
|
||||
WorldServer::WorldServer()
|
||||
: WorldConnection::WorldConnection("UCS")
|
||||
{
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "UCS", Config->SharedKey));
|
||||
m_connection->OnMessage(std::bind(&WorldServer::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
SetOnMessageHandler(std::bind(&WorldServer::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
WorldServer::~WorldServer()
|
||||
{
|
||||
}
|
||||
|
||||
void WorldServer::ProcessMessage(uint16 opcode, EQ::Net::Packet &p)
|
||||
void WorldServer::ProcessMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
{
|
||||
ServerPacket tpack(opcode, p);
|
||||
ServerPacket *pack = &tpack;
|
||||
|
||||
@ -18,20 +18,14 @@
|
||||
#ifndef WORLDSERVER_H
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../net/servertalk_client_connection.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include <memory>
|
||||
#include "../world_connection.h"
|
||||
|
||||
class WorldServer
|
||||
class WorldServer : public EQ::WorldConnection
|
||||
{
|
||||
public:
|
||||
WorldServer();
|
||||
~WorldServer();
|
||||
void ProcessMessage(uint16 opcode, EQ::Net::Packet &);
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
void ProcessMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@ -502,6 +502,16 @@ int main(int argc, char** argv) {
|
||||
web_interface.RemoveConnection(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified([](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogF(Logs::General, Logs::World_Server, "New connection from {0} with identifier {1}",
|
||||
connection->GetUUID(), connection->GetIdentifier());
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved([](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
LogF(Logs::General, Logs::World_Server, "Removed connection from {0} with identifier {1}",
|
||||
connection->GetUUID(), connection->GetIdentifier());
|
||||
});
|
||||
|
||||
EQ::Net::EQStreamManagerOptions opts(9000, false, false);
|
||||
opts.daybreak_options.resend_delay_ms = RuleI(Network, ResendDelayBaseMS);
|
||||
opts.daybreak_options.resend_delay_factor = RuleR(Network, ResendDelayFactor);
|
||||
|
||||
@ -1199,6 +1199,8 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf);
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
@ -1284,6 +1286,8 @@ void TaskManager::SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *T
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_OpenNewTasksWindow, buf);
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
@ -2550,7 +2554,7 @@ void Client::SendTaskComplete(int TaskIndex) {
|
||||
tcs->unknown04 = 0x00000002;
|
||||
|
||||
Log.LogDebugType(Logs::Detail, Logs::Tasks, "SendTasksComplete");
|
||||
DumpPacket(outapp); fflush(stdout);
|
||||
DumpPacket(outapp, true); fflush(stdout);
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
@ -2631,6 +2635,7 @@ void ClientTaskState::SendTaskHistory(Client *c, int TaskIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
@ -2656,6 +2661,7 @@ void Client::SendTaskActivityComplete(int TaskID, int ActivityID, int TaskIndex,
|
||||
tac->task_completed = 0x00000001;
|
||||
tac->stage_complete = TaskIncomplete;
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
@ -2685,6 +2691,8 @@ void Client::SendTaskFailed(int TaskID, int TaskIndex, TaskType type)
|
||||
|
||||
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskFailed");
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
@ -2740,6 +2748,7 @@ void TaskManager::SendCompletedTasksToClient(Client *c, ClientTaskState *State)
|
||||
buf = buf + 4;
|
||||
}
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
@ -2764,6 +2773,8 @@ void TaskManager::SendTaskActivityShort(Client *c, int TaskID, int ActivityID, i
|
||||
outapp->WriteUInt32(0);
|
||||
outapp->WriteUInt32(0xffffffff);
|
||||
outapp->WriteUInt8(0);
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
c->FastQueuePacket(&outapp);
|
||||
|
||||
return;
|
||||
@ -2781,7 +2792,7 @@ void TaskManager::SendTaskActivityShort(Client *c, int TaskID, int ActivityID, i
|
||||
tass->ActivityType = 0xffffffff;
|
||||
tass->unknown4 = 0x00000000;
|
||||
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
@ -2843,6 +2854,8 @@ void TaskManager::SendTaskActivityLong(Client *c, int TaskID, int ActivityID, in
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_TaskActivity, buf);
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
@ -2903,6 +2916,8 @@ void TaskManager::SendTaskActivityNew(Client *c, int TaskID, int ActivityID, int
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_TaskActivity, buf);
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
@ -3070,6 +3085,8 @@ void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, ClientTaskInf
|
||||
tdt->Points = 0x00000000; // Points Count TODO: this does have a visible affect on the client ...
|
||||
tdt->has_reward_selection = 0; // TODO: new rewards window
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
@ -3194,6 +3211,8 @@ void ClientTaskState::CancelTask(Client *c, int SequenceNumber, TaskType type, b
|
||||
|
||||
Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask");
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
|
||||
@ -3805,6 +3824,8 @@ void SharedTaskState::SendMembersList(Client *to) const
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_SharedTaskMemberList, buf);
|
||||
|
||||
DumpPacket(outapp, true);
|
||||
|
||||
to->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
@ -79,33 +79,43 @@ WorldServer::~WorldServer() {
|
||||
|
||||
void WorldServer::Connect()
|
||||
{
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "Zone", Config->SharedKey));
|
||||
m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
OnConnected();
|
||||
});
|
||||
|
||||
m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
bool WorldServer::SendPacket(ServerPacket *pack)
|
||||
{
|
||||
m_connection->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string WorldServer::GetIP() const
|
||||
{
|
||||
return m_connection->Handle()->RemoteIP();
|
||||
}
|
||||
|
||||
uint16 WorldServer::GetPort() const
|
||||
{
|
||||
return m_connection->Handle()->RemotePort();
|
||||
m_connection.reset(new EQ::WorldConnection("Zone"));
|
||||
m_connection->SetOnConnectedHandler(std::bind(&WorldServer::OnConnected, this));
|
||||
m_connection->SetOnMessageHandler(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
bool WorldServer::Connected() const
|
||||
{
|
||||
return m_connection->Connected();
|
||||
if (m_connection) {
|
||||
return m_connection->Connected();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WorldServer::SendPacket(ServerPacket *pack)
|
||||
{
|
||||
if (m_connection) {
|
||||
m_connection->SendPacket(pack);
|
||||
}
|
||||
}
|
||||
|
||||
std::string WorldServer::GetIP() const
|
||||
{
|
||||
if (m_connection) {
|
||||
return m_connection->GetIP();
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
uint16 WorldServer::GetPort() const
|
||||
{
|
||||
if (m_connection) {
|
||||
return m_connection->GetPort();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WorldServer::SetZoneData(uint32 iZoneID, uint32 iInstanceID) {
|
||||
@ -2026,9 +2036,9 @@ bool WorldServer::SendChannelMessage(Client* from, const char* to, uint8 chan_nu
|
||||
scm->queued = 0;
|
||||
strcpy(scm->message, buffer);
|
||||
|
||||
bool ret = SendPacket(pack);
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WorldServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, uint32 type, const char* message, ...) {
|
||||
@ -2064,9 +2074,9 @@ bool WorldServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to
|
||||
sem->minstatus = to_minstatus;
|
||||
strcpy(sem->message, buffer);
|
||||
|
||||
bool ret = SendPacket(pack);
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WorldServer::SendVoiceMacro(Client* From, uint32 Type, char* Target, uint32 MacroNumber, uint32 GroupOrRaidID) {
|
||||
@ -2101,15 +2111,19 @@ bool WorldServer::SendVoiceMacro(Client* From, uint32 Type, char* Target, uint32
|
||||
|
||||
svm->MacroNumber = MacroNumber;
|
||||
|
||||
bool Ret = SendPacket(pack);
|
||||
SendPacket(pack);
|
||||
|
||||
safe_delete(pack);
|
||||
|
||||
return Ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WorldServer::RezzPlayer(EQApplicationPacket* rpack, uint32 rezzexp, uint32 dbid, uint16 opcode)
|
||||
{
|
||||
if (!Connected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Log(Logs::Detail, Logs::Spells, "WorldServer::RezzPlayer rezzexp is %i (0 is normal for RezzComplete", rezzexp);
|
||||
auto pack = new ServerPacket(ServerOP_RezzPlayer, sizeof(RezzPlayer_Struct));
|
||||
RezzPlayer_Struct* sem = (RezzPlayer_Struct*)pack->pBuffer;
|
||||
@ -2117,14 +2131,9 @@ bool WorldServer::RezzPlayer(EQApplicationPacket* rpack, uint32 rezzexp, uint32
|
||||
sem->rez = *(Resurrect_Struct*)rpack->pBuffer;
|
||||
sem->exp = rezzexp;
|
||||
sem->dbid = dbid;
|
||||
bool ret = SendPacket(pack);
|
||||
if (ret)
|
||||
Log(Logs::Detail, Logs::Spells, "Sending player rezz packet to world spellid:%i", sem->rez.spellid);
|
||||
else
|
||||
Log(Logs::Detail, Logs::Spells, "NOT Sending player rezz packet to world");
|
||||
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldServer::SendReloadTasks(int Command, int TaskID) {
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
#ifndef WORLDSERVER_H
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
#include "../common/world_connection.h"
|
||||
#include <memory>
|
||||
|
||||
class ServerPacket;
|
||||
class EQApplicationPacket;
|
||||
@ -31,10 +31,10 @@ public:
|
||||
~WorldServer();
|
||||
|
||||
void Connect();
|
||||
bool SendPacket(ServerPacket* pack);
|
||||
bool Connected() const;
|
||||
void SendPacket(ServerPacket* pack);
|
||||
std::string GetIP() const;
|
||||
uint16 GetPort() const;
|
||||
bool Connected() const;
|
||||
|
||||
void HandleMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
|
||||
@ -72,7 +72,7 @@ private:
|
||||
uint32 cur_groupid;
|
||||
uint32 last_groupid;
|
||||
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
std::unique_ptr<EQ::WorldConnection> m_connection;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user