本文整理汇总了C++中LauncherList类的典型用法代码示例。如果您正苦于以下问题:C++ LauncherList类的具体用法?C++ LauncherList怎么用?C++ LauncherList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LauncherList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
vector<string> EQW::ListLaunchers() {
// vector<string> list;
// database.GetLauncherList(list);
vector<string> launchers;
launcher_list.GetLauncherNameList(launchers);
return(launchers);
/* if(list.empty()) {
return(launchers);
} else if(launchers.empty()) {
return(list);
}
//union the two lists.
vector<string>::iterator curo, endo, curi, endi;
curo = list.begin();
endo = list.end();
for(; curo != endo; curo++) {
bool found = false;
curi = launchers.begin();
endi = launchers.end();
for(; curi != endi; curi++) {
if(*curo == *curi) {
found = true;
break;
}
}
if(found)
break;
launchers.push_back(*curo);
}
return(launchers);*/
}
示例2: BootStaticZone
bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
//make sure the short name is valid.
if(database.GetZoneID(short_name) == 0)
return false;
//database update
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
char zonebuf[32];
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
zonebuf[31] = '\0';
std::string query = StringFormat("INSERT INTO launcher_zones (launcher, zone, port) "
"VALUES('%s', '%s', %d)", namebuf, zonebuf, port);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
//update our internal state.
LauncherZone lz;
lz.name = short_name;
lz.port = port;
m_zones[lz.name] = lz;
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->BootZone(short_name, port);
}
return true;
}
示例3: DeleteLauncher
void EQLConfig::DeleteLauncher() {
launcher_list.Remove(m_name.c_str());
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
if (!database.RunQuery(query, MakeAnyLenString(&query,
"DELETE FROM launcher WHERE name='%s'",
namebuf), errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1 query: %s", errbuf);
safe_delete_array(query);
return;
}
safe_delete_array(query);
if (!database.RunQuery(query, MakeAnyLenString(&query,
"DELETE FROM launcher_zones WHERE launcher='%s'",
namebuf), errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2 query: %s", errbuf);
safe_delete_array(query);
return;
}
safe_delete_array(query);
}
示例4: itoa
map<string,string> EQW::GetZoneDetails(Const_char *zone_ref) {
map<string,string> res;
ZoneServer *zs = zoneserver_list.FindByID(atoi(zone_ref));
if(zs == NULL) {
res["error"] = "Invalid zone.";
return(res);
}
res["type"] = zs->IsStaticZone()?"static":"dynamic";
res["zone_id"] = itoa(zs->GetZoneID());
res["launch_name"] = zs->GetLaunchName();
res["launched_name"] = zs->GetLaunchedName();
res["short_name"] = zs->GetZoneName();
res["long_name"] = zs->GetZoneLongName();
res["port"] = itoa(zs->GetCPort());
res["player_count"] = itoa(zs->NumPlayers());
//this isnt gunna work for dynamic zones...
res["launcher"] = "";
if(zs->GetZoneID() != 0) {
LauncherLink *ll = launcher_list.FindByZone(zs->GetLaunchName());
if(ll != NULL)
res["launcher"] = ll->GetName();
}
return(res);
}
示例5: DeleteStaticZone
bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
//check internal state
std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
Log.Out(Logs::General, Logs::Error, "Update for unknown zone %s", short_name);
return false;
}
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
char zonebuf[32];
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
zonebuf[31] = '\0';
std::string query = StringFormat("DELETE FROM launcher_zones WHERE "
"launcher = '%s' AND zone = '%s'", namebuf, zonebuf);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
//internal update.
m_zones.erase(res);
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->StopZone(short_name);
}
return true;
}
示例6: SetDynamicCount
bool EQLConfig::SetDynamicCount(int count) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
if (!database.RunQuery(query, MakeAnyLenString(&query,
"UPDATE launcher SET dynamics=%d WHERE name='%s'",
count, namebuf), errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in SetDynamicCount query: %s", errbuf);
safe_delete_array(query);
return false;
}
safe_delete_array(query);
//update in-memory version.
m_dynamics = count;
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->BootDynamics(count);
}
return(false);
}
示例7: CountLaunchers
int EQW::CountLaunchers(bool active_only) {
if(active_only)
return(launcher_list.GetLauncherCount());
vector<string> it(EQW::ListLaunchers());
return(it.size());
}
示例8:
std::map<std::string,std::string> EQLConfig::GetZoneDetails(Const_char *zone_ref) {
std::map<std::string,std::string> res;
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll == nullptr) {
res["name"] = zone_ref;
res["up"] = "0";
res["starts"] = "0";
res["port"] = "0";
} else {
ll->GetZoneDetails(zone_ref, res);
}
return(res);
}
示例9: ChangeStaticZone
bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
//make sure the short name is valid.
if(database.GetZoneID(short_name) == 0)
return(false);
//check internal state
std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name);
return(false);
}
//database update
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
char zonebuf[32];
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
zonebuf[31] = '\0';
if (!database.RunQuery(query, MakeAnyLenString(&query,
"UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'",
port, namebuf, zonebuf), errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", errbuf);
safe_delete_array(query);
return false;
}
safe_delete_array(query);
//update internal state
res->second.port = port;
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->RestartZone(short_name);
}
return(true);
}
示例10: DeleteLauncher
void EQLConfig::DeleteLauncher() {
launcher_list.Remove(m_name.c_str());
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
std::string query = StringFormat("DELETE FROM launcher WHERE name = '%s'", namebuf);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return;
}
query = StringFormat("DELETE FROM launcher_zones WHERE launcher = '%s'", namebuf);
results = database.QueryDatabase(query);
if (!results.Success()) {
return;
}
}
示例11: DeleteStaticZone
bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
//check internal state
std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name);
return(false);
}
//database update
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
char zonebuf[32];
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
zonebuf[31] = '\0';
if (!database.RunQuery(query, MakeAnyLenString(&query,
"DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'",
namebuf, zonebuf), errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", errbuf);
safe_delete_array(query);
return false;
}
safe_delete_array(query);
//internal update.
m_zones.erase(res);
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->StopZone(short_name);
}
return true;
}
示例12: ChangeStaticZone
bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
//make sure the short name is valid.
if(database.GetZoneID(short_name) == 0)
return false;
//check internal state
std::map<std::string, LauncherZone>::iterator res;
res = m_zones.find(short_name);
if(res == m_zones.end()) {
//not found.
Log.Out(Logs::General, Logs::Error, "Update for unknown zone %s", short_name);
return false;
}
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
char zonebuf[32];
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
zonebuf[31] = '\0';
std::string query = StringFormat("UPDATE launcher_zones SET port=%d WHERE "
"launcher = '%s' AND zone = '%s'",port, namebuf, zonebuf);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
//update internal state
res->second.port = port;
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->RestartZone(short_name);
}
return true;
}
示例13: BootStaticZone
bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
//make sure the short name is valid.
if(database.GetZoneID(short_name) == 0)
return(false);
//database update
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
char zonebuf[32];
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
zonebuf[31] = '\0';
if (!database.RunQuery(query, MakeAnyLenString(&query,
"INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)",
namebuf, zonebuf, port), errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in BootStaticZone query: %s", errbuf);
safe_delete_array(query);
return false;
}
safe_delete_array(query);
//update our internal state.
LauncherZone lz;
lz.name = short_name;
lz.port = port;
m_zones[lz.name] = lz;
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->BootZone(short_name, port);
}
return(true);
}
示例14: SetDynamicCount
bool EQLConfig::SetDynamicCount(int count) {
char namebuf[128];
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
namebuf[127] = '\0';
std::string query = StringFormat("UPDATE launcher SET dynamics=%d WHERE name='%s'", count, namebuf);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
return false;
}
//update in-memory version.
m_dynamics = count;
//if the launcher is connected, update it.
LauncherLink *ll = launcher_list.Get(m_name.c_str());
if(ll != nullptr) {
ll->BootDynamics(count);
}
return false;
}
示例15: main
int main(int argc, char** argv) {
RegisterExecutablePlatform(ExePlatformWorld);
set_exception_handler();
// Load server configuration
_log(WORLD__INIT, "Loading server configuration..");
if (!WorldConfig::LoadConfig()) {
_log(WORLD__INIT_ERR, "Loading server configuration failed.");
return(1);
}
const WorldConfig *Config=WorldConfig::get();
if(!load_log_settings(Config->LogSettingsFile.c_str()))
_log(WORLD__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str());
else
_log(WORLD__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str());
_log(WORLD__INIT, "CURRENT_VERSION: %s", CURRENT_VERSION);
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
_log(WORLD__INIT_ERR, "Could not set signal handler");
return 0;
}
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
_log(WORLD__INIT_ERR, "Could not set signal handler");
return 0;
}
#ifndef WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
_log(WORLD__INIT_ERR, "Could not set signal handler");
return 0;
}
#endif
// add login server config to list
if (Config->LoginCount == 0) {
if (Config->LoginHost.length()) {
loginserverlist.Add(Config->LoginHost.c_str(), Config->LoginPort, Config->LoginAccount.c_str(), Config->LoginPassword.c_str());
_log(WORLD__INIT, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort);
}
} else {
LinkedList<LoginConfig*> loginlist=Config->loginlist;
LinkedListIterator<LoginConfig*> iterator(loginlist);
iterator.Reset();
while(iterator.MoreElements()) {
loginserverlist.Add(iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), iterator.GetData()->LoginPassword.c_str());
_log(WORLD__INIT, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort);
iterator.Advance();
}
}
_log(WORLD__INIT, "Connecting to MySQL...");
if (!database.Connect(
Config->DatabaseHost.c_str(),
Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort)) {
_log(WORLD__INIT_ERR, "Cannot continue without a database connection.");
return(1);
}
dbasync = new DBAsync(&database);
guild_mgr.SetDatabase(&database);
if (argc >= 2) {
char tmp[2];
if (strcasecmp(argv[1], "help") == 0 || strcasecmp(argv[1], "?") == 0 || strcasecmp(argv[1], "/?") == 0 || strcasecmp(argv[1], "-?") == 0 || strcasecmp(argv[1], "-h") == 0 || strcasecmp(argv[1], "-help") == 0) {
cout << "Worldserver command line commands:" << endl;
cout << "adduser username password flag - adds a user account" << endl;
cout << "flag username flag - sets GM flag on the account" << endl;
cout << "startzone zoneshortname - sets the starting zone" << endl;
cout << "-holdzones - reboots lost zones" << endl;
return 0;
}
else if (strcasecmp(argv[1], "-holdzones") == 0) {
cout << "Reboot Zones mode ON" << endl;
holdzones = true;
}
else if (database.GetVariable("disablecommandline", tmp, 2)) {
if (strlen(tmp) == 1) {
if (tmp[0] == '1') {
cout << "Command line disabled in database... exiting" << endl;
return 0;
}
}
}
else if (strcasecmp(argv[1], "adduser") == 0) {
if (argc == 5) {
if (Seperator::IsNumber(argv[4])) {
if (atoi(argv[4]) >= 0 && atoi(argv[4]) <= 255) {
if (database.CreateAccount(argv[2], argv[3], atoi(argv[4])) == 0)
cout << "database.CreateAccount failed." << endl;
else
cout << "Account created: Username='" << argv[2] << "', Password='" << argv[3] << "', status=" << argv[4] << endl;
return 0;
//.........这里部分代码省略.........