mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 00:46:46 +00:00
Fix some edge case with account name not being passed to world
This commit is contained in:
+3
-2
@@ -414,10 +414,11 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) {
|
||||
|
||||
is_player_zoning = (li->zoning == 1);
|
||||
|
||||
uint32 id = atoi(name);
|
||||
LogDebug("Receiving Login Info Packet from Client | name [{0}] password [{1}]", name, password);
|
||||
|
||||
uint32 id = atoi(name);
|
||||
if (id == 0) {
|
||||
Log(Logs::General, Logs::World_Server, "Login ID is 0, disconnecting.");
|
||||
LogWarning("Receiving Login Info Packet from Client | account_id is 0 - disconnecting");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+151
-101
@@ -26,44 +26,53 @@
|
||||
#include "../common/guilds.h"
|
||||
#include "../common/string_util.h"
|
||||
|
||||
extern uint32 numplayers;
|
||||
extern uint32 numplayers;
|
||||
extern LoginServerList loginserverlist;
|
||||
extern ClientList client_list;
|
||||
extern volatile bool RunLoops;
|
||||
extern ClientList client_list;
|
||||
extern volatile bool RunLoops;
|
||||
|
||||
ClientListEntry::ClientListEntry(uint32 in_id, uint32 iLSID, const char *iLoginServerName, const char* iLoginName, const char* iLoginKey, int16 iWorldAdmin, uint32 ip, uint8 local)
|
||||
: id(in_id)
|
||||
ClientListEntry::ClientListEntry(
|
||||
uint32 in_id,
|
||||
uint32 iLSID,
|
||||
const char *iLoginServerName,
|
||||
const char *iLoginName,
|
||||
const char *iLoginKey,
|
||||
int16 iWorldAdmin,
|
||||
uint32 ip,
|
||||
uint8 local
|
||||
)
|
||||
: id(in_id)
|
||||
{
|
||||
ClearVars(true);
|
||||
|
||||
pIP = ip;
|
||||
pIP = ip;
|
||||
pLSID = iLSID;
|
||||
if (iLSID > 0) {
|
||||
|
||||
|
||||
paccountid = database.GetAccountIDFromLSID(iLoginServerName, iLSID, paccountname, &padmin);
|
||||
}
|
||||
|
||||
strn0cpy(plsname, iLoginName, sizeof(plsname));
|
||||
strn0cpy(loginserver_account_name, iLoginName, sizeof(loginserver_account_name));
|
||||
strn0cpy(plskey, iLoginKey, sizeof(plskey));
|
||||
strn0cpy(pLoginServer, iLoginServerName, sizeof(pLoginServer));
|
||||
strn0cpy(source_loginserver, iLoginServerName, sizeof(source_loginserver));
|
||||
pworldadmin = iWorldAdmin;
|
||||
plocal=(local==1);
|
||||
plocal = (local == 1);
|
||||
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pLFGMatchFilter = false;
|
||||
memset(pLFGComments, 0, 64);
|
||||
}
|
||||
|
||||
ClientListEntry::ClientListEntry(uint32 in_id, ZoneServer* iZS, ServerClientList_Struct* scl, int8 iOnline)
|
||||
: id(in_id)
|
||||
ClientListEntry::ClientListEntry(uint32 in_id, ZoneServer *iZS, ServerClientList_Struct *scl, int8 iOnline)
|
||||
: id(in_id)
|
||||
{
|
||||
ClearVars(true);
|
||||
|
||||
pIP = 0;
|
||||
pIP = 0;
|
||||
pLSID = scl->LSAccountID;
|
||||
strn0cpy(plsname, scl->name, sizeof(plsname));
|
||||
strn0cpy(loginserver_account_name, scl->name, sizeof(loginserver_account_name));
|
||||
strn0cpy(plskey, scl->lskey, sizeof(plskey));
|
||||
pworldadmin = 0;
|
||||
|
||||
@@ -71,19 +80,22 @@ ClientListEntry::ClientListEntry(uint32 in_id, ZoneServer* iZS, ServerClientList
|
||||
strn0cpy(paccountname, scl->AccountName, sizeof(paccountname));
|
||||
padmin = scl->Admin;
|
||||
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pinstance = 0;
|
||||
pLFGFromLevel = 0;
|
||||
pLFGToLevel = 0;
|
||||
pLFGMatchFilter = false;
|
||||
memset(pLFGComments, 0, 64);
|
||||
|
||||
if (iOnline >= CLE_Status_Zoning)
|
||||
if (iOnline >= CLE_Status_Zoning) {
|
||||
Update(iZS, scl, iOnline);
|
||||
else
|
||||
}
|
||||
else {
|
||||
SetOnline(iOnline);
|
||||
}
|
||||
}
|
||||
|
||||
ClientListEntry::~ClientListEntry() {
|
||||
ClientListEntry::~ClientListEntry()
|
||||
{
|
||||
if (RunLoops) {
|
||||
Camp(); // updates zoneserver's numplayers
|
||||
client_list.RemoveCLEReferances(this);
|
||||
@@ -93,97 +105,108 @@ ClientListEntry::~ClientListEntry() {
|
||||
tell_queue.clear();
|
||||
}
|
||||
|
||||
void ClientListEntry::SetChar(uint32 iCharID, const char* iCharName) {
|
||||
void ClientListEntry::SetChar(uint32 iCharID, const char *iCharName)
|
||||
{
|
||||
pcharid = iCharID;
|
||||
strn0cpy(pname, iCharName, sizeof(pname));
|
||||
}
|
||||
|
||||
void ClientListEntry::SetOnline(ZoneServer* iZS, int8 iOnline) {
|
||||
if (iZS == this->Server())
|
||||
void ClientListEntry::SetOnline(ZoneServer *iZS, int8 iOnline)
|
||||
{
|
||||
if (iZS == this->Server()) {
|
||||
SetOnline(iOnline);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientListEntry::SetOnline(int8 iOnline) {
|
||||
if (iOnline >= CLE_Status_Online && pOnline < CLE_Status_Online)
|
||||
void ClientListEntry::SetOnline(int8 iOnline)
|
||||
{
|
||||
if (iOnline >= CLE_Status_Online && pOnline < CLE_Status_Online) {
|
||||
numplayers++;
|
||||
}
|
||||
else if (iOnline < CLE_Status_Online && pOnline >= CLE_Status_Online) {
|
||||
numplayers--;
|
||||
}
|
||||
if (iOnline != CLE_Status_Online || pOnline < CLE_Status_Online)
|
||||
if (iOnline != CLE_Status_Online || pOnline < CLE_Status_Online) {
|
||||
pOnline = iOnline;
|
||||
if (iOnline < CLE_Status_Zoning)
|
||||
}
|
||||
if (iOnline < CLE_Status_Zoning) {
|
||||
Camp();
|
||||
if (pOnline >= CLE_Status_Online)
|
||||
}
|
||||
if (pOnline >= CLE_Status_Online) {
|
||||
stale = 0;
|
||||
}
|
||||
}
|
||||
void ClientListEntry::LSUpdate(ZoneServer* iZS){
|
||||
if(WorldConfig::get()->UpdateStats){
|
||||
void ClientListEntry::LSUpdate(ZoneServer *iZS)
|
||||
{
|
||||
if (WorldConfig::get()->UpdateStats) {
|
||||
auto pack = new ServerPacket;
|
||||
pack->opcode = ServerOP_LSZoneInfo;
|
||||
pack->size = sizeof(ZoneInfo_Struct);
|
||||
pack->opcode = ServerOP_LSZoneInfo;
|
||||
pack->size = sizeof(ZoneInfo_Struct);
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
ZoneInfo_Struct* zone =(ZoneInfo_Struct*)pack->pBuffer;
|
||||
zone->count=iZS->NumPlayers();
|
||||
zone->zone = iZS->GetZoneID();
|
||||
ZoneInfo_Struct *zone = (ZoneInfo_Struct *) pack->pBuffer;
|
||||
zone->count = iZS->NumPlayers();
|
||||
zone->zone = iZS->GetZoneID();
|
||||
zone->zone_wid = iZS->GetID();
|
||||
loginserverlist.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
}
|
||||
void ClientListEntry::LSZoneChange(ZoneToZone_Struct* ztz){
|
||||
if(WorldConfig::get()->UpdateStats){
|
||||
void ClientListEntry::LSZoneChange(ZoneToZone_Struct *ztz)
|
||||
{
|
||||
if (WorldConfig::get()->UpdateStats) {
|
||||
auto pack = new ServerPacket;
|
||||
pack->opcode = ServerOP_LSPlayerZoneChange;
|
||||
pack->size = sizeof(ServerLSPlayerZoneChange_Struct);
|
||||
pack->opcode = ServerOP_LSPlayerZoneChange;
|
||||
pack->size = sizeof(ServerLSPlayerZoneChange_Struct);
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
ServerLSPlayerZoneChange_Struct* zonechange =(ServerLSPlayerZoneChange_Struct*)pack->pBuffer;
|
||||
ServerLSPlayerZoneChange_Struct *zonechange = (ServerLSPlayerZoneChange_Struct *) pack->pBuffer;
|
||||
zonechange->lsaccount_id = LSID();
|
||||
zonechange->from = ztz->current_zone_id;
|
||||
zonechange->to = ztz->requested_zone_id;
|
||||
zonechange->from = ztz->current_zone_id;
|
||||
zonechange->to = ztz->requested_zone_id;
|
||||
loginserverlist.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
}
|
||||
void ClientListEntry::Update(ZoneServer* iZS, ServerClientList_Struct* scl, int8 iOnline) {
|
||||
void ClientListEntry::Update(ZoneServer *iZS, ServerClientList_Struct *scl, int8 iOnline)
|
||||
{
|
||||
if (pzoneserver != iZS) {
|
||||
if (pzoneserver){
|
||||
if (pzoneserver) {
|
||||
pzoneserver->RemovePlayer();
|
||||
LSUpdate(pzoneserver);
|
||||
}
|
||||
if (iZS){
|
||||
if (iZS) {
|
||||
iZS->AddPlayer();
|
||||
LSUpdate(iZS);
|
||||
}
|
||||
}
|
||||
pzoneserver = iZS;
|
||||
pzone = scl->zone;
|
||||
pinstance = scl->instance_id;
|
||||
pcharid = scl->charid;
|
||||
pzoneserver = iZS;
|
||||
pzone = scl->zone;
|
||||
pinstance = scl->instance_id;
|
||||
pcharid = scl->charid;
|
||||
|
||||
strcpy(pname, scl->name);
|
||||
if (paccountid == 0) {
|
||||
paccountid = scl->AccountID;
|
||||
strcpy(paccountname, scl->AccountName);
|
||||
strcpy(plsname, scl->AccountName);
|
||||
pIP = scl->IP;
|
||||
strcpy(loginserver_account_name, scl->AccountName);
|
||||
pIP = scl->IP;
|
||||
pLSID = scl->LSAccountID;
|
||||
strn0cpy(plskey, scl->lskey, sizeof(plskey));
|
||||
}
|
||||
padmin = scl->Admin;
|
||||
plevel = scl->level;
|
||||
pclass_ = scl->class_;
|
||||
prace = scl->race;
|
||||
panon = scl->anon;
|
||||
ptellsoff = scl->tellsoff;
|
||||
pguild_id = scl->guild_id;
|
||||
pLFG = scl->LFG;
|
||||
gm = scl->gm;
|
||||
padmin = scl->Admin;
|
||||
plevel = scl->level;
|
||||
pclass_ = scl->class_;
|
||||
prace = scl->race;
|
||||
panon = scl->anon;
|
||||
ptellsoff = scl->tellsoff;
|
||||
pguild_id = scl->guild_id;
|
||||
pLFG = scl->LFG;
|
||||
gm = scl->gm;
|
||||
pClientVersion = scl->ClientVersion;
|
||||
|
||||
// Fields from the LFG Window
|
||||
if((scl->LFGFromLevel != 0) && (scl->LFGToLevel != 0)) {
|
||||
pLFGFromLevel = scl->LFGFromLevel;
|
||||
pLFGToLevel = scl->LFGToLevel;
|
||||
if ((scl->LFGFromLevel != 0) && (scl->LFGToLevel != 0)) {
|
||||
pLFGFromLevel = scl->LFGFromLevel;
|
||||
pLFGToLevel = scl->LFGToLevel;
|
||||
pLFGMatchFilter = scl->LFGMatchFilter;
|
||||
memcpy(pLFGComments, scl->LFGComments, sizeof(pLFGComments));
|
||||
}
|
||||
@@ -191,26 +214,29 @@ void ClientListEntry::Update(ZoneServer* iZS, ServerClientList_Struct* scl, int8
|
||||
SetOnline(iOnline);
|
||||
}
|
||||
|
||||
void ClientListEntry::LeavingZone(ZoneServer* iZS, int8 iOnline) {
|
||||
if (iZS != 0 && iZS != pzoneserver)
|
||||
void ClientListEntry::LeavingZone(ZoneServer *iZS, int8 iOnline)
|
||||
{
|
||||
if (iZS != 0 && iZS != pzoneserver) {
|
||||
return;
|
||||
}
|
||||
SetOnline(iOnline);
|
||||
|
||||
if (pzoneserver){
|
||||
if (pzoneserver) {
|
||||
pzoneserver->RemovePlayer();
|
||||
LSUpdate(pzoneserver);
|
||||
}
|
||||
pzoneserver = 0;
|
||||
pzone = 0;
|
||||
pzone = 0;
|
||||
}
|
||||
|
||||
void ClientListEntry::ClearVars(bool iAll) {
|
||||
void ClientListEntry::ClearVars(bool iAll)
|
||||
{
|
||||
if (iAll) {
|
||||
pOnline = CLE_Status_Never;
|
||||
stale = 0;
|
||||
stale = 0;
|
||||
|
||||
pLSID = 0;
|
||||
memset(plsname, 0, sizeof(plsname));
|
||||
memset(loginserver_account_name, 0, sizeof(loginserver_account_name));
|
||||
memset(plskey, 0, sizeof(plskey));
|
||||
pworldadmin = 0;
|
||||
|
||||
@@ -219,27 +245,29 @@ void ClientListEntry::ClearVars(bool iAll) {
|
||||
padmin = 0;
|
||||
}
|
||||
pzoneserver = 0;
|
||||
pzone = 0;
|
||||
pcharid = 0;
|
||||
pzone = 0;
|
||||
pcharid = 0;
|
||||
memset(pname, 0, sizeof(pname));
|
||||
plevel = 0;
|
||||
pclass_ = 0;
|
||||
prace = 0;
|
||||
panon = 0;
|
||||
ptellsoff = 0;
|
||||
pguild_id = GUILD_NONE;
|
||||
pLFG = 0;
|
||||
gm = 0;
|
||||
plevel = 0;
|
||||
pclass_ = 0;
|
||||
prace = 0;
|
||||
panon = 0;
|
||||
ptellsoff = 0;
|
||||
pguild_id = GUILD_NONE;
|
||||
pLFG = 0;
|
||||
gm = 0;
|
||||
pClientVersion = 0;
|
||||
for (auto &elem : tell_queue)
|
||||
safe_delete_array(elem);
|
||||
tell_queue.clear();
|
||||
}
|
||||
|
||||
void ClientListEntry::Camp(ZoneServer* iZS) {
|
||||
if (iZS != 0 && iZS != pzoneserver)
|
||||
void ClientListEntry::Camp(ZoneServer *iZS)
|
||||
{
|
||||
if (iZS != 0 && iZS != pzoneserver) {
|
||||
return;
|
||||
if (pzoneserver){
|
||||
}
|
||||
if (pzoneserver) {
|
||||
pzoneserver->RemovePlayer();
|
||||
LSUpdate(pzoneserver);
|
||||
}
|
||||
@@ -249,33 +277,51 @@ void ClientListEntry::Camp(ZoneServer* iZS) {
|
||||
stale = 0;
|
||||
}
|
||||
|
||||
bool ClientListEntry::CheckStale() {
|
||||
bool ClientListEntry::CheckStale()
|
||||
{
|
||||
stale++;
|
||||
if (stale > 20) {
|
||||
if (pOnline > CLE_Status_Offline)
|
||||
if (pOnline > CLE_Status_Offline) {
|
||||
SetOnline(CLE_Status_Offline);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClientListEntry::CheckAuth(uint32 iLSID, const char* iKey) {
|
||||
if (pLSID == iLSID && strncmp(plskey, iKey, 10) == 0) {
|
||||
bool ClientListEntry::CheckAuth(uint32 loginserver_account_id, const char *key_password)
|
||||
{
|
||||
if (pLSID == loginserver_account_id && strncmp(plskey, key_password, 10) == 0) {
|
||||
if (paccountid == 0 && LSID() > 0) {
|
||||
int16 tmpStatus = WorldConfig::get()->DefaultStatus;
|
||||
paccountid = database.CreateAccount(plsname, 0, tmpStatus, pLoginServer, LSID());
|
||||
int16 default_account_status = WorldConfig::get()->DefaultStatus;
|
||||
|
||||
paccountid = database.CreateAccount(
|
||||
loginserver_account_name,
|
||||
0,
|
||||
default_account_status,
|
||||
source_loginserver,
|
||||
LSID()
|
||||
);
|
||||
|
||||
if (!paccountid) {
|
||||
Log(Logs::Detail, Logs::World_Server,"Error adding local account for LS login: '%s:%s', duplicate name?", pLoginServer, plsname);
|
||||
LogInfo(
|
||||
"Error adding local account for LS login: [{0}:{1}], duplicate name",
|
||||
source_loginserver,
|
||||
loginserver_account_name
|
||||
);
|
||||
return false;
|
||||
}
|
||||
strn0cpy(paccountname, plsname, sizeof(paccountname));
|
||||
padmin = tmpStatus;
|
||||
strn0cpy(paccountname, loginserver_account_name, sizeof(paccountname));
|
||||
padmin = default_account_status;
|
||||
}
|
||||
std::string lsworldadmin;
|
||||
if (database.GetVariable("honorlsworldadmin", lsworldadmin))
|
||||
if (atoi(lsworldadmin.c_str()) == 1 && pworldadmin != 0 && (padmin < pworldadmin || padmin == 0))
|
||||
if (database.GetVariable("honorlsworldadmin", lsworldadmin)) {
|
||||
if (atoi(lsworldadmin.c_str()) == 1 && pworldadmin != 0 && (padmin < pworldadmin || padmin == 0)) {
|
||||
padmin = pworldadmin;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -283,13 +329,17 @@ bool ClientListEntry::CheckAuth(uint32 iLSID, const char* iKey) {
|
||||
|
||||
void ClientListEntry::ProcessTellQueue()
|
||||
{
|
||||
if (!Server())
|
||||
if (!Server()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ServerPacket *pack;
|
||||
auto it = tell_queue.begin();
|
||||
auto it = tell_queue.begin();
|
||||
while (it != tell_queue.end()) {
|
||||
pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + strlen((*it)->message) + 1);
|
||||
pack = new ServerPacket(
|
||||
ServerOP_ChannelMessage,
|
||||
sizeof(ServerChannelMessage_Struct) + strlen((*it)->message) + 1
|
||||
);
|
||||
memcpy(pack->pBuffer, *it, pack->size);
|
||||
Server()->SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
|
||||
+5
-5
@@ -28,7 +28,7 @@ public:
|
||||
void Update(ZoneServer* zoneserver, ServerClientList_Struct* scl, int8 iOnline = CLE_Status_InZone);
|
||||
void LSUpdate(ZoneServer* zoneserver);
|
||||
void LSZoneChange(ZoneToZone_Struct* ztz);
|
||||
bool CheckAuth(uint32 iLSID, const char* key);
|
||||
bool CheckAuth(uint32 loginserver_account_id, const char* key_password);
|
||||
void SetOnline(ZoneServer* iZS, int8 iOnline);
|
||||
void SetOnline(int8 iOnline = CLE_Status_Online);
|
||||
void SetChar(uint32 iCharID, const char* iCharName);
|
||||
@@ -42,10 +42,10 @@ public:
|
||||
void Camp(ZoneServer* iZS = 0);
|
||||
|
||||
// Login Server stuff
|
||||
inline const char* LoginServer() const { return pLoginServer; }
|
||||
inline const char* LoginServer() const { return source_loginserver; }
|
||||
inline uint32 LSID() const { return pLSID; }
|
||||
inline uint32 LSAccountID() const { return pLSID; }
|
||||
inline const char* LSName() const { return plsname; }
|
||||
inline const char* LSName() const { return loginserver_account_name; }
|
||||
inline int16 WorldAdmin() const { return pworldadmin; }
|
||||
inline const char* GetLSKey() const { return plskey; }
|
||||
inline const int8 GetOnline() const { return pOnline; }
|
||||
@@ -95,9 +95,9 @@ private:
|
||||
uint8 stale;
|
||||
|
||||
// Login Server stuff
|
||||
char pLoginServer[64]; //Loginserver we came from.
|
||||
char source_loginserver[64]; //Loginserver we came from.
|
||||
uint32 pLSID;
|
||||
char plsname[32];
|
||||
char loginserver_account_name[32];
|
||||
char plskey[16];
|
||||
int16 pworldadmin; // Login server's suggested admin status setting
|
||||
bool plocal;
|
||||
|
||||
@@ -410,15 +410,18 @@ void ClientList::CLEKeepAlive(uint32 numupdates, uint32* wid) {
|
||||
}
|
||||
}
|
||||
|
||||
ClientListEntry* ClientList::CheckAuth(uint32 iLSID, const char* iKey) {
|
||||
LinkedListIterator<ClientListEntry*> iterator(clientlist);
|
||||
ClientListEntry *ClientList::CheckAuth(uint32 iLSID, const char *iKey)
|
||||
{
|
||||
LinkedListIterator<ClientListEntry *> iterator(clientlist);
|
||||
|
||||
iterator.Reset();
|
||||
while(iterator.MoreElements()) {
|
||||
if (iterator.GetData()->CheckAuth(iLSID, iKey))
|
||||
while (iterator.MoreElements()) {
|
||||
if (iterator.GetData()->CheckAuth(iLSID, iKey)) {
|
||||
return iterator.GetData();
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+353
-123
@@ -36,180 +36,236 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "clientlist.h"
|
||||
#include "world_config.h"
|
||||
|
||||
extern ZSList zoneserver_list;
|
||||
extern ClientList client_list;
|
||||
extern uint32 numzones;
|
||||
extern uint32 numplayers;
|
||||
extern volatile bool RunLoops;
|
||||
extern ZSList zoneserver_list;
|
||||
extern ClientList client_list;
|
||||
extern uint32 numzones;
|
||||
extern uint32 numplayers;
|
||||
extern volatile bool RunLoops;
|
||||
|
||||
LoginServer::LoginServer(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool legacy)
|
||||
LoginServer::LoginServer(const char *iAddress, uint16 iPort, const char *Account, const char *Password, bool legacy)
|
||||
{
|
||||
strn0cpy(LoginServerAddress, iAddress, 256);
|
||||
LoginServerPort = iPort;
|
||||
LoginAccount = Account;
|
||||
LoginPassword = Password;
|
||||
LoginServerPort = iPort;
|
||||
LoginAccount = Account;
|
||||
LoginPassword = Password;
|
||||
CanAccountUpdate = false;
|
||||
IsLegacy = legacy;
|
||||
IsLegacy = legacy;
|
||||
Connect();
|
||||
}
|
||||
|
||||
LoginServer::~LoginServer() {
|
||||
LoginServer::~LoginServer()
|
||||
{
|
||||
}
|
||||
|
||||
void LoginServer::ProcessUsertoWorldReqLeg(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
void LoginServer::ProcessUsertoWorldReqLeg(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
UsertoWorldRequestLegacy_Struct* utwr = (UsertoWorldRequestLegacy_Struct*)p.Data();
|
||||
uint32 id = database.GetAccountIDFromLSID("eqemu", utwr->lsaccountid);
|
||||
int16 status = database.CheckStatus(id);
|
||||
UsertoWorldRequestLegacy_Struct *utwr = (UsertoWorldRequestLegacy_Struct *) p.Data();
|
||||
uint32 id = database.GetAccountIDFromLSID("eqemu", utwr->lsaccountid);
|
||||
int16 status = database.CheckStatus(id);
|
||||
|
||||
auto outpack = new ServerPacket;
|
||||
outpack->opcode = ServerOP_UsertoWorldRespLeg;
|
||||
outpack->size = sizeof(UsertoWorldResponseLegacy_Struct);
|
||||
outpack->opcode = ServerOP_UsertoWorldRespLeg;
|
||||
outpack->size = sizeof(UsertoWorldResponseLegacy_Struct);
|
||||
outpack->pBuffer = new uchar[outpack->size];
|
||||
memset(outpack->pBuffer, 0, outpack->size);
|
||||
UsertoWorldResponseLegacy_Struct* utwrs = (UsertoWorldResponseLegacy_Struct*)outpack->pBuffer;
|
||||
UsertoWorldResponseLegacy_Struct *utwrs = (UsertoWorldResponseLegacy_Struct *) outpack->pBuffer;
|
||||
utwrs->lsaccountid = utwr->lsaccountid;
|
||||
utwrs->ToID = utwr->FromID;
|
||||
utwrs->ToID = utwr->FromID;
|
||||
|
||||
if (Config->Locked == true)
|
||||
{
|
||||
if ((status == 0 || status < 100) && (status != -2 || status != -1))
|
||||
if (Config->Locked == true) {
|
||||
if ((status == 0 || status < 100) && (status != -2 || status != -1)) {
|
||||
utwrs->response = 0;
|
||||
if (status >= 100)
|
||||
}
|
||||
if (status >= 100) {
|
||||
utwrs->response = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
utwrs->response = 1;
|
||||
}
|
||||
|
||||
int32 x = Config->MaxClients;
|
||||
if ((int32)numplayers >= x && x != -1 && x != 255 && status < 80)
|
||||
if ((int32) numplayers >= x && x != -1 && x != 255 && status < 80) {
|
||||
utwrs->response = -3;
|
||||
}
|
||||
|
||||
if (status == -1)
|
||||
if (status == -1) {
|
||||
utwrs->response = -1;
|
||||
if (status == -2)
|
||||
}
|
||||
if (status == -2) {
|
||||
utwrs->response = -2;
|
||||
}
|
||||
|
||||
utwrs->worldid = utwr->worldid;
|
||||
SendPacket(outpack);
|
||||
delete outpack;
|
||||
}
|
||||
|
||||
void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
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->login, utwr->lsaccountid);
|
||||
int16 status = database.CheckStatus(id);
|
||||
UsertoWorldRequest_Struct *utwr = (UsertoWorldRequest_Struct *) p.Data();
|
||||
uint32 id = database.GetAccountIDFromLSID(utwr->login, utwr->lsaccountid);
|
||||
int16 status = database.CheckStatus(id);
|
||||
|
||||
auto outpack = new ServerPacket;
|
||||
outpack->opcode = ServerOP_UsertoWorldResp;
|
||||
outpack->size = sizeof(UsertoWorldResponse_Struct);
|
||||
outpack->opcode = ServerOP_UsertoWorldResp;
|
||||
outpack->size = sizeof(UsertoWorldResponse_Struct);
|
||||
outpack->pBuffer = new uchar[outpack->size];
|
||||
memset(outpack->pBuffer, 0, outpack->size);
|
||||
UsertoWorldResponse_Struct* utwrs = (UsertoWorldResponse_Struct*)outpack->pBuffer;
|
||||
UsertoWorldResponse_Struct *utwrs = (UsertoWorldResponse_Struct *) outpack->pBuffer;
|
||||
utwrs->lsaccountid = utwr->lsaccountid;
|
||||
utwrs->ToID = utwr->FromID;
|
||||
utwrs->ToID = utwr->FromID;
|
||||
strn0cpy(utwrs->login, utwr->login, 64);
|
||||
|
||||
if (Config->Locked == true)
|
||||
{
|
||||
if ((status == 0 || status < 100) && (status != -2 || status != -1))
|
||||
if (Config->Locked == true) {
|
||||
if ((status == 0 || status < 100) && (status != -2 || status != -1)) {
|
||||
utwrs->response = 0;
|
||||
if (status >= 100)
|
||||
}
|
||||
if (status >= 100) {
|
||||
utwrs->response = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
utwrs->response = 1;
|
||||
}
|
||||
|
||||
int32 x = Config->MaxClients;
|
||||
if ((int32)numplayers >= x && x != -1 && x != 255 && status < 80)
|
||||
if ((int32) numplayers >= x && x != -1 && x != 255 && status < 80) {
|
||||
utwrs->response = -3;
|
||||
}
|
||||
|
||||
if (status == -1)
|
||||
if (status == -1) {
|
||||
utwrs->response = -1;
|
||||
if (status == -2)
|
||||
}
|
||||
if (status == -2) {
|
||||
utwrs->response = -2;
|
||||
}
|
||||
|
||||
utwrs->worldid = utwr->worldid;
|
||||
SendPacket(outpack);
|
||||
delete outpack;
|
||||
}
|
||||
|
||||
void LoginServer::ProcessLSClientAuthLeg(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
void LoginServer::ProcessLSClientAuthLegacy(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Received ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
try {
|
||||
auto slsca = p.GetSerialize<ClientAuthLegacy_Struct>(0);
|
||||
auto client_authentication_request = p.GetSerialize<ClientAuthLegacy_Struct>(0);
|
||||
|
||||
if (RuleI(World, AccountSessionLimit) >= 0) {
|
||||
// Enforce the limit on the number of characters on the same account that can be
|
||||
// online at the same time.
|
||||
client_list.EnforceSessionLimit(slsca.lsaccount_id);
|
||||
client_list.EnforceSessionLimit(client_authentication_request.loginserver_account_id);
|
||||
}
|
||||
|
||||
client_list.CLEAdd(slsca.lsaccount_id, "eqemu", slsca.name, slsca.key, slsca.worldadmin, slsca.ip, slsca.local);
|
||||
LogDebug(
|
||||
"Processing Loginserver Auth Legacy | account_id [{0}] account_name [{1}] key [{2}] admin [{3}] ip [{4}] "
|
||||
"local_network [{5}]",
|
||||
client_authentication_request.loginserver_account_id,
|
||||
client_authentication_request.loginserver_account_name,
|
||||
client_authentication_request.key,
|
||||
client_authentication_request.is_world_admin,
|
||||
client_authentication_request.ip,
|
||||
client_authentication_request.is_client_from_local_network
|
||||
);
|
||||
|
||||
client_list.CLEAdd(
|
||||
client_authentication_request.loginserver_account_id,
|
||||
"eqemu",
|
||||
client_authentication_request.loginserver_account_name,
|
||||
client_authentication_request.key,
|
||||
client_authentication_request.is_world_admin,
|
||||
client_authentication_request.ip,
|
||||
client_authentication_request.is_client_from_local_network
|
||||
);
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
LogF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what());
|
||||
LogError("Error parsing ClientAuthLegacy packet from world\nReason [{0}]", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
Log(Logs::Detail, Logs::World_Server, "Received ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
try {
|
||||
auto slsca = p.GetSerialize<ClientAuth_Struct>(0);
|
||||
auto client_authentication_request = p.GetSerialize<ClientAuth_Struct>(0);
|
||||
|
||||
if (RuleI(World, AccountSessionLimit) >= 0) {
|
||||
// Enforce the limit on the number of characters on the same account that can be
|
||||
// online at the same time.
|
||||
client_list.EnforceSessionLimit(slsca.lsaccount_id);
|
||||
client_list.EnforceSessionLimit(client_authentication_request.loginserver_account_id);
|
||||
}
|
||||
|
||||
client_list.CLEAdd(slsca.lsaccount_id, slsca.lsname, slsca.name, slsca.key, slsca.worldadmin, slsca.ip, slsca.local);
|
||||
LogDebug(
|
||||
"Processing Loginserver Auth | account_id [{0}] account_name [{1}] loginserver_name [{2}] key [{3}] "
|
||||
"admin [{4}] ip [{5}] local_network [{6}]",
|
||||
client_authentication_request.loginserver_account_id,
|
||||
client_authentication_request.account_name,
|
||||
client_authentication_request.loginserver_name,
|
||||
client_authentication_request.key,
|
||||
client_authentication_request.is_world_admin,
|
||||
client_authentication_request.ip,
|
||||
client_authentication_request.is_client_from_local_network
|
||||
);
|
||||
|
||||
client_list.CLEAdd(
|
||||
client_authentication_request.loginserver_account_id,
|
||||
client_authentication_request.loginserver_name,
|
||||
client_authentication_request.account_name,
|
||||
client_authentication_request.key,
|
||||
client_authentication_request.is_world_admin,
|
||||
client_authentication_request.ip,
|
||||
client_authentication_request.is_client_from_local_network
|
||||
);
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
LogF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what());
|
||||
LogError("Error parsing ClientAuth packet from world\nReason [{0}]", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServer::ProcessLSFatalError(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
void LoginServer::ProcessLSFatalError(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
Log(Logs::Detail, Logs::World_Server, "Login server responded with FatalError.");
|
||||
if (p.Length() > 1) {
|
||||
Log(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) {
|
||||
void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
ServerSystemwideMessage* swm = (ServerSystemwideMessage*)p.Data();
|
||||
ServerSystemwideMessage *swm = (ServerSystemwideMessage *) p.Data();
|
||||
zoneserver_list.SendEmoteMessageRaw(0, 0, 0, swm->type, swm->message);
|
||||
}
|
||||
|
||||
void LoginServer::ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
void LoginServer::ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
if (!Config->WorldAddress.length()) {
|
||||
WorldConfig::SetWorldAddress((char *)p.Data());
|
||||
Log(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data());
|
||||
WorldConfig::SetWorldAddress((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) {
|
||||
void LoginServer::ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p)
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode);
|
||||
|
||||
@@ -217,7 +273,8 @@ void LoginServer::ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p) {
|
||||
CanAccountUpdate = true;
|
||||
}
|
||||
|
||||
bool LoginServer::Connect() {
|
||||
bool LoginServer::Connect()
|
||||
{
|
||||
char errbuf[1024];
|
||||
if ((LoginServerIP = ResolveIP(LoginServerAddress, errbuf)) == 0) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.", LoginServerAddress);
|
||||
@@ -225,88 +282,252 @@ bool LoginServer::Connect() {
|
||||
}
|
||||
|
||||
if (LoginServerIP == 0 || LoginServerPort == 0) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
LogInfo(
|
||||
"Connect info incomplete, cannot connect: [{0}:{1}]",
|
||||
LoginServerAddress,
|
||||
LoginServerPort
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsLegacy) {
|
||||
legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false));
|
||||
legacy_client->OnConnect([this](EQ::Net::ServertalkLegacyClient *client) {
|
||||
if (client) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
SendInfo();
|
||||
SendStatus();
|
||||
zoneserver_list.SendLSZones();
|
||||
legacy_client->OnConnect(
|
||||
[this](EQ::Net::ServertalkLegacyClient *client) {
|
||||
if (client) {
|
||||
LogInfo(
|
||||
"Connected to Legacy Loginserver: [{0}:{1}]",
|
||||
LoginServerAddress,
|
||||
LoginServerPort
|
||||
);
|
||||
|
||||
statusupdate_timer.reset(new EQ::Timer(LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
SendInfo();
|
||||
SendStatus();
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
legacy_client->OnMessage(ServerOP_UsertoWorldReqLeg, std::bind(&LoginServer::ProcessUsertoWorldReqLeg, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_UsertoWorldReq, std::bind(&LoginServer::ProcessUsertoWorldReq, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSClientAuthLeg, std::bind(&LoginServer::ProcessLSClientAuthLeg, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSClientAuth, std::bind(&LoginServer::ProcessLSClientAuth, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSFatalError, std::bind(&LoginServer::ProcessLSFatalError, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_SystemwideMessage, std::bind(&LoginServer::ProcessSystemwideMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSRemoteAddr, std::bind(&LoginServer::ProcessLSRemoteAddr, this, std::placeholders::_1, std::placeholders::_2));
|
||||
legacy_client->OnMessage(ServerOP_LSAccountUpdate, std::bind(&LoginServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2));
|
||||
statusupdate_timer.reset(
|
||||
new EQ::Timer(
|
||||
LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
SendStatus();
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
LogInfo(
|
||||
"Could not connect to Legacy Loginserver: [{0}:{1}]",
|
||||
LoginServerAddress,
|
||||
LoginServerPort
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_UsertoWorldReqLeg,
|
||||
std::bind(
|
||||
&LoginServer::ProcessUsertoWorldReqLeg,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_UsertoWorldReq,
|
||||
std::bind(
|
||||
&LoginServer::ProcessUsertoWorldReq,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_LSClientAuthLeg,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSClientAuthLegacy,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_LSClientAuth,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSClientAuth,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_LSFatalError,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSFatalError,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_SystemwideMessage,
|
||||
std::bind(
|
||||
&LoginServer::ProcessSystemwideMessage,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_LSRemoteAddr,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSRemoteAddr,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
legacy_client->OnMessage(
|
||||
ServerOP_LSAccountUpdate,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSAccountUpdate,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", ""));
|
||||
client->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
||||
if (client) {
|
||||
Log(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
SendInfo();
|
||||
SendStatus();
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
statusupdate_timer.reset(new EQ::Timer(LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
client->OnConnect(
|
||||
[this](EQ::Net::ServertalkClient *client) {
|
||||
if (client) {
|
||||
LogInfo(
|
||||
"Connected to Loginserver: {0}:{1}",
|
||||
LoginServerAddress,
|
||||
LoginServerPort
|
||||
);
|
||||
SendInfo();
|
||||
SendStatus();
|
||||
}));
|
||||
}
|
||||
else {
|
||||
Log(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort);
|
||||
}
|
||||
});
|
||||
zoneserver_list.SendLSZones();
|
||||
|
||||
client->OnMessage(ServerOP_UsertoWorldReqLeg, std::bind(&LoginServer::ProcessUsertoWorldReqLeg, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_UsertoWorldReq, std::bind(&LoginServer::ProcessUsertoWorldReq, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSClientAuthLeg, std::bind(&LoginServer::ProcessLSClientAuthLeg, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSClientAuth, std::bind(&LoginServer::ProcessLSClientAuth, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSFatalError, std::bind(&LoginServer::ProcessLSFatalError, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_SystemwideMessage, std::bind(&LoginServer::ProcessSystemwideMessage, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSRemoteAddr, std::bind(&LoginServer::ProcessLSRemoteAddr, this, std::placeholders::_1, std::placeholders::_2));
|
||||
client->OnMessage(ServerOP_LSAccountUpdate, std::bind(&LoginServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2));
|
||||
statusupdate_timer.reset(
|
||||
new EQ::Timer(
|
||||
LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) {
|
||||
SendStatus();
|
||||
}
|
||||
));
|
||||
}
|
||||
else {
|
||||
LogInfo(
|
||||
"Could not connect to Loginserver: {0}:{1}",
|
||||
LoginServerAddress,
|
||||
LoginServerPort
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
client->OnMessage(
|
||||
ServerOP_UsertoWorldReqLeg,
|
||||
std::bind(
|
||||
&LoginServer::ProcessUsertoWorldReqLeg,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_UsertoWorldReq,
|
||||
std::bind(
|
||||
&LoginServer::ProcessUsertoWorldReq,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_LSClientAuthLeg,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSClientAuthLegacy,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_LSClientAuth,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSClientAuth,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_LSFatalError,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSFatalError,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_SystemwideMessage,
|
||||
std::bind(
|
||||
&LoginServer::ProcessSystemwideMessage,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_LSRemoteAddr,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSRemoteAddr,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
client->OnMessage(
|
||||
ServerOP_LSAccountUpdate,
|
||||
std::bind(
|
||||
&LoginServer::ProcessLSAccountUpdate,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoginServer::SendInfo() {
|
||||
void LoginServer::SendInfo()
|
||||
{
|
||||
const WorldConfig *Config = WorldConfig::get();
|
||||
|
||||
auto pack = new ServerPacket;
|
||||
pack->opcode = ServerOP_NewLSInfo;
|
||||
pack->size = sizeof(ServerNewLSInfo_Struct);
|
||||
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());
|
||||
strcpy(lsi->shortname, Config->ShortName.c_str());
|
||||
strn0cpy(lsi->account, LoginAccount.c_str(), 30);
|
||||
strn0cpy(lsi->password, LoginPassword.c_str(), 30);
|
||||
if (Config->WorldAddress.length())
|
||||
if (Config->WorldAddress.length()) {
|
||||
strcpy(lsi->remote_address, Config->WorldAddress.c_str());
|
||||
if (Config->LocalAddress.length())
|
||||
}
|
||||
if (Config->LocalAddress.length()) {
|
||||
strcpy(lsi->local_address, Config->LocalAddress.c_str());
|
||||
}
|
||||
else {
|
||||
auto local_addr = IsLegacy ? legacy_client->Handle()->LocalIP() : client->Handle()->LocalIP();
|
||||
strcpy(lsi->local_address, local_addr.c_str());
|
||||
@@ -316,22 +537,26 @@ void LoginServer::SendInfo() {
|
||||
delete pack;
|
||||
}
|
||||
|
||||
void LoginServer::SendStatus() {
|
||||
void LoginServer::SendStatus()
|
||||
{
|
||||
auto pack = new ServerPacket;
|
||||
pack->opcode = ServerOP_LSStatus;
|
||||
pack->size = sizeof(ServerLSStatus_Struct);
|
||||
pack->opcode = ServerOP_LSStatus;
|
||||
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)
|
||||
if (WorldConfig::get()->Locked) {
|
||||
lss->status = -2;
|
||||
else if (numzones <= 0)
|
||||
}
|
||||
else if (numzones <= 0) {
|
||||
lss->status = -2;
|
||||
else
|
||||
}
|
||||
else {
|
||||
lss->status = numplayers;
|
||||
}
|
||||
|
||||
lss->num_zones = numzones;
|
||||
lss->num_zones = numzones;
|
||||
lss->num_players = numplayers;
|
||||
SendPacket(pack);
|
||||
delete pack;
|
||||
@@ -351,10 +576,15 @@ void LoginServer::SendPacket(ServerPacket *pack)
|
||||
}
|
||||
}
|
||||
|
||||
void LoginServer::SendAccountUpdate(ServerPacket* pack) {
|
||||
ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *)pack->pBuffer;
|
||||
void LoginServer::SendAccountUpdate(ServerPacket *pack)
|
||||
{
|
||||
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);
|
||||
Log(Logs::Detail,
|
||||
Logs::World_Server,
|
||||
"Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d",
|
||||
LoginServerAddress,
|
||||
LoginServerPort);
|
||||
strn0cpy(s->worldaccount, LoginAccount.c_str(), 30);
|
||||
strn0cpy(s->worldpassword, LoginPassword.c_str(), 30);
|
||||
SendPacket(pack);
|
||||
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
void ProcessUsertoWorldReqLeg(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessLSClientAuthLeg(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessLSClientAuthLegacy(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessLSFatalError(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p);
|
||||
void ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p);
|
||||
|
||||
Reference in New Issue
Block a user