mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-02 12:22:27 +00:00
- 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)
213 lines
4.6 KiB
C++
213 lines
4.6 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/>.
|
|
*/
|
|
#pragma once
|
|
|
|
#include "common/json/json.h"
|
|
#include "common/linked_list.h"
|
|
#include "common/path_manager.h"
|
|
|
|
#include "fmt/format.h"
|
|
#include <fstream>
|
|
|
|
struct LoginConfig {
|
|
std::string LoginHost;
|
|
std::string LoginAccount;
|
|
std::string LoginPassword;
|
|
uint16 LoginPort;
|
|
bool LoginLegacy;
|
|
};
|
|
|
|
class EQEmuConfig
|
|
{
|
|
public:
|
|
virtual std::string GetByName(const std::string &var_name) const;
|
|
|
|
// From <world/>
|
|
std::string ShortName;
|
|
std::string LongName;
|
|
std::string WorldAddress;
|
|
std::string LocalAddress;
|
|
std::string LoginHost;
|
|
std::string LoginAccount;
|
|
std::string LoginPassword;
|
|
uint16 LoginPort;
|
|
bool LoginLegacy;
|
|
uint32 LoginCount;
|
|
LinkedList<LoginConfig*> loginlist;
|
|
bool Locked;
|
|
uint16 WorldTCPPort;
|
|
std::string WorldIP;
|
|
uint16 TelnetTCPPort;
|
|
std::string TelnetIP;
|
|
bool TelnetEnabled;
|
|
int32 MaxClients;
|
|
bool WorldHTTPEnabled;
|
|
uint16 WorldHTTPPort;
|
|
std::string WorldHTTPMimeFile;
|
|
std::string SharedKey;
|
|
bool DisableConfigChecks;
|
|
|
|
// From <database/>
|
|
std::string DatabaseHost;
|
|
std::string DatabaseUsername;
|
|
std::string DatabasePassword;
|
|
std::string DatabaseDB;
|
|
uint16 DatabasePort;
|
|
|
|
// From <content_database/>
|
|
std::string ContentDbHost;
|
|
std::string ContentDbUsername;
|
|
std::string ContentDbPassword;
|
|
std::string ContentDbName;
|
|
uint16 ContentDbPort;
|
|
|
|
// From <qsdatabase> // QueryServ
|
|
std::string QSDatabaseHost;
|
|
std::string QSDatabaseUsername;
|
|
std::string QSDatabasePassword;
|
|
std::string QSDatabaseDB;
|
|
uint16 QSDatabasePort;
|
|
std::string QSHost;
|
|
int QSPort;
|
|
|
|
// From <files/>
|
|
std::string SpellsFile;
|
|
std::string OpCodesFile;
|
|
std::string MailOpCodesFile;
|
|
std::string PluginPlFile;
|
|
|
|
// From <directories/>
|
|
std::string MapDir;
|
|
std::string QuestDir;
|
|
std::string PluginDir;
|
|
std::string LuaModuleDir;
|
|
std::string PatchDir;
|
|
std::string OpcodeDir;
|
|
std::string SharedMemDir;
|
|
std::string LogDir;
|
|
|
|
// From <launcher/>
|
|
std::string LogPrefix;
|
|
std::string LogSuffix;
|
|
std::string ZoneExe;
|
|
uint32 RestartWait;
|
|
uint32 TerminateWait;
|
|
uint32 InitialBootWait;
|
|
uint32 ZoneBootInterval;
|
|
|
|
// From <zones/>
|
|
uint16 ZonePortLow;
|
|
uint16 ZonePortHigh;
|
|
uint8 DefaultStatus;
|
|
|
|
bool auto_database_updates;
|
|
|
|
const std::string &GetUCSHost() const;
|
|
uint16 GetUCSPort() const;
|
|
|
|
std::vector<std::string> GetQuestDirectories() const
|
|
{
|
|
return m_quest_directories;
|
|
}
|
|
|
|
std::vector<std::string> GetPluginsDirectories() const
|
|
{
|
|
return m_plugin_directories;
|
|
}
|
|
|
|
std::vector<std::string> GetLuaModuleDirectories() const
|
|
{
|
|
return m_lua_module_directories;
|
|
}
|
|
|
|
|
|
// uint16 DynamicCount;
|
|
|
|
// map<string,uint16> StaticZones;
|
|
|
|
protected:
|
|
|
|
std::string m_ucs_host;
|
|
uint16 m_ucs_port;
|
|
|
|
static EQEmuConfig *_config;
|
|
Json::Value _root;
|
|
static std::string ConfigFile;
|
|
|
|
std::vector<std::string> m_quest_directories = {};
|
|
std::vector<std::string> m_plugin_directories = {};
|
|
std::vector<std::string> m_lua_module_directories = {};
|
|
|
|
protected:
|
|
void parse_config();
|
|
|
|
EQEmuConfig()
|
|
{
|
|
|
|
}
|
|
|
|
public:
|
|
virtual ~EQEmuConfig() {}
|
|
|
|
// Produce a const singleton
|
|
static const EQEmuConfig *get()
|
|
{
|
|
LoadConfig();
|
|
return (_config);
|
|
}
|
|
|
|
// Load the config
|
|
static bool LoadConfig(const std::string& path = "")
|
|
{
|
|
if (_config != nullptr) {
|
|
return true;
|
|
}
|
|
_config = new EQEmuConfig;
|
|
|
|
return parseFile(path);
|
|
}
|
|
|
|
// Load config file and parse data
|
|
static bool parseFile(const std::string& file_path = ".")
|
|
{
|
|
if (_config == nullptr) {
|
|
return LoadConfig(file_path);
|
|
}
|
|
|
|
std::string file = fmt::format(
|
|
"{}/{}",
|
|
(file_path.empty() ? PathManager::Instance()->GetServerPath() : file_path),
|
|
EQEmuConfig::ConfigFile
|
|
);
|
|
|
|
std::ifstream fconfig(file, std::ifstream::binary);
|
|
|
|
try {
|
|
fconfig >> _config->_root;
|
|
_config->parse_config();
|
|
}
|
|
catch (std::exception &) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void Dump() const;
|
|
void CheckUcsConfigConversion();
|
|
};
|