mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-15 12:58:22 +00:00
Merge of a monster
This commit is contained in:
+46
-47
@@ -1,19 +1,19 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "../common/global_define.h"
|
||||
#include <iostream>
|
||||
@@ -43,10 +43,10 @@ extern volatile bool RunLoops;
|
||||
|
||||
LoginServer::LoginServer(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool legacy)
|
||||
{
|
||||
strn0cpy(LoginServerAddress,iAddress,256);
|
||||
strn0cpy(LoginServerAddress, iAddress, 256);
|
||||
LoginServerPort = iPort;
|
||||
strn0cpy(LoginAccount,Account,31);
|
||||
strn0cpy(LoginPassword,Password,31);
|
||||
strn0cpy(LoginAccount, Account, 31);
|
||||
strn0cpy(LoginPassword, Password, 31);
|
||||
CanAccountUpdate = false;
|
||||
IsLegacy = legacy;
|
||||
Connect();
|
||||
@@ -57,7 +57,7 @@ LoginServer::~LoginServer() {
|
||||
|
||||
void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
UsertoWorldRequest_Struct* utwr = (UsertoWorldRequest_Struct*)p.Data();
|
||||
uint32 id = database.GetAccountIDFromLSID(utwr->lsaccountid);
|
||||
@@ -99,8 +99,8 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
|
||||
void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
try {
|
||||
auto slsca = p.GetSerialize<ClientAuth_Struct>(0);
|
||||
|
||||
@@ -109,27 +109,27 @@ void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
// online at the same time.
|
||||
client_list.EnforceSessionLimit(slsca.lsaccount_id);
|
||||
}
|
||||
|
||||
|
||||
client_list.CLEAdd(slsca.lsaccount_id, slsca.name, slsca.key, slsca.worldadmin, slsca.ip, slsca.local);
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
Log.OutF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what());
|
||||
LogF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServer::ProcessLSFatalError(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Login server responded with FatalError.");
|
||||
Log(Logs::Detail, Logs::World_Server, "Login server responded with FatalError.");
|
||||
if (p.Length() > 1) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, " %s", (const char*)p.Data());
|
||||
Log(Logs::Detail, Logs::World_Server, " %s", (const char*)p.Data());
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
ServerSystemwideMessage* swm = (ServerSystemwideMessage*)p.Data();
|
||||
zoneserver_list.SendEmoteMessageRaw(0, 0, 0, swm->type, swm->message);
|
||||
@@ -137,44 +137,44 @@ void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p)
|
||||
|
||||
void LoginServer::ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
if (!Config->WorldAddress.length()) {
|
||||
WorldConfig::SetWorldAddress((char *)p.Data());
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data());
|
||||
Log(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data());
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServer::ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from loginserver");
|
||||
Log(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from loginserver");
|
||||
CanAccountUpdate = true;
|
||||
}
|
||||
|
||||
bool LoginServer::Connect() {
|
||||
std::string tmp;
|
||||
if(database.GetVariable("loginType", tmp) && strcasecmp(tmp.c_str(), "MinILogin") == 0) {
|
||||
if (database.GetVariable("loginType", tmp) && strcasecmp(tmp.c_str(), "MinILogin") == 0) {
|
||||
minilogin = true;
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Setting World to MiniLogin Server type");
|
||||
Log(Logs::Detail, Logs::World_Server, "Setting World to MiniLogin Server type");
|
||||
}
|
||||
else
|
||||
minilogin = false;
|
||||
|
||||
if (minilogin && WorldConfig::get()->WorldAddress.length()==0) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "**** For minilogin to work, you need to set the <address> element in the <world> section.");
|
||||
if (minilogin && WorldConfig::get()->WorldAddress.length() == 0) {
|
||||
Log(Logs::Detail, Logs::World_Server, "**** For minilogin to work, you need to set the <address> element in the <world> section.");
|
||||
return false;
|
||||
}
|
||||
|
||||
char errbuf[1024];
|
||||
if ((LoginServerIP = ResolveIP(LoginServerAddress, errbuf)) == 0) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.",LoginServerAddress);
|
||||
Log(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.", LoginServerAddress);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LoginServerIP == 0 || LoginServerPort == 0) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d",LoginServerAddress,LoginServerPort);
|
||||
Log(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ bool LoginServer::Connect() {
|
||||
legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false));
|
||||
legacy_client->OnConnect([this](EQ::Net::ServertalkLegacyClient *client) {
|
||||
if (client) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
Log(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
if (minilogin)
|
||||
SendInfo();
|
||||
else
|
||||
@@ -195,7 +195,7 @@ bool LoginServer::Connect() {
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
Log(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -211,7 +211,7 @@ bool LoginServer::Connect() {
|
||||
client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", ""));
|
||||
client->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
if (client) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
Log(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
if (minilogin)
|
||||
SendInfo();
|
||||
else
|
||||
@@ -224,7 +224,7 @@ bool LoginServer::Connect() {
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
Log(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -239,14 +239,14 @@ bool LoginServer::Connect() {
|
||||
return true;
|
||||
}
|
||||
void LoginServer::SendInfo() {
|
||||
const WorldConfig *Config=WorldConfig::get();
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
|
||||
auto pack = new ServerPacket;
|
||||
pack->opcode = ServerOP_LSInfo;
|
||||
pack->size = sizeof(ServerLSInfo_Struct);
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memset(pack->pBuffer, 0, pack->size);
|
||||
ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*) pack->pBuffer;
|
||||
ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*)pack->pBuffer;
|
||||
strcpy(lsi->protocolversion, EQEMU_PROTOCOL_VERSION);
|
||||
strcpy(lsi->serverversion, LOGIN_VERSION);
|
||||
strcpy(lsi->name, Config->LongName.c_str());
|
||||
@@ -258,14 +258,14 @@ void LoginServer::SendInfo() {
|
||||
}
|
||||
|
||||
void LoginServer::SendNewInfo() {
|
||||
const WorldConfig *Config=WorldConfig::get();
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
|
||||
auto pack = new ServerPacket;
|
||||
pack->opcode = ServerOP_NewLSInfo;
|
||||
pack->size = sizeof(ServerNewLSInfo_Struct);
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memset(pack->pBuffer, 0, pack->size);
|
||||
ServerNewLSInfo_Struct* lsi = (ServerNewLSInfo_Struct*) pack->pBuffer;
|
||||
ServerNewLSInfo_Struct* lsi = (ServerNewLSInfo_Struct*)pack->pBuffer;
|
||||
strcpy(lsi->protocolversion, EQEMU_PROTOCOL_VERSION);
|
||||
strcpy(lsi->serverversion, LOGIN_VERSION);
|
||||
strcpy(lsi->name, Config->LongName.c_str());
|
||||
@@ -291,7 +291,7 @@ void LoginServer::SendStatus() {
|
||||
pack->size = sizeof(ServerLSStatus_Struct);
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memset(pack->pBuffer, 0, pack->size);
|
||||
ServerLSStatus_Struct* lss = (ServerLSStatus_Struct*) pack->pBuffer;
|
||||
ServerLSStatus_Struct* lss = (ServerLSStatus_Struct*)pack->pBuffer;
|
||||
|
||||
if (WorldConfig::get()->Locked)
|
||||
lss->status = -2;
|
||||
@@ -307,12 +307,11 @@ void LoginServer::SendStatus() {
|
||||
}
|
||||
|
||||
void LoginServer::SendAccountUpdate(ServerPacket* pack) {
|
||||
ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *) pack->pBuffer;
|
||||
if(CanUpdate()) {
|
||||
Log.Out(Logs::Detail, Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d",LoginServerAddress,LoginServerPort);
|
||||
ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *)pack->pBuffer;
|
||||
if (CanUpdate()) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
strn0cpy(s->worldaccount, LoginAccount, 30);
|
||||
strn0cpy(s->worldpassword, LoginPassword, 30);
|
||||
SendPacket(pack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user