mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 15:41:30 +00:00
Merge pull request #207 from addtheice/RunQueryToDatabaseQuery_zone_zoning
Run query to database query zone zoning
This commit is contained in:
commit
7c451f8170
@ -723,16 +723,11 @@ void Client::SetZoneFlag(uint32 zone_id) {
|
|||||||
|
|
||||||
zone_flags.insert(zone_id);
|
zone_flags.insert(zone_id);
|
||||||
|
|
||||||
//update the DB
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
|
|
||||||
// Retrieve all waypoints for this grid
|
// Retrieve all waypoints for this grid
|
||||||
if(!database.RunQuery(query,MakeAnyLenString(&query,
|
std::string query = StringFormat("INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)", CharacterID(), zone_id);
|
||||||
"INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)",
|
auto results = database.QueryDatabase(query);
|
||||||
CharacterID(),zone_id),errbuf)) {
|
if(!results.Success())
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), results.ErrorMessage().c_str());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::ClearZoneFlag(uint32 zone_id) {
|
void Client::ClearZoneFlag(uint32 zone_id) {
|
||||||
@ -741,40 +736,27 @@ void Client::ClearZoneFlag(uint32 zone_id) {
|
|||||||
|
|
||||||
zone_flags.erase(zone_id);
|
zone_flags.erase(zone_id);
|
||||||
|
|
||||||
//update the DB
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
|
|
||||||
// Retrieve all waypoints for this grid
|
// Retrieve all waypoints for this grid
|
||||||
if(!database.RunQuery(query,MakeAnyLenString(&query,
|
std::string query = StringFormat("DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d", CharacterID(), zone_id);
|
||||||
"DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d",
|
auto results = database.QueryDatabase(query);
|
||||||
CharacterID(),zone_id),errbuf)) {
|
if(!results.Success())
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), errbuf);
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), results.ErrorMessage().c_str());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::LoadZoneFlags() {
|
void Client::LoadZoneFlags() {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
// Retrieve all waypoints for this grid
|
// Retrieve all waypoints for this grid
|
||||||
if(database.RunQuery(query,MakeAnyLenString(&query,
|
std::string query = StringFormat("SELECT zoneID from zone_flags WHERE charID=%d", CharacterID());
|
||||||
"SELECT zoneID from zone_flags WHERE charID=%d",
|
auto results = database.QueryDatabase(query);
|
||||||
CharacterID()),errbuf,&result))
|
if (!results.Success()) {
|
||||||
{
|
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str());
|
||||||
while((row = mysql_fetch_row(result))) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto row = results.begin(); row != results.end(); ++row)
|
||||||
zone_flags.insert(atoi(row[0]));
|
zone_flags.insert(atoi(row[0]));
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else // DB query error!
|
|
||||||
{
|
|
||||||
LogFile->write(EQEMuLog::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), errbuf);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Client::HasZoneFlag(uint32 zone_id) const {
|
bool Client::HasZoneFlag(uint32 zone_id) const {
|
||||||
return(zone_flags.find(zone_id) != zone_flags.end());
|
return(zone_flags.find(zone_id) != zone_flags.end());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user