mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-28 07:22:29 +00:00
Consolidated LoadBy code into new LoadBy method
This commit is contained in:
parent
8d909ea8e2
commit
7692793289
@ -141,48 +141,37 @@ void QGlobalCache::LoadByNPCID(uint32 npcID)
|
|||||||
{
|
{
|
||||||
std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate "
|
std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate "
|
||||||
"FROM quest_globals WHERE npcid = %d", npcID);
|
"FROM quest_globals WHERE npcid = %d", npcID);
|
||||||
auto results = database.QueryDatabase(query);
|
LoadBy(query);
|
||||||
if (!results.Success())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row)
|
|
||||||
AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGlobalCache::LoadByCharID(uint32 charID)
|
void QGlobalCache::LoadByCharID(uint32 charID)
|
||||||
{
|
{
|
||||||
std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate "
|
std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate "
|
||||||
"FROM quest_globals WHERE charid = %d && npcid = 0", charID);
|
"FROM quest_globals WHERE charid = %d && npcid = 0", charID);
|
||||||
auto results = database.QueryDatabase(query);
|
LoadBy(query);
|
||||||
if (!results.Success())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row)
|
|
||||||
AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGlobalCache::LoadByZoneID(uint32 zoneID)
|
void QGlobalCache::LoadByZoneID(uint32 zoneID)
|
||||||
{
|
{
|
||||||
std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate "
|
std::string query = StringFormat("SELECT name, charid, npcid, zoneid, value, expdate "
|
||||||
"FROM quest_globals WHERE zoneid = %d && npcid = 0 && charid = 0", zoneID);
|
"FROM quest_globals WHERE zoneid = %d && npcid = 0 && charid = 0", zoneID);
|
||||||
auto results = database.QueryDatabase(query);
|
LoadBy(query);
|
||||||
if (!results.Success())
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row)
|
|
||||||
AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QGlobalCache::LoadByGlobalContext()
|
void QGlobalCache::LoadByGlobalContext()
|
||||||
{
|
{
|
||||||
std::string query = "SELECT name, charid, npcid, zoneid, value, expdate "
|
std::string query = "SELECT name, charid, npcid, zoneid, value, expdate "
|
||||||
"FROM quest_globals WHERE zoneid = 0 && npcid = 0 && charid = 0";
|
"FROM quest_globals WHERE zoneid = 0 && npcid = 0 && charid = 0";
|
||||||
|
LoadBy(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGlobalCache::LoadBy(const std::string query)
|
||||||
|
{
|
||||||
auto results = database.QueryDatabase(query);
|
auto results = database.QueryDatabase(query);
|
||||||
if (!results.Success())
|
if (!results.Success())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row)
|
for (auto row = results.begin(); row != results.end(); ++row)
|
||||||
AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF));
|
AddGlobal(0, QGlobal(std::string(row[0]), atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5]? atoi(row[5]): 0xFFFFFFFF));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public:
|
|||||||
void LoadByZoneID(uint32 zoneID); //zone
|
void LoadByZoneID(uint32 zoneID); //zone
|
||||||
void LoadByGlobalContext(); //zone
|
void LoadByGlobalContext(); //zone
|
||||||
protected:
|
protected:
|
||||||
|
void LoadBy(const std::string query);
|
||||||
std::list<QGlobal> qGlobalBucket;
|
std::list<QGlobal> qGlobalBucket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user