mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Shared memory formatting main.cpp [skip ci]
This commit is contained in:
parent
286c08b8d5
commit
49d835165c
@ -39,8 +39,11 @@ EQEmuLogSys LogSys;
|
|||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
inline bool MakeDirectory(const std::string &directory_name)
|
inline bool MakeDirectory(const std::string &directory_name)
|
||||||
@ -54,7 +57,7 @@ inline bool MakeDirectory(const std::string &directory_name)
|
|||||||
_mkdir(directory_name.c_str());
|
_mkdir(directory_name.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(directory_name.c_str(), &st) == 0) {
|
if (stat(directory_name.c_str(), &st) == 0) {
|
||||||
@ -69,13 +72,14 @@ inline bool MakeDirectory(const std::string &directory_name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
RegisterExecutablePlatform(ExePlatformSharedMemory);
|
RegisterExecutablePlatform(ExePlatformSharedMemory);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
LogInfo("Shared Memory Loader Program");
|
LogInfo("Shared Memory Loader Program");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if (!EQEmuConfig::LoadConfig()) {
|
||||||
LogError("Unable to load configuration file");
|
LogError("Unable to load configuration file");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -85,8 +89,11 @@ int main(int argc, char **argv) {
|
|||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
LogInfo("Connecting to database");
|
LogInfo("Connecting to database");
|
||||||
if (!database.Connect(
|
if (!database.Connect(
|
||||||
Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
Config->DatabaseHost.c_str(),
|
||||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort
|
Config->DatabaseUsername.c_str(),
|
||||||
|
Config->DatabasePassword.c_str(),
|
||||||
|
Config->DatabaseDB.c_str(),
|
||||||
|
Config->DatabasePort
|
||||||
)) {
|
)) {
|
||||||
LogError("Unable to connect to the database, cannot continue without a database connection");
|
LogError("Unable to connect to the database, cannot continue without a database connection");
|
||||||
return 1;
|
return 1;
|
||||||
@ -114,133 +121,136 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string hotfix_name = "";
|
std::string hotfix_name = "";
|
||||||
bool load_all = true;
|
|
||||||
bool load_items = false;
|
bool load_all = true;
|
||||||
bool load_factions = false;
|
bool load_items = false;
|
||||||
bool load_loot = false;
|
bool load_factions = false;
|
||||||
|
bool load_loot = false;
|
||||||
bool load_skill_caps = false;
|
bool load_skill_caps = false;
|
||||||
bool load_spells = false;
|
bool load_spells = false;
|
||||||
bool load_bd = false;
|
bool load_bd = false;
|
||||||
if(argc > 1) {
|
|
||||||
for(int i = 1; i < argc; ++i) {
|
if (argc > 1) {
|
||||||
switch(argv[i][0]) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
case 'b':
|
switch (argv[i][0]) {
|
||||||
if(strcasecmp("base_data", argv[i]) == 0) {
|
case 'b':
|
||||||
load_bd = true;
|
if (strcasecmp("base_data", argv[i]) == 0) {
|
||||||
load_all = false;
|
load_bd = true;
|
||||||
}
|
load_all = false;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
if(strcasecmp("items", argv[i]) == 0) {
|
|
||||||
load_items = true;
|
|
||||||
load_all = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
if(strcasecmp("factions", argv[i]) == 0) {
|
|
||||||
load_factions = true;
|
|
||||||
load_all = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
if(strcasecmp("loot", argv[i]) == 0) {
|
|
||||||
load_loot = true;
|
|
||||||
load_all = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
if(strcasecmp("skill_caps", argv[i]) == 0) {
|
|
||||||
load_skill_caps = true;
|
|
||||||
load_all = false;
|
|
||||||
} else if(strcasecmp("spells", argv[i]) == 0) {
|
|
||||||
load_spells = true;
|
|
||||||
load_all = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '-': {
|
|
||||||
auto split = SplitString(argv[i], '=');
|
|
||||||
if(split.size() >= 2) {
|
|
||||||
auto command = split[0];
|
|
||||||
auto argument = split[1];
|
|
||||||
if(strcasecmp("-hotfix", command.c_str()) == 0) {
|
|
||||||
hotfix_name = argument;
|
|
||||||
load_all = true;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
if (strcasecmp("items", argv[i]) == 0) {
|
||||||
|
load_items = true;
|
||||||
|
load_all = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
if (strcasecmp("factions", argv[i]) == 0) {
|
||||||
|
load_factions = true;
|
||||||
|
load_all = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
if (strcasecmp("loot", argv[i]) == 0) {
|
||||||
|
load_loot = true;
|
||||||
|
load_all = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
if (strcasecmp("skill_caps", argv[i]) == 0) {
|
||||||
|
load_skill_caps = true;
|
||||||
|
load_all = false;
|
||||||
|
}
|
||||||
|
else if (strcasecmp("spells", argv[i]) == 0) {
|
||||||
|
load_spells = true;
|
||||||
|
load_all = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '-': {
|
||||||
|
auto split = SplitString(argv[i], '=');
|
||||||
|
if (split.size() >= 2) {
|
||||||
|
auto command = split[0];
|
||||||
|
auto argument = split[1];
|
||||||
|
if (strcasecmp("-hotfix", command.c_str()) == 0) {
|
||||||
|
hotfix_name = argument;
|
||||||
|
load_all = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hotfix_name.length() > 0) {
|
if (hotfix_name.length() > 0) {
|
||||||
LogInfo("Writing data for hotfix [{}]", hotfix_name.c_str());
|
LogInfo("Writing data for hotfix [{}]", hotfix_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_all || load_items) {
|
if (load_all || load_items) {
|
||||||
LogInfo("Loading items");
|
LogInfo("Loading items");
|
||||||
try {
|
try {
|
||||||
LoadItems(&database, hotfix_name);
|
LoadItems(&database, hotfix_name);
|
||||||
} catch(std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
LogError("{}", ex.what());
|
LogError("{}", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_all || load_factions) {
|
if (load_all || load_factions) {
|
||||||
LogInfo("Loading factions");
|
LogInfo("Loading factions");
|
||||||
try {
|
try {
|
||||||
LoadFactions(&database, hotfix_name);
|
LoadFactions(&database, hotfix_name);
|
||||||
} catch(std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
LogError("{}", ex.what());
|
LogError("{}", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_all || load_loot) {
|
if (load_all || load_loot) {
|
||||||
LogInfo("Loading loot");
|
LogInfo("Loading loot");
|
||||||
try {
|
try {
|
||||||
LoadLoot(&database, hotfix_name);
|
LoadLoot(&database, hotfix_name);
|
||||||
} catch(std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
LogError("{}", ex.what());
|
LogError("{}", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_all || load_skill_caps) {
|
if (load_all || load_skill_caps) {
|
||||||
LogInfo("Loading skill caps");
|
LogInfo("Loading skill caps");
|
||||||
try {
|
try {
|
||||||
LoadSkillCaps(&database, hotfix_name);
|
LoadSkillCaps(&database, hotfix_name);
|
||||||
} catch(std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
LogError("{}", ex.what());
|
LogError("{}", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_all || load_spells) {
|
if (load_all || load_spells) {
|
||||||
LogInfo("Loading spells");
|
LogInfo("Loading spells");
|
||||||
try {
|
try {
|
||||||
LoadSpells(&database, hotfix_name);
|
LoadSpells(&database, hotfix_name);
|
||||||
} catch(std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
LogError("{}", ex.what());
|
LogError("{}", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_all || load_bd) {
|
if (load_all || load_bd) {
|
||||||
LogInfo("Loading base data");
|
LogInfo("Loading base data");
|
||||||
try {
|
try {
|
||||||
LoadBaseData(&database, hotfix_name);
|
LoadBaseData(&database, hotfix_name);
|
||||||
} catch(std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
LogError("{}", ex.what());
|
LogError("{}", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
LogSys.CloseFileLogs();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user