DelGlobal converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-18 21:13:20 -07:00
parent 87efd22394
commit c6091c4f27

View File

@ -3928,36 +3928,26 @@ void Mob::TarGlobal(const char *varname, const char *value, const char *duration
}
void Mob::DelGlobal(const char *varname) {
// delglobal(varname)
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
int qgZoneid=zone->GetZoneID();
int qgCharid=0;
int qgNpcid=0;
if (this->IsNPC())
{
qgNpcid = this->GetNPCTypeID();
}
if (this->IsClient())
{
qgCharid = this->CastToClient()->CharacterID();
}
else
{
qgCharid = -qgNpcid; // make char id negative npc id as a fudge
}
if (!database.RunQuery(query,
MakeAnyLenString(&query,
"DELETE FROM quest_globals WHERE name='%s'"
" && (npcid=0 || npcid=%i) && (charid=0 || charid=%i) && (zoneid=%i || zoneid=0)",
varname,qgNpcid,qgCharid,qgZoneid),errbuf))
{
//_log(QUESTS, "DelGlobal error deleting %s : %s", varname, errbuf);
}
safe_delete_array(query);
std::string query = StringFormat("DELETE FROM quest_globals "
"WHERE name='%s' && (npcid=0 || npcid=%i) "
"&& (charid=0 || charid=%i) "
"&& (zoneid=%i || zoneid=0)",
varname, qgNpcid, qgCharid, qgZoneid);
database.QueryDatabase(query);
if(zone)
{