mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Working on world <-> zone communication needs a ton of work really need to rewrite how world works with zones.
This commit is contained in:
parent
0264c0d60a
commit
2447c38c82
@ -297,7 +297,7 @@ void EQ::Net::ServertalkClient::ProcessMessage(EQ::Net::Packet &p)
|
||||
|
||||
auto cb = m_message_callbacks.find(opcode);
|
||||
if (cb != m_message_callbacks.end()) {
|
||||
cb->second(opcode, packet);
|
||||
m_message_callback_any(opcode, packet);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "servertalk_server_connection.h"
|
||||
#include "servertalk_server.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "../util/uuid.h"
|
||||
|
||||
EQ::Net::ServertalkServerConnection::ServertalkServerConnection(std::shared_ptr<EQ::Net::TCPConnection> c, EQ::Net::ServertalkServer *parent, bool encrypted, bool allow_downgrade)
|
||||
{
|
||||
@ -8,6 +9,7 @@ EQ::Net::ServertalkServerConnection::ServertalkServerConnection(std::shared_ptr<
|
||||
m_parent = parent;
|
||||
m_encrypted = encrypted;
|
||||
m_allow_downgrade = allow_downgrade;
|
||||
m_uuid = EQ::Util::UUID::Generate().ToString();
|
||||
m_connection->OnRead(std::bind(&ServertalkServerConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_connection->OnDisconnect(std::bind(&ServertalkServerConnection::OnDisconnect, this, std::placeholders::_1));
|
||||
m_connection->Start();
|
||||
|
||||
@ -25,6 +25,7 @@ namespace EQ
|
||||
|
||||
std::string GetIdentifier() const { return m_identifier; }
|
||||
std::shared_ptr<EQ::Net::TCPConnection> Handle() { return m_connection; }
|
||||
std::string GetUUID() const { return m_uuid; }
|
||||
private:
|
||||
void OnRead(TCPConnection* c, const unsigned char* data, size_t sz);
|
||||
void ProcessReadBuffer();
|
||||
@ -41,6 +42,7 @@ namespace EQ
|
||||
std::vector<char> m_buffer;
|
||||
std::unordered_map<uint16_t, std::function<void(uint16_t, EQ::Net::Packet&)>> m_message_callbacks;
|
||||
std::string m_identifier;
|
||||
std::string m_uuid;
|
||||
|
||||
bool m_encrypted;
|
||||
bool m_allow_downgrade;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "../common/types.h"
|
||||
#include "../common/packet_functions.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../net/packet.h"
|
||||
#include <cereal/cereal.hpp>
|
||||
#include <cereal/types/string.hpp>
|
||||
|
||||
@ -223,6 +224,22 @@ public:
|
||||
_wpos = 0;
|
||||
_rpos = 0;
|
||||
}
|
||||
|
||||
ServerPacket(uint16 in_opcode, const EQ::Net::Packet &p) {
|
||||
this->compressed = false;
|
||||
size = p.Length();
|
||||
opcode = in_opcode;
|
||||
if (size == 0) {
|
||||
pBuffer = 0;
|
||||
}
|
||||
else {
|
||||
pBuffer = new uchar[size];
|
||||
memcpy(pBuffer, p.Data(), size);
|
||||
}
|
||||
_wpos = 0;
|
||||
_rpos = 0;
|
||||
}
|
||||
|
||||
ServerPacket* Copy() {
|
||||
if (this == 0) {
|
||||
return 0;
|
||||
|
||||
@ -52,40 +52,38 @@ WorldServer::~WorldServer()
|
||||
|
||||
void WorldServer::Connect()
|
||||
{
|
||||
m_server.reset(new EQ::Net::ServertalkServer());
|
||||
//Config->WorldIP, Config->WorldTCPPort, "QS", Config->SharedKey
|
||||
m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "QueryServ", Config->SharedKey));
|
||||
|
||||
m_link->OnMessageType(ServerOP_Speech, std::bind(&WorldServer::HandleMessage, this, ServerOP_Speech, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSPlayerLogTrades, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSPlayerLogTrades, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSPlayerLogHandins, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSPlayerLogHandins, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSPlayerLogNPCKills, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSPlayerLogNPCKills, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSPlayerLogDeletes, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSPlayerLogDeletes, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSPlayerLogMoves, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSPlayerLogMoves, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSPlayerLogMerchantTransactions, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSPlayerLogMerchantTransactions, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QueryServGeneric, std::bind(&WorldServer::HandleMessage, this, ServerOP_QueryServGeneric, std::placeholders::_1));
|
||||
m_link->OnMessageType(ServerOP_QSSendQuery, std::bind(&WorldServer::HandleMessage, this, ServerOP_QSSendQuery, std::placeholders::_1));
|
||||
m_connection->OnMessage(ServerOP_Speech, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSPlayerLogTrades, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSPlayerLogHandins, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSPlayerLogNPCKills, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSPlayerLogDeletes, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSPlayerLogMoves, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSPlayerLogMerchantTransactions, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QueryServGeneric, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_connection->OnMessage(ServerOP_QSSendQuery, std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
bool WorldServer::SendPacket(ServerPacket *pack)
|
||||
{
|
||||
EQ::Net::ReadOnlyPacket p(pack->pBuffer, pack->size);
|
||||
->SendPacket(pack->opcode, p);
|
||||
m_connection->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string WorldServer::GetIP() const
|
||||
{
|
||||
return m_link->GetIP();
|
||||
return m_connection->Handle()->RemoteIP();
|
||||
}
|
||||
|
||||
uint16 WorldServer::GetPort() const
|
||||
{
|
||||
return m_link->GetPort();
|
||||
return m_connection->Handle()->RemotePort();
|
||||
}
|
||||
|
||||
bool WorldServer::Connected() const
|
||||
{
|
||||
return m_link->Connected();
|
||||
return m_connection->Connected();
|
||||
}
|
||||
|
||||
void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
@ -118,7 +116,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
}
|
||||
case ServerOP_QSPlayerLogNPCKills: {
|
||||
QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)p.Data();
|
||||
uint32 Members = p.Length() - sizeof(QSPlayerLogNPCKill_Struct);
|
||||
uint32 Members = (uint32)(p.Length() - sizeof(QSPlayerLogNPCKill_Struct));
|
||||
if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct);
|
||||
database.LogPlayerNPCKill(QS, Members);
|
||||
break;
|
||||
@ -170,7 +168,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
ServerPacket pack;
|
||||
pack.pBuffer = (uchar*)p.Data();
|
||||
pack.opcode = opcode;
|
||||
pack.size = p.Length();
|
||||
pack.size = (uint32)p.Length();
|
||||
lfguildmanager.HandlePacket(&pack);
|
||||
pack.pBuffer = nullptr;
|
||||
break;
|
||||
@ -186,7 +184,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
ServerPacket pack;
|
||||
pack.pBuffer = (uchar*)p.Data();
|
||||
pack.opcode = opcode;
|
||||
pack.size = p.Length();
|
||||
pack.size = (uint32)p.Length();
|
||||
|
||||
database.GeneralQueryReceive(&pack);
|
||||
pack.pBuffer = nullptr;
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/net/servertalk_server.h"
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
|
||||
class WorldServer
|
||||
{
|
||||
@ -35,7 +35,7 @@ class WorldServer
|
||||
|
||||
void HandleMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
private:
|
||||
std::unique_ptr<EQ::Net::ServertalkServer> m_server;
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ SET(world_sources
|
||||
cliententry.cpp
|
||||
clientlist.cpp
|
||||
CMakeLists.txt
|
||||
console.cpp
|
||||
eql_config.cpp
|
||||
eqw.cpp
|
||||
eqw_http_handler.cpp
|
||||
@ -39,7 +38,6 @@ SET(world_headers
|
||||
cliententry.h
|
||||
clientlist.h
|
||||
CMakeLists.txt
|
||||
console.h
|
||||
eql_config.h
|
||||
eqw.h
|
||||
eqw_http_handler.h
|
||||
|
||||
@ -432,15 +432,11 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
|
||||
}
|
||||
else
|
||||
id=atoi(name);
|
||||
#ifdef IPBASED_AUTH_HACK
|
||||
if ((cle = zoneserver_list.CheckAuth(inet_ntoa(tmpip), password)))
|
||||
#else
|
||||
if (loginserverlist.Connected() == false && !is_player_zoning) {
|
||||
Log.Out(Logs::General, Logs::World_Server,"Error: Login server login while not connected to login server.");
|
||||
return false;
|
||||
}
|
||||
if (((cle = client_list.CheckAuth(name, password)) || (cle = client_list.CheckAuth(id, password))))
|
||||
#endif
|
||||
{
|
||||
if (cle->AccountID() == 0 || (!minilogin && cle->LSID()==0)) {
|
||||
Log.Out(Logs::General, Logs::World_Server,"ID is 0. Is this server connected to minilogin?");
|
||||
@ -1255,11 +1251,7 @@ void Client::Clearance(int8 response)
|
||||
if(local_addr[0]) {
|
||||
zs_addr = local_addr;
|
||||
} else {
|
||||
struct in_addr in;
|
||||
in.s_addr = zs->GetIP();
|
||||
zs_addr = inet_ntoa(in);
|
||||
|
||||
if(strcmp(zs_addr, "127.0.0.1") == 0)
|
||||
if(strcmp(zs->GetIP().c_str(), "127.0.0.1") == 0)
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Local zone address was %s, setting local address to: %s", zs_addr, WorldConfig::get()->LocalAddress.c_str());
|
||||
zs_addr = WorldConfig::get()->LocalAddress.c_str();
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
extern ConsoleList console_list;
|
||||
extern ZSList zoneserver_list;
|
||||
uint32 numplayers = 0; //this really wants to be a member variable of ClientList...
|
||||
|
||||
@ -1113,7 +1112,6 @@ void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct*
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
|
||||
else
|
||||
AppendAnyLenString(&output, &outsize, &outlen, "\n");
|
||||
console_list.SendConsoleWho(connection, to, admin, &output, &outsize, &outlen);
|
||||
}
|
||||
if (output)
|
||||
connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
|
||||
|
||||
@ -241,32 +241,26 @@ bool Console::Process() {
|
||||
if (tcpc->GetMode() == EmuTCPConnection::modePacket) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetIP();
|
||||
if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) {
|
||||
auto zs = new ZoneServer(tcpc);
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"New zoneserver #%d from %s:%d", zs->GetID(), inet_ntoa(in), GetPort());
|
||||
zoneserver_list.Add(zs);
|
||||
numzones++;
|
||||
tcpc = 0;
|
||||
} else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"New launcher from %s:%d", inet_ntoa(in), GetPort());
|
||||
launcher_list.Add(tcpc);
|
||||
tcpc = 0;
|
||||
}
|
||||
else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS)
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"New UCS Connection from %s:%d", inet_ntoa(in), GetPort());
|
||||
UCSLink.SetConnection(tcpc);
|
||||
tcpc = 0;
|
||||
}
|
||||
else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeQueryServ)
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"New QS Connection from %s:%d", inet_ntoa(in), GetPort());
|
||||
QSLink.SetConnection(tcpc);
|
||||
tcpc = 0;
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Unsupported packet mode from %s:%d", inet_ntoa(in), GetPort());
|
||||
}
|
||||
//if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) {
|
||||
// auto zs = new ZoneServer(tcpc);
|
||||
// Log.Out(Logs::Detail, Logs::World_Server,"New zoneserver #%d from %s:%d", zs->GetID(), inet_ntoa(in), GetPort());
|
||||
// zoneserver_list.Add(zs);
|
||||
// numzones++;
|
||||
// tcpc = 0;
|
||||
//} else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) {
|
||||
// Log.Out(Logs::Detail, Logs::World_Server,"New launcher from %s:%d", inet_ntoa(in), GetPort());
|
||||
// launcher_list.Add(tcpc);
|
||||
// tcpc = 0;
|
||||
//}
|
||||
//else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS)
|
||||
//{
|
||||
// Log.Out(Logs::Detail, Logs::World_Server,"New UCS Connection from %s:%d", inet_ntoa(in), GetPort());
|
||||
// UCSLink.SetConnection(tcpc);
|
||||
// tcpc = 0;
|
||||
//}
|
||||
//else {
|
||||
// Log.Out(Logs::Detail, Logs::World_Server,"Unsupported packet mode from %s:%d", inet_ntoa(in), GetPort());
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
char* command = 0;
|
||||
|
||||
105
world/net.cpp
105
world/net.cpp
@ -107,8 +107,6 @@ bool holdzones = false;
|
||||
const WorldConfig *Config;
|
||||
EQEmuLogSys Log;
|
||||
|
||||
extern ConsoleList console_list;
|
||||
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
@ -338,10 +336,12 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(RuleB(World, ClearTempMerchantlist)){
|
||||
Log.Out(Logs::General, Logs::World_Server, "Clearing temporary merchant lists..");
|
||||
database.ClearMerchantTemp();
|
||||
}
|
||||
|
||||
Log.Out(Logs::General, Logs::World_Server, "Loading EQ time of day..");
|
||||
TimeOfDay_Struct eqTime;
|
||||
time_t realtime;
|
||||
@ -385,14 +385,43 @@ int main(int argc, char** argv) {
|
||||
database.LoadCharacterCreateAllocations();
|
||||
database.LoadCharacterCreateCombos();
|
||||
|
||||
char errbuf[TCPConnection_ErrorBufferSize];
|
||||
if (tcps.Open(Config->WorldTCPPort, errbuf)) {
|
||||
Log.Out(Logs::General, Logs::World_Server,"Zone (TCP) listener started.");
|
||||
} else {
|
||||
Log.Out(Logs::General, Logs::World_Server,"Failed to start zone (TCP) listener on port %d:",Config->WorldTCPPort);
|
||||
Log.Out(Logs::General, Logs::World_Server," %s",errbuf);
|
||||
return 1;
|
||||
}
|
||||
std::unique_ptr<EQ::Net::ServertalkServer> server_connection;
|
||||
server_connection.reset(new EQ::Net::ServertalkServer());
|
||||
|
||||
EQ::Net::ServertalkServerOptions server_opts;
|
||||
server_opts.port = Config->WorldTCPPort;
|
||||
server_opts.ipv6 = false;
|
||||
server_opts.credentials = Config->SharedKey;
|
||||
server_connection->Listen(server_opts);
|
||||
Log.Out(Logs::General, Logs::World_Server, "Server (TCP) listener started.");
|
||||
|
||||
server_connection->OnConnectionIdentified("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
zoneserver_list.Add(new ZoneServer(connection));
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("Zone", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
zoneserver_list.Remove(connection->GetUUID());
|
||||
});
|
||||
|
||||
server_connection->OnConnectionIdentified("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}",
|
||||
connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID());
|
||||
|
||||
QSLink.AddConnection(connection);
|
||||
});
|
||||
|
||||
server_connection->OnConnectionRemoved("QueryServ", [](std::shared_ptr<EQ::Net::ServertalkServerConnection> connection) {
|
||||
Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}",
|
||||
connection->GetUUID());
|
||||
|
||||
QSLink.RemoveConnection(connection);
|
||||
});
|
||||
|
||||
EQ::Net::EQStreamManagerOptions opts(9000, false, false);
|
||||
EQ::Net::EQStreamManager eqsm(opts);
|
||||
@ -450,31 +479,31 @@ int main(int argc, char** argv) {
|
||||
|
||||
client_list.Process();
|
||||
|
||||
while ((tcpc = tcps.NewQueuePop())) {
|
||||
struct in_addr in;
|
||||
in.s_addr = tcpc->GetrIP();
|
||||
|
||||
/* World - Tell what is being connected */
|
||||
if (tcpc->GetMode() == EmuTCPConnection::modePacket) {
|
||||
if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "New Zone Server from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
}
|
||||
else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "New Launcher from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
}
|
||||
else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "New UCS Connection from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
}
|
||||
else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeQueryServ) {
|
||||
Log.Out(Logs::General, Logs::World_Server, "New QS Connection from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::General, Logs::World_Server, "Unsupported packet mode from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
}
|
||||
}
|
||||
|
||||
console_list.Add(new Console(tcpc));
|
||||
}
|
||||
//while ((tcpc = tcps.NewQueuePop())) {
|
||||
// struct in_addr in;
|
||||
// in.s_addr = tcpc->GetrIP();
|
||||
//
|
||||
// /* World - Tell what is being connected */
|
||||
// if (tcpc->GetMode() == EmuTCPConnection::modePacket) {
|
||||
// if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New Zone Server from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New Launcher from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New UCS Connection from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else if (tcpc->GetPacketMode() == EmuTCPConnection::packetModeQueryServ) {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "New QS Connection from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// else {
|
||||
// Log.Out(Logs::General, Logs::World_Server, "Unsupported packet mode from %s:%d", inet_ntoa(in), tcpc->GetrPort());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// console_list.Add(new Console(tcpc));
|
||||
//}
|
||||
|
||||
if(PurgeInstanceTimer.Check())
|
||||
{
|
||||
@ -491,11 +520,9 @@ int main(int argc, char** argv) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "EQTime successfully saved.");
|
||||
}
|
||||
|
||||
console_list.Process();
|
||||
zoneserver_list.Process();
|
||||
launcher_list.Process();
|
||||
UCSLink.Process();
|
||||
QSLink.Process();
|
||||
LFPGroupList.Process();
|
||||
adventure_manager.Process();
|
||||
|
||||
@ -508,12 +535,10 @@ int main(int argc, char** argv) {
|
||||
Sleep(1);
|
||||
}
|
||||
Log.Out(Logs::General, Logs::World_Server, "World main loop completed.");
|
||||
Log.Out(Logs::General, Logs::World_Server, "Shutting down console connections (if any).");
|
||||
console_list.KillAll();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Shutting down zone connections (if any).");
|
||||
zoneserver_list.KillAll();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped.");
|
||||
tcps.Close();
|
||||
//tcps.Close();
|
||||
Log.Out(Logs::General, Logs::World_Server, "Signaling HTTP service to stop...");
|
||||
http_server.Stop();
|
||||
Log.CloseFileLogs();
|
||||
|
||||
@ -15,122 +15,41 @@ extern ZSList zoneserver_list;
|
||||
|
||||
QueryServConnection::QueryServConnection()
|
||||
{
|
||||
Stream = 0;
|
||||
authenticated = false;
|
||||
}
|
||||
|
||||
void QueryServConnection::SetConnection(EmuTCPConnection *inStream)
|
||||
void QueryServConnection::AddConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection)
|
||||
{
|
||||
if(Stream)
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Incoming QueryServ Connection while we were already connected to a QueryServ.");
|
||||
Stream->Disconnect();
|
||||
}
|
||||
|
||||
Stream = inStream;
|
||||
|
||||
authenticated = false;
|
||||
//Set handlers
|
||||
connection->OnMessage(ServerOP_QueryServGeneric, std::bind(&QueryServConnection::HandleGenericMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
connection->OnMessage(ServerOP_LFGuildUpdate, std::bind(&QueryServConnection::HandleLFGuildUpdateMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
m_streams.insert(std::make_pair(connection->GetUUID(), connection));
|
||||
}
|
||||
|
||||
bool QueryServConnection::Process()
|
||||
void QueryServConnection::RemoveConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection)
|
||||
{
|
||||
if (!Stream || !Stream->Connected())
|
||||
return false;
|
||||
|
||||
ServerPacket *pack = 0;
|
||||
|
||||
while((pack = Stream->PopPacket()))
|
||||
{
|
||||
if (!authenticated)
|
||||
{
|
||||
if (WorldConfig::get()->SharedKey.length() > 0)
|
||||
{
|
||||
if (pack->opcode == ServerOP_ZAAuth && pack->size == 16)
|
||||
{
|
||||
uint8 tmppass[16];
|
||||
|
||||
MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
|
||||
|
||||
if (memcmp(pack->pBuffer, tmppass, 16) == 0)
|
||||
authenticated = true;
|
||||
else
|
||||
{
|
||||
struct in_addr in;
|
||||
in.s_addr = GetIP();
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "QueryServ authorization failed.");
|
||||
auto pack = new ServerPacket(ServerOP_ZAAuthFailed);
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct in_addr in;
|
||||
in.s_addr = GetIP();
|
||||
Log.Out(Logs::General, Logs::QS_Server, "QueryServ authorization failed.");
|
||||
auto pack = new ServerPacket(ServerOP_ZAAuthFailed);
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
Disconnect();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::QS_Server,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
|
||||
authenticated = true;
|
||||
}
|
||||
|
||||
delete pack;
|
||||
continue;
|
||||
}
|
||||
switch(pack->opcode)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case ServerOP_KeepAlive:
|
||||
{
|
||||
// ignore this
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZAAuth:
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Got authentication from QueryServ when they are already authenticated.");
|
||||
break;
|
||||
}
|
||||
case ServerOP_QueryServGeneric:
|
||||
{
|
||||
uint32 ZoneID = pack->ReadUInt32();
|
||||
uint16 InstanceID = pack->ReadUInt32();
|
||||
zoneserver_list.SendPacket(ZoneID, InstanceID, pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_LFGuildUpdate:
|
||||
{
|
||||
zoneserver_list.SendPacket(pack);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Log.Out(Logs::Detail, Logs::QS_Server, "Unknown ServerOPcode from QueryServ 0x%04x, size %d", pack->opcode, pack->size);
|
||||
DumpPacket(pack->pBuffer, pack->size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete pack;
|
||||
auto iter = m_streams.find(connection->GetUUID());
|
||||
if (iter != m_streams.end()) {
|
||||
m_streams.erase(iter);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
void QueryServConnection::HandleGenericMessage(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
uint32 ZoneID = p.GetUInt32(0);
|
||||
uint16 InstanceID = p.GetUInt32(4);
|
||||
ServerPacket pack(opcode, p);
|
||||
zoneserver_list.SendPacket(ZoneID, InstanceID, &pack);
|
||||
}
|
||||
|
||||
void QueryServConnection::HandleLFGuildUpdateMessage(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
ServerPacket pack(opcode, p);
|
||||
zoneserver_list.SendPacket(&pack);
|
||||
}
|
||||
|
||||
bool QueryServConnection::SendPacket(ServerPacket* pack)
|
||||
{
|
||||
if(!Stream)
|
||||
return false;
|
||||
for (auto &stream : m_streams) {
|
||||
stream.second->SendPacket(pack);
|
||||
}
|
||||
|
||||
return Stream->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -2,22 +2,20 @@
|
||||
#define QueryServ_H
|
||||
|
||||
#include "../common/types.h"
|
||||
#include "../common/emu_tcp_connection.h"
|
||||
#include "../common/net/servertalk_server.h"
|
||||
#include "../common/servertalk.h"
|
||||
|
||||
class QueryServConnection
|
||||
{
|
||||
public:
|
||||
QueryServConnection();
|
||||
void SetConnection(EmuTCPConnection *inStream);
|
||||
bool Process();
|
||||
void AddConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection);
|
||||
void RemoveConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection);
|
||||
void HandleGenericMessage(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void HandleLFGuildUpdateMessage(uint16_t opcode, EQ::Net::Packet &p);
|
||||
bool SendPacket(ServerPacket* pack);
|
||||
void Disconnect() { if(Stream) Stream->Disconnect(); }
|
||||
void SendMessage(const char *From, const char *Message);
|
||||
private:
|
||||
inline uint32 GetIP() const { return Stream ? Stream->GetrIP() : 0; }
|
||||
EmuTCPConnection *Stream;
|
||||
bool authenticated;
|
||||
std::map<std::string, std::shared_ptr<EQ::Net::ServertalkServerConnection>> m_streams;
|
||||
};
|
||||
|
||||
#endif /*QueryServ_H_*/
|
||||
|
||||
@ -26,9 +26,8 @@
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/random.h"
|
||||
|
||||
extern uint32 numzones;
|
||||
extern uint32 numzones;
|
||||
extern bool holdzones;
|
||||
extern ConsoleList console_list;
|
||||
extern EQEmu::Random emu_random;
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
@ -61,17 +60,27 @@ void ZSList::ShowUpTime(WorldTCPConnection* con, const char* adminname) {
|
||||
}
|
||||
|
||||
void ZSList::Add(ZoneServer* zoneserver) {
|
||||
list.Insert(zoneserver);
|
||||
zoneserver->SendGroupIDs(); //send its initial set of group ids
|
||||
list.push_back(std::unique_ptr<ZoneServer>(zoneserver));
|
||||
zoneserver->SendGroupIDs();
|
||||
}
|
||||
|
||||
void ZSList::Remove(const std::string &uuid)
|
||||
{
|
||||
auto iter = list.begin();
|
||||
while (iter != list.end()) {
|
||||
if ((*iter)->GetUUID().compare(uuid) == 0) {
|
||||
list.erase(iter);
|
||||
return;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void ZSList::KillAll() {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
iterator.GetData()->Disconnect();
|
||||
iterator.RemoveCurrent();
|
||||
auto iterator = list.begin();
|
||||
while(iterator != list.end()) {
|
||||
(*iterator)->Disconnect();
|
||||
iterator = list.erase(iterator);
|
||||
numzones--;
|
||||
}
|
||||
}
|
||||
@ -88,159 +97,120 @@ void ZSList::Process() {
|
||||
Process();
|
||||
CatchSignal(2);
|
||||
}
|
||||
|
||||
if(reminder && reminder->Check() && shutdowntimer){
|
||||
SendEmoteMessage(0,0,0,15,"<SYSTEMWIDE MESSAGE>:SYSTEM MSG:World coming down, everyone log out now. World will shut down in %i minutes...", ((shutdowntimer->GetRemainingTime()/1000) / 60));
|
||||
}
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (!iterator.GetData()->Process()) {
|
||||
ZoneServer* zs = iterator.GetData();
|
||||
struct in_addr in;
|
||||
in.s_addr = zs->GetIP();
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Removing zoneserver #%d at %s:%d",zs->GetID(),zs->GetCAddress(),zs->GetCPort());
|
||||
zs->LSShutDownUpdate(zs->GetZoneID());
|
||||
if (holdzones){
|
||||
Log.Out(Logs::Detail, Logs::World_Server,"Hold Zones mode is ON - rebooting lost zone");
|
||||
if(!zs->IsStaticZone())
|
||||
RebootZone(inet_ntoa(in),zs->GetCPort(),zs->GetCAddress(),zs->GetID());
|
||||
else
|
||||
RebootZone(inet_ntoa(in),zs->GetCPort(),zs->GetCAddress(),zs->GetID(),database.GetZoneID(zs->GetZoneName()));
|
||||
}
|
||||
|
||||
iterator.RemoveCurrent();
|
||||
numzones--;
|
||||
}
|
||||
else {
|
||||
iterator.Advance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ZSList::SendPacket(ServerPacket* pack) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
iterator.GetData()->SendPacket(pack);
|
||||
iterator.Advance();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
(*iterator)->SendPacket(pack);
|
||||
iterator++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ZSList::SendPacket(uint32 ZoneID, ServerPacket* pack) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetZoneID() == ZoneID) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
return(tmp->SendPacket(pack));
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetZoneID() == ZoneID) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
tmp->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
if(instanceID != 0)
|
||||
{
|
||||
while(iterator.MoreElements()) {
|
||||
if(iterator.GetData()->GetInstanceID() == instanceID) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
return(tmp->SendPacket(pack));
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if((*iterator)->GetInstanceID() == instanceID) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
tmp->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetZoneID() == ZoneID
|
||||
&& iterator.GetData()->GetInstanceID() == 0) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
return(tmp->SendPacket(pack));
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetZoneID() == ZoneID
|
||||
&& (*iterator)->GetInstanceID() == 0) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
tmp->SendPacket(pack);
|
||||
return true;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
ZoneServer* ZSList::FindByName(const char* zonename) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
if (strcasecmp(iterator.GetData()->GetZoneName(), zonename) == 0) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if (strcasecmp((*iterator)->GetZoneName(), zonename) == 0) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
return tmp;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZoneServer* ZSList::FindByID(uint32 ZoneID) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetID() == ZoneID) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetID() == ZoneID) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
return tmp;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZoneServer* ZSList::FindByZoneID(uint32 ZoneID) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
if (tmp->GetZoneID() == ZoneID && tmp->GetInstanceID() == 0) {
|
||||
return tmp;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZoneServer* ZSList::FindByPort(uint16 port) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
if (iterator.GetData()->GetCPort() == port) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetCPort() == port) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
return tmp;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZoneServer* ZSList::FindByInstanceID(uint32 InstanceID)
|
||||
{
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements())
|
||||
{
|
||||
if (iterator.GetData()->GetInstanceID() == InstanceID) {
|
||||
ZoneServer* tmp = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetInstanceID() == InstanceID) {
|
||||
ZoneServer* tmp = (*iterator).get();
|
||||
return tmp;
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -283,11 +253,6 @@ void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) {
|
||||
}
|
||||
|
||||
void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection) {
|
||||
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
struct in_addr in;
|
||||
|
||||
iterator.Reset();
|
||||
char locked[4];
|
||||
if (WorldConfig::get()->Locked == true){
|
||||
strcpy(locked, "Yes");
|
||||
@ -318,9 +283,10 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
|
||||
|
||||
ZoneServer* zone_server_data = 0;
|
||||
|
||||
while (iterator.MoreElements()) {
|
||||
zone_server_data = iterator.GetData();
|
||||
in.s_addr = zone_server_data->GetIP();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
zone_server_data = (*iterator).get();
|
||||
auto addr = zone_server_data->GetIP();
|
||||
|
||||
if (zone_server_data->IsStaticZone()){
|
||||
z++;
|
||||
@ -352,7 +318,7 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
|
||||
"#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)",
|
||||
zone_server_data->GetID(),
|
||||
is_static_string,
|
||||
inet_ntoa(in),
|
||||
addr.c_str(),
|
||||
zone_server_data->GetPort(),
|
||||
zone_server_data->NumPlayers(),
|
||||
zone_server_data->GetCAddress(),
|
||||
@ -398,7 +364,7 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
|
||||
if (connection->IsConsole()){
|
||||
@ -462,9 +428,7 @@ void ZSList::SendChannelMessageRaw(const char* from, const char* to, uint8 chan_
|
||||
scm->language = language;
|
||||
scm->chan_num = chan_num;
|
||||
strcpy(&scm->message[0], message);
|
||||
if (scm->chan_num == 5 || scm->chan_num == 6 || scm->chan_num == 11) {
|
||||
console_list.SendChannelMessage(scm);
|
||||
}
|
||||
|
||||
pack->Deflate();
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
@ -496,13 +460,6 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m
|
||||
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;
|
||||
|
||||
if (to) {
|
||||
if (to[0] == '*') {
|
||||
Console* con = console_list.FindByAccountName(&to[1]);
|
||||
if (con)
|
||||
con->SendEmoteMessageRaw(to, to_guilddbid, to_minstatus, type, message);
|
||||
delete pack;
|
||||
return;
|
||||
}
|
||||
strcpy((char *) sem->to, to);
|
||||
}
|
||||
else {
|
||||
@ -519,8 +476,6 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m
|
||||
pack->Deflate();
|
||||
if (tempto[0] == 0) {
|
||||
SendPacket(pack);
|
||||
if (to_guilddbid == 0)
|
||||
console_list.SendEmoteMessageRaw(type, message);
|
||||
}
|
||||
else {
|
||||
ZoneServer* zs = FindByName(to);
|
||||
@ -578,24 +533,24 @@ void ZSList::SOPZoneBootup(const char* adminname, uint32 ZoneServerID, const cha
|
||||
}
|
||||
|
||||
void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skipid, uint32 zoneid){
|
||||
// get random zone
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
// get random zone
|
||||
uint32 x = 0;
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
x++;
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
if (x == 0)
|
||||
return;
|
||||
auto tmp = new ZoneServer *[x];
|
||||
uint32 y = 0;
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (!strcmp(iterator.GetData()->GetCAddress(),ip2) && !iterator.GetData()->IsBootingUp() && iterator.GetData()->GetID() != skipid) {
|
||||
tmp[y++] = iterator.GetData();
|
||||
|
||||
iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if (!strcmp((*iterator)->GetCAddress(),ip2) && !(*iterator)->IsBootingUp() && (*iterator)->GetID() != skipid) {
|
||||
tmp[y++] = (*iterator).get();
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
if (y == 0) {
|
||||
safe_delete_array(tmp);
|
||||
@ -645,95 +600,56 @@ uint16 ZSList::GetAvailableZonePort()
|
||||
uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) {
|
||||
if(iInstanceID > 0)
|
||||
{
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if(iterator.GetData()->GetInstanceID() == iInstanceID)
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if((*iterator)->GetInstanceID() == iInstanceID)
|
||||
{
|
||||
return iterator.GetData()->GetID();
|
||||
return (*iterator)->GetID();
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetZoneID() == 0 && !iterator.GetData()->IsBootingUp()) {
|
||||
ZoneServer* zone=iterator.GetData();
|
||||
iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetZoneID() == 0 && !(*iterator)->IsBootingUp()) {
|
||||
ZoneServer* zone=(*iterator).get();
|
||||
zone->TriggerBootup(iZoneID, iInstanceID);
|
||||
return zone->GetID();
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if(iterator.GetData()->GetZoneID() == iZoneID && iterator.GetData()->GetInstanceID() == 0)
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if((*iterator)->GetZoneID() == iZoneID && (*iterator)->GetInstanceID() == 0)
|
||||
{
|
||||
return iterator.GetData()->GetID();
|
||||
return (*iterator)->GetID();
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetZoneID() == 0 && !iterator.GetData()->IsBootingUp()) {
|
||||
ZoneServer* zone=iterator.GetData();
|
||||
iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
if ((*iterator)->GetZoneID() == 0 && !(*iterator)->IsBootingUp()) {
|
||||
ZoneServer* zone = (*iterator).get();
|
||||
zone->TriggerBootup(iZoneID);
|
||||
return zone->GetID();
|
||||
}
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*Old Random boot zones use this if your server is distributed across computers.
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
|
||||
srand(time(nullptr));
|
||||
uint32 x = 0;
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
x++;
|
||||
iterator.Advance();
|
||||
}
|
||||
if (x == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZoneServer** tmp = new ZoneServer*[x];
|
||||
uint32 y = 0;
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->GetZoneID() == 0 && !iterator.GetData()->IsBootingUp()) {
|
||||
tmp[y++] = iterator.GetData();
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
if (y == 0) {
|
||||
safe_delete(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 z = rand() % y;
|
||||
|
||||
tmp[z]->TriggerBootup(iZoneID);
|
||||
uint32 ret = tmp[z]->GetID();
|
||||
safe_delete(tmp);
|
||||
return ret;
|
||||
*/
|
||||
}
|
||||
|
||||
void ZSList::SendLSZones(){
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
ZoneServer* zs = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while(iterator != list.end()) {
|
||||
ZoneServer* zs = (*iterator).get();
|
||||
zs->LSBootUpdate(zs->GetZoneID(),true);
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -742,12 +658,11 @@ int ZSList::GetZoneCount() {
|
||||
}
|
||||
|
||||
void ZSList::GetZoneIDList(std::vector<uint32> &zones) {
|
||||
LinkedListIterator<ZoneServer*> iterator(list);
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
ZoneServer* zs = iterator.GetData();
|
||||
auto iterator = list.begin();
|
||||
while (iterator != list.end()) {
|
||||
ZoneServer* zs = (*iterator).get();
|
||||
zones.push_back(zs->GetID());
|
||||
iterator.Advance();
|
||||
iterator++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "../common/timer.h"
|
||||
#include "../common/linked_list.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class WorldTCPConnection;
|
||||
class ServerPacket;
|
||||
@ -35,6 +36,7 @@ public:
|
||||
|
||||
void SendTimeSync();
|
||||
void Add(ZoneServer* zoneserver);
|
||||
void Remove(const std::string &uuid);
|
||||
void Process();
|
||||
void KillAll();
|
||||
bool SendPacket(ServerPacket* pack);
|
||||
@ -60,7 +62,7 @@ public:
|
||||
|
||||
protected:
|
||||
uint32 NextID;
|
||||
LinkedList<ZoneServer*> list;
|
||||
std::list<std::unique_ptr<ZoneServer>> list;
|
||||
uint16 pLockedZones[MaxLockedZones];
|
||||
uint32 CurGroupID;
|
||||
uint16 LastAllocatedPort;
|
||||
|
||||
2286
world/zoneserver.cpp
2286
world/zoneserver.cpp
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,9 @@
|
||||
#define ZONESERVER_H
|
||||
|
||||
#include "world_tcp_connection.h"
|
||||
#include "../common/emu_tcp_connection.h"
|
||||
#include "../net/servertalk_server.h"
|
||||
#include "../event/timer.h"
|
||||
#include "../timer.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
@ -29,17 +31,16 @@ class ServerPacket;
|
||||
|
||||
class ZoneServer : public WorldTCPConnection {
|
||||
public:
|
||||
ZoneServer(EmuTCPConnection* itcpc);
|
||||
ZoneServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection);
|
||||
~ZoneServer();
|
||||
virtual inline bool IsZoneServer() { return true; }
|
||||
|
||||
bool Process();
|
||||
bool SendPacket(ServerPacket* pack) { return tcpc->SendPacket(pack); }
|
||||
void SendPacket(ServerPacket* pack) { tcpc->SendPacket(pack); }
|
||||
void SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...);
|
||||
void SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message);
|
||||
bool SetZone(uint32 iZoneID, uint32 iInstanceID = 0, bool iStaticZone = false);
|
||||
void TriggerBootup(uint32 iZoneID = 0, uint32 iInstanceID = 0, const char* iAdminName = 0, bool iMakeStatic = false);
|
||||
void Disconnect() { tcpc->Disconnect(); }
|
||||
void Disconnect() { auto handle = tcpc->Handle(); if (handle) { handle->Disconnect(); } }
|
||||
void IncomingClient(Client* client);
|
||||
void LSBootUpdate(uint32 zoneid, uint32 iInstanceID = 0, bool startup = false);
|
||||
void LSSleepUpdate(uint32 zoneid);
|
||||
@ -47,14 +48,15 @@ public:
|
||||
uint32 GetPrevZoneID() { return zone_server_previous_zone_id; }
|
||||
void ChangeWID(uint32 iCharID, uint32 iWID);
|
||||
void SendGroupIDs();
|
||||
void HandleMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
|
||||
inline const char* GetZoneName() const { return zone_name; }
|
||||
inline const char* GetZoneLongName() const { return long_name; }
|
||||
const char* GetCompileTime() const{ return compiled; }
|
||||
void SetCompile(char* in_compile){ strcpy(compiled,in_compile); }
|
||||
inline uint32 GetZoneID() const { return zone_server_zone_id; }
|
||||
inline uint32 GetIP() const { return tcpc->GetrIP(); }
|
||||
inline uint16 GetPort() const { return tcpc->GetrPort(); }
|
||||
inline std::string GetIP() const { return tcpc->Handle() ? tcpc->Handle()->RemoteIP() : ""; }
|
||||
inline uint16 GetPort() const { return tcpc->Handle() ? tcpc->Handle()->RemotePort() : 0; }
|
||||
inline const char* GetCAddress() const { return client_address; }
|
||||
inline const char* GetCLocalAddress() const { return client_local_address; }
|
||||
inline uint16 GetCPort() const { return client_port; }
|
||||
@ -66,6 +68,7 @@ public:
|
||||
inline void RemovePlayer() { zone_player_count--; }
|
||||
inline const char * GetLaunchName() const { return(launcher_name.c_str()); }
|
||||
inline const char * GetLaunchedName() const { return(launched_name.c_str()); }
|
||||
std::string GetUUID() const { return tcpc->GetUUID(); }
|
||||
|
||||
inline uint32 GetInstanceID() { return instance_id; }
|
||||
inline void SetInstanceID(uint32 i) { instance_id = i; }
|
||||
@ -73,7 +76,8 @@ public:
|
||||
inline uint32 GetZoneOSProcessID() { return zone_os_process_id; }
|
||||
|
||||
private:
|
||||
EmuTCPConnection* const tcpc;
|
||||
std::shared_ptr<EQ::Net::ServertalkServerConnection> tcpc;
|
||||
std::unique_ptr<EQ::Timer> boot_timer_obj;
|
||||
|
||||
uint32 zone_server_id;
|
||||
char client_address[250];
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/data_verification.h"
|
||||
#include "../common/misc_functions.h"
|
||||
#include "queryserv.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "string_ids.h"
|
||||
|
||||
@ -172,7 +172,6 @@ int command_init(void)
|
||||
command_add("chat", "[channel num] [message] - Send a channel message to all zones", 200, command_chat) ||
|
||||
command_add("checklos", "- Check for line of sight to your target", 50, command_checklos) ||
|
||||
command_add("clearinvsnapshots", "[use rule] - Clear inventory snapshot history (true - elapsed entries, false - all entries)", 200, command_clearinvsnapshots) ||
|
||||
command_add("connectworldserver", "- Make zone attempt to connect to worldserver", 200, command_connectworldserver) ||
|
||||
command_add("corpse", "- Manipulate corpses, use with no arguments for help", 50, command_corpse) ||
|
||||
command_add("crashtest", "- Crash the zoneserver", 255, command_crashtest) ||
|
||||
command_add("cvs", "- Summary of client versions currently online.", 200, command_cvs) ||
|
||||
@ -820,17 +819,6 @@ void command_setanim(Client *c, const Seperator *sep)
|
||||
c->Message(0, "Usage: #setanim [animnum]");
|
||||
}
|
||||
|
||||
void command_connectworldserver(Client *c, const Seperator *sep)
|
||||
{
|
||||
if(worldserver.Connected())
|
||||
c->Message(0, "Error: Already connected to world server");
|
||||
else
|
||||
{
|
||||
c->Message(0, "Attempting to connect to world server...");
|
||||
worldserver.AsyncConnect();
|
||||
}
|
||||
}
|
||||
|
||||
void command_serverinfo(Client *c, const Seperator *sep)
|
||||
{
|
||||
#ifdef _WINDOWS
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/misc_functions.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "entity.h"
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/misc_functions.h"
|
||||
|
||||
#include "quest_parser_collection.h"
|
||||
#include "string_ids.h"
|
||||
|
||||
12
zone/net.cpp
12
zone/net.cpp
@ -216,7 +216,6 @@ int main(int argc, char** argv) {
|
||||
worldserver.SetLauncherName("NONE");
|
||||
}
|
||||
|
||||
worldserver.SetPassword(Config->SharedKey.c_str());
|
||||
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Connecting to MySQL...");
|
||||
if (!database.Connect(
|
||||
@ -397,9 +396,7 @@ int main(int argc, char** argv) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Loading quests");
|
||||
parse->ReloadQuests();
|
||||
|
||||
if (!worldserver.Connect()) {
|
||||
Log.Out(Logs::General, Logs::Error, "Worldserver Connection Failed :: worldserver.Connect()");
|
||||
}
|
||||
worldserver.Connect();
|
||||
|
||||
Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect
|
||||
#ifdef EQPROFILE
|
||||
@ -440,8 +437,6 @@ int main(int argc, char** argv) {
|
||||
//Advance the timer to our current point in time
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
worldserver.Process();
|
||||
|
||||
if (!eqsf_open && Config->ZonePort != 0) {
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort);
|
||||
|
||||
@ -524,10 +519,7 @@ int main(int argc, char** argv) {
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
// AsyncLoadVariables(dbasync, &database);
|
||||
entity_list.UpdateWho();
|
||||
if (worldserver.TryReconnect() && (!worldserver.Connected()))
|
||||
worldserver.AsyncConnect();
|
||||
}
|
||||
});
|
||||
|
||||
@ -553,7 +545,6 @@ int main(int argc, char** argv) {
|
||||
if (zone != 0)
|
||||
Zone::Shutdown(true);
|
||||
//Fix for Linux world server problem.
|
||||
worldserver.Disconnect();
|
||||
safe_delete(taskmanager);
|
||||
command_deinit();
|
||||
#ifdef BOTS
|
||||
@ -576,7 +567,6 @@ void Shutdown()
|
||||
{
|
||||
Zone::Shutdown(true);
|
||||
RunLoops = false;
|
||||
worldserver.Disconnect();
|
||||
Log.Out(Logs::General, Logs::Zone_Server, "Shutting down...");
|
||||
Log.CloseFileLogs();
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "../common/skills.h"
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/data_verification.h"
|
||||
#include "../common/misc_functions.h"
|
||||
|
||||
#include "quest_parser_collection.h"
|
||||
#include "string_ids.h"
|
||||
|
||||
@ -76,6 +76,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/data_verification.h"
|
||||
#include "../common/misc_functions.h"
|
||||
|
||||
#include "quest_parser_collection.h"
|
||||
#include "string_ids.h"
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/misc_functions.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "entity.h"
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/misc_functions.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "entity.h"
|
||||
|
||||
3337
zone/worldserver.cpp
3337
zone/worldserver.cpp
File diff suppressed because it is too large
Load Diff
@ -18,27 +18,31 @@
|
||||
#ifndef WORLDSERVER_H
|
||||
#define WORLDSERVER_H
|
||||
|
||||
#include "../common/worldconn.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/net/servertalk_client_connection.h"
|
||||
|
||||
class ServerPacket;
|
||||
class EQApplicationPacket;
|
||||
class Client;
|
||||
|
||||
class WorldServer : public WorldConnection {
|
||||
class WorldServer {
|
||||
public:
|
||||
WorldServer();
|
||||
virtual ~WorldServer();
|
||||
~WorldServer();
|
||||
|
||||
virtual void Process();
|
||||
void Connect();
|
||||
bool SendPacket(ServerPacket* pack);
|
||||
std::string GetIP() const;
|
||||
uint16 GetPort() const;
|
||||
bool Connected() const;
|
||||
|
||||
void HandleMessage(uint16 opcode, const EQ::Net::Packet &p);
|
||||
|
||||
void SendGuildJoin(GuildJoin_Struct* gj);
|
||||
bool SendChannelMessage(Client* from, const char* to, uint8 chan_num, uint32 guilddbid, uint8 language, const char* message, ...);
|
||||
bool SendEmoteMessage(const char* to, uint32 to_guilddbid, uint32 type, const char* message, ...);
|
||||
bool SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...);
|
||||
bool SendVoiceMacro(Client* From, uint32 Type, char* Target, uint32 MacroNumber, uint32 GroupOrRaidID = 0);
|
||||
void SetZoneData(uint32 iZoneID, uint32 iInstanceID = 0);
|
||||
uint32 SendGroupIdRequest();
|
||||
bool RezzPlayer(EQApplicationPacket* rpack, uint32 rezzexp, uint32 dbid, uint16 opcode);
|
||||
bool IsOOCMuted() const { return(oocmuted); }
|
||||
|
||||
@ -67,6 +71,8 @@ private:
|
||||
|
||||
uint32 cur_groupid;
|
||||
uint32 last_groupid;
|
||||
|
||||
std::unique_ptr<EQ::Net::ServertalkClient> m_connection;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user