mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-16 05:11:29 +00:00
ChangeStaticZone converted to QueryDatabase
This commit is contained in:
parent
e4320f98f8
commit
0af394fb96
@ -195,7 +195,7 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
||||||
//make sure the short name is valid.
|
//make sure the short name is valid.
|
||||||
if(database.GetZoneID(short_name) == 0)
|
if(database.GetZoneID(short_name) == 0)
|
||||||
return(false);
|
return false;
|
||||||
|
|
||||||
//check internal state
|
//check internal state
|
||||||
std::map<std::string, LauncherZone>::iterator res;
|
std::map<std::string, LauncherZone>::iterator res;
|
||||||
@ -203,14 +203,9 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
if(res == m_zones.end()) {
|
if(res == m_zones.end()) {
|
||||||
//not found.
|
//not found.
|
||||||
LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name);
|
LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name);
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//database update
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
|
|
||||||
char namebuf[128];
|
char namebuf[128];
|
||||||
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64
|
||||||
namebuf[127] = '\0';
|
namebuf[127] = '\0';
|
||||||
@ -218,15 +213,13 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
|
database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16
|
||||||
zonebuf[31] = '\0';
|
zonebuf[31] = '\0';
|
||||||
|
|
||||||
if (!database.RunQuery(query, MakeAnyLenString(&query,
|
std::string query = StringFormat("UPDATE launcher_zones SET port=%d WHERE "
|
||||||
"UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'",
|
"launcher = '%s' AND zone = '%s'",port, namebuf, zonebuf);
|
||||||
port, namebuf, zonebuf), errbuf)) {
|
auto results = database.QueryDatabase(query);
|
||||||
LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", errbuf);
|
if (!results.Success()) {
|
||||||
safe_delete_array(query);
|
LogFile->write(EQEMuLog::Error, "Error in ChangeStaticZone query: %s", results.ErrorMessage().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
|
|
||||||
//update internal state
|
//update internal state
|
||||||
res->second.port = port;
|
res->second.port = port;
|
||||||
@ -237,7 +230,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) {
|
|||||||
ll->RestartZone(short_name);
|
ll->RestartZone(short_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
bool EQLConfig::DeleteStaticZone(Const_char *short_name) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user