eqemu-server/world/launcher_list.cpp
Knightly 7ab909ee47 Standardize Licensing
- License was intended to be GPLv3 per earlier commit of GPLv3 LICENSE FILE
- This is confirmed by the inclusion of libraries that are incompatible with GPLv2
- This is also confirmed by KLS and the agreement of KLS's predecessors
- Added GPLv3 license headers to the compilable source files
- Removed Folly licensing in strings.h since the string functions do not match the Folly functions and are standard functions - this must have been left over from previous implementations
- Removed individual contributor license headers since the project has been under the "developer" mantle for many years
- Removed comments on files that were previously automatically generated since they've been manually modified multiple times and there are no automatic scripts referencing them (removed in 2023)
2026-04-01 17:09:57 -07:00

154 lines
4.0 KiB
C++

/* EQEmu: EQEmulator
Copyright (C) 2001-2026 EQEmu Development Team
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; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; 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, see <http://www.gnu.org/licenses/>.
*/
#include "launcher_list.h"
#include "world/eql_config.h"
#include "world/launcher_link.h"
LauncherList::LauncherList()
: nextID(1)
{
}
LauncherList::~LauncherList() {
std::vector<LauncherLink *>::iterator cur, end;
cur = m_pendingLaunchers.begin();
end = m_pendingLaunchers.end();
for (; cur != end; ++cur) {
delete *cur;
}
std::map<std::string, EQLConfig *>::iterator curc, endc;
curc = m_configs.begin();
endc = m_configs.end();
for (; curc != endc; ++curc) {
delete curc->second;
}
std::map<std::string, LauncherLink *>::iterator curl, endl;
curl = m_launchers.begin();
endl = m_launchers.end();
for (; curl != endl; ++curl) {
delete curl->second;
}
}
void LauncherList::Process() {
std::vector<LauncherLink *>::iterator cur;
cur = m_pendingLaunchers.begin();
while (cur != m_pendingLaunchers.end()) {
LauncherLink *l = *cur;
if (l->HasName()) {
//launcher has identified itself now.
//remove ourself from the pending list
cur = m_pendingLaunchers.erase(cur);
std::string name = l->GetName();
//kill off anybody else using our name.
std::map<std::string, LauncherLink *>::iterator res;
res = m_launchers.find(name);
if (res != m_launchers.end()) {
LogInfo("Ghosting launcher [{}]", name.c_str());
delete res->second;
}
LogInfo("Removing pending launcher [{}]. Adding [{}] to active list", l->GetID(), name.c_str());
//put the launcher in the list.
m_launchers[name] = l;
}
else {
++cur;
}
}
}
LauncherLink *LauncherList::Get(const char *name) {
std::map<std::string, LauncherLink *>::iterator res;
res = m_launchers.find(name);
if (res == m_launchers.end())
return(nullptr);
return(res->second);
}
void LauncherList::Add(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn) {
auto it = new LauncherLink(nextID++, conn);
LogInfo("Adding pending launcher [{}]", it->GetID());
m_pendingLaunchers.push_back(it);
}
void LauncherList::Remove(std::shared_ptr<EQ::Net::ServertalkServerConnection> conn)
{
auto pendingLauncherIter = m_pendingLaunchers.begin();
while (pendingLauncherIter != m_pendingLaunchers.end()) {
if ((*pendingLauncherIter)->GetUUID() == conn->GetUUID()) {
m_pendingLaunchers.erase(pendingLauncherIter);
break;
}
++pendingLauncherIter;
}
auto launcherIter = m_launchers.begin();
while (launcherIter != m_launchers.end()) {
if (launcherIter->second->GetUUID() == conn->GetUUID()) {
m_launchers.erase(launcherIter);
break;
}
++launcherIter;
}
}
int LauncherList::GetLauncherCount() {
return(m_launchers.size());
}
void LauncherList::LoadList() {
std::vector<std::string> launchers;
database.GetLauncherList(launchers);
std::vector<std::string>::iterator cur, end;
cur = launchers.begin();
end = launchers.end();
for (; cur != end; ++cur) {
m_configs[*cur] = new EQLConfig(cur->c_str());
}
}
EQLConfig *LauncherList::GetConfig(const char *name) {
std::map<std::string, EQLConfig *>::iterator res;
res = m_configs.find(name);
if (res == m_configs.end()) {
return(nullptr);
}
return(res->second);
}
void LauncherList::Remove(const char *name) {
std::map<std::string, EQLConfig *>::iterator resc;
resc = m_configs.find(name);
if (resc != m_configs.end()) {
delete resc->second;
m_configs.erase(resc);
}
std::map<std::string, LauncherLink *>::iterator resl;
resl = m_launchers.find(name);
if (resl != m_launchers.end()) {
resl->second->Disconnect();
}
}