mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-07 15:32:25 +00:00
delglobal converted to QueryDatabase
This commit is contained in:
parent
58343480ff
commit
1bb5c4e0d8
@ -1408,22 +1408,14 @@ void QuestManager::targlobal(const char *varname, const char *value, const char
|
|||||||
|
|
||||||
void QuestManager::delglobal(const char *varname) {
|
void QuestManager::delglobal(const char *varname) {
|
||||||
QuestManagerCurrentQuestVars();
|
QuestManagerCurrentQuestVars();
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
int qgZoneid=zone->GetZoneID();
|
int qgZoneid=zone->GetZoneID();
|
||||||
int qgCharid=0;
|
int qgCharid=0;
|
||||||
int qgNpcid=owner->GetNPCTypeID();
|
int qgNpcid=owner->GetNPCTypeID();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved
|
if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved
|
||||||
{
|
|
||||||
qgCharid=initiator->CharacterID();
|
qgCharid=initiator->CharacterID();
|
||||||
}
|
else
|
||||||
|
|
||||||
else {
|
|
||||||
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
||||||
}
|
|
||||||
|
|
||||||
/* QS: PlayerLogQGlobalUpdate */
|
/* QS: PlayerLogQGlobalUpdate */
|
||||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||||
@ -1431,31 +1423,32 @@ void QuestManager::delglobal(const char *varname) {
|
|||||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!database.RunQuery(query,
|
std::string query = StringFormat("DELETE FROM quest_globals "
|
||||||
MakeAnyLenString(&query,
|
"WHERE name = '%s' "
|
||||||
"DELETE FROM quest_globals WHERE name='%s'"
|
"&& (npcid=0 || npcid=%i) "
|
||||||
" && (npcid=0 || npcid=%i) && (charid=0 || charid=%i) && (zoneid=%i || zoneid=0)",
|
"&& (charid=0 || charid=%i) "
|
||||||
varname,qgNpcid,qgCharid,qgZoneid),errbuf))
|
"&& (zoneid=%i || zoneid=0)",
|
||||||
{
|
varname, qgNpcid, qgCharid, qgZoneid);
|
||||||
std::cerr << "delglobal error deleting " << varname << " : " << errbuf << std::endl;
|
auto results = database.QueryDatabase(query);
|
||||||
}
|
if (!results.Success())
|
||||||
safe_delete_array(query);
|
std::cerr << "delglobal error deleting " << varname << " : " << results.ErrorMessage() << std::endl;
|
||||||
|
|
||||||
if(zone) {
|
if(!zone)
|
||||||
ServerPacket* pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct));
|
return;
|
||||||
ServerQGlobalDelete_Struct *qgu = (ServerQGlobalDelete_Struct*)pack->pBuffer;
|
|
||||||
|
|
||||||
qgu->npc_id = qgNpcid;
|
ServerPacket* pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct));
|
||||||
qgu->char_id = qgCharid;
|
ServerQGlobalDelete_Struct *qgu = (ServerQGlobalDelete_Struct*)pack->pBuffer;
|
||||||
qgu->zone_id = qgZoneid;
|
|
||||||
strcpy(qgu->name, varname);
|
|
||||||
|
|
||||||
entity_list.DeleteQGlobal(std::string((char*)qgu->name), qgu->npc_id, qgu->char_id, qgu->zone_id);
|
qgu->npc_id = qgNpcid;
|
||||||
zone->DeleteQGlobal(std::string((char*)qgu->name), qgu->npc_id, qgu->char_id, qgu->zone_id);
|
qgu->char_id = qgCharid;
|
||||||
|
qgu->zone_id = qgZoneid;
|
||||||
|
strcpy(qgu->name, varname);
|
||||||
|
|
||||||
worldserver.SendPacket(pack);
|
entity_list.DeleteQGlobal(std::string((char*)qgu->name), qgu->npc_id, qgu->char_id, qgu->zone_id);
|
||||||
safe_delete(pack);
|
zone->DeleteQGlobal(std::string((char*)qgu->name), qgu->npc_id, qgu->char_id, qgu->zone_id);
|
||||||
}
|
|
||||||
|
worldserver.SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts duration string to duration value (in seconds)
|
// Converts duration string to duration value (in seconds)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user