mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-25 21:02:26 +00:00
LoadAdventureEntries converted to QueryDatabase
This commit is contained in:
parent
37b45be6d8
commit
8b05eff179
@ -693,54 +693,36 @@ bool AdventureManager::LoadAdventureTemplates()
|
|||||||
|
|
||||||
bool AdventureManager::LoadAdventureEntries()
|
bool AdventureManager::LoadAdventureEntries()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = "SELECT id, template_id FROM adventure_template_entry";
|
||||||
char* query = 0;
|
auto results = database.QueryDatabase(query);
|
||||||
MYSQL_RES *result;
|
if (!results.Success())
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT id, template_id FROM adventure_template_entry"), errbuf, &result))
|
|
||||||
{
|
{
|
||||||
while((row = mysql_fetch_row(result)))
|
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query.c_str(), results.ErrorMessage().c_str());
|
||||||
{
|
|
||||||
int id = atoi(row[0]);
|
|
||||||
int template_id = atoi(row[1]);
|
|
||||||
AdventureTemplate* tid = nullptr;
|
|
||||||
|
|
||||||
std::map<uint32, AdventureTemplate*>::iterator t_iter = adventure_templates.find(template_id);
|
|
||||||
if(t_iter == adventure_templates.end())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tid = adventure_templates[template_id];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<AdventureTemplate*> temp;
|
|
||||||
std::map<uint32, std::list<AdventureTemplate*> >::iterator iter = adventure_entries.find(id);
|
|
||||||
if(iter == adventure_entries.end())
|
|
||||||
{
|
|
||||||
temp.push_back(tid);
|
|
||||||
adventure_entries[id] = temp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
temp = adventure_entries[id];
|
|
||||||
temp.push_back(tid);
|
|
||||||
adventure_entries[id] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
safe_delete_array(query);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::LoadAdventureEntries: %s (%s)", query, errbuf);
|
|
||||||
safe_delete_array(query);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row)
|
||||||
|
{
|
||||||
|
int id = atoi(row[0]);
|
||||||
|
int template_id = atoi(row[1]);
|
||||||
|
AdventureTemplate* tid = nullptr;
|
||||||
|
|
||||||
|
auto t_iter = adventure_templates.find(template_id);
|
||||||
|
if(t_iter == adventure_templates.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tid = adventure_templates[template_id];
|
||||||
|
|
||||||
|
std::list<AdventureTemplate*> temp;
|
||||||
|
auto iter = adventure_entries.find(id);
|
||||||
|
if(iter == adventure_entries.end())
|
||||||
|
temp = adventure_entries[id];
|
||||||
|
|
||||||
|
temp.push_back(tid);
|
||||||
|
adventure_entries[id] = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int door_id)
|
void AdventureManager::PlayerClickedDoor(const char *player, int zone_id, int door_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user